livedesk 0.1.382 → 0.1.384
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.
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import{r as TS,a as u,M as Wc,S as Bt,R as Oo,B as ES,P as Pm,X as zs,b as Bo,C as Hr,F as Xv,L as Ls,A as Py,c as RS,d as Zv,E as Jv,T as DS,D as Yh,e as In,f as _S,g as LS,h as zS,i as IS,j as tn,k as tf,l as Eo,m as Hy,n as _l,o as $y,p as ln,q as Uy,s as qy,t as OS,u as BS,v as nf,H as Rl,W as Ro,w as FS,x as PS,y as Do,K as _o,z as Gy,G as Vy,I as af,J as HS,N as tu,O as Ll,Q as To,U as ex,V as $S,Y as US,Z as Wh,_ as Kc,$ as Kh,a0 as qS,a1 as Qh,a2 as Yy,a3 as GS,a4 as $r,a5 as tx,a6 as Xh,a7 as hf,a8 as Wy,a9 as Vd,aa as VS,ab as Ky,ac as YS,ad as Qy,ae as WS,af as KS,ag as jh,ah as QS,ai as XS,aj as ZS,ak as JS,al as e0,am as t0,an as n0,ao as nx,ap as a0,aq as s0,ar as Yd,as as qc,at as Wd,au as i0,av as r0,aw as jl,ax as l0,ay as ax,az as Xy,aA as sx,aB as ix,aC as o0}from"./icons-MsRY-S-W.js";import{r as Zy}from"./react-C3IPw5cG.js";import{c as c0}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"]'))l(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const m of d.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&l(m)}).observe(document,{childList:!0,subtree:!0});function r(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 l(c){if(c.ep)return;c.ep=!0;const d=r(c);fetch(c.href,d)}})();var Hm={exports:{}},Oc={};var rx;function u0(){if(rx)return Oc;rx=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function r(l,c,d){var m=null;if(d!==void 0&&(m=""+d),c.key!==void 0&&(m=""+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:l,key:m,ref:c!==void 0?c:null,props:d}}return Oc.Fragment=a,Oc.jsx=r,Oc.jsxs=r,Oc}var lx;function d0(){return lx||(lx=1,Hm.exports=u0()),Hm.exports}var s=d0(),$m={exports:{}},Bc={},Um={exports:{}},qm={};var ox;function f0(){return ox||(ox=1,(function(n){function a(O,Z){var X=O.length;O.push(Z);e:for(;0<X;){var D=X-1>>>1,K=O[D];if(0<c(K,Z))O[D]=Z,O[X]=K,X=D;else break e}}function r(O){return O.length===0?null:O[0]}function l(O){if(O.length===0)return null;var Z=O[0],X=O.pop();if(X!==Z){O[0]=X;e:for(var D=0,K=O.length,ce=K>>>1;D<ce;){var W=2*(D+1)-1,P=O[W],me=W+1,ge=O[me];if(0>c(P,X))me<K&&0>c(ge,P)?(O[D]=ge,O[me]=X,D=me):(O[D]=P,O[W]=X,D=W);else if(me<K&&0>c(ge,X))O[D]=ge,O[me]=X,D=me;else break e}}return Z}function c(O,Z){var X=O.sortIndex-Z.sortIndex;return X!==0?X:O.id-Z.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 m=Date,p=m.now();n.unstable_now=function(){return m.now()-p}}var v=[],g=[],w=1,y=null,b=3,j=!1,C=!1,A=!1,T=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function $(O){for(var Z=r(g);Z!==null;){if(Z.callback===null)l(g);else if(Z.startTime<=O)l(g),Z.sortIndex=Z.expirationTime,a(v,Z);else break;Z=r(g)}}function F(O){if(A=!1,$(O),!C)if(r(v)!==null)C=!0,q||(q=!0,Q());else{var Z=r(g);Z!==null&&Y(F,Z.startTime-O)}}var q=!1,L=-1,_=5,ie=-1;function V(){return T?!0:!(n.unstable_now()-ie<_)}function ne(){if(T=!1,q){var O=n.unstable_now();ie=O;var Z=!0;try{e:{C=!1,A&&(A=!1,E(L),L=-1),j=!0;var X=b;try{t:{for($(O),y=r(v);y!==null&&!(y.expirationTime>O&&V());){var D=y.callback;if(typeof D=="function"){y.callback=null,b=y.priorityLevel;var K=D(y.expirationTime<=O);if(O=n.unstable_now(),typeof K=="function"){y.callback=K,$(O),Z=!0;break t}y===r(v)&&l(v),$(O)}else l(v);y=r(v)}if(y!==null)Z=!0;else{var ce=r(g);ce!==null&&Y(F,ce.startTime-O),Z=!1}}break e}finally{y=null,b=X,j=!1}Z=void 0}}finally{Z?Q():q=!1}}}var Q;if(typeof R=="function")Q=function(){R(ne)};else if(typeof MessageChannel<"u"){var J=new MessageChannel,le=J.port2;J.port1.onmessage=ne,Q=function(){le.postMessage(null)}}else Q=function(){k(ne,0)};function Y(O,Z){L=k(function(){O(n.unstable_now())},Z)}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(O){O.callback=null},n.unstable_forceFrameRate=function(O){0>O||125<O?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):_=0<O?Math.floor(1e3/O):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(O){switch(b){case 1:case 2:case 3:var Z=3;break;default:Z=b}var X=b;b=Z;try{return O()}finally{b=X}},n.unstable_requestPaint=function(){T=!0},n.unstable_runWithPriority=function(O,Z){switch(O){case 1:case 2:case 3:case 4:case 5:break;default:O=3}var X=b;b=O;try{return Z()}finally{b=X}},n.unstable_scheduleCallback=function(O,Z,X){var D=n.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?D+X:D):X=D,O){case 1:var K=-1;break;case 2:K=250;break;case 5:K=1073741823;break;case 4:K=1e4;break;default:K=5e3}return K=X+K,O={id:w++,callback:Z,priorityLevel:O,startTime:X,expirationTime:K,sortIndex:-1},X>D?(O.sortIndex=X,a(g,O),r(v)===null&&O===r(g)&&(A?(E(L),L=-1):A=!0,Y(F,X-D))):(O.sortIndex=K,a(v,O),C||j||(C=!0,q||(q=!0,Q()))),O},n.unstable_shouldYield=V,n.unstable_wrapCallback=function(O){var Z=b;return function(){var X=b;b=Z;try{return O.apply(this,arguments)}finally{b=X}}}})(qm)),qm}var cx;function m0(){return cx||(cx=1,Um.exports=f0()),Um.exports}var ux;function h0(){if(ux)return Bc;ux=1;var n=m0(),a=TS(),r=Zy();function l(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var i=2;i<arguments.length;i++)t+="&args[]="+encodeURIComponent(arguments[i])}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,i=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(i=t.return),e=t.return;while(e)}return t.tag===3?i:null}function m(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 v(e){if(d(e)!==e)throw Error(l(188))}function g(e){var t=e.alternate;if(!t){if(t=d(e),t===null)throw Error(l(188));return t!==e?null:e}for(var i=e,o=t;;){var f=i.return;if(f===null)break;var h=f.alternate;if(h===null){if(o=f.return,o!==null){i=o;continue}break}if(f.child===h.child){for(h=f.child;h;){if(h===i)return v(f),e;if(h===o)return v(f),t;h=h.sibling}throw Error(l(188))}if(i.return!==o.return)i=f,o=h;else{for(var S=!1,M=f.child;M;){if(M===i){S=!0,i=f,o=h;break}if(M===o){S=!0,o=f,i=h;break}M=M.sibling}if(!S){for(M=h.child;M;){if(M===i){S=!0,i=h,o=f;break}if(M===o){S=!0,o=h,i=f;break}M=M.sibling}if(!S)throw Error(l(189))}}if(i.alternate!==o)throw Error(l(190))}if(i.tag!==3)throw Error(l(188));return i.stateNode.current===i?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 y=Object.assign,b=Symbol.for("react.element"),j=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),R=Symbol.for("react.context"),$=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),q=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),V=Symbol.for("react.memo_cache_sentinel"),ne=Symbol.iterator;function Q(e){return e===null||typeof e!="object"?null:(e=ne&&e[ne]||e["@@iterator"],typeof e=="function"?e:null)}var J=Symbol.for("react.client.reference");function le(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===J?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case A:return"Fragment";case k:return"Profiler";case T:return"StrictMode";case F:return"Suspense";case q:return"SuspenseList";case ie:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case R:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case $: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:le(e.type)||"Memo";case _:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}var Y=Array.isArray,O=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},D=[],K=-1;function ce(e){return{current:e}}function W(e){0>K||(e.current=D[K],D[K]=null,K--)}function P(e,t){K++,D[K]=e.current,e.current=t}var me=ce(null),ge=ce(null),xe=ce(null),Ce=ce(null);function Le(e,t){switch(P(xe,t),P(ge,e),P(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?wv(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=wv(t),e=bv(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}W(me),P(me,e)}function ze(){W(me),W(ge),W(xe)}function ue(e){e.memoizedState!==null&&P(Ce,e);var t=me.current,i=bv(t,e.type);t!==i&&(P(ge,e),P(me,i))}function Ye(e){ge.current===e&&(W(me),W(ge)),Ce.current===e&&(W(Ce),_c._currentValue=X)}var We,oe;function Ae(e){if(We===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);We=t&&t[1]||"",oe=-1<i.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+We+e+oe}var je=!1;function Ee(e,t){if(!e||je)return"";je=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var Se=function(){throw Error()};if(Object.defineProperty(Se.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Se,[])}catch(fe){var re=fe}Reflect.construct(e,[],Se)}else{try{Se.call()}catch(fe){re=fe}e.call(Se.prototype)}}else{try{throw Error()}catch(fe){re=fe}(Se=e())&&typeof Se.catch=="function"&&Se.catch(function(){})}}catch(fe){if(fe&&re&&typeof fe.stack=="string")return[fe.stack,re.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=o.DetermineComponentFrameRoot(),S=h[0],M=h[1];if(S&&M){var H=S.split(`
|
|
4
|
+
`),se=M.split(`
|
|
5
|
+
`);for(f=o=0;o<H.length&&!H[o].includes("DetermineComponentFrameRoot");)o++;for(;f<se.length&&!se[f].includes("DetermineComponentFrameRoot");)f++;if(o===H.length||f===se.length)for(o=H.length-1,f=se.length-1;1<=o&&0<=f&&H[o]!==se[f];)f--;for(;1<=o&&0<=f;o--,f--)if(H[o]!==se[f]){if(o!==1||f!==1)do if(o--,f--,0>f||H[o]!==se[f]){var ye=`
|
|
6
|
+
`+H[o].replace(" at new "," at ");return e.displayName&&ye.includes("<anonymous>")&&(ye=ye.replace("<anonymous>",e.displayName)),ye}while(1<=o&&0<=f);break}}}finally{je=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?Ae(i):""}function Re(e,t){switch(e.tag){case 26:case 27:case 5:return Ae(e.type);case 16:return Ae("Lazy");case 13:return e.child!==t&&t!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return Ee(e.type,!1);case 11:return Ee(e.type.render,!1);case 1:return Ee(e.type,!0);case 31:return Ae("Activity");default:return""}}function Fe(e){try{var t="",i=null;do t+=Re(e,i),i=e,e=e.return;while(e);return t}catch(o){return`
|
|
7
|
+
Error generating stack: `+o.message+`
|
|
8
|
+
`+o.stack}}var pe=Object.prototype.hasOwnProperty,ke=n.unstable_scheduleCallback,de=n.unstable_cancelCallback,we=n.unstable_shouldYield,Ge=n.unstable_requestPaint,tt=n.unstable_now,wn=n.unstable_getCurrentPriorityLevel,Qe=n.unstable_ImmediatePriority,ht=n.unstable_UserBlockingPriority,St=n.unstable_NormalPriority,Tn=n.unstable_LowPriority,Oe=n.unstable_IdlePriority,Ft=n.log,Gt=n.unstable_setDisableYieldValue,pt=null,it=null;function nn(e){if(typeof Ft=="function"&&Gt(e),it&&typeof it.setStrictMode=="function")try{it.setStrictMode(pt,e)}catch{}}var Mt=Math.clz32?Math.clz32:Xi,De=Math.log,En=Math.LN2;function Xi(e){return e>>>=0,e===0?32:31-(De(e)/En|0)|0}var fn=256,Pn=262144,pa=4194304;function Ja(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 Rn(e,t,i){var o=e.pendingLanes;if(o===0)return 0;var f=0,h=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var M=o&134217727;return M!==0?(o=M&~h,o!==0?f=Ja(o):(S&=M,S!==0?f=Ja(S):i||(i=M&~e,i!==0&&(f=Ja(i))))):(M=o&~h,M!==0?f=Ja(M):S!==0?f=Ja(S):i||(i=o&~e,i!==0&&(f=Ja(i)))),f===0?0:t!==0&&t!==f&&(t&h)===0&&(h=f&-f,i=t&-t,h>=i||h===32&&(i&4194048)!==0)?t:f}function es(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ie(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 fi(){var e=pa;return pa<<=1,(pa&62914560)===0&&(pa=4194304),e}function ft(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function ts(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Vt(e,t,i,o,f,h){var S=e.pendingLanes;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=i,e.entangledLanes&=i,e.errorRecoveryDisabledLanes&=i,e.shellSuspendCounter=0;var M=e.entanglements,H=e.expirationTimes,se=e.hiddenUpdates;for(i=S&~i;0<i;){var ye=31-Mt(i),Se=1<<ye;M[ye]=0,H[ye]=-1;var re=se[ye];if(re!==null)for(se[ye]=null,ye=0;ye<re.length;ye++){var fe=re[ye];fe!==null&&(fe.lane&=-536870913)}i&=~Se}o!==0&&Bs(e,o,0),h!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=h&~(S&~t))}function Bs(e,t,i){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-Mt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|i&261930}function B(e,t){var i=e.entangledLanes|=t;for(e=e.entanglements;i;){var o=31-Mt(i),f=1<<o;f&t|e[o]&t&&(e[o]|=t),i&=~f}}function $e(e,t){var i=t&-t;return i=(i&42)!==0?1:mt(i),(i&(e.suspendedLanes|t))!==0?0:i}function mt(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 an(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function mn(){var e=Z.p;return e!==0?e:(e=window.event,e===void 0?32:qv(e.type))}function Fs(e,t){var i=Z.p;try{return Z.p=e,t()}finally{Z.p=i}}var ia=Math.random().toString(36).slice(2),te="__reactFiber$"+ia,Ne="__reactProps$"+ia,He="__reactContainer$"+ia,at="__reactEvents$"+ia,Kt="__reactListeners$"+ia,Tt="__reactHandles$"+ia,Xe="__reactResources$"+ia,rt="__reactMarker$"+ia;function Qt(e){delete e[te],delete e[Ne],delete e[at],delete e[Kt],delete e[Tt]}function $t(e){var t=e[te];if(t)return t;for(var i=e.parentNode;i;){if(t=i[He]||i[te]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Mv(e);e!==null;){if(i=e[te])return i;e=Mv(e)}return t}e=i,i=e.parentNode}return null}function Dt(e){if(e=e[te]||e[He]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Pt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function Ut(e){var t=e[Xe];return t||(t=e[Xe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function _t(e){e[rt]=!0}var hn=new Set,ns={};function on(e,t){Xt(e,t),Xt(e+"Capture",t)}function Xt(e,t){for(ns[e]=t,e=0;e<t.length;e++)hn.add(t[e])}var xs=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]*$"),ys={},mi={};function Ho(e){return pe.call(mi,e)?!0:pe.call(ys,e)?!1:xs.test(e)?mi[e]=!0:(ys[e]=!0,!1)}function Zi(e,t,i){if(Ho(t))if(i===null)e.removeAttribute(t);else{switch(typeof i){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,""+i)}}function Bl(e,t,i){if(i===null)e.removeAttribute(t);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+i)}}function Oa(e,t,i,o){if(o===null)e.removeAttribute(i);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(i);return}e.setAttributeNS(t,i,""+o)}}function Kn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ou(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function cu(e,t,i){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var f=o.get,h=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return f.call(this)},set:function(S){i=""+S,h.call(this,S)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return i},setValue:function(S){i=""+S},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Qn(e){if(!e._valueTracker){var t=ou(e)?"checked":"value";e._valueTracker=cu(e,t,""+e[t])}}function Fl(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),o="";return e&&(o=ou(e)?e.checked?"true":"false":e.value),e=o,e!==i?(t.setValue(e),!0):!1}function ra(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 ga=/[\n"\\]/g;function bn(e){return e.replace(ga,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function hi(e,t,i,o,f,h,S,M){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=""+Kn(t)):e.value!==""+Kn(t)&&(e.value=""+Kn(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?er(e,S,Kn(t)):i!=null?er(e,S,Kn(i)):o!=null&&e.removeAttribute("value"),f==null&&h!=null&&(e.defaultChecked=!!h),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?e.name=""+Kn(M):e.removeAttribute("name")}function Ji(e,t,i,o,f,h,S,M){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.type=h),t!=null||i!=null){if(!(h!=="submit"&&h!=="reset"||t!=null)){Qn(e);return}i=i!=null?""+Kn(i):"",t=t!=null?""+Kn(t):i,M||t===e.value||(e.value=t),e.defaultValue=t}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=M?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),Qn(e)}function er(e,t,i){t==="number"&&ra(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function as(e,t,i,o){if(e=e.options,t){t={};for(var f=0;f<i.length;f++)t["$"+i[f]]=!0;for(i=0;i<e.length;i++)f=t.hasOwnProperty("$"+e[i].value),e[i].selected!==f&&(e[i].selected=f),f&&o&&(e[i].defaultSelected=!0)}else{for(i=""+Kn(i),t=null,f=0;f<e.length;f++){if(e[f].value===i){e[f].selected=!0,o&&(e[f].defaultSelected=!0);return}t!==null||e[f].disabled||(t=e[f])}t!==null&&(t.selected=!0)}}function pi(e,t,i){if(t!=null&&(t=""+Kn(t),t!==e.value&&(e.value=t),i==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=i!=null?""+Kn(i):""}function gi(e,t,i,o){if(t==null){if(o!=null){if(i!=null)throw Error(l(92));if(Y(o)){if(1<o.length)throw Error(l(93));o=o[0]}i=o}i==null&&(i=""),t=i}i=Kn(t),e.defaultValue=i,o=e.textContent,o===i&&o!==""&&o!==null&&(e.value=o),Qn(e)}function Ps(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}var Vr=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 Yr(e,t,i){var o=t.indexOf("--")===0;i==null||typeof i=="boolean"||i===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,i):typeof i!="number"||i===0||Vr.has(t)?t==="float"?e.cssFloat=i:e[t]=(""+i).trim():e[t]=i+"px"}function Wr(e,t,i){if(t!=null&&typeof t!="object")throw Error(l(62));if(e=e.style,i!=null){for(var o in i)!i.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var f in t)o=t[f],t.hasOwnProperty(f)&&i[f]!==o&&Yr(e,f,o)}else for(var h in t)t.hasOwnProperty(h)&&Yr(e,h,t[h])}function tr(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 $o=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"]]),uu=/^[\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 Ba(e){return uu.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Hn(){}var ss=null;function Uo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Hs=null,Kr=null;function du(e){var t=Dt(e);if(t&&(e=t.stateNode)){var i=e[Ne]||null;e:switch(e=t.stateNode,t.type){case"input":if(hi(e,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name),t=i.name,i.type==="radio"&&t!=null){for(i=e;i.parentNode;)i=i.parentNode;for(i=i.querySelectorAll('input[name="'+bn(""+t)+'"][type="radio"]'),t=0;t<i.length;t++){var o=i[t];if(o!==e&&o.form===e.form){var f=o[Ne]||null;if(!f)throw Error(l(90));hi(o,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(t=0;t<i.length;t++)o=i[t],o.form===e.form&&Fl(o)}break e;case"textarea":pi(e,i.value,i.defaultValue);break e;case"select":t=i.value,t!=null&&as(e,!!i.multiple,t,!1)}}}var $s=!1;function fu(e,t,i){if($s)return e(t,i);$s=!0;try{var o=e(t);return o}finally{if($s=!1,(Hs!==null||Kr!==null)&&(ad(),Hs&&(t=Hs,e=Kr,Kr=Hs=null,du(t),e)))for(t=0;t<e.length;t++)du(e[t])}}function is(e,t){var i=e.stateNode;if(i===null)return null;var o=i[Ne]||null;if(o===null)return null;i=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(i&&typeof i!="function")throw Error(l(231,t,typeof i));return i}var Fa=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),mu=!1;if(Fa)try{var Pl={};Object.defineProperty(Pl,"passive",{get:function(){mu=!0}}),window.addEventListener("test",Pl,Pl),window.removeEventListener("test",Pl,Pl)}catch{mu=!1}var vi=null,qo=null,Qr=null;function Go(){if(Qr)return Qr;var e,t=qo,i=t.length,o,f="value"in vi?vi.value:vi.textContent,h=f.length;for(e=0;e<i&&t[e]===f[e];e++);var S=i-e;for(o=1;o<=S&&t[i-o]===f[h-o];o++);return Qr=f.slice(e,1<o?1-o:void 0)}function Hl(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 $l(){return!0}function hu(){return!1}function Dn(e){function t(i,o,f,h,S){this._reactName=i,this._targetInst=f,this.type=o,this.nativeEvent=h,this.target=S,this.currentTarget=null;for(var M in e)e.hasOwnProperty(M)&&(i=e[M],this[M]=i?i(h):h[M]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?$l:hu,this.isPropagationStopped=hu,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var i=this.nativeEvent;i&&(i.preventDefault?i.preventDefault():typeof i.returnValue!="unknown"&&(i.returnValue=!1),this.isDefaultPrevented=$l)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=$l)},persist:function(){},isPersistent:$l}),t}var ws={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Us=Dn(ws),va=y({},ws,{view:0,detail:0}),Ul=Dn(va),ql,Gl,nr,qs=y({},va,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vs,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!==nr&&(nr&&e.type==="mousemove"?(ql=e.screenX-nr.screenX,Gl=e.screenY-nr.screenY):Gl=ql=0,nr=e),ql)},movementY:function(e){return"movementY"in e?e.movementY:Gl}}),Vl=Dn(qs),pu=y({},qs,{dataTransfer:0}),et=Dn(pu),ut=y({},va,{relatedTarget:0}),Xn=Dn(ut),ar=y({},ws,{animationName:0,elapsedTime:0,pseudoElement:0}),Gs=Dn(ar),Je=y({},ws,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),gu=Dn(Je),jf=y({},ws,{data:0}),Xr=Dn(jf),Zr={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Vo={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"},sr={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Pa(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=sr[e])?!!t[e]:!1}function Vs(){return Pa}var $n=y({},va,{key:function(e){if(e.key){var t=Zr[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Hl(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Vo[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vs,charCode:function(e){return e.type==="keypress"?Hl(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Hl(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ys=Dn($n),Me=y({},qs,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Yo=Dn(Me),Cf=y({},va,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vs}),rs=Dn(Cf),kf=y({},ws,{propertyName:0,elapsedTime:0,pseudoElement:0}),Wo=Dn(kf),Jr=y({},qs,{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}),vu=Dn(Jr),Yl=y({},ws,{newState:0,oldState:0}),xu=Dn(Yl),qt=[9,13,27,32],Wl=Fa&&"CompositionEvent"in window,Ws=null;Fa&&"documentMode"in document&&(Ws=document.documentMode);var xi=Fa&&"TextEvent"in window&&!Ws,yu=Fa&&(!Wl||Ws&&8<Ws&&11>=Ws),wu=" ",Yt=!1;function yi(e,t){switch(e){case"keyup":return qt.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function bu(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var wi=!1;function bs(e,t){switch(e){case"compositionend":return bu(t);case"keypress":return t.which!==32?null:(Yt=!0,wu);case"textInput":return e=t.data,e===wu&&Yt?null:e;default:return null}}function Su(e,t){if(wi)return e==="compositionend"||!Wl&&yi(e,t)?(e=Go(),Qr=qo=vi=null,wi=!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 yu&&t.locale!=="ko"?null:t.data;default:return null}}var Kl={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 el(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Kl[e.type]:t==="textarea"}function xa(e,t,i,o){Hs?Kr?Kr.push(o):Kr=[o]:Hs=o,t=ud(t,"onChange"),0<t.length&&(i=new Us("onChange","change",null,i,o),e.push({event:i,listeners:t}))}var ya=null,Ks=null;function ls(e){hv(e,0)}function Un(e){var t=Pt(e);if(Fl(t))return e}function Zn(e,t){if(e==="change")return t}var ju=!1;if(Fa){var Ql;if(Fa){var Qs="oninput"in document;if(!Qs){var Cu=document.createElement("div");Cu.setAttribute("oninput","return;"),Qs=typeof Cu.oninput=="function"}Ql=Qs}else Ql=!1;ju=Ql&&(!document.documentMode||9<document.documentMode)}function _n(){ya&&(ya.detachEvent("onpropertychange",bi),Ks=ya=null)}function bi(e){if(e.propertyName==="value"&&Un(Ks)){var t=[];xa(t,Ks,e,Uo(e)),fu(ls,t)}}function Ss(e,t,i){e==="focusin"?(_n(),ya=t,Ks=i,ya.attachEvent("onpropertychange",bi)):e==="focusout"&&_n()}function ir(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Un(Ks)}function Xl(e,t){if(e==="click")return Un(t)}function Zl(e,t){if(e==="input"||e==="change")return Un(t)}function js(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Jn=typeof Object.is=="function"?Object.is:js;function tl(e,t){if(Jn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(o=0;o<i.length;o++){var f=i[o];if(!pe.call(t,f)||!Jn(e[f],t[f]))return!1}return!0}function nl(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function al(e,t){var i=nl(e);e=0;for(var o;i;){if(i.nodeType===3){if(o=e+i.textContent.length,e<=t&&o>=t)return{node:i,offset:t-e};e=o}e:{for(;i;){if(i.nextSibling){i=i.nextSibling;break e}i=i.parentNode}i=void 0}i=nl(i)}}function Ko(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ko(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Si(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=ra(e.document);t instanceof e.HTMLIFrameElement;){try{var i=typeof t.contentWindow.location.href=="string"}catch{i=!1}if(i)e=t.contentWindow;else break;t=ra(e.document)}return t}function Jl(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 ku=Fa&&"documentMode"in document&&11>=document.documentMode,rr=null,Xs=null,sl=null,eo=!1;function Au(e,t,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;eo||rr==null||rr!==ra(o)||(o=rr,"selectionStart"in o&&Jl(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}),sl&&tl(sl,o)||(sl=o,o=ud(Xs,"onSelect"),0<o.length&&(t=new Us("onSelect","select",null,t,i),e.push({event:t,listeners:o}),t.target=rr)))}function ji(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var Ci={animationend:ji("Animation","AnimationEnd"),animationiteration:ji("Animation","AnimationIteration"),animationstart:ji("Animation","AnimationStart"),transitionrun:ji("Transition","TransitionRun"),transitionstart:ji("Transition","TransitionStart"),transitioncancel:ji("Transition","TransitionCancel"),transitionend:ji("Transition","TransitionEnd")},Qo={},Xo={};Fa&&(Xo=document.createElement("div").style,"AnimationEvent"in window||(delete Ci.animationend.animation,delete Ci.animationiteration.animation,delete Ci.animationstart.animation),"TransitionEvent"in window||delete Ci.transitionend.transition);function Ha(e){if(Qo[e])return Qo[e];if(!Ci[e])return e;var t=Ci[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in Xo)return Qo[e]=t[i];return e}var Zo=Ha("animationend"),Cs=Ha("animationiteration"),il=Ha("animationstart"),lr=Ha("transitionrun"),ki=Ha("transitionstart"),Jo=Ha("transitioncancel"),Nu=Ha("transitionend"),ec=new Map,rl="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(" ");rl.push("scrollEnd");function la(e,t){ec.set(e,t),on(t,[e])}var Zs=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)},wa=[],ks=0,to=0;function Ai(){for(var e=ks,t=to=ks=0;t<e;){var i=wa[t];wa[t++]=null;var o=wa[t];wa[t++]=null;var f=wa[t];wa[t++]=null;var h=wa[t];if(wa[t++]=null,o!==null&&f!==null){var S=o.pending;S===null?f.next=f:(f.next=S.next,S.next=f),o.pending=f}h!==0&&ol(i,f,h)}}function or(e,t,i,o){wa[ks++]=e,wa[ks++]=t,wa[ks++]=i,wa[ks++]=o,to|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function ll(e,t,i,o){return or(e,t,i,o),Js(e)}function os(e,t){return or(e,null,null,t),Js(e)}function ol(e,t,i){e.lanes|=i;var o=e.alternate;o!==null&&(o.lanes|=i);for(var f=!1,h=e.return;h!==null;)h.childLanes|=i,o=h.alternate,o!==null&&(o.childLanes|=i),h.tag===22&&(e=h.stateNode,e===null||e._visibility&1||(f=!0)),e=h,h=h.return;return e.tag===3?(h=e.stateNode,f&&t!==null&&(f=31-Mt(i),e=h.hiddenUpdates,o=e[f],o===null?e[f]=[t]:o.push(t),t.lane=i|536870912),h):null}function Js(e){if(50<Ac)throw Ac=0,um=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var As={};function cr(e,t,i,o){this.tag=e,this.key=i,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 Sn(e,t,i,o){return new cr(e,t,i,o)}function no(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qn(e,t){var i=e.alternate;return i===null?(i=Sn(e.tag,t,e.key,e.mode),i.elementType=e.elementType,i.type=e.type,i.stateNode=e.stateNode,i.alternate=e,e.alternate=i):(i.pendingProps=t,i.type=e.type,i.flags=0,i.subtreeFlags=0,i.deletions=null),i.flags=e.flags&65011712,i.childLanes=e.childLanes,i.lanes=e.lanes,i.child=e.child,i.memoizedProps=e.memoizedProps,i.memoizedState=e.memoizedState,i.updateQueue=e.updateQueue,t=e.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},i.sibling=e.sibling,i.index=e.index,i.ref=e.ref,i.refCleanup=e.refCleanup,i}function cl(e,t){e.flags&=65011714;var i=e.alternate;return i===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=i.childLanes,e.lanes=i.lanes,e.child=i.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=i.memoizedProps,e.memoizedState=i.memoizedState,e.updateQueue=i.updateQueue,e.type=i.type,t=i.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ni(e,t,i,o,f,h){var S=0;if(o=e,typeof e=="function")no(e)&&(S=1);else if(typeof e=="string")S=vS(e,i,me.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case ie:return e=Sn(31,i,t,f),e.elementType=ie,e.lanes=h,e;case A:return ei(i.children,f,h,t);case T:S=8,f|=24;break;case k:return e=Sn(12,i,t,f|2),e.elementType=k,e.lanes=h,e;case F:return e=Sn(13,i,t,f),e.elementType=F,e.lanes=h,e;case q:return e=Sn(19,i,t,f),e.elementType=q,e.lanes=h,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:S=10;break e;case E:S=9;break e;case $:S=11;break e;case L:S=14;break e;case _:S=16,o=null;break e}S=29,i=Error(l(130,e===null?"null":typeof e,"")),o=null}return t=Sn(S,i,t,f),t.elementType=e,t.type=o,t.lanes=h,t}function ei(e,t,i,o){return e=Sn(7,e,o,t),e.lanes=i,e}function ba(e,t,i){return e=Sn(6,e,null,t),e.lanes=i,e}function tc(e){var t=Sn(18,null,null,0);return t.stateNode=e,t}function Mi(e,t,i){return t=Sn(4,e.children!==null?e.children:[],e.key,t),t.lanes=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ur=new WeakMap;function Sa(e,t){if(typeof e=="object"&&e!==null){var i=ur.get(e);return i!==void 0?i:(t={value:e,source:t,stack:Fe(t)},ur.set(e,t),t)}return{value:e,source:t,stack:Fe(t)}}var Ti=[],cn=0,ul=null,Ei=0,ea=[],Ln=0,ti=null,$a=1,cs="";function Ns(e,t){Ti[cn++]=Ei,Ti[cn++]=ul,ul=e,Ei=t}function ao(e,t,i){ea[Ln++]=$a,ea[Ln++]=cs,ea[Ln++]=ti,ti=e;var o=$a;e=cs;var f=32-Mt(o)-1;o&=~(1<<f),i+=1;var h=32-Mt(t)+f;if(30<h){var S=f-f%5;h=(o&(1<<S)-1).toString(32),o>>=S,f-=S,$a=1<<32-Mt(t)+f|i<<f|o,cs=h+e}else $a=1<<h|i<<f|o,cs=e}function so(e){e.return!==null&&(Ns(e,1),ao(e,1,0))}function Ri(e){for(;e===ul;)ul=Ti[--cn],Ti[cn]=null,Ei=Ti[--cn],Ti[cn]=null;for(;e===ti;)ti=ea[--Ln],ea[Ln]=null,cs=ea[--Ln],ea[Ln]=null,$a=ea[--Ln],ea[Ln]=null}function nc(e,t){ea[Ln++]=$a,ea[Ln++]=cs,ea[Ln++]=ti,$a=t.id,cs=t.overflow,ti=e}var pn=null,Lt=null,gt=!1,Ua=null,ja=!1,ac=Error(l(519));function qa(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ai(Sa(t,e)),ac}function Mu(e){var t=e.stateNode,i=e.type,o=e.memoizedProps;switch(t[te]=e,t[Ne]=o,i){case"dialog":yt("cancel",t),yt("close",t);break;case"iframe":case"object":case"embed":yt("load",t);break;case"video":case"audio":for(i=0;i<Mc.length;i++)yt(Mc[i],t);break;case"source":yt("error",t);break;case"img":case"image":case"link":yt("error",t),yt("load",t);break;case"details":yt("toggle",t);break;case"input":yt("invalid",t),Ji(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":yt("invalid",t);break;case"textarea":yt("invalid",t),gi(t,o.value,o.defaultValue,o.children)}i=o.children,typeof i!="string"&&typeof i!="number"&&typeof i!="bigint"||t.textContent===""+i||o.suppressHydrationWarning===!0||xv(t.textContent,i)?(o.popover!=null&&(yt("beforetoggle",t),yt("toggle",t)),o.onScroll!=null&&yt("scroll",t),o.onScrollEnd!=null&&yt("scrollend",t),o.onClick!=null&&(t.onclick=Hn),t=!0):t=!1,t||qa(e,!0)}function sc(e){for(pn=e.return;pn;)switch(pn.tag){case 5:case 31:case 13:ja=!1;return;case 27:case 3:ja=!0;return;default:pn=pn.return}}function Di(e){if(e!==pn)return!1;if(!gt)return sc(e),gt=!0,!1;var t=e.tag,i;if((i=t!==3&&t!==27)&&((i=t===5)&&(i=e.type,i=!(i!=="form"&&i!=="button")||km(e.type,e.memoizedProps)),i=!i),i&&Lt&&qa(e),sc(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Lt=Nv(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Lt=Nv(e)}else t===27?(t=Lt,Rr(e.type)?(e=Em,Em=null,Lt=e):Lt=t):Lt=pn?hs(e.stateNode.nextSibling):null;return!0}function ni(){Lt=pn=null,gt=!1}function ic(){var e=Ua;return e!==null&&(Ta===null?Ta=e:Ta.push.apply(Ta,e),Ua=null),e}function ai(e){Ua===null?Ua=[e]:Ua.push(e)}var us=ce(null),ds=null,Ms=null;function fs(e,t,i){P(us,t._currentValue),t._currentValue=i}function Ga(e){e._currentValue=us.current,W(us)}function Te(e,t,i){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===i)break;e=e.return}}function dr(e,t,i,o){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var h=f.dependencies;if(h!==null){var S=f.child;h=h.firstContext;e:for(;h!==null;){var M=h;h=f;for(var H=0;H<t.length;H++)if(M.context===t[H]){h.lanes|=i,M=h.alternate,M!==null&&(M.lanes|=i),Te(h.return,i,e),o||(S=null);break e}h=M.next}}else if(f.tag===18){if(S=f.return,S===null)throw Error(l(341));S.lanes|=i,h=S.alternate,h!==null&&(h.lanes|=i),Te(S,i,e),S=null}else S=f.child;if(S!==null)S.return=f;else for(S=f;S!==null;){if(S===e){S=null;break}if(f=S.sibling,f!==null){f.return=S.return,S=f;break}S=S.return}f=S}}function _i(e,t,i,o){e=null;for(var f=t,h=!1;f!==null;){if(!h){if((f.flags&524288)!==0)h=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var S=f.alternate;if(S===null)throw Error(l(387));if(S=S.memoizedProps,S!==null){var M=f.type;Jn(f.pendingProps.value,S.value)||(e!==null?e.push(M):e=[M])}}else if(f===Ce.current){if(S=f.alternate,S===null)throw Error(l(387));S.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(_c):e=[_c])}f=f.return}e!==null&&dr(t,e,i,o),t.flags|=262144}function io(e){for(e=e.firstContext;e!==null;){if(!Jn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function fr(e){ds=e,Ms=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function gn(e){return dl(ds,e)}function ro(e,t){return ds===null&&fr(e),dl(e,t)}function dl(e,t){var i=t._currentValue;if(t={context:t,memoizedValue:i,next:null},Ms===null){if(e===null)throw Error(l(308));Ms=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Ms=Ms.next=t;return i}var An=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(i,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(i){return i()})}},oa=n.unstable_scheduleCallback,vt=n.unstable_NormalPriority,un={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function rc(){return{controller:new An,data:new Map,refCount:0}}function fl(e){e.refCount--,e.refCount===0&&oa(vt,function(){e.controller.abort()})}var ml=null,lc=0,mr=0,hr=null;function Af(e,t){if(ml===null){var i=ml=[];lc=0,mr=gm(),hr={status:"pending",value:void 0,then:function(o){i.push(o)}}}return lc++,t.then(Tu,Tu),t}function Tu(){if(--lc===0&&ml!==null){hr!==null&&(hr.status="fulfilled");var e=ml;ml=null,mr=0,hr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Nf(e,t){var i=[],o={status:"pending",value:null,reason:null,then:function(f){i.push(f)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var f=0;f<i.length;f++)(0,i[f])(t)},function(f){for(o.status="rejected",o.reason=f,f=0;f<i.length;f++)(0,i[f])(void 0)}),o}var Eu=O.S;O.S=function(e,t){$g=tt(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Af(e,t),Eu!==null&&Eu(e,t)};var Li=ce(null);function oc(){var e=Li.current;return e!==null?e:Ht.pooledCache}function lo(e,t){t===null?P(Li,Li.current):P(Li,t.pool)}function Ru(){var e=oc();return e===null?null:{parent:un._currentValue,pool:e}}var pr=Error(l(460)),hl=Error(l(474)),gr=Error(l(542)),oo={then:function(){}};function Du(e){return e=e.status,e==="fulfilled"||e==="rejected"}function _u(e,t,i){switch(i=e[i],i===void 0?e.push(t):i!==t&&(t.then(Hn,Hn),t=i),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,zu(e),e;default:if(typeof t.status=="string")t.then(Hn,Hn);else{if(e=Ht,e!==null&&100<e.shellSuspendCounter)throw Error(l(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var f=t;f.status="fulfilled",f.value=o}},function(o){if(t.status==="pending"){var f=t;f.status="rejected",f.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,zu(e),e}throw Ii=t,pr}}function zi(e){try{var t=e._init;return t(e._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(Ii=i,pr):i}}var Ii=null;function Lu(){if(Ii===null)throw Error(l(459));var e=Ii;return Ii=null,e}function zu(e){if(e===pr||e===gr)throw Error(l(483))}var vr=null,pl=0;function Ts(e){var t=pl;return pl+=1,vr===null&&(vr=[]),_u(vr,e,t)}function xr(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function yr(e,t){throw t.$$typeof===b?Error(l(525)):(e=Object.prototype.toString.call(t),Error(l(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function Iu(e){function t(ee,G){if(e){var ae=ee.deletions;ae===null?(ee.deletions=[G],ee.flags|=16):ae.push(G)}}function i(ee,G){if(!e)return null;for(;G!==null;)t(ee,G),G=G.sibling;return null}function o(ee){for(var G=new Map;ee!==null;)ee.key!==null?G.set(ee.key,ee):G.set(ee.index,ee),ee=ee.sibling;return G}function f(ee,G){return ee=qn(ee,G),ee.index=0,ee.sibling=null,ee}function h(ee,G,ae){return ee.index=ae,e?(ae=ee.alternate,ae!==null?(ae=ae.index,ae<G?(ee.flags|=67108866,G):ae):(ee.flags|=67108866,G)):(ee.flags|=1048576,G)}function S(ee){return e&&ee.alternate===null&&(ee.flags|=67108866),ee}function M(ee,G,ae,be){return G===null||G.tag!==6?(G=ba(ae,ee.mode,be),G.return=ee,G):(G=f(G,ae),G.return=ee,G)}function H(ee,G,ae,be){var Ke=ae.type;return Ke===A?ye(ee,G,ae.props.children,be,ae.key):G!==null&&(G.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===_&&zi(Ke)===G.type)?(G=f(G,ae.props),xr(G,ae),G.return=ee,G):(G=Ni(ae.type,ae.key,ae.props,null,ee.mode,be),xr(G,ae),G.return=ee,G)}function se(ee,G,ae,be){return G===null||G.tag!==4||G.stateNode.containerInfo!==ae.containerInfo||G.stateNode.implementation!==ae.implementation?(G=Mi(ae,ee.mode,be),G.return=ee,G):(G=f(G,ae.children||[]),G.return=ee,G)}function ye(ee,G,ae,be,Ke){return G===null||G.tag!==7?(G=ei(ae,ee.mode,be,Ke),G.return=ee,G):(G=f(G,ae),G.return=ee,G)}function Se(ee,G,ae){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=ba(""+G,ee.mode,ae),G.return=ee,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case j:return ae=Ni(G.type,G.key,G.props,null,ee.mode,ae),xr(ae,G),ae.return=ee,ae;case C:return G=Mi(G,ee.mode,ae),G.return=ee,G;case _:return G=zi(G),Se(ee,G,ae)}if(Y(G)||Q(G))return G=ei(G,ee.mode,ae,null),G.return=ee,G;if(typeof G.then=="function")return Se(ee,Ts(G),ae);if(G.$$typeof===R)return Se(ee,ro(ee,G),ae);yr(ee,G)}return null}function re(ee,G,ae,be){var Ke=G!==null?G.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return Ke!==null?null:M(ee,G,""+ae,be);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case j:return ae.key===Ke?H(ee,G,ae,be):null;case C:return ae.key===Ke?se(ee,G,ae,be):null;case _:return ae=zi(ae),re(ee,G,ae,be)}if(Y(ae)||Q(ae))return Ke!==null?null:ye(ee,G,ae,be,null);if(typeof ae.then=="function")return re(ee,G,Ts(ae),be);if(ae.$$typeof===R)return re(ee,G,ro(ee,ae),be);yr(ee,ae)}return null}function fe(ee,G,ae,be,Ke){if(typeof be=="string"&&be!==""||typeof be=="number"||typeof be=="bigint")return ee=ee.get(ae)||null,M(G,ee,""+be,Ke);if(typeof be=="object"&&be!==null){switch(be.$$typeof){case j:return ee=ee.get(be.key===null?ae:be.key)||null,H(G,ee,be,Ke);case C:return ee=ee.get(be.key===null?ae:be.key)||null,se(G,ee,be,Ke);case _:return be=zi(be),fe(ee,G,ae,be,Ke)}if(Y(be)||Q(be))return ee=ee.get(ae)||null,ye(G,ee,be,Ke,null);if(typeof be.then=="function")return fe(ee,G,ae,Ts(be),Ke);if(be.$$typeof===R)return fe(ee,G,ae,ro(G,be),Ke);yr(G,be)}return null}function qe(ee,G,ae,be){for(var Ke=null,Ct=null,Ve=G,dt=G=0,bt=null;Ve!==null&&dt<ae.length;dt++){Ve.index>dt?(bt=Ve,Ve=null):bt=Ve.sibling;var kt=re(ee,Ve,ae[dt],be);if(kt===null){Ve===null&&(Ve=bt);break}e&&Ve&&kt.alternate===null&&t(ee,Ve),G=h(kt,G,dt),Ct===null?Ke=kt:Ct.sibling=kt,Ct=kt,Ve=bt}if(dt===ae.length)return i(ee,Ve),gt&&Ns(ee,dt),Ke;if(Ve===null){for(;dt<ae.length;dt++)Ve=Se(ee,ae[dt],be),Ve!==null&&(G=h(Ve,G,dt),Ct===null?Ke=Ve:Ct.sibling=Ve,Ct=Ve);return gt&&Ns(ee,dt),Ke}for(Ve=o(Ve);dt<ae.length;dt++)bt=fe(Ve,ee,dt,ae[dt],be),bt!==null&&(e&&bt.alternate!==null&&Ve.delete(bt.key===null?dt:bt.key),G=h(bt,G,dt),Ct===null?Ke=bt:Ct.sibling=bt,Ct=bt);return e&&Ve.forEach(function(Ir){return t(ee,Ir)}),gt&&Ns(ee,dt),Ke}function Ze(ee,G,ae,be){if(ae==null)throw Error(l(151));for(var Ke=null,Ct=null,Ve=G,dt=G=0,bt=null,kt=ae.next();Ve!==null&&!kt.done;dt++,kt=ae.next()){Ve.index>dt?(bt=Ve,Ve=null):bt=Ve.sibling;var Ir=re(ee,Ve,kt.value,be);if(Ir===null){Ve===null&&(Ve=bt);break}e&&Ve&&Ir.alternate===null&&t(ee,Ve),G=h(Ir,G,dt),Ct===null?Ke=Ir:Ct.sibling=Ir,Ct=Ir,Ve=bt}if(kt.done)return i(ee,Ve),gt&&Ns(ee,dt),Ke;if(Ve===null){for(;!kt.done;dt++,kt=ae.next())kt=Se(ee,kt.value,be),kt!==null&&(G=h(kt,G,dt),Ct===null?Ke=kt:Ct.sibling=kt,Ct=kt);return gt&&Ns(ee,dt),Ke}for(Ve=o(Ve);!kt.done;dt++,kt=ae.next())kt=fe(Ve,ee,dt,kt.value,be),kt!==null&&(e&&kt.alternate!==null&&Ve.delete(kt.key===null?dt:kt.key),G=h(kt,G,dt),Ct===null?Ke=kt:Ct.sibling=kt,Ct=kt);return e&&Ve.forEach(function(MS){return t(ee,MS)}),gt&&Ns(ee,dt),Ke}function Ot(ee,G,ae,be){if(typeof ae=="object"&&ae!==null&&ae.type===A&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case j:e:{for(var Ke=ae.key;G!==null;){if(G.key===Ke){if(Ke=ae.type,Ke===A){if(G.tag===7){i(ee,G.sibling),be=f(G,ae.props.children),be.return=ee,ee=be;break e}}else if(G.elementType===Ke||typeof Ke=="object"&&Ke!==null&&Ke.$$typeof===_&&zi(Ke)===G.type){i(ee,G.sibling),be=f(G,ae.props),xr(be,ae),be.return=ee,ee=be;break e}i(ee,G);break}else t(ee,G);G=G.sibling}ae.type===A?(be=ei(ae.props.children,ee.mode,be,ae.key),be.return=ee,ee=be):(be=Ni(ae.type,ae.key,ae.props,null,ee.mode,be),xr(be,ae),be.return=ee,ee=be)}return S(ee);case C:e:{for(Ke=ae.key;G!==null;){if(G.key===Ke)if(G.tag===4&&G.stateNode.containerInfo===ae.containerInfo&&G.stateNode.implementation===ae.implementation){i(ee,G.sibling),be=f(G,ae.children||[]),be.return=ee,ee=be;break e}else{i(ee,G);break}else t(ee,G);G=G.sibling}be=Mi(ae,ee.mode,be),be.return=ee,ee=be}return S(ee);case _:return ae=zi(ae),Ot(ee,G,ae,be)}if(Y(ae))return qe(ee,G,ae,be);if(Q(ae)){if(Ke=Q(ae),typeof Ke!="function")throw Error(l(150));return ae=Ke.call(ae),Ze(ee,G,ae,be)}if(typeof ae.then=="function")return Ot(ee,G,Ts(ae),be);if(ae.$$typeof===R)return Ot(ee,G,ro(ee,ae),be);yr(ee,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint"?(ae=""+ae,G!==null&&G.tag===6?(i(ee,G.sibling),be=f(G,ae),be.return=ee,ee=be):(i(ee,G),be=ba(ae,ee.mode,be),be.return=ee,ee=be),S(ee)):i(ee,G)}return function(ee,G,ae,be){try{pl=0;var Ke=Ot(ee,G,ae,be);return vr=null,Ke}catch(Ve){if(Ve===pr||Ve===gr)throw Ve;var Ct=Sn(29,Ve,null,ee.mode);return Ct.lanes=be,Ct.return=ee,Ct}}}var si=Iu(!0),Ou=Iu(!1),Es=!1;function wr(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function co(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 Zt(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Va(e,t,i){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(Nt&2)!==0){var f=o.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),o.pending=t,t=Js(e),ol(e,null,i),t}return or(e,o,t,i),Js(e)}function br(e,t,i){if(t=t.updateQueue,t!==null&&(t=t.shared,(i&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,i|=o,t.lanes=i,B(e,i)}}function cc(e,t){var i=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,i===o)){var f=null,h=null;if(i=i.firstBaseUpdate,i!==null){do{var S={lane:i.lane,tag:i.tag,payload:i.payload,callback:null,next:null};h===null?f=h=S:h=h.next=S,i=i.next}while(i!==null);h===null?f=h=t:h=h.next=t}else f=h=t;i={baseState:o.baseState,firstBaseUpdate:f,lastBaseUpdate:h,shared:o.shared,callbacks:o.callbacks},e.updateQueue=i;return}e=i.lastBaseUpdate,e===null?i.firstBaseUpdate=t:e.next=t,i.lastBaseUpdate=t}var Bu=!1;function gl(){if(Bu){var e=hr;if(e!==null)throw e}}function vl(e,t,i,o){Bu=!1;var f=e.updateQueue;Es=!1;var h=f.firstBaseUpdate,S=f.lastBaseUpdate,M=f.shared.pending;if(M!==null){f.shared.pending=null;var H=M,se=H.next;H.next=null,S===null?h=se:S.next=se,S=H;var ye=e.alternate;ye!==null&&(ye=ye.updateQueue,M=ye.lastBaseUpdate,M!==S&&(M===null?ye.firstBaseUpdate=se:M.next=se,ye.lastBaseUpdate=H))}if(h!==null){var Se=f.baseState;S=0,ye=se=H=null,M=h;do{var re=M.lane&-536870913,fe=re!==M.lane;if(fe?(wt&re)===re:(o&re)===re){re!==0&&re===mr&&(Bu=!0),ye!==null&&(ye=ye.next={lane:0,tag:M.tag,payload:M.payload,callback:null,next:null});e:{var qe=e,Ze=M;re=t;var Ot=i;switch(Ze.tag){case 1:if(qe=Ze.payload,typeof qe=="function"){Se=qe.call(Ot,Se,re);break e}Se=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Ze.payload,re=typeof qe=="function"?qe.call(Ot,Se,re):qe,re==null)break e;Se=y({},Se,re);break e;case 2:Es=!0}}re=M.callback,re!==null&&(e.flags|=64,fe&&(e.flags|=8192),fe=f.callbacks,fe===null?f.callbacks=[re]:fe.push(re))}else fe={lane:re,tag:M.tag,payload:M.payload,callback:M.callback,next:null},ye===null?(se=ye=fe,H=Se):ye=ye.next=fe,S|=re;if(M=M.next,M===null){if(M=f.shared.pending,M===null)break;fe=M,M=fe.next,fe.next=null,f.lastBaseUpdate=fe,f.shared.pending=null}}while(!0);ye===null&&(H=Se),f.baseState=H,f.firstBaseUpdate=se,f.lastBaseUpdate=ye,h===null&&(f.shared.lanes=0),Ar|=S,e.lanes=S,e.memoizedState=Se}}function uc(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function xl(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;e<i.length;e++)uc(i[e],t)}var ms=ce(null),yl=ce(0);function Fu(e,t){e=qi,P(yl,e),P(ms,t),qi=e|t.baseLanes}function dc(){P(yl,qi),P(ms,ms.current)}function fc(){qi=yl.current,W(ms),W(yl)}var ca=ce(null),Ca=null;function ii(e){var t=e.alternate;P(zt,zt.current&1),P(ca,e),Ca===null&&(t===null||ms.current!==null||t.memoizedState!==null)&&(Ca=e)}function mc(e){P(zt,zt.current),P(ca,e),Ca===null&&(Ca=e)}function ua(e){e.tag===22?(P(zt,zt.current),P(ca,e),Ca===null&&(Ca=e)):ri()}function ri(){P(zt,zt.current),P(ca,ca.current)}function da(e){W(ca),Ca===e&&(Ca=null),W(zt)}var zt=ce(0);function uo(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Mm(i)||Tm(i)))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 Ya=0,st=null,At=null,x=null,N=!1,I=!1,U=!1,z=0,ve=0,he=null,_e=0;function Pe(){throw Error(l(321))}function lt(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!Jn(e[i],t[i]))return!1;return!0}function Jt(e,t,i,o,f,h){return Ya=h,st=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,O.H=e===null||e.memoizedState===null?Jp:Ff,U=!1,h=i(o,f),U=!1,I&&(h=ka(t,i,o,f)),Nn(e),h}function Nn(e){O.H=vc;var t=At!==null&&At.next!==null;if(Ya=0,x=At=st=null,N=!1,ve=0,he=null,t)throw Error(l(300));e===null||jn||(e=e.dependencies,e!==null&&io(e)&&(jn=!0))}function ka(e,t,i,o){st=e;var f=0;do{if(I&&(he=null),ve=0,I=!1,25<=f)throw Error(l(301));if(f+=1,x=At=null,e.updateQueue!=null){var h=e.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}O.H=eg,h=t(i,o)}while(I);return h}function fo(){var e=O.H,t=e.useState()[0];return t=typeof t.then=="function"?pc(t):t,e=e.useState()[0],(At!==null?At.memoizedState:null)!==e&&(st.flags|=1024),t}function Sr(){var e=z!==0;return z=0,e}function hc(e,t,i){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i}function jr(e){if(N){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}N=!1}Ya=0,x=At=st=null,I=!1,ve=z=0,he=null}function Gn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return x===null?st.memoizedState=x=e:x=x.next=e,x}function vn(){if(At===null){var e=st.alternate;e=e!==null?e.memoizedState:null}else e=At.next;var t=x===null?st.memoizedState:x.next;if(t!==null)x=t,At=e;else{if(e===null)throw st.alternate===null?Error(l(467)):Error(l(310));At=e,e={memoizedState:At.memoizedState,baseState:At.baseState,baseQueue:At.baseQueue,queue:At.queue,next:null},x===null?st.memoizedState=x=e:x=x.next=e}return x}function Pu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function pc(e){var t=ve;return ve+=1,he===null&&(he=[]),e=_u(he,e,t),t=st,(x===null?t.memoizedState:x.next)===null&&(t=t.alternate,O.H=t===null||t.memoizedState===null?Jp:Ff),e}function Hu(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return pc(e);if(e.$$typeof===R)return gn(e)}throw Error(l(438,String(e)))}function Mf(e){var t=null,i=st.updateQueue;if(i!==null&&(t=i.memoCache),t==null){var o=st.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(f){return f.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),i===null&&(i=Pu(),st.updateQueue=i),i.memoCache=t,i=t.data[t.index],i===void 0)for(i=t.data[t.index]=Array(e),o=0;o<e;o++)i[o]=V;return t.index++,i}function Oi(e,t){return typeof t=="function"?t(e):t}function $u(e){var t=vn();return Tf(t,At,e)}function Tf(e,t,i){var o=e.queue;if(o===null)throw Error(l(311));o.lastRenderedReducer=i;var f=e.baseQueue,h=o.pending;if(h!==null){if(f!==null){var S=f.next;f.next=h.next,h.next=S}t.baseQueue=f=h,o.pending=null}if(h=e.baseState,f===null)e.memoizedState=h;else{t=f.next;var M=S=null,H=null,se=t,ye=!1;do{var Se=se.lane&-536870913;if(Se!==se.lane?(wt&Se)===Se:(Ya&Se)===Se){var re=se.revertLane;if(re===0)H!==null&&(H=H.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),Se===mr&&(ye=!0);else if((Ya&re)===re){se=se.next,re===mr&&(ye=!0);continue}else Se={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},H===null?(M=H=Se,S=h):H=H.next=Se,st.lanes|=re,Ar|=re;Se=se.action,U&&i(h,Se),h=se.hasEagerState?se.eagerState:i(h,Se)}else re={lane:Se,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},H===null?(M=H=re,S=h):H=H.next=re,st.lanes|=Se,Ar|=Se;se=se.next}while(se!==null&&se!==t);if(H===null?S=h:H.next=M,!Jn(h,e.memoizedState)&&(jn=!0,ye&&(i=hr,i!==null)))throw i;e.memoizedState=h,e.baseState=S,e.baseQueue=H,o.lastRenderedState=h}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Ef(e){var t=vn(),i=t.queue;if(i===null)throw Error(l(311));i.lastRenderedReducer=e;var o=i.dispatch,f=i.pending,h=t.memoizedState;if(f!==null){i.pending=null;var S=f=f.next;do h=e(h,S.action),S=S.next;while(S!==f);Jn(h,t.memoizedState)||(jn=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),i.lastRenderedState=h}return[h,o]}function yp(e,t,i){var o=st,f=vn(),h=gt;if(h){if(i===void 0)throw Error(l(407));i=i()}else i=t();var S=!Jn((At||f).memoizedState,i);if(S&&(f.memoizedState=i,jn=!0),f=f.queue,_f(Sp.bind(null,o,f,e),[e]),f.getSnapshot!==t||S||x!==null&&x.memoizedState.tag&1){if(o.flags|=2048,mo(9,{destroy:void 0},bp.bind(null,o,f,i,t),null),Ht===null)throw Error(l(349));h||(Ya&127)!==0||wp(o,t,i)}return i}function wp(e,t,i){e.flags|=16384,e={getSnapshot:t,value:i},t=st.updateQueue,t===null?(t=Pu(),st.updateQueue=t,t.stores=[e]):(i=t.stores,i===null?t.stores=[e]:i.push(e))}function bp(e,t,i,o){t.value=i,t.getSnapshot=o,jp(t)&&Cp(e)}function Sp(e,t,i){return i(function(){jp(t)&&Cp(e)})}function jp(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!Jn(e,i)}catch{return!0}}function Cp(e){var t=os(e,2);t!==null&&Ea(t,e,2)}function Rf(e){var t=Gn();if(typeof e=="function"){var i=e;if(e=i(),U){nn(!0);try{i()}finally{nn(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oi,lastRenderedState:e},t}function kp(e,t,i,o){return e.baseState=i,Tf(e,At,typeof o=="function"?o:Oi)}function wb(e,t,i,o,f){if(Gu(e))throw Error(l(485));if(e=t.action,e!==null){var h={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){h.listeners.push(S)}};O.T!==null?i(!0):h.isTransition=!1,o(h),i=t.pending,i===null?(h.next=t.pending=h,Ap(t,h)):(h.next=i.next,t.pending=i.next=h)}}function Ap(e,t){var i=t.action,o=t.payload,f=e.state;if(t.isTransition){var h=O.T,S={};O.T=S;try{var M=i(f,o),H=O.S;H!==null&&H(S,M),Np(e,t,M)}catch(se){Df(e,t,se)}finally{h!==null&&S.types!==null&&(h.types=S.types),O.T=h}}else try{h=i(f,o),Np(e,t,h)}catch(se){Df(e,t,se)}}function Np(e,t,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(o){Mp(e,t,o)},function(o){return Df(e,t,o)}):Mp(e,t,i)}function Mp(e,t,i){t.status="fulfilled",t.value=i,Tp(t),e.state=i,t=e.pending,t!==null&&(i=t.next,i===t?e.pending=null:(i=i.next,t.next=i,Ap(e,i)))}function Df(e,t,i){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=i,Tp(t),t=t.next;while(t!==o)}e.action=null}function Tp(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Ep(e,t){return t}function Rp(e,t){if(gt){var i=Ht.formState;if(i!==null){e:{var o=st;if(gt){if(Lt){t:{for(var f=Lt,h=ja;f.nodeType!==8;){if(!h){f=null;break t}if(f=hs(f.nextSibling),f===null){f=null;break t}}h=f.data,f=h==="F!"||h==="F"?f:null}if(f){Lt=hs(f.nextSibling),o=f.data==="F!";break e}}qa(o)}o=!1}o&&(t=i[0])}}return i=Gn(),i.memoizedState=i.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ep,lastRenderedState:t},i.queue=o,i=Qp.bind(null,st,o),o.dispatch=i,o=Rf(!1),h=Bf.bind(null,st,!1,o.queue),o=Gn(),f={state:t,dispatch:null,action:e,pending:null},o.queue=f,i=wb.bind(null,st,f,h,i),f.dispatch=i,o.memoizedState=e,[t,i,!1]}function Dp(e){var t=vn();return _p(t,At,e)}function _p(e,t,i){if(t=Tf(e,t,Ep)[0],e=$u(Oi)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=pc(t)}catch(S){throw S===pr?gr:S}else o=t;t=vn();var f=t.queue,h=f.dispatch;return i!==t.memoizedState&&(st.flags|=2048,mo(9,{destroy:void 0},bb.bind(null,f,i),null)),[o,h,e]}function bb(e,t){e.action=t}function Lp(e){var t=vn(),i=At;if(i!==null)return _p(t,i,e);vn(),t=t.memoizedState,i=vn();var o=i.queue.dispatch;return i.memoizedState=e,[t,o,!1]}function mo(e,t,i,o){return e={tag:e,create:i,deps:o,inst:t,next:null},t=st.updateQueue,t===null&&(t=Pu(),st.updateQueue=t),i=t.lastEffect,i===null?t.lastEffect=e.next=e:(o=i.next,i.next=e,e.next=o,t.lastEffect=e),e}function zp(){return vn().memoizedState}function Uu(e,t,i,o){var f=Gn();st.flags|=e,f.memoizedState=mo(1|t,{destroy:void 0},i,o===void 0?null:o)}function qu(e,t,i,o){var f=vn();o=o===void 0?null:o;var h=f.memoizedState.inst;At!==null&&o!==null&<(o,At.memoizedState.deps)?f.memoizedState=mo(t,h,i,o):(st.flags|=e,f.memoizedState=mo(1|t,h,i,o))}function Ip(e,t){Uu(8390656,8,e,t)}function _f(e,t){qu(2048,8,e,t)}function Sb(e){st.flags|=4;var t=st.updateQueue;if(t===null)t=Pu(),st.updateQueue=t,t.events=[e];else{var i=t.events;i===null?t.events=[e]:i.push(e)}}function Op(e){var t=vn().memoizedState;return Sb({ref:t,nextImpl:e}),function(){if((Nt&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function Bp(e,t){return qu(4,2,e,t)}function Fp(e,t){return qu(4,4,e,t)}function Pp(e,t){if(typeof t=="function"){e=e();var i=t(e);return function(){typeof i=="function"?i():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Hp(e,t,i){i=i!=null?i.concat([e]):null,qu(4,4,Pp.bind(null,t,e),i)}function Lf(){}function $p(e,t){var i=vn();t=t===void 0?null:t;var o=i.memoizedState;return t!==null&<(t,o[1])?o[0]:(i.memoizedState=[e,t],e)}function Up(e,t){var i=vn();t=t===void 0?null:t;var o=i.memoizedState;if(t!==null&<(t,o[1]))return o[0];if(o=e(),U){nn(!0);try{e()}finally{nn(!1)}}return i.memoizedState=[o,t],o}function zf(e,t,i){return i===void 0||(Ya&1073741824)!==0&&(wt&261930)===0?e.memoizedState=t:(e.memoizedState=i,e=qg(),st.lanes|=e,Ar|=e,i)}function qp(e,t,i,o){return Jn(i,t)?i:ms.current!==null?(e=zf(e,i,o),Jn(e,t)||(jn=!0),e):(Ya&42)===0||(Ya&1073741824)!==0&&(wt&261930)===0?(jn=!0,e.memoizedState=i):(e=qg(),st.lanes|=e,Ar|=e,t)}function Gp(e,t,i,o,f){var h=Z.p;Z.p=h!==0&&8>h?h:8;var S=O.T,M={};O.T=M,Bf(e,!1,t,i);try{var H=f(),se=O.S;if(se!==null&&se(M,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var ye=Nf(H,o);gc(e,t,ye,Qa(e))}else gc(e,t,o,Qa(e))}catch(Se){gc(e,t,{then:function(){},status:"rejected",reason:Se},Qa())}finally{Z.p=h,S!==null&&M.types!==null&&(S.types=M.types),O.T=S}}function jb(){}function If(e,t,i,o){if(e.tag!==5)throw Error(l(476));var f=Vp(e).queue;Gp(e,f,t,X,i===null?jb:function(){return Yp(e),i(o)})}function Vp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oi,lastRenderedState:X},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Oi,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Yp(e){var t=Vp(e);t.next===null&&(t=e.alternate.memoizedState),gc(e,t.next.queue,{},Qa())}function Of(){return gn(_c)}function Wp(){return vn().memoizedState}function Kp(){return vn().memoizedState}function Cb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=Qa();e=Zt(i);var o=Va(t,e,i);o!==null&&(Ea(o,t,i),br(o,t,i)),t={cache:rc()},e.payload=t;return}t=t.return}}function kb(e,t,i){var o=Qa();i={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Gu(e)?Xp(t,i):(i=ll(e,t,i,o),i!==null&&(Ea(i,e,o),Zp(i,t,o)))}function Qp(e,t,i){var o=Qa();gc(e,t,i,o)}function gc(e,t,i,o){var f={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Gu(e))Xp(t,f);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=t.lastRenderedReducer,h!==null))try{var S=t.lastRenderedState,M=h(S,i);if(f.hasEagerState=!0,f.eagerState=M,Jn(M,S))return or(e,t,f,0),Ht===null&&Ai(),!1}catch{}if(i=ll(e,t,f,o),i!==null)return Ea(i,e,o),Zp(i,t,o),!0}return!1}function Bf(e,t,i,o){if(o={lane:2,revertLane:gm(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Gu(e)){if(t)throw Error(l(479))}else t=ll(e,i,o,2),t!==null&&Ea(t,e,2)}function Gu(e){var t=e.alternate;return e===st||t!==null&&t===st}function Xp(e,t){I=N=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function Zp(e,t,i){if((i&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,i|=o,t.lanes=i,B(e,i)}}var vc={readContext:gn,use:Hu,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useLayoutEffect:Pe,useInsertionEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useSyncExternalStore:Pe,useId:Pe,useHostTransitionStatus:Pe,useFormState:Pe,useActionState:Pe,useOptimistic:Pe,useMemoCache:Pe,useCacheRefresh:Pe};vc.useEffectEvent=Pe;var Jp={readContext:gn,use:Hu,useCallback:function(e,t){return Gn().memoizedState=[e,t===void 0?null:t],e},useContext:gn,useEffect:Ip,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,Uu(4194308,4,Pp.bind(null,t,e),i)},useLayoutEffect:function(e,t){return Uu(4194308,4,e,t)},useInsertionEffect:function(e,t){Uu(4,2,e,t)},useMemo:function(e,t){var i=Gn();t=t===void 0?null:t;var o=e();if(U){nn(!0);try{e()}finally{nn(!1)}}return i.memoizedState=[o,t],o},useReducer:function(e,t,i){var o=Gn();if(i!==void 0){var f=i(t);if(U){nn(!0);try{i(t)}finally{nn(!1)}}}else f=t;return o.memoizedState=o.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},o.queue=e,e=e.dispatch=kb.bind(null,st,e),[o.memoizedState,e]},useRef:function(e){var t=Gn();return e={current:e},t.memoizedState=e},useState:function(e){e=Rf(e);var t=e.queue,i=Qp.bind(null,st,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:Lf,useDeferredValue:function(e,t){var i=Gn();return zf(i,e,t)},useTransition:function(){var e=Rf(!1);return e=Gp.bind(null,st,e.queue,!0,!1),Gn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var o=st,f=Gn();if(gt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=t(),Ht===null)throw Error(l(349));(wt&127)!==0||wp(o,t,i)}f.memoizedState=i;var h={value:i,getSnapshot:t};return f.queue=h,Ip(Sp.bind(null,o,h,e),[e]),o.flags|=2048,mo(9,{destroy:void 0},bp.bind(null,o,h,i,t),null),i},useId:function(){var e=Gn(),t=Ht.identifierPrefix;if(gt){var i=cs,o=$a;i=(o&~(1<<32-Mt(o)-1)).toString(32)+i,t="_"+t+"R_"+i,i=z++,0<i&&(t+="H"+i.toString(32)),t+="_"}else i=_e++,t="_"+t+"r_"+i.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:Of,useFormState:Rp,useActionState:Rp,useOptimistic:function(e){var t=Gn();t.memoizedState=t.baseState=e;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=i,t=Bf.bind(null,st,!0,i),i.dispatch=t,[e,t]},useMemoCache:Mf,useCacheRefresh:function(){return Gn().memoizedState=Cb.bind(null,st)},useEffectEvent:function(e){var t=Gn(),i={impl:e};return t.memoizedState=i,function(){if((Nt&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},Ff={readContext:gn,use:Hu,useCallback:$p,useContext:gn,useEffect:_f,useImperativeHandle:Hp,useInsertionEffect:Bp,useLayoutEffect:Fp,useMemo:Up,useReducer:$u,useRef:zp,useState:function(){return $u(Oi)},useDebugValue:Lf,useDeferredValue:function(e,t){var i=vn();return qp(i,At.memoizedState,e,t)},useTransition:function(){var e=$u(Oi)[0],t=vn().memoizedState;return[typeof e=="boolean"?e:pc(e),t]},useSyncExternalStore:yp,useId:Wp,useHostTransitionStatus:Of,useFormState:Dp,useActionState:Dp,useOptimistic:function(e,t){var i=vn();return kp(i,At,e,t)},useMemoCache:Mf,useCacheRefresh:Kp};Ff.useEffectEvent=Op;var eg={readContext:gn,use:Hu,useCallback:$p,useContext:gn,useEffect:_f,useImperativeHandle:Hp,useInsertionEffect:Bp,useLayoutEffect:Fp,useMemo:Up,useReducer:Ef,useRef:zp,useState:function(){return Ef(Oi)},useDebugValue:Lf,useDeferredValue:function(e,t){var i=vn();return At===null?zf(i,e,t):qp(i,At.memoizedState,e,t)},useTransition:function(){var e=Ef(Oi)[0],t=vn().memoizedState;return[typeof e=="boolean"?e:pc(e),t]},useSyncExternalStore:yp,useId:Wp,useHostTransitionStatus:Of,useFormState:Lp,useActionState:Lp,useOptimistic:function(e,t){var i=vn();return At!==null?kp(i,At,e,t):(i.baseState=e,[e,i.queue.dispatch])},useMemoCache:Mf,useCacheRefresh:Kp};eg.useEffectEvent=Op;function Pf(e,t,i,o){t=e.memoizedState,i=i(o,t),i=i==null?t:y({},t,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Hf={enqueueSetState:function(e,t,i){e=e._reactInternals;var o=Qa(),f=Zt(o);f.payload=t,i!=null&&(f.callback=i),t=Va(e,f,o),t!==null&&(Ea(t,e,o),br(t,e,o))},enqueueReplaceState:function(e,t,i){e=e._reactInternals;var o=Qa(),f=Zt(o);f.tag=1,f.payload=t,i!=null&&(f.callback=i),t=Va(e,f,o),t!==null&&(Ea(t,e,o),br(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var i=Qa(),o=Zt(i);o.tag=2,t!=null&&(o.callback=t),t=Va(e,o,i),t!==null&&(Ea(t,e,i),br(t,e,i))}};function tg(e,t,i,o,f,h,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,h,S):t.prototype&&t.prototype.isPureReactComponent?!tl(i,o)||!tl(f,h):!0}function ng(e,t,i,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(i,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(i,o),t.state!==e&&Hf.enqueueReplaceState(t,t.state,null)}function wl(e,t){var i=t;if("ref"in t){i={};for(var o in t)o!=="ref"&&(i[o]=t[o])}if(e=e.defaultProps){i===t&&(i=y({},i));for(var f in e)i[f]===void 0&&(i[f]=e[f])}return i}function ag(e){Zs(e)}function sg(e){console.error(e)}function ig(e){Zs(e)}function Vu(e,t){try{var i=e.onUncaughtError;i(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function rg(e,t,i){try{var o=e.onCaughtError;o(i.value,{componentStack:i.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function $f(e,t,i){return i=Zt(i),i.tag=3,i.payload={element:null},i.callback=function(){Vu(e,t)},i}function lg(e){return e=Zt(e),e.tag=3,e}function og(e,t,i,o){var f=i.type.getDerivedStateFromError;if(typeof f=="function"){var h=o.value;e.payload=function(){return f(h)},e.callback=function(){rg(t,i,o)}}var S=i.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){rg(t,i,o),typeof f!="function"&&(Nr===null?Nr=new Set([this]):Nr.add(this));var M=o.stack;this.componentDidCatch(o.value,{componentStack:M!==null?M:""})})}function Ab(e,t,i,o,f){if(i.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=i.alternate,t!==null&&_i(t,i,f,!0),i=ca.current,i!==null){switch(i.tag){case 31:case 13:return Ca===null?sd():i.alternate===null&&dn===0&&(dn=3),i.flags&=-257,i.flags|=65536,i.lanes=f,o===oo?i.flags|=16384:(t=i.updateQueue,t===null?i.updateQueue=new Set([o]):t.add(o),mm(e,o,f)),!1;case 22:return i.flags|=65536,o===oo?i.flags|=16384:(t=i.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},i.updateQueue=t):(i=t.retryQueue,i===null?t.retryQueue=new Set([o]):i.add(o)),mm(e,o,f)),!1}throw Error(l(435,i.tag))}return mm(e,o,f),sd(),!1}if(gt)return t=ca.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=f,o!==ac&&(e=Error(l(422),{cause:o}),ai(Sa(e,i)))):(o!==ac&&(t=Error(l(423),{cause:o}),ai(Sa(t,i))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=Sa(o,i),f=$f(e.stateNode,o,f),cc(e,f),dn!==4&&(dn=2)),!1;var h=Error(l(520),{cause:o});if(h=Sa(h,i),kc===null?kc=[h]:kc.push(h),dn!==4&&(dn=2),t===null)return!0;o=Sa(o,i),i=t;do{switch(i.tag){case 3:return i.flags|=65536,e=f&-f,i.lanes|=e,e=$f(i.stateNode,o,e),cc(i,e),!1;case 1:if(t=i.type,h=i.stateNode,(i.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(Nr===null||!Nr.has(h))))return i.flags|=65536,f&=-f,i.lanes|=f,f=lg(f),og(f,e,i,o),cc(i,f),!1}i=i.return}while(i!==null);return!1}var Uf=Error(l(461)),jn=!1;function Vn(e,t,i,o){t.child=e===null?Ou(t,null,i,o):si(t,e.child,i,o)}function cg(e,t,i,o,f){i=i.render;var h=t.ref;if("ref"in o){var S={};for(var M in o)M!=="ref"&&(S[M]=o[M])}else S=o;return fr(t),o=Jt(e,t,i,S,h,f),M=Sr(),e!==null&&!jn?(hc(e,t,f),Bi(e,t,f)):(gt&&M&&so(t),t.flags|=1,Vn(e,t,o,f),t.child)}function ug(e,t,i,o,f){if(e===null){var h=i.type;return typeof h=="function"&&!no(h)&&h.defaultProps===void 0&&i.compare===null?(t.tag=15,t.type=h,dg(e,t,h,o,f)):(e=Ni(i.type,null,o,t,t.mode,f),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,!Xf(e,f)){var S=h.memoizedProps;if(i=i.compare,i=i!==null?i:tl,i(S,o)&&e.ref===t.ref)return Bi(e,t,f)}return t.flags|=1,e=qn(h,o),e.ref=t.ref,e.return=t,t.child=e}function dg(e,t,i,o,f){if(e!==null){var h=e.memoizedProps;if(tl(h,o)&&e.ref===t.ref)if(jn=!1,t.pendingProps=o=h,Xf(e,f))(e.flags&131072)!==0&&(jn=!0);else return t.lanes=e.lanes,Bi(e,t,f)}return qf(e,t,i,o,f)}function fg(e,t,i,o){var f=o.children,h=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(h=h!==null?h.baseLanes|i:i,e!==null){for(o=t.child=e.child,f=0;o!==null;)f=f|o.lanes|o.childLanes,o=o.sibling;o=f&~h}else o=0,t.child=null;return mg(e,t,h,i,o)}if((i&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&lo(t,h!==null?h.cachePool:null),h!==null?Fu(t,h):dc(),ua(t);else return o=t.lanes=536870912,mg(e,t,h!==null?h.baseLanes|i:i,i,o)}else h!==null?(lo(t,h.cachePool),Fu(t,h),ri(),t.memoizedState=null):(e!==null&&lo(t,null),dc(),ri());return Vn(e,t,f,i),t.child}function xc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function mg(e,t,i,o,f){var h=oc();return h=h===null?null:{parent:un._currentValue,pool:h},t.memoizedState={baseLanes:i,cachePool:h},e!==null&&lo(t,null),dc(),ua(t),e!==null&&_i(e,t,o,!0),t.childLanes=f,null}function Yu(e,t){return t=Ku({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function hg(e,t,i){return si(t,e.child,null,i),e=Yu(t,t.pendingProps),e.flags|=2,da(t),t.memoizedState=null,e}function Nb(e,t,i){var o=t.pendingProps,f=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(gt){if(o.mode==="hidden")return e=Yu(t,o),t.lanes=536870912,xc(null,e);if(mc(t),(e=Lt)?(e=Av(e,ja),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ti!==null?{id:$a,overflow:cs}:null,retryLane:536870912,hydrationErrors:null},i=tc(e),i.return=t,t.child=i,pn=t,Lt=null)):e=null,e===null)throw qa(t);return t.lanes=536870912,null}return Yu(t,o)}var h=e.memoizedState;if(h!==null){var S=h.dehydrated;if(mc(t),f)if(t.flags&256)t.flags&=-257,t=hg(e,t,i);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(jn||_i(e,t,i,!1),f=(i&e.childLanes)!==0,jn||f){if(o=Ht,o!==null&&(S=$e(o,i),S!==0&&S!==h.retryLane))throw h.retryLane=S,os(e,S),Ea(o,e,S),Uf;sd(),t=hg(e,t,i)}else e=h.treeContext,Lt=hs(S.nextSibling),pn=t,gt=!0,Ua=null,ja=!1,e!==null&&nc(t,e),t=Yu(t,o),t.flags|=4096;return t}return e=qn(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Wu(e,t){var i=t.ref;if(i===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof i!="function"&&typeof i!="object")throw Error(l(284));(e===null||e.ref!==i)&&(t.flags|=4194816)}}function qf(e,t,i,o,f){return fr(t),i=Jt(e,t,i,o,void 0,f),o=Sr(),e!==null&&!jn?(hc(e,t,f),Bi(e,t,f)):(gt&&o&&so(t),t.flags|=1,Vn(e,t,i,f),t.child)}function pg(e,t,i,o,f,h){return fr(t),t.updateQueue=null,i=ka(t,o,i,f),Nn(e),o=Sr(),e!==null&&!jn?(hc(e,t,h),Bi(e,t,h)):(gt&&o&&so(t),t.flags|=1,Vn(e,t,i,h),t.child)}function gg(e,t,i,o,f){if(fr(t),t.stateNode===null){var h=As,S=i.contextType;typeof S=="object"&&S!==null&&(h=gn(S)),h=new i(o,h),t.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Hf,t.stateNode=h,h._reactInternals=t,h=t.stateNode,h.props=o,h.state=t.memoizedState,h.refs={},wr(t),S=i.contextType,h.context=typeof S=="object"&&S!==null?gn(S):As,h.state=t.memoizedState,S=i.getDerivedStateFromProps,typeof S=="function"&&(Pf(t,i,S,o),h.state=t.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof h.getSnapshotBeforeUpdate=="function"||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(S=h.state,typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount(),S!==h.state&&Hf.enqueueReplaceState(h,h.state,null),vl(t,o,h,f),gl(),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){h=t.stateNode;var M=t.memoizedProps,H=wl(i,M);h.props=H;var se=h.context,ye=i.contextType;S=As,typeof ye=="object"&&ye!==null&&(S=gn(ye));var Se=i.getDerivedStateFromProps;ye=typeof Se=="function"||typeof h.getSnapshotBeforeUpdate=="function",M=t.pendingProps!==M,ye||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(M||se!==S)&&ng(t,h,o,S),Es=!1;var re=t.memoizedState;h.state=re,vl(t,o,h,f),gl(),se=t.memoizedState,M||re!==se||Es?(typeof Se=="function"&&(Pf(t,i,Se,o),se=t.memoizedState),(H=Es||tg(t,i,H,o,re,se,S))?(ye||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(t.flags|=4194308)):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=se),h.props=o,h.state=se,h.context=S,o=H):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{h=t.stateNode,co(e,t),S=t.memoizedProps,ye=wl(i,S),h.props=ye,Se=t.pendingProps,re=h.context,se=i.contextType,H=As,typeof se=="object"&&se!==null&&(H=gn(se)),M=i.getDerivedStateFromProps,(se=typeof M=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(S!==Se||re!==H)&&ng(t,h,o,H),Es=!1,re=t.memoizedState,h.state=re,vl(t,o,h,f),gl();var fe=t.memoizedState;S!==Se||re!==fe||Es||e!==null&&e.dependencies!==null&&io(e.dependencies)?(typeof M=="function"&&(Pf(t,i,M,o),fe=t.memoizedState),(ye=Es||tg(t,i,ye,o,re,fe,H)||e!==null&&e.dependencies!==null&&io(e.dependencies))?(se||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,fe,H),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,fe,H)),typeof h.componentDidUpdate=="function"&&(t.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=fe),h.props=o,h.state=fe,h.context=H,o=ye):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=1024),o=!1)}return h=o,Wu(e,t),o=(t.flags&128)!==0,h||o?(h=t.stateNode,i=o&&typeof i.getDerivedStateFromError!="function"?null:h.render(),t.flags|=1,e!==null&&o?(t.child=si(t,e.child,null,f),t.child=si(t,null,i,f)):Vn(e,t,i,f),t.memoizedState=h.state,e=t.child):e=Bi(e,t,f),e}function vg(e,t,i,o){return ni(),t.flags|=256,Vn(e,t,i,o),t.child}var Gf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Vf(e){return{baseLanes:e,cachePool:Ru()}}function Yf(e,t,i){return e=e!==null?e.childLanes&~i:0,t&&(e|=Ka),e}function xg(e,t,i){var o=t.pendingProps,f=!1,h=(t.flags&128)!==0,S;if((S=h)||(S=e!==null&&e.memoizedState===null?!1:(zt.current&2)!==0),S&&(f=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(gt){if(f?ii(t):ri(),(e=Lt)?(e=Av(e,ja),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:ti!==null?{id:$a,overflow:cs}:null,retryLane:536870912,hydrationErrors:null},i=tc(e),i.return=t,t.child=i,pn=t,Lt=null)):e=null,e===null)throw qa(t);return Tm(e)?t.lanes=32:t.lanes=536870912,null}var M=o.children;return o=o.fallback,f?(ri(),f=t.mode,M=Ku({mode:"hidden",children:M},f),o=ei(o,f,i,null),M.return=t,o.return=t,M.sibling=o,t.child=M,o=t.child,o.memoizedState=Vf(i),o.childLanes=Yf(e,S,i),t.memoizedState=Gf,xc(null,o)):(ii(t),Wf(t,M))}var H=e.memoizedState;if(H!==null&&(M=H.dehydrated,M!==null)){if(h)t.flags&256?(ii(t),t.flags&=-257,t=Kf(e,t,i)):t.memoizedState!==null?(ri(),t.child=e.child,t.flags|=128,t=null):(ri(),M=o.fallback,f=t.mode,o=Ku({mode:"visible",children:o.children},f),M=ei(M,f,i,null),M.flags|=2,o.return=t,M.return=t,o.sibling=M,t.child=o,si(t,e.child,null,i),o=t.child,o.memoizedState=Vf(i),o.childLanes=Yf(e,S,i),t.memoizedState=Gf,t=xc(null,o));else if(ii(t),Tm(M)){if(S=M.nextSibling&&M.nextSibling.dataset,S)var se=S.dgst;S=se,o=Error(l(419)),o.stack="",o.digest=S,ai({value:o,source:null,stack:null}),t=Kf(e,t,i)}else if(jn||_i(e,t,i,!1),S=(i&e.childLanes)!==0,jn||S){if(S=Ht,S!==null&&(o=$e(S,i),o!==0&&o!==H.retryLane))throw H.retryLane=o,os(e,o),Ea(S,e,o),Uf;Mm(M)||sd(),t=Kf(e,t,i)}else Mm(M)?(t.flags|=192,t.child=e.child,t=null):(e=H.treeContext,Lt=hs(M.nextSibling),pn=t,gt=!0,Ua=null,ja=!1,e!==null&&nc(t,e),t=Wf(t,o.children),t.flags|=4096);return t}return f?(ri(),M=o.fallback,f=t.mode,H=e.child,se=H.sibling,o=qn(H,{mode:"hidden",children:o.children}),o.subtreeFlags=H.subtreeFlags&65011712,se!==null?M=qn(se,M):(M=ei(M,f,i,null),M.flags|=2),M.return=t,o.return=t,o.sibling=M,t.child=o,xc(null,o),o=t.child,M=e.child.memoizedState,M===null?M=Vf(i):(f=M.cachePool,f!==null?(H=un._currentValue,f=f.parent!==H?{parent:H,pool:H}:f):f=Ru(),M={baseLanes:M.baseLanes|i,cachePool:f}),o.memoizedState=M,o.childLanes=Yf(e,S,i),t.memoizedState=Gf,xc(e.child,o)):(ii(t),i=e.child,e=i.sibling,i=qn(i,{mode:"visible",children:o.children}),i.return=t,i.sibling=null,e!==null&&(S=t.deletions,S===null?(t.deletions=[e],t.flags|=16):S.push(e)),t.child=i,t.memoizedState=null,i)}function Wf(e,t){return t=Ku({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ku(e,t){return e=Sn(22,e,null,t),e.lanes=0,e}function Kf(e,t,i){return si(t,e.child,null,i),e=Wf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function yg(e,t,i){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),Te(e.return,t,i)}function Qf(e,t,i,o,f,h){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:i,tailMode:f,treeForkCount:h}:(S.isBackwards=t,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=i,S.tailMode=f,S.treeForkCount=h)}function wg(e,t,i){var o=t.pendingProps,f=o.revealOrder,h=o.tail;o=o.children;var S=zt.current,M=(S&2)!==0;if(M?(S=S&1|2,t.flags|=128):S&=1,P(zt,S),Vn(e,t,o,i),o=gt?Ei:0,!M&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&yg(e,i,t);else if(e.tag===19)yg(e,i,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(f){case"forwards":for(i=t.child,f=null;i!==null;)e=i.alternate,e!==null&&uo(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=t.child,t.child=null):(f=i.sibling,i.sibling=null),Qf(t,!1,f,i,h,o);break;case"backwards":case"unstable_legacy-backwards":for(i=null,f=t.child,t.child=null;f!==null;){if(e=f.alternate,e!==null&&uo(e)===null){t.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}Qf(t,!0,i,null,h,o);break;case"together":Qf(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function Bi(e,t,i){if(e!==null&&(t.dependencies=e.dependencies),Ar|=t.lanes,(i&t.childLanes)===0)if(e!==null){if(_i(e,t,i,!1),(i&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(l(153));if(t.child!==null){for(e=t.child,i=qn(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=qn(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}function Xf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&io(e)))}function Mb(e,t,i){switch(t.tag){case 3:Le(t,t.stateNode.containerInfo),fs(t,un,e.memoizedState.cache),ni();break;case 27:case 5:ue(t);break;case 4:Le(t,t.stateNode.containerInfo);break;case 10:fs(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,mc(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(ii(t),t.flags|=128,null):(i&t.child.childLanes)!==0?xg(e,t,i):(ii(t),e=Bi(e,t,i),e!==null?e.sibling:null);ii(t);break;case 19:var f=(e.flags&128)!==0;if(o=(i&t.childLanes)!==0,o||(_i(e,t,i,!1),o=(i&t.childLanes)!==0),f){if(o)return wg(e,t,i);t.flags|=128}if(f=t.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),P(zt,zt.current),o)break;return null;case 22:return t.lanes=0,fg(e,t,i,t.pendingProps);case 24:fs(t,un,e.memoizedState.cache)}return Bi(e,t,i)}function bg(e,t,i){if(e!==null)if(e.memoizedProps!==t.pendingProps)jn=!0;else{if(!Xf(e,i)&&(t.flags&128)===0)return jn=!1,Mb(e,t,i);jn=(e.flags&131072)!==0}else jn=!1,gt&&(t.flags&1048576)!==0&&ao(t,Ei,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=zi(t.elementType),t.type=e,typeof e=="function")no(e)?(o=wl(e,o),t.tag=1,t=gg(null,t,e,o,i)):(t.tag=0,t=qf(null,t,e,o,i));else{if(e!=null){var f=e.$$typeof;if(f===$){t.tag=11,t=cg(null,t,e,o,i);break e}else if(f===L){t.tag=14,t=ug(null,t,e,o,i);break e}}throw t=le(e)||e,Error(l(306,t,""))}}return t;case 0:return qf(e,t,t.type,t.pendingProps,i);case 1:return o=t.type,f=wl(o,t.pendingProps),gg(e,t,o,f,i);case 3:e:{if(Le(t,t.stateNode.containerInfo),e===null)throw Error(l(387));o=t.pendingProps;var h=t.memoizedState;f=h.element,co(e,t),vl(t,o,null,i);var S=t.memoizedState;if(o=S.cache,fs(t,un,o),o!==h.cache&&dr(t,[un],i,!0),gl(),o=S.element,h.isDehydrated)if(h={element:o,isDehydrated:!1,cache:S.cache},t.updateQueue.baseState=h,t.memoizedState=h,t.flags&256){t=vg(e,t,o,i);break e}else if(o!==f){f=Sa(Error(l(424)),t),ai(f),t=vg(e,t,o,i);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Lt=hs(e.firstChild),pn=t,gt=!0,Ua=null,ja=!0,i=Ou(t,null,o,i),t.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(ni(),o===f){t=Bi(e,t,i);break e}Vn(e,t,o,i)}t=t.child}return t;case 26:return Wu(e,t),e===null?(i=Dv(t.type,null,t.pendingProps,null))?t.memoizedState=i:gt||(i=t.type,e=t.pendingProps,o=dd(xe.current).createElement(i),o[te]=t,o[Ne]=e,Yn(o,i,e),_t(o),t.stateNode=o):t.memoizedState=Dv(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return ue(t),e===null&>&&(o=t.stateNode=Tv(t.type,t.pendingProps,xe.current),pn=t,ja=!0,f=Lt,Rr(t.type)?(Em=f,Lt=hs(o.firstChild)):Lt=f),Vn(e,t,t.pendingProps.children,i),Wu(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&>&&((f=o=Lt)&&(o=sS(o,t.type,t.pendingProps,ja),o!==null?(t.stateNode=o,pn=t,Lt=hs(o.firstChild),ja=!1,f=!0):f=!1),f||qa(t)),ue(t),f=t.type,h=t.pendingProps,S=e!==null?e.memoizedProps:null,o=h.children,km(f,h)?o=null:S!==null&&km(f,S)&&(t.flags|=32),t.memoizedState!==null&&(f=Jt(e,t,fo,null,null,i),_c._currentValue=f),Wu(e,t),Vn(e,t,o,i),t.child;case 6:return e===null&>&&((e=i=Lt)&&(i=iS(i,t.pendingProps,ja),i!==null?(t.stateNode=i,pn=t,Lt=null,e=!0):e=!1),e||qa(t)),null;case 13:return xg(e,t,i);case 4:return Le(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=si(t,null,o,i):Vn(e,t,o,i),t.child;case 11:return cg(e,t,t.type,t.pendingProps,i);case 7:return Vn(e,t,t.pendingProps,i),t.child;case 8:return Vn(e,t,t.pendingProps.children,i),t.child;case 12:return Vn(e,t,t.pendingProps.children,i),t.child;case 10:return o=t.pendingProps,fs(t,t.type,o.value),Vn(e,t,o.children,i),t.child;case 9:return f=t.type._context,o=t.pendingProps.children,fr(t),f=gn(f),o=o(f),t.flags|=1,Vn(e,t,o,i),t.child;case 14:return ug(e,t,t.type,t.pendingProps,i);case 15:return dg(e,t,t.type,t.pendingProps,i);case 19:return wg(e,t,i);case 31:return Nb(e,t,i);case 22:return fg(e,t,i,t.pendingProps);case 24:return fr(t),o=gn(un),e===null?(f=oc(),f===null&&(f=Ht,h=rc(),f.pooledCache=h,h.refCount++,h!==null&&(f.pooledCacheLanes|=i),f=h),t.memoizedState={parent:o,cache:f},wr(t),fs(t,un,f)):((e.lanes&i)!==0&&(co(e,t),vl(t,null,null,i),gl()),f=e.memoizedState,h=t.memoizedState,f.parent!==o?(f={parent:o,cache:o},t.memoizedState=f,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=f),fs(t,un,o)):(o=h.cache,fs(t,un,o),o!==f.cache&&dr(t,[un],i,!0))),Vn(e,t,t.pendingProps.children,i),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function Fi(e){e.flags|=4}function Zf(e,t,i,o,f){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(Wg())e.flags|=8192;else throw Ii=oo,hl}else e.flags&=-16777217}function Sg(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Ov(t))if(Wg())e.flags|=8192;else throw Ii=oo,hl}function Qu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?fi():536870912,e.lanes|=t,vo|=t)}function yc(e,t){if(!gt)switch(e.tailMode){case"hidden":t=e.tail;for(var i=null;t!==null;)t.alternate!==null&&(i=t),t=t.sibling;i===null?e.tail=null:i.sibling=null;break;case"collapsed":i=e.tail;for(var o=null;i!==null;)i.alternate!==null&&(o=i),i=i.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function Wt(e){var t=e.alternate!==null&&e.alternate.child===e.child,i=0,o=0;if(t)for(var f=e.child;f!==null;)i|=f.lanes|f.childLanes,o|=f.subtreeFlags&65011712,o|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)i|=f.lanes|f.childLanes,o|=f.subtreeFlags,o|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=o,e.childLanes=i,t}function Tb(e,t,i){var o=t.pendingProps;switch(Ri(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wt(t),null;case 1:return Wt(t),null;case 3:return i=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),Ga(un),ze(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(Di(t)?Fi(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,ic())),Wt(t),null;case 26:var f=t.type,h=t.memoizedState;return e===null?(Fi(t),h!==null?(Wt(t),Sg(t,h)):(Wt(t),Zf(t,f,null,o,i))):h?h!==e.memoizedState?(Fi(t),Wt(t),Sg(t,h)):(Wt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&Fi(t),Wt(t),Zf(t,f,e,o,i)),null;case 27:if(Ye(t),i=xe.current,f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&Fi(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Wt(t),null}e=me.current,Di(t)?Mu(t):(e=Tv(f,o,i),t.stateNode=e,Fi(t))}return Wt(t),null;case 5:if(Ye(t),f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&Fi(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Wt(t),null}if(h=me.current,Di(t))Mu(t);else{var S=dd(xe.current);switch(h){case 1:h=S.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:h=S.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":h=S.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":h=S.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":h=S.createElement("div"),h.innerHTML="<script><\/script>",h=h.removeChild(h.firstChild);break;case"select":h=typeof o.is=="string"?S.createElement("select",{is:o.is}):S.createElement("select"),o.multiple?h.multiple=!0:o.size&&(h.size=o.size);break;default:h=typeof o.is=="string"?S.createElement(f,{is:o.is}):S.createElement(f)}}h[te]=t,h[Ne]=o;e:for(S=t.child;S!==null;){if(S.tag===5||S.tag===6)h.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=h;e:switch(Yn(h,f,o),f){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Fi(t)}}return Wt(t),Zf(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&Fi(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(l(166));if(e=xe.current,Di(t)){if(e=t.stateNode,i=t.memoizedProps,o=null,f=pn,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[te]=t,e=!!(e.nodeValue===i||o!==null&&o.suppressHydrationWarning===!0||xv(e.nodeValue,i)),e||qa(t,!0)}else e=dd(e).createTextNode(o),e[te]=t,t.stateNode=e}return Wt(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(o=Di(t),i!==null){if(e===null){if(!o)throw Error(l(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(557));e[te]=t}else ni(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Wt(t),e=!1}else i=ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?(da(t),t):(da(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Wt(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=Di(t),o!==null&&o.dehydrated!==null){if(e===null){if(!f)throw Error(l(318));if(f=t.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(l(317));f[te]=t}else ni(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Wt(t),f=!1}else f=ic(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?(da(t),t):(da(t),null)}return da(t),(t.flags&128)!==0?(t.lanes=i,t):(i=o!==null,e=e!==null&&e.memoizedState!==null,i&&(o=t.child,f=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(f=o.alternate.memoizedState.cachePool.pool),h=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),h!==f&&(o.flags|=2048)),i!==e&&i&&(t.child.flags|=8192),Qu(t,t.updateQueue),Wt(t),null);case 4:return ze(),e===null&&wm(t.stateNode.containerInfo),Wt(t),null;case 10:return Ga(t.type),Wt(t),null;case 19:if(W(zt),o=t.memoizedState,o===null)return Wt(t),null;if(f=(t.flags&128)!==0,h=o.rendering,h===null)if(f)yc(o,!1);else{if(dn!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(h=uo(e),h!==null){for(t.flags|=128,yc(o,!1),e=h.updateQueue,t.updateQueue=e,Qu(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)cl(i,e),i=i.sibling;return P(zt,zt.current&1|2),gt&&Ns(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&tt()>td&&(t.flags|=128,f=!0,yc(o,!1),t.lanes=4194304)}else{if(!f)if(e=uo(h),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,Qu(t,e),yc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!gt)return Wt(t),null}else 2*tt()-o.renderingStartTime>td&&i!==536870912&&(t.flags|=128,f=!0,yc(o,!1),t.lanes=4194304);o.isBackwards?(h.sibling=t.child,t.child=h):(e=o.last,e!==null?e.sibling=h:t.child=h,o.last=h)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=tt(),e.sibling=null,i=zt.current,P(zt,f?i&1|2:i&1),gt&&Ns(t,o.treeForkCount),e):(Wt(t),null);case 22:case 23:return da(t),fc(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(i&536870912)!==0&&(t.flags&128)===0&&(Wt(t),t.subtreeFlags&6&&(t.flags|=8192)):Wt(t),i=t.updateQueue,i!==null&&Qu(t,i.retryQueue),i=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==i&&(t.flags|=2048),e!==null&&W(Li),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Ga(un),Wt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function Eb(e,t){switch(Ri(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ga(un),ze(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ye(t),null;case 31:if(t.memoizedState!==null){if(da(t),t.alternate===null)throw Error(l(340));ni()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(da(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));ni()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return W(zt),null;case 4:return ze(),null;case 10:return Ga(t.type),null;case 22:case 23:return da(t),fc(),e!==null&&W(Li),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ga(un),null;case 25:return null;default:return null}}function jg(e,t){switch(Ri(t),t.tag){case 3:Ga(un),ze();break;case 26:case 27:case 5:Ye(t);break;case 4:ze();break;case 31:t.memoizedState!==null&&da(t);break;case 13:da(t);break;case 19:W(zt);break;case 10:Ga(t.type);break;case 22:case 23:da(t),fc(),e!==null&&W(Li);break;case 24:Ga(un)}}function wc(e,t){try{var i=t.updateQueue,o=i!==null?i.lastEffect:null;if(o!==null){var f=o.next;i=f;do{if((i.tag&e)===e){o=void 0;var h=i.create,S=i.inst;o=h(),S.destroy=o}i=i.next}while(i!==f)}}catch(M){Rt(t,t.return,M)}}function Cr(e,t,i){try{var o=t.updateQueue,f=o!==null?o.lastEffect:null;if(f!==null){var h=f.next;o=h;do{if((o.tag&e)===e){var S=o.inst,M=S.destroy;if(M!==void 0){S.destroy=void 0,f=t;var H=i,se=M;try{se()}catch(ye){Rt(f,H,ye)}}}o=o.next}while(o!==h)}}catch(ye){Rt(t,t.return,ye)}}function Cg(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{xl(t,i)}catch(o){Rt(e,e.return,o)}}}function kg(e,t,i){i.props=wl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(o){Rt(e,t,o)}}function bc(e,t){try{var i=e.ref;if(i!==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 i=="function"?e.refCleanup=i(o):i.current=o}}catch(f){Rt(e,t,f)}}function li(e,t){var i=e.ref,o=e.refCleanup;if(i!==null)if(typeof o=="function")try{o()}catch(f){Rt(e,t,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof i=="function")try{i(null)}catch(f){Rt(e,t,f)}else i.current=null}function Ag(e){var t=e.type,i=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":i.autoFocus&&o.focus();break e;case"img":i.src?o.src=i.src:i.srcSet&&(o.srcset=i.srcSet)}}catch(f){Rt(e,e.return,f)}}function Jf(e,t,i){try{var o=e.stateNode;Zb(o,e.type,i,t),o[Ne]=t}catch(f){Rt(e,e.return,f)}}function Ng(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Rr(e.type)||e.tag===4}function em(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ng(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&&Rr(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 tm(e,t,i){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i).insertBefore(e,t):(t=i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,t.appendChild(e),i=i._reactRootContainer,i!=null||t.onclick!==null||(t.onclick=Hn));else if(o!==4&&(o===27&&Rr(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(tm(e,t,i),e=e.sibling;e!==null;)tm(e,t,i),e=e.sibling}function Xu(e,t,i){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?i.insertBefore(e,t):i.appendChild(e);else if(o!==4&&(o===27&&Rr(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(Xu(e,t,i),e=e.sibling;e!==null;)Xu(e,t,i),e=e.sibling}function Mg(e){var t=e.stateNode,i=e.memoizedProps;try{for(var o=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);Yn(t,o,i),t[te]=e,t[Ne]=i}catch(h){Rt(e,e.return,h)}}var Pi=!1,Cn=!1,nm=!1,Tg=typeof WeakSet=="function"?WeakSet:Set,zn=null;function Rb(e,t){if(e=e.containerInfo,jm=xd,e=Si(e),Jl(e)){if("selectionStart"in e)var i={start:e.selectionStart,end:e.selectionEnd};else e:{i=(i=e.ownerDocument)&&i.defaultView||window;var o=i.getSelection&&i.getSelection();if(o&&o.rangeCount!==0){i=o.anchorNode;var f=o.anchorOffset,h=o.focusNode;o=o.focusOffset;try{i.nodeType,h.nodeType}catch{i=null;break e}var S=0,M=-1,H=-1,se=0,ye=0,Se=e,re=null;t:for(;;){for(var fe;Se!==i||f!==0&&Se.nodeType!==3||(M=S+f),Se!==h||o!==0&&Se.nodeType!==3||(H=S+o),Se.nodeType===3&&(S+=Se.nodeValue.length),(fe=Se.firstChild)!==null;)re=Se,Se=fe;for(;;){if(Se===e)break t;if(re===i&&++se===f&&(M=S),re===h&&++ye===o&&(H=S),(fe=Se.nextSibling)!==null)break;Se=re,re=Se.parentNode}Se=fe}i=M===-1||H===-1?null:{start:M,end:H}}else i=null}i=i||{start:0,end:0}}else i=null;for(Cm={focusedElem:e,selectionRange:i},xd=!1,zn=t;zn!==null;)if(t=zn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,zn=e;else for(;zn!==null;){switch(t=zn,h=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(i=0;i<e.length;i++)f=e[i],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&h!==null){e=void 0,i=t,f=h.memoizedProps,h=h.memoizedState,o=i.stateNode;try{var qe=wl(i.type,f);e=o.getSnapshotBeforeUpdate(qe,h),o.__reactInternalSnapshotBeforeUpdate=e}catch(Ze){Rt(i,i.return,Ze)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,i=e.nodeType,i===9)Nm(e);else if(i===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(l(163))}if(e=t.sibling,e!==null){e.return=t.return,zn=e;break}zn=t.return}}function Eg(e,t,i){var o=i.flags;switch(i.tag){case 0:case 11:case 15:$i(e,i),o&4&&wc(5,i);break;case 1:if($i(e,i),o&4)if(e=i.stateNode,t===null)try{e.componentDidMount()}catch(S){Rt(i,i.return,S)}else{var f=wl(i.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(f,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){Rt(i,i.return,S)}}o&64&&Cg(i),o&512&&bc(i,i.return);break;case 3:if($i(e,i),o&64&&(e=i.updateQueue,e!==null)){if(t=null,i.child!==null)switch(i.child.tag){case 27:case 5:t=i.child.stateNode;break;case 1:t=i.child.stateNode}try{xl(e,t)}catch(S){Rt(i,i.return,S)}}break;case 27:t===null&&o&4&&Mg(i);case 26:case 5:$i(e,i),t===null&&o&4&&Ag(i),o&512&&bc(i,i.return);break;case 12:$i(e,i);break;case 31:$i(e,i),o&4&&_g(e,i);break;case 13:$i(e,i),o&4&&Lg(e,i),o&64&&(e=i.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(i=Pb.bind(null,i),rS(e,i))));break;case 22:if(o=i.memoizedState!==null||Pi,!o){t=t!==null&&t.memoizedState!==null||Cn,f=Pi;var h=Cn;Pi=o,(Cn=t)&&!h?Ui(e,i,(i.subtreeFlags&8772)!==0):$i(e,i),Pi=f,Cn=h}break;case 30:break;default:$i(e,i)}}function Rg(e){var t=e.alternate;t!==null&&(e.alternate=null,Rg(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Qt(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 en=null,Aa=!1;function Hi(e,t,i){for(i=i.child;i!==null;)Dg(e,t,i),i=i.sibling}function Dg(e,t,i){if(it&&typeof it.onCommitFiberUnmount=="function")try{it.onCommitFiberUnmount(pt,i)}catch{}switch(i.tag){case 26:Cn||li(i,t),Hi(e,t,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Cn||li(i,t);var o=en,f=Aa;Rr(i.type)&&(en=i.stateNode,Aa=!1),Hi(e,t,i),Ec(i.stateNode),en=o,Aa=f;break;case 5:Cn||li(i,t);case 6:if(o=en,f=Aa,en=null,Hi(e,t,i),en=o,Aa=f,en!==null)if(Aa)try{(en.nodeType===9?en.body:en.nodeName==="HTML"?en.ownerDocument.body:en).removeChild(i.stateNode)}catch(h){Rt(i,t,h)}else try{en.removeChild(i.stateNode)}catch(h){Rt(i,t,h)}break;case 18:en!==null&&(Aa?(e=en,Cv(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,i.stateNode),ko(e)):Cv(en,i.stateNode));break;case 4:o=en,f=Aa,en=i.stateNode.containerInfo,Aa=!0,Hi(e,t,i),en=o,Aa=f;break;case 0:case 11:case 14:case 15:Cr(2,i,t),Cn||Cr(4,i,t),Hi(e,t,i);break;case 1:Cn||(li(i,t),o=i.stateNode,typeof o.componentWillUnmount=="function"&&kg(i,t,o)),Hi(e,t,i);break;case 21:Hi(e,t,i);break;case 22:Cn=(o=Cn)||i.memoizedState!==null,Hi(e,t,i),Cn=o;break;default:Hi(e,t,i)}}function _g(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ko(e)}catch(i){Rt(t,t.return,i)}}}function Lg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ko(e)}catch(i){Rt(t,t.return,i)}}function Db(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Tg),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Tg),t;default:throw Error(l(435,e.tag))}}function Zu(e,t){var i=Db(e);t.forEach(function(o){if(!i.has(o)){i.add(o);var f=Hb.bind(null,e,o);o.then(f,f)}})}function Na(e,t){var i=t.deletions;if(i!==null)for(var o=0;o<i.length;o++){var f=i[o],h=e,S=t,M=S;e:for(;M!==null;){switch(M.tag){case 27:if(Rr(M.type)){en=M.stateNode,Aa=!1;break e}break;case 5:en=M.stateNode,Aa=!1;break e;case 3:case 4:en=M.stateNode.containerInfo,Aa=!0;break e}M=M.return}if(en===null)throw Error(l(160));Dg(h,S,f),en=null,Aa=!1,h=f.alternate,h!==null&&(h.return=null),f.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)zg(t,e),t=t.sibling}var Rs=null;function zg(e,t){var i=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:Na(t,e),Ma(e),o&4&&(Cr(3,e,e.return),wc(3,e),Cr(5,e,e.return));break;case 1:Na(t,e),Ma(e),o&512&&(Cn||i===null||li(i,i.return)),o&64&&Pi&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(i=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=i===null?o:i.concat(o))));break;case 26:var f=Rs;if(Na(t,e),Ma(e),o&512&&(Cn||i===null||li(i,i.return)),o&4){var h=i!==null?i.memoizedState:null;if(o=e.memoizedState,i===null)if(o===null)if(e.stateNode===null){e:{o=e.type,i=e.memoizedProps,f=f.ownerDocument||f;t:switch(o){case"title":h=f.getElementsByTagName("title")[0],(!h||h[rt]||h[te]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=f.createElement(o),f.head.insertBefore(h,f.querySelector("head > title"))),Yn(h,o,i),h[te]=e,_t(h),o=h;break e;case"link":var S=zv("link","href",f).get(o+(i.href||""));if(S){for(var M=0;M<S.length;M++)if(h=S[M],h.getAttribute("href")===(i.href==null||i.href===""?null:i.href)&&h.getAttribute("rel")===(i.rel==null?null:i.rel)&&h.getAttribute("title")===(i.title==null?null:i.title)&&h.getAttribute("crossorigin")===(i.crossOrigin==null?null:i.crossOrigin)){S.splice(M,1);break t}}h=f.createElement(o),Yn(h,o,i),f.head.appendChild(h);break;case"meta":if(S=zv("meta","content",f).get(o+(i.content||""))){for(M=0;M<S.length;M++)if(h=S[M],h.getAttribute("content")===(i.content==null?null:""+i.content)&&h.getAttribute("name")===(i.name==null?null:i.name)&&h.getAttribute("property")===(i.property==null?null:i.property)&&h.getAttribute("http-equiv")===(i.httpEquiv==null?null:i.httpEquiv)&&h.getAttribute("charset")===(i.charSet==null?null:i.charSet)){S.splice(M,1);break t}}h=f.createElement(o),Yn(h,o,i),f.head.appendChild(h);break;default:throw Error(l(468,o))}h[te]=e,_t(h),o=h}e.stateNode=o}else Iv(f,e.type,e.stateNode);else e.stateNode=Lv(f,o,e.memoizedProps);else h!==o?(h===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):h.count--,o===null?Iv(f,e.type,e.stateNode):Lv(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Jf(e,e.memoizedProps,i.memoizedProps)}break;case 27:Na(t,e),Ma(e),o&512&&(Cn||i===null||li(i,i.return)),i!==null&&o&4&&Jf(e,e.memoizedProps,i.memoizedProps);break;case 5:if(Na(t,e),Ma(e),o&512&&(Cn||i===null||li(i,i.return)),e.flags&32){f=e.stateNode;try{Ps(f,"")}catch(qe){Rt(e,e.return,qe)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,Jf(e,f,i!==null?i.memoizedProps:f)),o&1024&&(nm=!0);break;case 6:if(Na(t,e),Ma(e),o&4){if(e.stateNode===null)throw Error(l(162));o=e.memoizedProps,i=e.stateNode;try{i.nodeValue=o}catch(qe){Rt(e,e.return,qe)}}break;case 3:if(hd=null,f=Rs,Rs=fd(t.containerInfo),Na(t,e),Rs=f,Ma(e),o&4&&i!==null&&i.memoizedState.isDehydrated)try{ko(t.containerInfo)}catch(qe){Rt(e,e.return,qe)}nm&&(nm=!1,Ig(e));break;case 4:o=Rs,Rs=fd(e.stateNode.containerInfo),Na(t,e),Ma(e),Rs=o;break;case 12:Na(t,e),Ma(e);break;case 31:Na(t,e),Ma(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Zu(e,o)));break;case 13:Na(t,e),Ma(e),e.child.flags&8192&&e.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(ed=tt()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Zu(e,o)));break;case 22:f=e.memoizedState!==null;var H=i!==null&&i.memoizedState!==null,se=Pi,ye=Cn;if(Pi=se||f,Cn=ye||H,Na(t,e),Cn=ye,Pi=se,Ma(e),o&8192)e:for(t=e.stateNode,t._visibility=f?t._visibility&-2:t._visibility|1,f&&(i===null||H||Pi||Cn||bl(e)),i=null,t=e;;){if(t.tag===5||t.tag===26){if(i===null){H=i=t;try{if(h=H.stateNode,f)S=h.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{M=H.stateNode;var Se=H.memoizedProps.style,re=Se!=null&&Se.hasOwnProperty("display")?Se.display:null;M.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(qe){Rt(H,H.return,qe)}}}else if(t.tag===6){if(i===null){H=t;try{H.stateNode.nodeValue=f?"":H.memoizedProps}catch(qe){Rt(H,H.return,qe)}}}else if(t.tag===18){if(i===null){H=t;try{var fe=H.stateNode;f?kv(fe,!0):kv(H.stateNode,!1)}catch(qe){Rt(H,H.return,qe)}}}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;i===t&&(i=null),t=t.return}i===t&&(i=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(i=o.retryQueue,i!==null&&(o.retryQueue=null,Zu(e,i))));break;case 19:Na(t,e),Ma(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Zu(e,o)));break;case 30:break;case 21:break;default:Na(t,e),Ma(e)}}function Ma(e){var t=e.flags;if(t&2){try{for(var i,o=e.return;o!==null;){if(Ng(o)){i=o;break}o=o.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var f=i.stateNode,h=em(e);Xu(e,h,f);break;case 5:var S=i.stateNode;i.flags&32&&(Ps(S,""),i.flags&=-33);var M=em(e);Xu(e,M,S);break;case 3:case 4:var H=i.stateNode.containerInfo,se=em(e);tm(e,se,H);break;default:throw Error(l(161))}}catch(ye){Rt(e,e.return,ye)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ig(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Ig(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function $i(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Eg(e,t.alternate,t),t=t.sibling}function bl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Cr(4,t,t.return),bl(t);break;case 1:li(t,t.return);var i=t.stateNode;typeof i.componentWillUnmount=="function"&&kg(t,t.return,i),bl(t);break;case 27:Ec(t.stateNode);case 26:case 5:li(t,t.return),bl(t);break;case 22:t.memoizedState===null&&bl(t);break;case 30:bl(t);break;default:bl(t)}e=e.sibling}}function Ui(e,t,i){for(i=i&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,f=e,h=t,S=h.flags;switch(h.tag){case 0:case 11:case 15:Ui(f,h,i),wc(4,h);break;case 1:if(Ui(f,h,i),o=h,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(se){Rt(o,o.return,se)}if(o=h,f=o.updateQueue,f!==null){var M=o.stateNode;try{var H=f.shared.hiddenCallbacks;if(H!==null)for(f.shared.hiddenCallbacks=null,f=0;f<H.length;f++)uc(H[f],M)}catch(se){Rt(o,o.return,se)}}i&&S&64&&Cg(h),bc(h,h.return);break;case 27:Mg(h);case 26:case 5:Ui(f,h,i),i&&o===null&&S&4&&Ag(h),bc(h,h.return);break;case 12:Ui(f,h,i);break;case 31:Ui(f,h,i),i&&S&4&&_g(f,h);break;case 13:Ui(f,h,i),i&&S&4&&Lg(f,h);break;case 22:h.memoizedState===null&&Ui(f,h,i),bc(h,h.return);break;case 30:break;default:Ui(f,h,i)}t=t.sibling}}function am(e,t){var i=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(i=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==i&&(e!=null&&e.refCount++,i!=null&&fl(i))}function sm(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&fl(e))}function Ds(e,t,i,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Og(e,t,i,o),t=t.sibling}function Og(e,t,i,o){var f=t.flags;switch(t.tag){case 0:case 11:case 15:Ds(e,t,i,o),f&2048&&wc(9,t);break;case 1:Ds(e,t,i,o);break;case 3:Ds(e,t,i,o),f&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&fl(e)));break;case 12:if(f&2048){Ds(e,t,i,o),e=t.stateNode;try{var h=t.memoizedProps,S=h.id,M=h.onPostCommit;typeof M=="function"&&M(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(H){Rt(t,t.return,H)}}else Ds(e,t,i,o);break;case 31:Ds(e,t,i,o);break;case 13:Ds(e,t,i,o);break;case 23:break;case 22:h=t.stateNode,S=t.alternate,t.memoizedState!==null?h._visibility&2?Ds(e,t,i,o):Sc(e,t):h._visibility&2?Ds(e,t,i,o):(h._visibility|=2,ho(e,t,i,o,(t.subtreeFlags&10256)!==0||!1)),f&2048&&am(S,t);break;case 24:Ds(e,t,i,o),f&2048&&sm(t.alternate,t);break;default:Ds(e,t,i,o)}}function ho(e,t,i,o,f){for(f=f&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var h=e,S=t,M=i,H=o,se=S.flags;switch(S.tag){case 0:case 11:case 15:ho(h,S,M,H,f),wc(8,S);break;case 23:break;case 22:var ye=S.stateNode;S.memoizedState!==null?ye._visibility&2?ho(h,S,M,H,f):Sc(h,S):(ye._visibility|=2,ho(h,S,M,H,f)),f&&se&2048&&am(S.alternate,S);break;case 24:ho(h,S,M,H,f),f&&se&2048&&sm(S.alternate,S);break;default:ho(h,S,M,H,f)}t=t.sibling}}function Sc(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var i=e,o=t,f=o.flags;switch(o.tag){case 22:Sc(i,o),f&2048&&am(o.alternate,o);break;case 24:Sc(i,o),f&2048&&sm(o.alternate,o);break;default:Sc(i,o)}t=t.sibling}}var jc=8192;function po(e,t,i){if(e.subtreeFlags&jc)for(e=e.child;e!==null;)Bg(e,t,i),e=e.sibling}function Bg(e,t,i){switch(e.tag){case 26:po(e,t,i),e.flags&jc&&e.memoizedState!==null&&xS(i,Rs,e.memoizedState,e.memoizedProps);break;case 5:po(e,t,i);break;case 3:case 4:var o=Rs;Rs=fd(e.stateNode.containerInfo),po(e,t,i),Rs=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=jc,jc=16777216,po(e,t,i),jc=o):po(e,t,i));break;default:po(e,t,i)}}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 Cc(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var i=0;i<t.length;i++){var o=t[i];zn=o,Hg(o,e)}Fg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Pg(e),e=e.sibling}function Pg(e){switch(e.tag){case 0:case 11:case 15:Cc(e),e.flags&2048&&Cr(9,e,e.return);break;case 3:Cc(e);break;case 12:Cc(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ju(e)):Cc(e);break;default:Cc(e)}}function Ju(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var i=0;i<t.length;i++){var o=t[i];zn=o,Hg(o,e)}Fg(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Cr(8,t,t.return),Ju(t);break;case 22:i=t.stateNode,i._visibility&2&&(i._visibility&=-3,Ju(t));break;default:Ju(t)}e=e.sibling}}function Hg(e,t){for(;zn!==null;){var i=zn;switch(i.tag){case 0:case 11:case 15:Cr(8,i,t);break;case 23:case 22:if(i.memoizedState!==null&&i.memoizedState.cachePool!==null){var o=i.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:fl(i.memoizedState.cache)}if(o=i.child,o!==null)o.return=i,zn=o;else e:for(i=e;zn!==null;){o=zn;var f=o.sibling,h=o.return;if(Rg(o),o===i){zn=null;break e}if(f!==null){f.return=h,zn=f;break e}zn=h}}}var _b={getCacheForType:function(e){var t=gn(un),i=t.data.get(e);return i===void 0&&(i=e(),t.data.set(e,i)),i},cacheSignal:function(){return gn(un).controller.signal}},Lb=typeof WeakMap=="function"?WeakMap:Map,Nt=0,Ht=null,xt=null,wt=0,Et=0,Wa=null,kr=!1,go=!1,im=!1,qi=0,dn=0,Ar=0,Sl=0,rm=0,Ka=0,vo=0,kc=null,Ta=null,lm=!1,ed=0,$g=0,td=1/0,nd=null,Nr=null,Mn=0,Mr=null,xo=null,Gi=0,om=0,cm=null,Ug=null,Ac=0,um=null;function Qa(){return(Nt&2)!==0&&wt!==0?wt&-wt:O.T!==null?gm():mn()}function qg(){if(Ka===0)if((wt&536870912)===0||gt){var e=Pn;Pn<<=1,(Pn&3932160)===0&&(Pn=262144),Ka=e}else Ka=536870912;return e=ca.current,e!==null&&(e.flags|=32),Ka}function Ea(e,t,i){(e===Ht&&(Et===2||Et===9)||e.cancelPendingCommit!==null)&&(yo(e,0),Tr(e,wt,Ka,!1)),ts(e,i),((Nt&2)===0||e!==Ht)&&(e===Ht&&((Nt&2)===0&&(Sl|=i),dn===4&&Tr(e,wt,Ka,!1)),oi(e))}function Gg(e,t,i){if((Nt&6)!==0)throw Error(l(327));var o=!i&&(t&127)===0&&(t&e.expiredLanes)===0||es(e,t),f=o?Ob(e,t):fm(e,t,!0),h=o;do{if(f===0){go&&!o&&Tr(e,t,0,!1);break}else{if(i=e.current.alternate,h&&!zb(i)){f=fm(e,t,!1),h=!1;continue}if(f===2){if(h=t,e.errorRecoveryDisabledLanes&h)var S=0;else S=e.pendingLanes&-536870913,S=S!==0?S:S&536870912?536870912:0;if(S!==0){t=S;e:{var M=e;f=kc;var H=M.current.memoizedState.isDehydrated;if(H&&(yo(M,S).flags|=256),S=fm(M,S,!1),S!==2){if(im&&!H){M.errorRecoveryDisabledLanes|=h,Sl|=h,f=4;break e}h=Ta,Ta=f,h!==null&&(Ta===null?Ta=h:Ta.push.apply(Ta,h))}f=S}if(h=!1,f!==2)continue}}if(f===1){yo(e,0),Tr(e,t,0,!0);break}e:{switch(o=e,h=f,h){case 0:case 1:throw Error(l(345));case 4:if((t&4194048)!==t)break;case 6:Tr(o,t,Ka,!kr);break e;case 2:Ta=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(f=ed+300-tt(),10<f)){if(Tr(o,t,Ka,!kr),Rn(o,0,!0)!==0)break e;Gi=t,o.timeoutHandle=Sv(Vg.bind(null,o,i,Ta,nd,lm,t,Ka,Sl,vo,kr,h,"Throttled",-0,0),f);break e}Vg(o,i,Ta,nd,lm,t,Ka,Sl,vo,kr,h,null,-0,0)}}break}while(!0);oi(e)}function Vg(e,t,i,o,f,h,S,M,H,se,ye,Se,re,fe){if(e.timeoutHandle=-1,Se=t.subtreeFlags,Se&8192||(Se&16785408)===16785408){Se={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Hn},Bg(t,h,Se);var qe=(h&62914560)===h?ed-tt():(h&4194048)===h?$g-tt():0;if(qe=yS(Se,qe),qe!==null){Gi=h,e.cancelPendingCommit=qe(ev.bind(null,e,t,h,i,o,f,S,M,H,ye,Se,null,re,fe)),Tr(e,h,S,!se);return}}ev(e,t,h,i,o,f,S,M,H)}function zb(e){for(var t=e;;){var i=t.tag;if((i===0||i===11||i===15)&&t.flags&16384&&(i=t.updateQueue,i!==null&&(i=i.stores,i!==null)))for(var o=0;o<i.length;o++){var f=i[o],h=f.getSnapshot;f=f.value;try{if(!Jn(h(),f))return!1}catch{return!1}}if(i=t.child,t.subtreeFlags&16384&&i!==null)i.return=t,t=i;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 Tr(e,t,i,o){t&=~rm,t&=~Sl,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var f=t;0<f;){var h=31-Mt(f),S=1<<h;o[h]=-1,f&=~S}i!==0&&Bs(e,i,t)}function ad(){return(Nt&6)===0?(Nc(0),!1):!0}function dm(){if(xt!==null){if(Et===0)var e=xt.return;else e=xt,Ms=ds=null,jr(e),vr=null,pl=0,e=xt;for(;e!==null;)jg(e.alternate,e),e=e.return;xt=null}}function yo(e,t){var i=e.timeoutHandle;i!==-1&&(e.timeoutHandle=-1,tS(i)),i=e.cancelPendingCommit,i!==null&&(e.cancelPendingCommit=null,i()),Gi=0,dm(),Ht=e,xt=i=qn(e.current,null),wt=t,Et=0,Wa=null,kr=!1,go=es(e,t),im=!1,vo=Ka=rm=Sl=Ar=dn=0,Ta=kc=null,lm=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var f=31-Mt(o),h=1<<f;t|=e[f],o&=~h}return qi=t,Ai(),i}function Yg(e,t){st=null,O.H=vc,t===pr||t===gr?(t=Lu(),Et=3):t===hl?(t=Lu(),Et=4):Et=t===Uf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Wa=t,xt===null&&(dn=1,Vu(e,Sa(t,e.current)))}function Wg(){var e=ca.current;return e===null?!0:(wt&4194048)===wt?Ca===null:(wt&62914560)===wt||(wt&536870912)!==0?e===Ca:!1}function Kg(){var e=O.H;return O.H=vc,e===null?vc:e}function Qg(){var e=O.A;return O.A=_b,e}function sd(){dn=4,kr||(wt&4194048)!==wt&&ca.current!==null||(go=!0),(Ar&134217727)===0&&(Sl&134217727)===0||Ht===null||Tr(Ht,wt,Ka,!1)}function fm(e,t,i){var o=Nt;Nt|=2;var f=Kg(),h=Qg();(Ht!==e||wt!==t)&&(nd=null,yo(e,t)),t=!1;var S=dn;e:do try{if(Et!==0&&xt!==null){var M=xt,H=Wa;switch(Et){case 8:dm(),S=6;break e;case 3:case 2:case 9:case 6:ca.current===null&&(t=!0);var se=Et;if(Et=0,Wa=null,wo(e,M,H,se),i&&go){S=0;break e}break;default:se=Et,Et=0,Wa=null,wo(e,M,H,se)}}Ib(),S=dn;break}catch(ye){Yg(e,ye)}while(!0);return t&&e.shellSuspendCounter++,Ms=ds=null,Nt=o,O.H=f,O.A=h,xt===null&&(Ht=null,wt=0,Ai()),S}function Ib(){for(;xt!==null;)Xg(xt)}function Ob(e,t){var i=Nt;Nt|=2;var o=Kg(),f=Qg();Ht!==e||wt!==t?(nd=null,td=tt()+500,yo(e,t)):go=es(e,t);e:do try{if(Et!==0&&xt!==null){t=xt;var h=Wa;t:switch(Et){case 1:Et=0,Wa=null,wo(e,t,h,1);break;case 2:case 9:if(Du(h)){Et=0,Wa=null,Zg(t);break}t=function(){Et!==2&&Et!==9||Ht!==e||(Et=7),oi(e)},h.then(t,t);break e;case 3:Et=7;break e;case 4:Et=5;break e;case 7:Du(h)?(Et=0,Wa=null,Zg(t)):(Et=0,Wa=null,wo(e,t,h,7));break;case 5:var S=null;switch(xt.tag){case 26:S=xt.memoizedState;case 5:case 27:var M=xt;if(S?Ov(S):M.stateNode.complete){Et=0,Wa=null;var H=M.sibling;if(H!==null)xt=H;else{var se=M.return;se!==null?(xt=se,id(se)):xt=null}break t}}Et=0,Wa=null,wo(e,t,h,5);break;case 6:Et=0,Wa=null,wo(e,t,h,6);break;case 8:dm(),dn=6;break e;default:throw Error(l(462))}}Bb();break}catch(ye){Yg(e,ye)}while(!0);return Ms=ds=null,O.H=o,O.A=f,Nt=i,xt!==null?0:(Ht=null,wt=0,Ai(),dn)}function Bb(){for(;xt!==null&&!we();)Xg(xt)}function Xg(e){var t=bg(e.alternate,e,qi);e.memoizedProps=e.pendingProps,t===null?id(e):xt=t}function Zg(e){var t=e,i=t.alternate;switch(t.tag){case 15:case 0:t=pg(i,t,t.pendingProps,t.type,void 0,wt);break;case 11:t=pg(i,t,t.pendingProps,t.type.render,t.ref,wt);break;case 5:jr(t);default:jg(i,t),t=xt=cl(t,qi),t=bg(i,t,qi)}e.memoizedProps=e.pendingProps,t===null?id(e):xt=t}function wo(e,t,i,o){Ms=ds=null,jr(t),vr=null,pl=0;var f=t.return;try{if(Ab(e,f,t,i,wt)){dn=1,Vu(e,Sa(i,e.current)),xt=null;return}}catch(h){if(f!==null)throw xt=f,h;dn=1,Vu(e,Sa(i,e.current)),xt=null;return}t.flags&32768?(gt||o===1?e=!0:go||(wt&536870912)!==0?e=!1:(kr=e=!0,(o===2||o===9||o===3||o===6)&&(o=ca.current,o!==null&&o.tag===13&&(o.flags|=16384))),Jg(t,e)):id(t)}function id(e){var t=e;do{if((t.flags&32768)!==0){Jg(t,kr);return}e=t.return;var i=Tb(t.alternate,t,qi);if(i!==null){xt=i;return}if(t=t.sibling,t!==null){xt=t;return}xt=t=e}while(t!==null);dn===0&&(dn=5)}function Jg(e,t){do{var i=Eb(e.alternate,e);if(i!==null){i.flags&=32767,xt=i;return}if(i=e.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!t&&(e=e.sibling,e!==null)){xt=e;return}xt=e=i}while(e!==null);dn=6,xt=null}function ev(e,t,i,o,f,h,S,M,H){e.cancelPendingCommit=null;do rd();while(Mn!==0);if((Nt&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(h=t.lanes|t.childLanes,h|=to,Vt(e,i,h,S,M,H),e===Ht&&(xt=Ht=null,wt=0),xo=t,Mr=e,Gi=i,om=h,cm=f,Ug=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,$b(St,function(){return iv(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=O.T,O.T=null,f=Z.p,Z.p=2,S=Nt,Nt|=4;try{Rb(e,t,i)}finally{Nt=S,Z.p=f,O.T=o}}Mn=1,tv(),nv(),av()}}function tv(){if(Mn===1){Mn=0;var e=Mr,t=xo,i=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||i){i=O.T,O.T=null;var o=Z.p;Z.p=2;var f=Nt;Nt|=4;try{zg(t,e);var h=Cm,S=Si(e.containerInfo),M=h.focusedElem,H=h.selectionRange;if(S!==M&&M&&M.ownerDocument&&Ko(M.ownerDocument.documentElement,M)){if(H!==null&&Jl(M)){var se=H.start,ye=H.end;if(ye===void 0&&(ye=se),"selectionStart"in M)M.selectionStart=se,M.selectionEnd=Math.min(ye,M.value.length);else{var Se=M.ownerDocument||document,re=Se&&Se.defaultView||window;if(re.getSelection){var fe=re.getSelection(),qe=M.textContent.length,Ze=Math.min(H.start,qe),Ot=H.end===void 0?Ze:Math.min(H.end,qe);!fe.extend&&Ze>Ot&&(S=Ot,Ot=Ze,Ze=S);var ee=al(M,Ze),G=al(M,Ot);if(ee&&G&&(fe.rangeCount!==1||fe.anchorNode!==ee.node||fe.anchorOffset!==ee.offset||fe.focusNode!==G.node||fe.focusOffset!==G.offset)){var ae=Se.createRange();ae.setStart(ee.node,ee.offset),fe.removeAllRanges(),Ze>Ot?(fe.addRange(ae),fe.extend(G.node,G.offset)):(ae.setEnd(G.node,G.offset),fe.addRange(ae))}}}}for(Se=[],fe=M;fe=fe.parentNode;)fe.nodeType===1&&Se.push({element:fe,left:fe.scrollLeft,top:fe.scrollTop});for(typeof M.focus=="function"&&M.focus(),M=0;M<Se.length;M++){var be=Se[M];be.element.scrollLeft=be.left,be.element.scrollTop=be.top}}xd=!!jm,Cm=jm=null}finally{Nt=f,Z.p=o,O.T=i}}e.current=t,Mn=2}}function nv(){if(Mn===2){Mn=0;var e=Mr,t=xo,i=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||i){i=O.T,O.T=null;var o=Z.p;Z.p=2;var f=Nt;Nt|=4;try{Eg(e,t.alternate,t)}finally{Nt=f,Z.p=o,O.T=i}}Mn=3}}function av(){if(Mn===4||Mn===3){Mn=0,Ge();var e=Mr,t=xo,i=Gi,o=Ug;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?Mn=5:(Mn=0,xo=Mr=null,sv(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Nr=null),an(i),t=t.stateNode,it&&typeof it.onCommitFiberRoot=="function")try{it.onCommitFiberRoot(pt,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=O.T,f=Z.p,Z.p=2,O.T=null;try{for(var h=e.onRecoverableError,S=0;S<o.length;S++){var M=o[S];h(M.value,{componentStack:M.stack})}}finally{O.T=t,Z.p=f}}(Gi&3)!==0&&rd(),oi(e),f=e.pendingLanes,(i&261930)!==0&&(f&42)!==0?e===um?Ac++:(Ac=0,um=e):Ac=0,Nc(0)}}function sv(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,fl(t)))}function rd(){return tv(),nv(),av(),iv()}function iv(){if(Mn!==5)return!1;var e=Mr,t=om;om=0;var i=an(Gi),o=O.T,f=Z.p;try{Z.p=32>i?32:i,O.T=null,i=cm,cm=null;var h=Mr,S=Gi;if(Mn=0,xo=Mr=null,Gi=0,(Nt&6)!==0)throw Error(l(331));var M=Nt;if(Nt|=4,Pg(h.current),Og(h,h.current,S,i),Nt=M,Nc(0,!1),it&&typeof it.onPostCommitFiberRoot=="function")try{it.onPostCommitFiberRoot(pt,h)}catch{}return!0}finally{Z.p=f,O.T=o,sv(e,t)}}function rv(e,t,i){t=Sa(i,t),t=$f(e.stateNode,t,2),e=Va(e,t,2),e!==null&&(ts(e,2),oi(e))}function Rt(e,t,i){if(e.tag===3)rv(e,e,i);else for(;t!==null;){if(t.tag===3){rv(t,e,i);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(Nr===null||!Nr.has(o))){e=Sa(i,e),i=lg(2),o=Va(t,i,2),o!==null&&(og(i,o,t,e),ts(o,2),oi(o));break}}t=t.return}}function mm(e,t,i){var o=e.pingCache;if(o===null){o=e.pingCache=new Lb;var f=new Set;o.set(t,f)}else f=o.get(t),f===void 0&&(f=new Set,o.set(t,f));f.has(i)||(im=!0,f.add(i),e=Fb.bind(null,e,t,i),t.then(e,e))}function Fb(e,t,i){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Ht===e&&(wt&i)===i&&(dn===4||dn===3&&(wt&62914560)===wt&&300>tt()-ed?(Nt&2)===0&&yo(e,0):rm|=i,vo===wt&&(vo=0)),oi(e)}function lv(e,t){t===0&&(t=fi()),e=os(e,t),e!==null&&(ts(e,t),oi(e))}function Pb(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),lv(e,i)}function Hb(e,t){var i=0;switch(e.tag){case 31:case 13:var o=e.stateNode,f=e.memoizedState;f!==null&&(i=f.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(l(314))}o!==null&&o.delete(t),lv(e,i)}function $b(e,t){return ke(e,t)}var ld=null,bo=null,hm=!1,od=!1,pm=!1,Er=0;function oi(e){e!==bo&&e.next===null&&(bo===null?ld=bo=e:bo=bo.next=e),od=!0,hm||(hm=!0,qb())}function Nc(e,t){if(!pm&&od){pm=!0;do for(var i=!1,o=ld;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var h=0;else{var S=o.suspendedLanes,M=o.pingedLanes;h=(1<<31-Mt(42|e)+1)-1,h&=f&~(S&~M),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(i=!0,dv(o,h))}else h=wt,h=Rn(o,o===Ht?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||es(o,h)||(i=!0,dv(o,h));o=o.next}while(i);pm=!1}}function Ub(){ov()}function ov(){od=hm=!1;var e=0;Er!==0&&eS()&&(e=Er);for(var t=tt(),i=null,o=ld;o!==null;){var f=o.next,h=cv(o,t);h===0?(o.next=null,i===null?ld=f:i.next=f,f===null&&(bo=i)):(i=o,(e!==0||(h&3)!==0)&&(od=!0)),o=f}Mn!==0&&Mn!==5||Nc(e),Er!==0&&(Er=0)}function cv(e,t){for(var i=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,h=e.pendingLanes&-62914561;0<h;){var S=31-Mt(h),M=1<<S,H=f[S];H===-1?((M&i)===0||(M&o)!==0)&&(f[S]=Ie(M,t)):H<=t&&(e.expiredLanes|=M),h&=~M}if(t=Ht,i=wt,i=Rn(e,e===t?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,i===0||e===t&&(Et===2||Et===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&de(o),e.callbackNode=null,e.callbackPriority=0;if((i&3)===0||es(e,i)){if(t=i&-i,t===e.callbackPriority)return t;switch(o!==null&&de(o),an(i)){case 2:case 8:i=ht;break;case 32:i=St;break;case 268435456:i=Oe;break;default:i=St}return o=uv.bind(null,e),i=ke(i,o),e.callbackPriority=t,e.callbackNode=i,t}return o!==null&&o!==null&&de(o),e.callbackPriority=2,e.callbackNode=null,2}function uv(e,t){if(Mn!==0&&Mn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var i=e.callbackNode;if(rd()&&e.callbackNode!==i)return null;var o=wt;return o=Rn(e,e===Ht?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Gg(e,o,t),cv(e,tt()),e.callbackNode!=null&&e.callbackNode===i?uv.bind(null,e):null)}function dv(e,t){if(rd())return null;Gg(e,t,!0)}function qb(){nS(function(){(Nt&6)!==0?ke(Qe,Ub):ov()})}function gm(){if(Er===0){var e=mr;e===0&&(e=fn,fn<<=1,(fn&261888)===0&&(fn=256)),Er=e}return Er}function fv(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Ba(""+e)}function mv(e,t){var i=t.ownerDocument.createElement("input");return i.name=t.name,i.value=t.value,e.id&&i.setAttribute("form",e.id),t.parentNode.insertBefore(i,t),e=new FormData(e),i.parentNode.removeChild(i),e}function Gb(e,t,i,o,f){if(t==="submit"&&i&&i.stateNode===f){var h=fv((f[Ne]||null).action),S=o.submitter;S&&(t=(t=S[Ne]||null)?fv(t.formAction):S.getAttribute("formAction"),t!==null&&(h=t,S=null));var M=new Us("action","action",null,o,f);e.push({event:M,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(Er!==0){var H=S?mv(f,S):new FormData(f);If(i,{pending:!0,data:H,method:f.method,action:h},null,H)}}else typeof h=="function"&&(M.preventDefault(),H=S?mv(f,S):new FormData(f),If(i,{pending:!0,data:H,method:f.method,action:h},h,H))},currentTarget:f}]})}}for(var vm=0;vm<rl.length;vm++){var xm=rl[vm],Vb=xm.toLowerCase(),Yb=xm[0].toUpperCase()+xm.slice(1);la(Vb,"on"+Yb)}la(Zo,"onAnimationEnd"),la(Cs,"onAnimationIteration"),la(il,"onAnimationStart"),la("dblclick","onDoubleClick"),la("focusin","onFocus"),la("focusout","onBlur"),la(lr,"onTransitionRun"),la(ki,"onTransitionStart"),la(Jo,"onTransitionCancel"),la(Nu,"onTransitionEnd"),Xt("onMouseEnter",["mouseout","mouseover"]),Xt("onMouseLeave",["mouseout","mouseover"]),Xt("onPointerEnter",["pointerout","pointerover"]),Xt("onPointerLeave",["pointerout","pointerover"]),on("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),on("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),on("onBeforeInput",["compositionend","keypress","textInput","paste"]),on("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),on("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),on("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mc="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(" "),Wb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Mc));function hv(e,t){t=(t&4)!==0;for(var i=0;i<e.length;i++){var o=e[i],f=o.event;o=o.listeners;e:{var h=void 0;if(t)for(var S=o.length-1;0<=S;S--){var M=o[S],H=M.instance,se=M.currentTarget;if(M=M.listener,H!==h&&f.isPropagationStopped())break e;h=M,f.currentTarget=se;try{h(f)}catch(ye){Zs(ye)}f.currentTarget=null,h=H}else for(S=0;S<o.length;S++){if(M=o[S],H=M.instance,se=M.currentTarget,M=M.listener,H!==h&&f.isPropagationStopped())break e;h=M,f.currentTarget=se;try{h(f)}catch(ye){Zs(ye)}f.currentTarget=null,h=H}}}}function yt(e,t){var i=t[at];i===void 0&&(i=t[at]=new Set);var o=e+"__bubble";i.has(o)||(pv(t,e,2,!1),i.add(o))}function ym(e,t,i){var o=0;t&&(o|=4),pv(i,e,o,t)}var cd="_reactListening"+Math.random().toString(36).slice(2);function wm(e){if(!e[cd]){e[cd]=!0,hn.forEach(function(i){i!=="selectionchange"&&(Wb.has(i)||ym(i,!1,e),ym(i,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[cd]||(t[cd]=!0,ym("selectionchange",!1,t))}}function pv(e,t,i,o){switch(qv(t)){case 2:var f=SS;break;case 8:f=jS;break;default:f=zm}i=f.bind(null,t,i,e),f=void 0,!mu||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(f=!0),o?f!==void 0?e.addEventListener(t,i,{capture:!0,passive:f}):e.addEventListener(t,i,!0):f!==void 0?e.addEventListener(t,i,{passive:f}):e.addEventListener(t,i,!1)}function bm(e,t,i,o,f){var h=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 M=o.stateNode.containerInfo;if(M===f)break;if(S===4)for(S=o.return;S!==null;){var H=S.tag;if((H===3||H===4)&&S.stateNode.containerInfo===f)return;S=S.return}for(;M!==null;){if(S=$t(M),S===null)return;if(H=S.tag,H===5||H===6||H===26||H===27){o=h=S;continue e}M=M.parentNode}}o=o.return}fu(function(){var se=h,ye=Uo(i),Se=[];e:{var re=ec.get(e);if(re!==void 0){var fe=Us,qe=e;switch(e){case"keypress":if(Hl(i)===0)break e;case"keydown":case"keyup":fe=Ys;break;case"focusin":qe="focus",fe=Xn;break;case"focusout":qe="blur",fe=Xn;break;case"beforeblur":case"afterblur":fe=Xn;break;case"click":if(i.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Vl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=et;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=rs;break;case Zo:case Cs:case il:fe=Gs;break;case Nu:fe=Wo;break;case"scroll":case"scrollend":fe=Ul;break;case"wheel":fe=vu;break;case"copy":case"cut":case"paste":fe=gu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=Yo;break;case"toggle":case"beforetoggle":fe=xu}var Ze=(t&4)!==0,Ot=!Ze&&(e==="scroll"||e==="scrollend"),ee=Ze?re!==null?re+"Capture":null:re;Ze=[];for(var G=se,ae;G!==null;){var be=G;if(ae=be.stateNode,be=be.tag,be!==5&&be!==26&&be!==27||ae===null||ee===null||(be=is(G,ee),be!=null&&Ze.push(Tc(G,be,ae))),Ot)break;G=G.return}0<Ze.length&&(re=new fe(re,qe,null,i,ye),Se.push({event:re,listeners:Ze}))}}if((t&7)===0){e:{if(re=e==="mouseover"||e==="pointerover",fe=e==="mouseout"||e==="pointerout",re&&i!==ss&&(qe=i.relatedTarget||i.fromElement)&&($t(qe)||qe[He]))break e;if((fe||re)&&(re=ye.window===ye?ye:(re=ye.ownerDocument)?re.defaultView||re.parentWindow:window,fe?(qe=i.relatedTarget||i.toElement,fe=se,qe=qe?$t(qe):null,qe!==null&&(Ot=d(qe),Ze=qe.tag,qe!==Ot||Ze!==5&&Ze!==27&&Ze!==6)&&(qe=null)):(fe=null,qe=se),fe!==qe)){if(Ze=Vl,be="onMouseLeave",ee="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(Ze=Yo,be="onPointerLeave",ee="onPointerEnter",G="pointer"),Ot=fe==null?re:Pt(fe),ae=qe==null?re:Pt(qe),re=new Ze(be,G+"leave",fe,i,ye),re.target=Ot,re.relatedTarget=ae,be=null,$t(ye)===se&&(Ze=new Ze(ee,G+"enter",qe,i,ye),Ze.target=ae,Ze.relatedTarget=Ot,be=Ze),Ot=be,fe&&qe)t:{for(Ze=Kb,ee=fe,G=qe,ae=0,be=ee;be;be=Ze(be))ae++;be=0;for(var Ke=G;Ke;Ke=Ze(Ke))be++;for(;0<ae-be;)ee=Ze(ee),ae--;for(;0<be-ae;)G=Ze(G),be--;for(;ae--;){if(ee===G||G!==null&&ee===G.alternate){Ze=ee;break t}ee=Ze(ee),G=Ze(G)}Ze=null}else Ze=null;fe!==null&&gv(Se,re,fe,Ze,!1),qe!==null&&Ot!==null&&gv(Se,Ot,qe,Ze,!0)}}e:{if(re=se?Pt(se):window,fe=re.nodeName&&re.nodeName.toLowerCase(),fe==="select"||fe==="input"&&re.type==="file")var Ct=Zn;else if(el(re))if(ju)Ct=Zl;else{Ct=ir;var Ve=Ss}else fe=re.nodeName,!fe||fe.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?se&&tr(se.elementType)&&(Ct=Zn):Ct=Xl;if(Ct&&(Ct=Ct(e,se))){xa(Se,Ct,i,ye);break e}Ve&&Ve(e,re,se),e==="focusout"&&se&&re.type==="number"&&se.memoizedProps.value!=null&&er(re,"number",re.value)}switch(Ve=se?Pt(se):window,e){case"focusin":(el(Ve)||Ve.contentEditable==="true")&&(rr=Ve,Xs=se,sl=null);break;case"focusout":sl=Xs=rr=null;break;case"mousedown":eo=!0;break;case"contextmenu":case"mouseup":case"dragend":eo=!1,Au(Se,i,ye);break;case"selectionchange":if(ku)break;case"keydown":case"keyup":Au(Se,i,ye)}var dt;if(Wl)e:{switch(e){case"compositionstart":var bt="onCompositionStart";break e;case"compositionend":bt="onCompositionEnd";break e;case"compositionupdate":bt="onCompositionUpdate";break e}bt=void 0}else wi?yi(e,i)&&(bt="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(bt="onCompositionStart");bt&&(yu&&i.locale!=="ko"&&(wi||bt!=="onCompositionStart"?bt==="onCompositionEnd"&&wi&&(dt=Go()):(vi=ye,qo="value"in vi?vi.value:vi.textContent,wi=!0)),Ve=ud(se,bt),0<Ve.length&&(bt=new Xr(bt,e,null,i,ye),Se.push({event:bt,listeners:Ve}),dt?bt.data=dt:(dt=bu(i),dt!==null&&(bt.data=dt)))),(dt=xi?bs(e,i):Su(e,i))&&(bt=ud(se,"onBeforeInput"),0<bt.length&&(Ve=new Xr("onBeforeInput","beforeinput",null,i,ye),Se.push({event:Ve,listeners:bt}),Ve.data=dt)),Gb(Se,e,se,i,ye)}hv(Se,t)})}function Tc(e,t,i){return{instance:e,listener:t,currentTarget:i}}function ud(e,t){for(var i=t+"Capture",o=[];e!==null;){var f=e,h=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||h===null||(f=is(e,i),f!=null&&o.unshift(Tc(e,f,h)),f=is(e,t),f!=null&&o.push(Tc(e,f,h))),e.tag===3)return o;e=e.return}return[]}function Kb(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function gv(e,t,i,o,f){for(var h=t._reactName,S=[];i!==null&&i!==o;){var M=i,H=M.alternate,se=M.stateNode;if(M=M.tag,H!==null&&H===o)break;M!==5&&M!==26&&M!==27||se===null||(H=se,f?(se=is(i,h),se!=null&&S.unshift(Tc(i,se,H))):f||(se=is(i,h),se!=null&&S.push(Tc(i,se,H)))),i=i.return}S.length!==0&&e.push({event:t,listeners:S})}var Qb=/\r\n?/g,Xb=/\u0000|\uFFFD/g;function vv(e){return(typeof e=="string"?e:""+e).replace(Qb,`
|
|
9
|
+
`).replace(Xb,"")}function xv(e,t){return t=vv(t),vv(e)===t}function It(e,t,i,o,f,h){switch(i){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Ps(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Ps(e,""+o);break;case"className":Bl(e,"class",o);break;case"tabIndex":Bl(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Bl(e,i,o);break;case"style":Wr(e,o,h);break;case"data":if(t!=="object"){Bl(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||i!=="href")){e.removeAttribute(i);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(i);break}o=Ba(""+o),e.setAttribute(i,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(i,"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 h=="function"&&(i==="formAction"?(t!=="input"&&It(e,t,"name",f.name,f,null),It(e,t,"formEncType",f.formEncType,f,null),It(e,t,"formMethod",f.formMethod,f,null),It(e,t,"formTarget",f.formTarget,f,null)):(It(e,t,"encType",f.encType,f,null),It(e,t,"method",f.method,f,null),It(e,t,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(i);break}o=Ba(""+o),e.setAttribute(i,o);break;case"onClick":o!=null&&(e.onclick=Hn);break;case"onScroll":o!=null&&yt("scroll",e);break;case"onScrollEnd":o!=null&&yt("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(l(61));if(i=o.__html,i!=null){if(f.children!=null)throw Error(l(60));e.innerHTML=i}}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}i=Ba(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",i);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(i,""+o):e.removeAttribute(i);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(i,""):e.removeAttribute(i);break;case"capture":case"download":o===!0?e.setAttribute(i,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(i,o):e.removeAttribute(i);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(i,o):e.removeAttribute(i);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(i):e.setAttribute(i,o);break;case"popover":yt("beforetoggle",e),yt("toggle",e),Zi(e,"popover",o);break;case"xlinkActuate":Oa(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Oa(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Oa(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Oa(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Oa(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Oa(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Oa(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Oa(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Oa(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Zi(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(i=$o.get(i)||i,Zi(e,i,o))}}function Sm(e,t,i,o,f,h){switch(i){case"style":Wr(e,o,h);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(l(61));if(i=o.__html,i!=null){if(f.children!=null)throw Error(l(60));e.innerHTML=i}}break;case"children":typeof o=="string"?Ps(e,o):(typeof o=="number"||typeof o=="bigint")&&Ps(e,""+o);break;case"onScroll":o!=null&&yt("scroll",e);break;case"onScrollEnd":o!=null&&yt("scrollend",e);break;case"onClick":o!=null&&(e.onclick=Hn);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ns.hasOwnProperty(i))e:{if(i[0]==="o"&&i[1]==="n"&&(f=i.endsWith("Capture"),t=i.slice(2,f?i.length-7:void 0),h=e[Ne]||null,h=h!=null?h[i]:null,typeof h=="function"&&e.removeEventListener(t,h,f),typeof o=="function")){typeof h!="function"&&h!==null&&(i in e?e[i]=null:e.hasAttribute(i)&&e.removeAttribute(i)),e.addEventListener(t,o,f);break e}i in e?e[i]=o:o===!0?e.setAttribute(i,""):Zi(e,i,o)}}}function Yn(e,t,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":yt("error",e),yt("load",e);var o=!1,f=!1,h;for(h in i)if(i.hasOwnProperty(h)){var S=i[h];if(S!=null)switch(h){case"src":o=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:It(e,t,h,S,i,null)}}f&&It(e,t,"srcSet",i.srcSet,i,null),o&&It(e,t,"src",i.src,i,null);return;case"input":yt("invalid",e);var M=h=S=f=null,H=null,se=null;for(o in i)if(i.hasOwnProperty(o)){var ye=i[o];if(ye!=null)switch(o){case"name":f=ye;break;case"type":S=ye;break;case"checked":H=ye;break;case"defaultChecked":se=ye;break;case"value":h=ye;break;case"defaultValue":M=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(l(137,t));break;default:It(e,t,o,ye,i,null)}}Ji(e,h,M,H,se,S,f,!1);return;case"select":yt("invalid",e),o=S=h=null;for(f in i)if(i.hasOwnProperty(f)&&(M=i[f],M!=null))switch(f){case"value":h=M;break;case"defaultValue":S=M;break;case"multiple":o=M;default:It(e,t,f,M,i,null)}t=h,i=S,e.multiple=!!o,t!=null?as(e,!!o,t,!1):i!=null&&as(e,!!o,i,!0);return;case"textarea":yt("invalid",e),h=f=o=null;for(S in i)if(i.hasOwnProperty(S)&&(M=i[S],M!=null))switch(S){case"value":o=M;break;case"defaultValue":f=M;break;case"children":h=M;break;case"dangerouslySetInnerHTML":if(M!=null)throw Error(l(91));break;default:It(e,t,S,M,i,null)}gi(e,o,f,h);return;case"option":for(H in i)i.hasOwnProperty(H)&&(o=i[H],o!=null)&&(H==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":It(e,t,H,o,i,null));return;case"dialog":yt("beforetoggle",e),yt("toggle",e),yt("cancel",e),yt("close",e);break;case"iframe":case"object":yt("load",e);break;case"video":case"audio":for(o=0;o<Mc.length;o++)yt(Mc[o],e);break;case"image":yt("error",e),yt("load",e);break;case"details":yt("toggle",e);break;case"embed":case"source":case"link":yt("error",e),yt("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(se in i)if(i.hasOwnProperty(se)&&(o=i[se],o!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:It(e,t,se,o,i,null)}return;default:if(tr(t)){for(ye in i)i.hasOwnProperty(ye)&&(o=i[ye],o!==void 0&&Sm(e,t,ye,o,i,void 0));return}}for(M in i)i.hasOwnProperty(M)&&(o=i[M],o!=null&&It(e,t,M,o,i,null))}function Zb(e,t,i,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,h=null,S=null,M=null,H=null,se=null,ye=null;for(fe in i){var Se=i[fe];if(i.hasOwnProperty(fe)&&Se!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":H=Se;default:o.hasOwnProperty(fe)||It(e,t,fe,null,o,Se)}}for(var re in o){var fe=o[re];if(Se=i[re],o.hasOwnProperty(re)&&(fe!=null||Se!=null))switch(re){case"type":h=fe;break;case"name":f=fe;break;case"checked":se=fe;break;case"defaultChecked":ye=fe;break;case"value":S=fe;break;case"defaultValue":M=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(l(137,t));break;default:fe!==Se&&It(e,t,re,fe,o,Se)}}hi(e,S,M,H,se,ye,h,f);return;case"select":fe=S=M=re=null;for(h in i)if(H=i[h],i.hasOwnProperty(h)&&H!=null)switch(h){case"value":break;case"multiple":fe=H;default:o.hasOwnProperty(h)||It(e,t,h,null,o,H)}for(f in o)if(h=o[f],H=i[f],o.hasOwnProperty(f)&&(h!=null||H!=null))switch(f){case"value":re=h;break;case"defaultValue":M=h;break;case"multiple":S=h;default:h!==H&&It(e,t,f,h,o,H)}t=M,i=S,o=fe,re!=null?as(e,!!i,re,!1):!!o!=!!i&&(t!=null?as(e,!!i,t,!0):as(e,!!i,i?[]:"",!1));return;case"textarea":fe=re=null;for(M in i)if(f=i[M],i.hasOwnProperty(M)&&f!=null&&!o.hasOwnProperty(M))switch(M){case"value":break;case"children":break;default:It(e,t,M,null,o,f)}for(S in o)if(f=o[S],h=i[S],o.hasOwnProperty(S)&&(f!=null||h!=null))switch(S){case"value":re=f;break;case"defaultValue":fe=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(l(91));break;default:f!==h&&It(e,t,S,f,o,h)}pi(e,re,fe);return;case"option":for(var qe in i)re=i[qe],i.hasOwnProperty(qe)&&re!=null&&!o.hasOwnProperty(qe)&&(qe==="selected"?e.selected=!1:It(e,t,qe,null,o,re));for(H in o)re=o[H],fe=i[H],o.hasOwnProperty(H)&&re!==fe&&(re!=null||fe!=null)&&(H==="selected"?e.selected=re&&typeof re!="function"&&typeof re!="symbol":It(e,t,H,re,o,fe));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Ze in i)re=i[Ze],i.hasOwnProperty(Ze)&&re!=null&&!o.hasOwnProperty(Ze)&&It(e,t,Ze,null,o,re);for(se in o)if(re=o[se],fe=i[se],o.hasOwnProperty(se)&&re!==fe&&(re!=null||fe!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(l(137,t));break;default:It(e,t,se,re,o,fe)}return;default:if(tr(t)){for(var Ot in i)re=i[Ot],i.hasOwnProperty(Ot)&&re!==void 0&&!o.hasOwnProperty(Ot)&&Sm(e,t,Ot,void 0,o,re);for(ye in o)re=o[ye],fe=i[ye],!o.hasOwnProperty(ye)||re===fe||re===void 0&&fe===void 0||Sm(e,t,ye,re,o,fe);return}}for(var ee in i)re=i[ee],i.hasOwnProperty(ee)&&re!=null&&!o.hasOwnProperty(ee)&&It(e,t,ee,null,o,re);for(Se in o)re=o[Se],fe=i[Se],!o.hasOwnProperty(Se)||re===fe||re==null&&fe==null||It(e,t,Se,re,o,fe)}function yv(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Jb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,i=performance.getEntriesByType("resource"),o=0;o<i.length;o++){var f=i[o],h=f.transferSize,S=f.initiatorType,M=f.duration;if(h&&M&&yv(S)){for(S=0,M=f.responseEnd,o+=1;o<i.length;o++){var H=i[o],se=H.startTime;if(se>M)break;var ye=H.transferSize,Se=H.initiatorType;ye&&yv(Se)&&(H=H.responseEnd,S+=ye*(H<M?1:(M-se)/(H-se)))}if(--o,t+=8*(h+S)/(f.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 jm=null,Cm=null;function dd(e){return e.nodeType===9?e:e.ownerDocument}function wv(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 bv(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 km(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 Am=null;function eS(){var e=window.event;return e&&e.type==="popstate"?e===Am?!1:(Am=e,!0):(Am=null,!1)}var Sv=typeof setTimeout=="function"?setTimeout:void 0,tS=typeof clearTimeout=="function"?clearTimeout:void 0,jv=typeof Promise=="function"?Promise:void 0,nS=typeof queueMicrotask=="function"?queueMicrotask:typeof jv<"u"?function(e){return jv.resolve(null).then(e).catch(aS)}:Sv;function aS(e){setTimeout(function(){throw e})}function Rr(e){return e==="head"}function Cv(e,t){var i=t,o=0;do{var f=i.nextSibling;if(e.removeChild(i),f&&f.nodeType===8)if(i=f.data,i==="/$"||i==="/&"){if(o===0){e.removeChild(f),ko(t);return}o--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")o++;else if(i==="html")Ec(e.ownerDocument.documentElement);else if(i==="head"){i=e.ownerDocument.head,Ec(i);for(var h=i.firstChild;h;){var S=h.nextSibling,M=h.nodeName;h[rt]||M==="SCRIPT"||M==="STYLE"||M==="LINK"&&h.rel.toLowerCase()==="stylesheet"||i.removeChild(h),h=S}}else i==="body"&&Ec(e.ownerDocument.body);i=f}while(i);ko(t)}function kv(e,t){var i=e;e=0;do{var o=i.nextSibling;if(i.nodeType===1?t?(i._stashedDisplay=i.style.display,i.style.display="none"):(i.style.display=i._stashedDisplay||"",i.getAttribute("style")===""&&i.removeAttribute("style")):i.nodeType===3&&(t?(i._stashedText=i.nodeValue,i.nodeValue=""):i.nodeValue=i._stashedText||""),o&&o.nodeType===8)if(i=o.data,i==="/$"){if(e===0)break;e--}else i!=="$"&&i!=="$?"&&i!=="$~"&&i!=="$!"||e++;i=o}while(i)}function Nm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var i=t;switch(t=t.nextSibling,i.nodeName){case"HTML":case"HEAD":case"BODY":Nm(i),Qt(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}e.removeChild(i)}}function sS(e,t,i,o){for(;e.nodeType===1;){var f=i;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[rt])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(h=e.getAttribute("rel"),h==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(h!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(h=e.getAttribute("src"),(h!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&h&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var h=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===h)return e}else return e;if(e=hs(e.nextSibling),e===null)break}return null}function iS(e,t,i){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!i||(e=hs(e.nextSibling),e===null))return null;return e}function Av(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=hs(e.nextSibling),e===null))return null;return e}function Mm(e){return e.data==="$?"||e.data==="$~"}function Tm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function rS(e,t){var i=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||i.readyState!=="loading")t();else{var o=function(){t(),i.removeEventListener("DOMContentLoaded",o)};i.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function hs(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 Em=null;function Nv(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"||i==="/&"){if(t===0)return hs(e.nextSibling);t--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||t++}e=e.nextSibling}return null}function Mv(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="$"||i==="$!"||i==="$?"||i==="$~"||i==="&"){if(t===0)return e;t--}else i!=="/$"&&i!=="/&"||t++}e=e.previousSibling}return null}function Tv(e,t,i){switch(t=dd(i),e){case"html":if(e=t.documentElement,!e)throw Error(l(452));return e;case"head":if(e=t.head,!e)throw Error(l(453));return e;case"body":if(e=t.body,!e)throw Error(l(454));return e;default:throw Error(l(451))}}function Ec(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Qt(e)}var ps=new Map,Ev=new Set;function fd(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Vi=Z.d;Z.d={f:lS,r:oS,D:cS,C:uS,L:dS,m:fS,X:hS,S:mS,M:pS};function lS(){var e=Vi.f(),t=ad();return e||t}function oS(e){var t=Dt(e);t!==null&&t.tag===5&&t.type==="form"?Yp(t):Vi.r(e)}var So=typeof document>"u"?null:document;function Rv(e,t,i){var o=So;if(o&&typeof t=="string"&&t){var f=bn(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),Ev.has(f)||(Ev.add(f),e={rel:e,crossOrigin:i,href:t},o.querySelector(f)===null&&(t=o.createElement("link"),Yn(t,"link",e),_t(t),o.head.appendChild(t)))}}function cS(e){Vi.D(e),Rv("dns-prefetch",e,null)}function uS(e,t){Vi.C(e,t),Rv("preconnect",e,t)}function dS(e,t,i){Vi.L(e,t,i);var o=So;if(o&&e&&t){var f='link[rel="preload"][as="'+bn(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+bn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+bn(i.imageSizes)+'"]')):f+='[href="'+bn(e)+'"]';var h=f;switch(t){case"style":h=jo(e);break;case"script":h=Co(e)}ps.has(h)||(e=y({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),ps.set(h,e),o.querySelector(f)!==null||t==="style"&&o.querySelector(Rc(h))||t==="script"&&o.querySelector(Dc(h))||(t=o.createElement("link"),Yn(t,"link",e),_t(t),o.head.appendChild(t)))}}function fS(e,t){Vi.m(e,t);var i=So;if(i&&e){var o=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+bn(o)+'"][href="'+bn(e)+'"]',h=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Co(e)}if(!ps.has(h)&&(e=y({rel:"modulepreload",href:e},t),ps.set(h,e),i.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(Dc(h)))return}o=i.createElement("link"),Yn(o,"link",e),_t(o),i.head.appendChild(o)}}}function mS(e,t,i){Vi.S(e,t,i);var o=So;if(o&&e){var f=Ut(o).hoistableStyles,h=jo(e);t=t||"default";var S=f.get(h);if(!S){var M={loading:0,preload:null};if(S=o.querySelector(Rc(h)))M.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},i),(i=ps.get(h))&&Rm(e,i);var H=S=o.createElement("link");_t(H),Yn(H,"link",e),H._p=new Promise(function(se,ye){H.onload=se,H.onerror=ye}),H.addEventListener("load",function(){M.loading|=1}),H.addEventListener("error",function(){M.loading|=2}),M.loading|=4,md(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:M},f.set(h,S)}}}function hS(e,t){Vi.X(e,t);var i=So;if(i&&e){var o=Ut(i).hoistableScripts,f=Co(e),h=o.get(f);h||(h=i.querySelector(Dc(f)),h||(e=y({src:e,async:!0},t),(t=ps.get(f))&&Dm(e,t),h=i.createElement("script"),_t(h),Yn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function pS(e,t){Vi.M(e,t);var i=So;if(i&&e){var o=Ut(i).hoistableScripts,f=Co(e),h=o.get(f);h||(h=i.querySelector(Dc(f)),h||(e=y({src:e,async:!0,type:"module"},t),(t=ps.get(f))&&Dm(e,t),h=i.createElement("script"),_t(h),Yn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function Dv(e,t,i,o){var f=(f=xe.current)?fd(f):null;if(!f)throw Error(l(446));switch(e){case"meta":case"title":return null;case"style":return typeof i.precedence=="string"&&typeof i.href=="string"?(t=jo(i.href),i=Ut(f).hoistableStyles,o=i.get(t),o||(o={type:"style",instance:null,count:0,state:null},i.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(i.rel==="stylesheet"&&typeof i.href=="string"&&typeof i.precedence=="string"){e=jo(i.href);var h=Ut(f).hoistableStyles,S=h.get(e);if(S||(f=f.ownerDocument||f,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(e,S),(h=f.querySelector(Rc(e)))&&!h._p&&(S.instance=h,S.state.loading=5),ps.has(e)||(i={rel:"preload",as:"style",href:i.href,crossOrigin:i.crossOrigin,integrity:i.integrity,media:i.media,hrefLang:i.hrefLang,referrerPolicy:i.referrerPolicy},ps.set(e,i),h||gS(f,e,i,S.state))),t&&o===null)throw Error(l(528,""));return S}if(t&&o!==null)throw Error(l(529,""));return null;case"script":return t=i.async,i=i.src,typeof i=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Co(i),i=Ut(f).hoistableScripts,o=i.get(t),o||(o={type:"script",instance:null,count:0,state:null},i.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(l(444,e))}}function jo(e){return'href="'+bn(e)+'"'}function Rc(e){return'link[rel="stylesheet"]['+e+"]"}function _v(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function gS(e,t,i,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}),Yn(t,"link",i),_t(t),e.head.appendChild(t))}function Co(e){return'[src="'+bn(e)+'"]'}function Dc(e){return"script[async]"+e}function Lv(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+bn(i.href)+'"]');if(o)return t.instance=o,_t(o),o;var f=y({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),_t(o),Yn(o,"style",f),md(o,i.precedence,e),t.instance=o;case"stylesheet":f=jo(i.href);var h=e.querySelector(Rc(f));if(h)return t.state.loading|=4,t.instance=h,_t(h),h;o=_v(i),(f=ps.get(f))&&Rm(o,f),h=(e.ownerDocument||e).createElement("link"),_t(h);var S=h;return S._p=new Promise(function(M,H){S.onload=M,S.onerror=H}),Yn(h,"link",o),t.state.loading|=4,md(h,i.precedence,e),t.instance=h;case"script":return h=Co(i.src),(f=e.querySelector(Dc(h)))?(t.instance=f,_t(f),f):(o=i,(f=ps.get(h))&&(o=y({},i),Dm(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),_t(f),Yn(f,"link",o),e.head.appendChild(f),t.instance=f);case"void":return null;default:throw Error(l(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,md(o,i.precedence,e));return t.instance}function md(e,t,i){for(var o=i.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=o.length?o[o.length-1]:null,h=f,S=0;S<o.length;S++){var M=o[S];if(M.dataset.precedence===t)h=M;else if(h!==f)break}h?h.parentNode.insertBefore(e,h.nextSibling):(t=i.nodeType===9?i.head:i,t.insertBefore(e,t.firstChild))}function Rm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Dm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var hd=null;function zv(e,t,i){if(hd===null){var o=new Map,f=hd=new Map;f.set(i,o)}else f=hd,o=f.get(i),o||(o=new Map,f.set(i,o));if(o.has(e))return o;for(o.set(e,null),i=i.getElementsByTagName(e),f=0;f<i.length;f++){var h=i[f];if(!(h[rt]||h[te]||e==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var S=h.getAttribute(t)||"";S=e+S;var M=o.get(S);M?M.push(h):o.set(S,[h])}}return o}function Iv(e,t,i){e=e.ownerDocument||e,e.head.insertBefore(i,t==="title"?e.querySelector("head > title"):null)}function vS(e,t,i){if(i===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 Ov(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function xS(e,t,i,o){if(i.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(i.state.loading&4)===0){if(i.instance===null){var f=jo(o.href),h=t.querySelector(Rc(f));if(h){t=h._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=pd.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=h,_t(h);return}h=t.ownerDocument||t,o=_v(o),(f=ps.get(f))&&Rm(o,f),h=h.createElement("link"),_t(h);var S=h;S._p=new Promise(function(M,H){S.onload=M,S.onerror=H}),Yn(h,"link",o),i.instance=h}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(i,t),(t=i.state.preload)&&(i.state.loading&3)===0&&(e.count++,i=pd.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var _m=0;function yS(e,t){return e.stylesheets&&e.count===0&&vd(e,e.stylesheets),0<e.count||0<e.imgCount?function(i){var o=setTimeout(function(){if(e.stylesheets&&vd(e,e.stylesheets),e.unsuspend){var h=e.unsuspend;e.unsuspend=null,h()}},6e4+t);0<e.imgBytes&&_m===0&&(_m=62500*Jb());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&vd(e,e.stylesheets),e.unsuspend)){var h=e.unsuspend;e.unsuspend=null,h()}},(e.imgBytes>_m?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function pd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)vd(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var gd=null;function vd(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,gd=new Map,t.forEach(wS,e),gd=null,pd.call(e))}function wS(e,t){if(!(t.state.loading&4)){var i=gd.get(e);if(i)var o=i.get(null);else{i=new Map,gd.set(e,i);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<f.length;h++){var S=f[h];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(i.set(S.dataset.precedence,S),o=S)}o&&i.set(null,o)}f=t.instance,S=f.getAttribute("data-precedence"),h=i.get(S)||o,h===o&&i.set(null,f),i.set(S,f),this.count++,o=pd.bind(this),f.addEventListener("load",o),f.addEventListener("error",o),h?h.parentNode.insertBefore(f,h.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),t.state.loading|=4}}var _c={$$typeof:R,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function bS(e,t,i,o,f,h,S,M,H){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=ft(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ft(0),this.hiddenUpdates=ft(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=h,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=H,this.incompleteTransitions=new Map}function Bv(e,t,i,o,f,h,S,M,H,se,ye,Se){return e=new bS(e,t,i,S,H,se,ye,Se,M),t=1,h===!0&&(t|=24),h=Sn(3,null,null,t),e.current=h,h.stateNode=e,t=rc(),t.refCount++,e.pooledCache=t,t.refCount++,h.memoizedState={element:o,isDehydrated:i,cache:t},wr(h),e}function Fv(e){return e?(e=As,e):As}function Pv(e,t,i,o,f,h){f=Fv(f),o.context===null?o.context=f:o.pendingContext=f,o=Zt(t),o.payload={element:i},h=h===void 0?null:h,h!==null&&(o.callback=h),i=Va(e,o,t),i!==null&&(Ea(i,e,t),br(i,e,t))}function Hv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<t?i:t}}function Lm(e,t){Hv(e,t),(e=e.alternate)&&Hv(e,t)}function $v(e){if(e.tag===13||e.tag===31){var t=os(e,67108864);t!==null&&Ea(t,e,67108864),Lm(e,67108864)}}function Uv(e){if(e.tag===13||e.tag===31){var t=Qa();t=mt(t);var i=os(e,t);i!==null&&Ea(i,e,t),Lm(e,t)}}var xd=!0;function SS(e,t,i,o){var f=O.T;O.T=null;var h=Z.p;try{Z.p=2,zm(e,t,i,o)}finally{Z.p=h,O.T=f}}function jS(e,t,i,o){var f=O.T;O.T=null;var h=Z.p;try{Z.p=8,zm(e,t,i,o)}finally{Z.p=h,O.T=f}}function zm(e,t,i,o){if(xd){var f=Im(o);if(f===null)bm(e,t,o,yd,i),Gv(e,o);else if(kS(f,e,t,i,o))o.stopPropagation();else if(Gv(e,o),t&4&&-1<CS.indexOf(e)){for(;f!==null;){var h=Dt(f);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var S=Ja(h.pendingLanes);if(S!==0){var M=h;for(M.pendingLanes|=2,M.entangledLanes|=2;S;){var H=1<<31-Mt(S);M.entanglements[1]|=H,S&=~H}oi(h),(Nt&6)===0&&(td=tt()+500,Nc(0))}}break;case 31:case 13:M=os(h,2),M!==null&&Ea(M,h,2),ad(),Lm(h,2)}if(h=Im(o),h===null&&bm(e,t,o,yd,i),h===f)break;f=h}f!==null&&o.stopPropagation()}else bm(e,t,o,null,i)}}function Im(e){return e=Uo(e),Om(e)}var yd=null;function Om(e){if(yd=null,e=$t(e),e!==null){var t=d(e);if(t===null)e=null;else{var i=t.tag;if(i===13){if(e=m(t),e!==null)return e;e=null}else if(i===31){if(e=p(t),e!==null)return e;e=null}else if(i===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return yd=e,null}function qv(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(wn()){case Qe:return 2;case ht:return 8;case St:case Tn:return 32;case Oe:return 268435456;default:return 32}default:return 32}}var Bm=!1,Dr=null,_r=null,Lr=null,Lc=new Map,zc=new Map,zr=[],CS="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 Gv(e,t){switch(e){case"focusin":case"focusout":Dr=null;break;case"dragenter":case"dragleave":_r=null;break;case"mouseover":case"mouseout":Lr=null;break;case"pointerover":case"pointerout":Lc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":zc.delete(t.pointerId)}}function Ic(e,t,i,o,f,h){return e===null||e.nativeEvent!==h?(e={blockedOn:t,domEventName:i,eventSystemFlags:o,nativeEvent:h,targetContainers:[f]},t!==null&&(t=Dt(t),t!==null&&$v(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,f!==null&&t.indexOf(f)===-1&&t.push(f),e)}function kS(e,t,i,o,f){switch(t){case"focusin":return Dr=Ic(Dr,e,t,i,o,f),!0;case"dragenter":return _r=Ic(_r,e,t,i,o,f),!0;case"mouseover":return Lr=Ic(Lr,e,t,i,o,f),!0;case"pointerover":var h=f.pointerId;return Lc.set(h,Ic(Lc.get(h)||null,e,t,i,o,f)),!0;case"gotpointercapture":return h=f.pointerId,zc.set(h,Ic(zc.get(h)||null,e,t,i,o,f)),!0}return!1}function Vv(e){var t=$t(e.target);if(t!==null){var i=d(t);if(i!==null){if(t=i.tag,t===13){if(t=m(i),t!==null){e.blockedOn=t,Fs(e.priority,function(){Uv(i)});return}}else if(t===31){if(t=p(i),t!==null){e.blockedOn=t,Fs(e.priority,function(){Uv(i)});return}}else if(t===3&&i.stateNode.current.memoizedState.isDehydrated){e.blockedOn=i.tag===3?i.stateNode.containerInfo:null;return}}}e.blockedOn=null}function wd(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var i=Im(e.nativeEvent);if(i===null){i=e.nativeEvent;var o=new i.constructor(i.type,i);ss=o,i.target.dispatchEvent(o),ss=null}else return t=Dt(i),t!==null&&$v(t),e.blockedOn=i,!1;t.shift()}return!0}function Yv(e,t,i){wd(e)&&i.delete(t)}function AS(){Bm=!1,Dr!==null&&wd(Dr)&&(Dr=null),_r!==null&&wd(_r)&&(_r=null),Lr!==null&&wd(Lr)&&(Lr=null),Lc.forEach(Yv),zc.forEach(Yv)}function bd(e,t){e.blockedOn===t&&(e.blockedOn=null,Bm||(Bm=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,AS)))}var Sd=null;function Wv(e){Sd!==e&&(Sd=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Sd===e&&(Sd=null);for(var t=0;t<e.length;t+=3){var i=e[t],o=e[t+1],f=e[t+2];if(typeof o!="function"){if(Om(o||i)===null)continue;break}var h=Dt(i);h!==null&&(e.splice(t,3),t-=3,If(h,{pending:!0,data:f,method:i.method,action:o},o,f))}}))}function ko(e){function t(H){return bd(H,e)}Dr!==null&&bd(Dr,e),_r!==null&&bd(_r,e),Lr!==null&&bd(Lr,e),Lc.forEach(t),zc.forEach(t);for(var i=0;i<zr.length;i++){var o=zr[i];o.blockedOn===e&&(o.blockedOn=null)}for(;0<zr.length&&(i=zr[0],i.blockedOn===null);)Vv(i),i.blockedOn===null&&zr.shift();if(i=(e.ownerDocument||e).$$reactFormReplay,i!=null)for(o=0;o<i.length;o+=3){var f=i[o],h=i[o+1],S=f[Ne]||null;if(typeof h=="function")S||Wv(i);else if(S){var M=null;if(h&&h.hasAttribute("formAction")){if(f=h,S=h[Ne]||null)M=S.formAction;else if(Om(f)!==null)continue}else M=S.action;typeof M=="function"?i[o+1]=M:(i.splice(o,3),o-=3),Wv(i)}}}function Kv(){function e(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(S){return f=S})},focusReset:"manual",scroll:"manual"})}function t(){f!==null&&(f(),f=null),o||setTimeout(i,20)}function i(){if(!o&&!navigation.transition){var h=navigation.currentEntry;h&&h.url!=null&&navigation.navigate(h.url,{state:h.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(i,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),f!==null&&(f(),f=null)}}}function Fm(e){this._internalRoot=e}jd.prototype.render=Fm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var i=t.current,o=Qa();Pv(i,o,e,t,null,null)},jd.prototype.unmount=Fm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Pv(e.current,2,null,e,null,null),ad(),t[He]=null}};function jd(e){this._internalRoot=e}jd.prototype.unstable_scheduleHydration=function(e){if(e){var t=mn();e={blockedOn:null,target:e,priority:t};for(var i=0;i<zr.length&&t!==0&&t<zr[i].priority;i++);zr.splice(i,0,e),i===0&&Vv(e)}};var Qv=a.version;if(Qv!=="19.2.7")throw Error(l(527,Qv,"19.2.7"));Z.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(l(188)):(e=Object.keys(e).join(","),Error(l(268,e)));return e=g(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var NS={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:O,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Cd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Cd.isDisabled&&Cd.supportsFiber)try{pt=Cd.inject(NS),it=Cd}catch{}}return Bc.createRoot=function(e,t){if(!c(e))throw Error(l(299));var i=!1,o="",f=ag,h=sg,S=ig;return t!=null&&(t.unstable_strictMode===!0&&(i=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(f=t.onUncaughtError),t.onCaughtError!==void 0&&(h=t.onCaughtError),t.onRecoverableError!==void 0&&(S=t.onRecoverableError)),t=Bv(e,1,!1,null,null,i,o,null,f,h,S,Kv),e[He]=t.current,wm(e),new Fm(t)},Bc.hydrateRoot=function(e,t,i){if(!c(e))throw Error(l(299));var o=!1,f="",h=ag,S=sg,M=ig,H=null;return i!=null&&(i.unstable_strictMode===!0&&(o=!0),i.identifierPrefix!==void 0&&(f=i.identifierPrefix),i.onUncaughtError!==void 0&&(h=i.onUncaughtError),i.onCaughtError!==void 0&&(S=i.onCaughtError),i.onRecoverableError!==void 0&&(M=i.onRecoverableError),i.formState!==void 0&&(H=i.formState)),t=Bv(e,1,!0,t,i??null,o,f,H,h,S,M,Kv),t.context=Fv(null),i=t.current,o=Qa(),o=mt(o),f=Zt(o),f.callback=null,Va(i,f,o),i=o,t.current.lanes=i,ts(t,i),oi(t),e[He]=t.current,wm(e),new jd(t)},Bc.version="19.2.7",Bc}var dx;function p0(){if(dx)return $m.exports;dx=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(),$m.exports=h0(),$m.exports}var g0=p0();const v0="https://otbyfkjxrkngvjziawki.supabase.co",x0="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",y0={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},fx=typeof window<"u"&&!!window.liveDesk,ct=c0(v0,x0,{auth:{autoRefreshToken:!0,persistSession:!fx,storage:fx?y0:void 0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}}),w0=new Set(["browserLanguage","platform","online","viewport","timezone","screen"]),b0={id:"browser-safe-v1",collect(){if(typeof navigator>"u")return{};const n={browserLanguage:navigator.language||"",platform:navigator.platform||"",online:navigator.onLine,timezone:typeof Intl>"u"?"":Intl.DateTimeFormat().resolvedOptions().timeZone||"",viewport:typeof window>"u"?void 0:{width:window.innerWidth,height:window.innerHeight},screen:typeof window>"u"?void 0:{width:window.screen.width,height:window.screen.height}};return Object.fromEntries(Object.entries(n).filter(([a,r])=>w0.has(a)&&r!==void 0))}};function S0(n,a="Support request failed."){if(n&&typeof n=="object"&&"message"in n){const r=String(n.message||"").trim();if(r)return r.replace(/^.*Support request failed:\s*/i,"")}return n instanceof Error?n.message:a}function j0(n=b0){return n.collect()}async function C0(n,a="livedesk"){const{data:r,error:l}=await ct.from("app_admins").select("role").eq("user_id",n).limit(1);if(l)throw l;const c=r?.[0]?.role||"user";if(c!=="owner"){const{error:j}=await ct.rpc("register_product_access",{p_product_key:a,p_access_type:"free"});if(j)throw j}const[d,m,p]=await Promise.all([ct.from("products").select("id, product_key, name, description, sort_order").order("sort_order"),ct.from("product_admins").select("product_id, role").eq("user_id",n),ct.from("user_products").select("product_id").eq("user_id",n).eq("is_active",!0)]);if(d.error)throw d.error;if(m.error)throw m.error;if(p.error)throw p.error;const v=d.data||[],g=(m.data||[]).map(j=>String(j.product_id)),w=(p.data||[]).map(j=>String(j.product_id)),y=c==="owner",b=y?v.map(j=>j.id):[...new Set([...g,...w])];return{products:v,access:{userId:n,globalRole:c,accessibleProductIds:b,managedProductIds:y?v.map(j=>j.id):g,canViewAllProducts:y,canViewAllPrivatePosts:y,canManageAllProducts:y,canCreateAnnouncements:y||g.length>0}}}async function k0(n=""){const{data:a,error:r}=await ct.rpc("search_support_posts",{p_query:n.trim()||null,p_limit:250});if(r)throw r;return a||[]}async function A0(n){const{data:a,error:r}=await ct.from("support_attachments").select("*").eq("post_id",n).order("created_at");if(r)throw r;const l=a||[];return Promise.all(l.map(async c=>{const d=await ct.storage.from("support-attachments").createSignedUrl(c.storage_path,3600);return{...c,signed_url:d.data?.signedUrl||void 0}}))}async function N0(){const{data:n,error:a}=await ct.from("support_notifications").select("*").order("created_at",{ascending:!1}).limit(30);if(a)throw a;return n||[]}async function M0(n){const{error:a}=await ct.rpc("mark_support_notification_read",{p_notification_id:n});if(a)throw a}async function mx(n){const{data:a,error:r}=await ct.from("support_comments").select("*").eq("post_id",n).order("created_at");if(r)throw r;return a||[]}async function T0(n){const{data:a,error:r}=await ct.from("support_votes").select("post_id").eq("user_id",n);if(r)throw r;return new Set((a||[]).map(l=>String(l.post_id)))}async function E0(n){const{data:a,error:r}=await ct.rpc("create_support_post",{p_product_id:n.productId,p_post_type:n.postType,p_title:n.title,p_body:n.body,p_visibility:n.visibility,p_app_version:n.appVersion||null,p_platform:typeof navigator>"u"?null:navigator.platform||null,p_os_version:typeof navigator>"u"?null:navigator.platform||null,p_environment:n.includeEnvironment?j0():{}});if(r)throw r;const l=Array.isArray(a)?a[0]?.post_id:a?.post_id;if(!l)throw new Error("Support post was not created.");return String(l)}const R0=new Set(["image/png","image/jpeg","image/webp","text/plain","text/markdown","application/json","application/pdf"]);async function D0(n,a){if(!R0.has(a.type))throw new Error("This file type is not allowed.");if(a.size<=0||a.size>10*1024*1024)throw new Error("Attachments must be smaller than 10 MB.");const r=a.name.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"")||"attachment",l=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,c=`${n}/${l}-${r}`,d=await ct.storage.from("support-attachments").upload(c,a,{contentType:a.type,upsert:!1});if(d.error)throw d.error;const{data:m,error:p}=await ct.rpc("add_support_attachment",{p_post_id:n,p_storage_path:c,p_file_name:r,p_mime_type:a.type,p_size_bytes:a.size});if(p)throw await ct.storage.from("support-attachments").remove([c]),p;const v=Array.isArray(m)?m[0]?.attachment_id:m?.attachment_id;if(!v)throw new Error("Attachment metadata was not created.");return String(v)}async function _0(n,a,r,l){const{error:c}=await ct.rpc("update_support_post",{p_post_id:n,p_title:a,p_body:r,p_visibility:l});if(c)throw c}async function L0(n,a){const{error:r}=await ct.rpc("add_support_comment",{p_post_id:n,p_body:a});if(r)throw r}async function z0(n){const{data:a,error:r}=await ct.rpc("toggle_support_vote",{p_post_id:n});if(r)throw r;const l=Array.isArray(a)?a[0]:a;return{voted:!!l?.voted,totalVotes:Number(l?.total_votes||0)}}async function I0(n,a){const{error:r}=await ct.rpc("change_support_post_status",{p_post_id:n,p_target_status:a});if(r)throw r}async function O0(n){const{error:a}=await ct.rpc("set_support_post_hidden",{p_post_id:n,p_hidden:!0});if(a)throw a}async function B0(n,a){const{error:r}=await ct.rpc("set_support_post_locked",{p_post_id:n,p_locked:a});if(r)throw r}async function F0(n,a){const{error:r}=await ct.rpc("set_support_post_pinned",{p_post_id:n,p_pinned:a});if(r)throw r}async function P0(n,a){const{error:r}=await ct.rpc("mark_support_duplicate",{p_post_id:n,p_duplicate_of_post_id:a});if(r)throw r}async function H0(n,a){const{error:r}=await ct.rpc("accept_support_answer",{p_post_id:n,p_comment_id:a});if(r)throw r}async function $0(n,a=!0){const{error:r}=await ct.rpc("hide_support_comment",{p_comment_id:n,p_hidden:a});if(r)throw r}const Ch=[{id:"question",label:"Questions",shortLabel:"Question"},{id:"issue",label:"Issues",shortLabel:"Issue"},{id:"feature",label:"Feature Requests",shortLabel:"Feature"},{id:"announcement",label:"Announcements",shortLabel:"Announcement"}],U0=[{id:"all",label:"All statuses"},{id:"needs-response",label:"Needs response"},{id:"open",label:"Open"},{id:"needs-info",label:"Needs more information"},{id:"in-progress",label:"In progress"},{id:"planned",label:"Planned"},{id:"released",label:"Released"},{id:"closed",label:"Closed"}],q0={question:["open","answered","resolved","closed"],issue:["open","needs-info","confirmed","in-progress","fixed","closed"],feature:["under-review","planned","in-progress","released","declined","closed"],announcement:["published","archived"]},G0={type:"all",product:"",status:"all",visibility:"all",sort:"recent",query:""};function Gm(){if(typeof window>"u")return G0;const n=new URLSearchParams(window.location.search),a=window.location.pathname.match(/^\/support\/(questions|issues|features|announcements)$/)?.[1],r=n.get("type")||a||"",l=r==="questions"||r==="question"?"question":r==="issues"||r==="issue"?"issue":r==="features"||r==="feature"?"feature":r==="announcements"||r==="announcement"?"announcement":"all",c=n.get("visibility"),d=n.get("sort");return{type:l,product:n.get("product")||"",status:n.get("status")||"all",visibility:c==="public"||c==="private"?c:"all",sort:d==="votes"||d==="newest"?d:"recent",query:n.get("q")||""}}function V0(n){return n==="all"?"":n==="question"?"questions":n==="issue"?"issues":n==="feature"?"features":"announcements"}function Y0(n,a){const r={...n,...a},l=new URLSearchParams;r.product&&l.set("product",r.product),r.status!=="all"&&l.set("status",r.status),r.visibility!=="all"&&l.set("visibility",r.visibility),r.sort!=="recent"&&l.set("sort",r.sort),r.query&&l.set("q",r.query);const c=V0(r.type),d=l.toString();return`/support${c?`/${c}`:""}${d?`?${d}`:""}`}function kd(n){const a=new Date(n);return Number.isFinite(a.getTime())?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):n}function Vm(n){return n.replaceAll("-"," ").replace(/\b\w/g,a=>a.toUpperCase())}function hx(n){return n==="question"?_S:n==="issue"?LS:n==="feature"?zS:IS}function px(n){return Ch.find(a=>a.id===n)?.shortLabel||n}function Ym(n,a){return n.find(r=>r.id===a)?.name||"Product"}function Ra(n){const a=S0(n);return/relation .* does not exist|function .* does not exist|schema cache/i.test(a)?"Support Board database is not installed yet. Apply the latest Supabase migration first.":/not-authenticated|jwt/i.test(a)?"Sign in again to use Support.":/product-access-denied|product-not-found/i.test(a)?"You do not have access to this product.":a}function Jy({session:n,currentProductKey:a="livedesk",appVersion:r="",onSignIn:l}){const[c,d]=u.useState(()=>Gm()),[m,p]=u.useState(null),[v,g]=u.useState([]),[w,y]=u.useState([]),[b,j]=u.useState(""),[C,A]=u.useState([]),[T,k]=u.useState([]),[E,R]=u.useState([]),[$,F]=u.useState(()=>new Set),[q,L]=u.useState(!0),[_,ie]=u.useState(""),[V,ne]=u.useState(""),[Q,J]=u.useState(!1),[le,Y]=u.useState(!1),[O,Z]=u.useState(""),[X,D]=u.useState(()=>Gm().query),[K,ce]=u.useState(!1),[W,P]=u.useState(!1),[me,ge]=u.useState(""),[xe,Ce]=u.useState(""),[Le,ze]=u.useState("free"),[ue,Ye]=u.useState(""),[We,oe]=u.useState(""),[Ae,je]=u.useState("admin"),[Ee,Re]=u.useState(""),[Fe,pe]=u.useState(""),[ke,de]=u.useState(""),[we,Ge]=u.useState(""),[tt,wn]=u.useState(""),[Qe,ht]=u.useState([]),[St,Tn]=u.useState({productId:"",postType:"question",title:"",body:"",visibility:"public",includeEnvironment:!0,files:[]}),Oe=u.useCallback(B=>{const $e={...c,...B};d($e),typeof window<"u"&&window.history.pushState({},"",Y0(c,B))},[c]);u.useEffect(()=>{const B=()=>d(Gm());return window.addEventListener("popstate",B),()=>window.removeEventListener("popstate",B)},[]);const Ft=u.useCallback(async()=>{const B=await k0(c.query);return y(B),n?.user.id&&F(await T0(n.user.id)),B},[c.query,n?.user.id]),Gt=u.useCallback(async()=>{if(!n?.user.id){p(null),g([]),y([]),j(""),R([]),L(!1);return}L(!0),ne("");try{const B=await C0(n.user.id,a);p(B.access),g(B.products),await Ft(),R(await N0())}catch(B){ne(Ra(B))}finally{L(!1)}},[a,Ft,n?.user.id]);u.useEffect(()=>{Gt()},[Gt]);const pt=u.useMemo(()=>m?m.canViewAllProducts?v:v.filter(B=>m.accessibleProductIds.includes(B.id)):[],[m,v]),it=u.useMemo(()=>{const B=pt.find($e=>$e.product_key===c.product);return m?.canViewAllProducts&&!c.product||c.product==="all"&&m?.canViewAllProducts?"all":B?B.product_key:pt.some($e=>$e.product_key===a)?a:pt[0]?.product_key||""},[m?.canViewAllProducts,pt,a,c.product]),nn=it==="all"?"":pt.find(B=>B.product_key===it)?.id||"",Mt=u.useMemo(()=>{const B=new Map(v.map(mt=>[mt.id,mt.product_key]));return[...w.filter(mt=>c.type!=="all"&&mt.post_type!==c.type||it!=="all"&&nn&&mt.product_id!==nn||c.status==="needs-response"&&!["open","needs-info"].includes(mt.status)||c.status!=="all"&&c.status!=="needs-response"&&mt.status!==c.status||c.visibility!=="all"&&mt.visibility!==c.visibility?!1:B.has(mt.product_id))].sort((mt,an)=>c.sort==="votes"?an.vote_count-mt.vote_count||an.updated_at.localeCompare(mt.updated_at):c.sort==="newest"?an.created_at.localeCompare(mt.created_at):Number(an.is_pinned)-Number(mt.is_pinned)||an.updated_at.localeCompare(mt.updated_at))},[w,v,c.sort,c.status,c.type,c.visibility,nn,it]),De=Mt.find(B=>B.id===b)||Mt[0]||null,En=!!(De&&m&&(m.canViewAllProducts||m.managedProductIds.includes(De.product_id))),Xi=!!(De&&n?.user.id===De.author_id)||En;u.useEffect(()=>{if(!De){j(""),A([]),Y(!1);return}De.id!==b&&j(De.id)},[De,b]),u.useEffect(()=>{let B=!0;return b?(mx(b).then($e=>{B&&A($e)}).catch($e=>{B&&ne(Ra($e))}),A0(b).then($e=>{B&&k($e)}).catch($e=>{B&&ne(Ra($e))}),()=>{B=!1}):(A([]),k([]),()=>{B=!1})},[b]),u.useEffect(()=>{!St.productId&&pt[0]&&Tn(B=>({...B,productId:nn||pt[0].id}))},[pt,St.productId,nn]),u.useEffect(()=>{D(c.query)},[c.query]),u.useEffect(()=>{!xe&&pt[0]&&Ce(pt[0].id),!We&&pt[0]&&oe(pt[0].id)},[pt,xe,We]);const fn=B=>{De&&y($e=>$e.map(mt=>mt.id===De.id?{...mt,...B}:mt))},Pn=async B=>{if(B.preventDefault(),!(!n||!St.productId)){ie("create"),ne("");try{const $e=await E0({productId:St.productId,postType:St.postType,title:St.title,body:St.body,visibility:St.postType==="announcement"?"public":St.visibility,appVersion:r,includeEnvironment:St.postType==="issue"&&St.includeEnvironment});for(const an of Qe)await D0($e,an);const mt=await Ft();J(!1),ht([]),Tn(an=>({...an,title:"",body:"",files:[]})),j($e),mt.some(an=>an.id===$e)||await Gt()}catch($e){ne(Ra($e))}finally{ie("")}}},pa=async B=>{if(B.preventDefault(),!!De){ie("edit"),ne("");try{await _0(De.id,De.title,De.body,De.visibility),Y(!1),await Ft()}catch($e){ne(Ra($e))}finally{ie("")}}},Ja=async B=>{if(B.preventDefault(),!(!De||!O.trim())){ie("comment"),ne("");try{await L0(De.id,O),Z(""),A(await mx(De.id)),await Ft()}catch($e){ne(Ra($e))}finally{ie("")}}},Rn=async()=>{if(!(!De||De.post_type!=="feature")){ie("vote"),ne("");try{const B=await z0(De.id);F($e=>{const mt=new Set($e);return B.voted?mt.add(De.id):mt.delete(De.id),mt}),fn({vote_count:B.totalVotes})}catch(B){ne(Ra(B))}finally{ie("")}}},es=async B=>{if(De){ie("status"),ne("");try{await I0(De.id,B),fn({status:B}),await Ft()}catch($e){ne(Ra($e))}finally{ie("")}}},Ie=async()=>{if(!(!De||!window.confirm("Hide this Support post from the board?"))){ie("hide"),ne("");try{await O0(De.id),j(""),await Ft()}catch(B){ne(Ra(B))}finally{ie("")}}},fi=async()=>{if(De){ie("lock"),ne("");try{await B0(De.id,!De.is_locked),fn({is_locked:!De.is_locked}),await Ft()}catch(B){ne(Ra(B))}finally{ie("")}}},ft=async()=>{if(De){ie("pin"),ne("");try{await F0(De.id,!De.is_pinned),fn({is_pinned:!De.is_pinned}),await Ft()}catch(B){ne(Ra(B))}finally{ie("")}}},ts=async B=>{if(De){ie(`accept-${B}`),ne("");try{await H0(De.id,B),fn({accepted_comment_id:B,status:De.post_type==="question"?"answered":De.status}),await Ft()}catch($e){ne(Ra($e))}finally{ie("")}}},Vt=async()=>{if(!(!De||!we||we===De.id)){ie("duplicate"),ne("");try{await P0(De.id,we),j(""),Ge(""),await Ft()}catch(B){ne(Ra(B))}finally{ie("")}}},Bs=async B=>{if(!B.read_at)try{await M0(B.id),R($e=>$e.map(mt=>mt.id===B.id?{...mt,read_at:new Date().toISOString()}:mt))}catch($e){ne(Ra($e))}B.post_id&&j(B.post_id),ce(!1)};return n?q&&!m?s.jsxs("section",{className:"support-page support-loading",children:[s.jsx(Oo,{className:"support-spin",size:23})," Loading Support Board..."]}):s.jsxs("section",{className:"support-page",children:[s.jsx("header",{className:"support-page-header support-page-actions-only",children:s.jsxs("div",{className:"support-header-actions",children:[s.jsxs("div",{className:"support-notification-wrap",children:[s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>ce(B=>!B),title:"Notifications",children:[s.jsx(ES,{size:16})," ",E.filter(B=>!B.read_at).length>0&&s.jsx("b",{children:E.filter(B=>!B.read_at).length})]}),K&&s.jsxs("div",{className:"support-notification-popover",children:[s.jsx("strong",{children:"Notifications"}),E.length===0?s.jsx("span",{className:"support-muted",children:"No notifications yet."}):E.map(B=>s.jsxs("button",{type:"button",className:B.read_at?"":"unread",onClick:()=>{Bs(B)},children:[s.jsx("b",{children:B.title}),s.jsx("span",{children:B.body}),s.jsx("small",{children:kd(B.created_at)})]},B.id))]})]}),m?.canViewAllProducts&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>P(B=>!B),children:[s.jsx(Bt,{size:16})," Admin"]}),s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{Gt()},disabled:q,children:[s.jsx(Oo,{size:16,className:q?"support-spin":""})," Refresh"]}),s.jsxs("button",{className:"support-primary-button",type:"button",onClick:()=>J(!0),disabled:pt.length===0,children:[s.jsx(Pm,{size:17})," New request"]})]})}),V&&s.jsxs("div",{className:"support-error",role:"alert",children:[s.jsx(zs,{size:17})," ",s.jsx("span",{children:V}),s.jsx("button",{type:"button",onClick:()=>ne(""),"aria-label":"Dismiss error",children:s.jsx(zs,{size:15})})]}),Q&&s.jsxs("form",{className:"support-composer",onSubmit:B=>{Pn(B)},children:[s.jsxs("div",{className:"support-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"New Support request"}),s.jsx("strong",{children:"Describe one actionable problem or idea."})]}),s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>J(!1),"aria-label":"Close composer",children:s.jsx(zs,{size:18})})]}),s.jsxs("div",{className:"support-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsx("select",{value:St.productId,onChange:B=>Tn($e=>({...$e,productId:B.target.value})),children:pt.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Type"}),s.jsx("select",{value:St.postType,onChange:B=>Tn($e=>({...$e,postType:B.target.value})),children:Ch.filter(B=>B.id!=="announcement"||m?.canCreateAnnouncements).map(B=>s.jsx("option",{value:B.id,children:B.label},B.id))})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:"Title"}),s.jsx("input",{required:!0,minLength:3,maxLength:180,value:St.title,onChange:B=>Tn($e=>({...$e,title:B.target.value})),placeholder:"A short, searchable summary"})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:St.postType==="issue"?"What happened?":St.postType==="feature"?"Describe the desired behavior":St.postType==="announcement"?"Announcement":"Question"}),s.jsx("textarea",{required:!0,value:St.body,onChange:B=>Tn($e=>({...$e,body:B.target.value})),placeholder:"Include the context another person needs to respond.",rows:6})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Visibility"}),s.jsxs("select",{value:St.visibility,disabled:St.postType==="announcement",onChange:B=>Tn($e=>({...$e,visibility:B.target.value})),children:[s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]})]}),St.postType==="issue"&&s.jsxs("label",{className:"support-checkbox",children:[s.jsx("input",{type:"checkbox",checked:St.includeEnvironment,onChange:B=>Tn($e=>({...$e,includeEnvironment:B.target.checked}))}),s.jsx("span",{children:"Attach safe browser/runtime details"})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:"Attachments"}),s.jsx("input",{type:"file",multiple:!0,accept:"image/png,image/jpeg,image/webp,text/plain,text/markdown,application/json,application/pdf",onChange:B=>ht(Array.from(B.target.files||[]).slice(0,5))}),s.jsx("small",{className:"support-muted",children:"Up to 5 files, 10 MB each. Images, text, JSON, Markdown, and PDF."})]})]}),s.jsxs("div",{className:"support-composer-footer",children:[s.jsx("span",{children:Qe.length>0?`${Qe.length} attachment${Qe.length===1?"":"s"} selected.`:"Private posts are visible only to you and the product support staff."}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:_==="create",children:[s.jsx(Bo,{size:16})," ",_==="create"?"Submitting...":"Submit request"]})]})]}),s.jsxs("div",{className:"support-tabs",role:"tablist","aria-label":"Support post type",children:[s.jsx("button",{className:c.type==="all"?"active":"",type:"button",onClick:()=>Oe({type:"all"}),children:"All"}),Ch.map(B=>{const $e=hx(B.id);return s.jsxs("button",{className:c.type===B.id?"active":"",type:"button",onClick:()=>Oe({type:B.id}),children:[s.jsx($e,{size:15})," ",B.label]},B.id)})]}),W&&m?.canViewAllProducts&&s.jsxs("section",{className:"support-admin-panel",children:[s.jsxs("div",{className:"support-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Owner controls"}),s.jsx("strong",{children:"Products and access are managed by immutable user IDs behind these email lookup forms."})]}),s.jsx(Bt,{size:19})]}),s.jsxs("div",{className:"support-admin-grid",children:[s.jsxs("form",{onSubmit:B=>{},children:[s.jsx("strong",{children:"Grant product access"}),s.jsx("input",{type:"email",required:!0,placeholder:"User email",value:me,onChange:B=>ge(B.target.value)}),s.jsx("select",{value:xe,onChange:B=>Ce(B.target.value),children:pt.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))}),s.jsxs("select",{value:Le,onChange:B=>ze(B.target.value),children:[s.jsx("option",{value:"free",children:"Free"}),s.jsx("option",{value:"user",children:"User"}),s.jsx("option",{value:"paid",children:"Paid"}),s.jsx("option",{value:"beta",children:"Beta"}),s.jsx("option",{value:"staff",children:"Staff"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:tt==="access",children:[s.jsx(Hr,{size:15})," Grant access"]})]}),s.jsxs("form",{onSubmit:B=>{},children:[s.jsx("strong",{children:"Assign product admin"}),s.jsx("input",{type:"email",required:!0,placeholder:"Admin email",value:ue,onChange:B=>Ye(B.target.value)}),s.jsx("select",{value:We,onChange:B=>oe(B.target.value),children:pt.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))}),s.jsxs("select",{value:Ae,onChange:B=>je(B.target.value),children:[s.jsx("option",{value:"admin",children:"Admin"}),s.jsx("option",{value:"support",children:"Support"}),s.jsx("option",{value:"moderator",children:"Moderator"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:tt==="product-admin",children:[s.jsx(Bt,{size:15})," Assign admin"]})]}),s.jsxs("form",{onSubmit:B=>{},children:[s.jsx("strong",{children:"Add a product"}),s.jsx("input",{required:!0,pattern:"[a-z0-9][a-z0-9_-]{1,48}",placeholder:"product-key",value:Ee,onChange:B=>Re(B.target.value)}),s.jsx("input",{required:!0,placeholder:"Product name",value:Fe,onChange:B=>pe(B.target.value)}),s.jsx("input",{placeholder:"Description",value:ke,onChange:B=>de(B.target.value)}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:tt==="product",children:[s.jsx(Pm,{size:15})," Add product"]})]})]})]}),s.jsxs("form",{className:"support-search-bar",onSubmit:B=>{B.preventDefault(),Oe({query:X.trim()})},children:[s.jsxs("label",{children:[s.jsx("span",{children:"Search Support"}),s.jsx("input",{value:X,onChange:B=>D(B.target.value),placeholder:"Search titles and request details"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",children:[s.jsx(Xv,{size:15})," Search"]}),c.query&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{D(""),Oe({query:""})},"aria-label":"Clear search",children:s.jsx(zs,{size:16})})]}),s.jsxs("div",{className:"support-filter-bar",children:[s.jsxs("div",{className:"support-filter-title",children:[s.jsx(Xv,{size:16}),s.jsx("span",{children:"Filter"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsxs("select",{value:it,onChange:B=>Oe({product:B.target.value}),disabled:!m?.canViewAllProducts&&pt.length<=1,children:[s.jsx("option",{value:"all",children:"All products"}),pt.map(B=>s.jsx("option",{value:B.product_key,children:B.name},B.id))]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Status"}),s.jsx("select",{value:c.status,onChange:B=>Oe({status:B.target.value}),children:U0.map(B=>s.jsx("option",{value:B.id,children:B.label},B.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Visibility"}),s.jsxs("select",{value:c.visibility,onChange:B=>Oe({visibility:B.target.value}),children:[s.jsx("option",{value:"all",children:"All visibility"}),s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Sort"}),s.jsxs("select",{value:c.sort,onChange:B=>Oe({sort:B.target.value}),children:[s.jsx("option",{value:"recent",children:"Recently updated"}),s.jsx("option",{value:"newest",children:"Newest"}),s.jsx("option",{value:"votes",children:"Most votes"})]})]})]}),m?.canViewAllProducts&&s.jsxs("div",{className:"support-admin-shortcuts",children:[s.jsxs("span",{children:[s.jsx(Bt,{size:15})," Owner view"]}),s.jsx("button",{type:"button",onClick:()=>Oe({status:"needs-response"}),children:"Needs response"}),s.jsx("button",{type:"button",onClick:()=>Oe({visibility:"private"}),children:"Private requests"}),s.jsx("button",{type:"button",onClick:()=>Oe({type:"feature",status:"all",sort:"votes"}),children:"High-vote features"})]}),s.jsxs("div",{className:"support-board-layout",children:[s.jsxs("section",{className:"support-post-list","aria-label":"Support posts",children:[s.jsxs("div",{className:"support-list-heading",children:[s.jsxs("span",{children:[Mt.length," request",Mt.length===1?"":"s"]}),s.jsx("small",{children:it==="all"?"All products":Ym(pt,nn)})]}),Mt.length===0?s.jsxs("div",{className:"support-list-empty",children:[s.jsx(Wc,{size:25}),s.jsx("strong",{children:"No posts match these filters."}),s.jsx("span",{children:"Start with a focused question, issue report, or feature request."}),pt.length>0&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>J(!0),children:[s.jsx(Pm,{size:16})," Create the first request"]})]}):Mt.map(B=>{const $e=hx(B.post_type);return s.jsxs("button",{type:"button",className:`support-post-row ${B.id===De?.id?"active":""}`,onClick:()=>{j(B.id),Y(!1)},children:[s.jsx("span",{className:"support-post-row-icon",children:s.jsx($e,{size:17})}),s.jsxs("span",{className:"support-post-row-copy",children:[s.jsxs("span",{className:"support-post-row-meta",children:[s.jsx("b",{children:Ym(v,B.product_id)}),s.jsx("em",{children:px(B.post_type)}),B.visibility==="private"&&s.jsx(Ls,{size:13})]}),s.jsx("strong",{children:B.title}),s.jsxs("small",{children:[Vm(B.status)," · ",kd(B.updated_at)," · ",B.comment_count," comments"]})]}),B.post_type==="feature"&&s.jsxs("span",{className:"support-vote-count",children:[s.jsx(Py,{size:14})," ",B.vote_count]})]},B.id)})]}),s.jsx("section",{className:"support-post-detail","aria-label":"Support post detail",children:De?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"support-detail-head",children:[s.jsxs("div",{className:"support-detail-badges",children:[s.jsx("span",{className:"support-product-badge",children:Ym(v,De.product_id)}),s.jsx("span",{className:"support-type-badge",children:px(De.post_type)}),s.jsx("span",{className:`support-status-badge status-${De.status}`,children:Vm(De.status)}),De.visibility==="private"&&s.jsxs("span",{className:"support-private-badge",children:[s.jsx(Ls,{size:13})," Private"]})]}),s.jsxs("div",{className:"support-detail-actions",children:[Xi&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>Y(B=>!B),title:"Edit post",children:s.jsx(RS,{size:16})}),En&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{ft()},disabled:_==="pin",title:De.is_pinned?"Unpin post":"Pin post",children:s.jsx(Zv,{size:16})}),s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{fi()},disabled:_==="lock",title:De.is_locked?"Unlock post":"Lock post",children:s.jsx(Ls,{size:16})}),s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{Ie()},disabled:_==="hide",title:"Hide post",children:s.jsx(Jv,{size:16})})]})]})]}),le?s.jsxs("form",{className:"support-edit-form",onSubmit:B=>{pa(B)},children:[s.jsx("input",{value:De.title,onChange:B=>fn({title:B.target.value}),minLength:3,maxLength:180,required:!0}),s.jsx("textarea",{value:De.body,onChange:B=>fn({body:B.target.value}),rows:9,required:!0}),s.jsxs("div",{className:"support-edit-actions",children:[s.jsxs("select",{value:De.visibility,onChange:B=>fn({visibility:B.target.value}),children:[s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:_==="edit",children:[s.jsx(Hr,{size:16})," Save changes"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:De.title}),s.jsx("div",{className:"support-detail-body",children:De.body.split(`
|
|
10
|
+
`).map((B,$e)=>s.jsx("p",{children:B||" "},`${De.id}-body-${$e}`))})]}),s.jsxs("div",{className:"support-detail-meta",children:[s.jsxs("span",{children:["Opened ",kd(De.created_at)]}),De.app_version&&s.jsxs("span",{children:["Version ",De.app_version]}),De.platform&&s.jsx("span",{children:De.platform}),De.is_locked&&s.jsxs("span",{children:[s.jsx(Ls,{size:13})," Locked"]}),De.is_pinned&&s.jsxs("span",{children:[s.jsx(Zv,{size:13})," Pinned"]})]}),s.jsxs("div",{className:"support-detail-controls",children:[De.post_type==="feature"&&s.jsxs("button",{className:`support-vote-button ${$.has(De.id)?"voted":""}`,type:"button",onClick:()=>{Rn()},disabled:_==="vote",children:[s.jsx(DS,{size:16})," ",$.has(De.id)?"Voted":"Vote"," ",s.jsx("b",{children:De.vote_count})]}),En&&s.jsxs("label",{className:"support-status-control",children:[s.jsx("span",{children:"Change status"}),s.jsx("select",{value:De.status,onChange:B=>{es(B.target.value)},disabled:_==="status",children:(q0[De.post_type]||[]).map(B=>s.jsx("option",{value:B,children:Vm(B)},B))})]}),En&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"support-status-control",value:we,onChange:B=>Ge(B.target.value),children:[s.jsx("option",{value:"",children:"Duplicate of..."}),Mt.filter(B=>B.id!==De.id&&B.product_id===De.product_id).map(B=>s.jsx("option",{value:B.id,children:B.title.slice(0,55)},B.id))]}),s.jsx("button",{className:"support-secondary-button",type:"button",onClick:()=>{Vt()},disabled:!we||_==="duplicate",children:"Merge duplicate"})]})]}),T.length>0&&s.jsxs("div",{className:"support-attachments",children:[s.jsx("div",{className:"support-section-heading",children:s.jsxs("div",{children:[s.jsx("span",{children:"Attachments"}),s.jsxs("strong",{children:[T.length," file",T.length===1?"":"s"]})]})}),T.map(B=>s.jsxs("a",{href:B.signed_url,target:"_blank",rel:"noreferrer",children:[s.jsx(Yh,{size:14})," ",B.file_name,s.jsxs("small",{children:[Math.ceil(B.size_bytes/1024)," KB"]})]},B.id))]}),s.jsxs("div",{className:"support-comments",children:[s.jsxs("div",{className:"support-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Discussion"}),s.jsxs("strong",{children:[C.length," comment",C.length===1?"":"s"]})]}),De.is_locked&&s.jsxs("span",{className:"support-locked-label",children:[s.jsx(Ls,{size:14})," Locked"]})]}),C.length===0?s.jsx("p",{className:"support-muted",children:"No response yet. Keep the conversation focused on this request."}):s.jsx("div",{className:"support-comment-list",children:C.map(B=>s.jsxs("article",{className:`support-comment ${B.is_staff_answer?"staff":""} ${De.accepted_comment_id===B.id?"accepted":""}`,children:[s.jsxs("div",{className:"support-comment-head",children:[s.jsx("strong",{children:B.is_staff_answer?"LiveDesk Support":B.author_id===n.user.id?"You":"Support user"}),B.is_staff_answer&&s.jsxs("span",{children:[s.jsx(Bt,{size:13})," Staff answer"]}),De.accepted_comment_id===B.id&&s.jsxs("span",{children:[s.jsx(In,{size:13})," Accepted"]}),s.jsx("time",{children:kd(B.created_at)})]}),s.jsx("p",{children:B.body}),s.jsxs("div",{className:"support-comment-actions",children:[(n.user.id===De.author_id||En)&&De.post_type==="question"&&De.accepted_comment_id!==B.id&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{ts(B.id)},disabled:_===`accept-${B.id}`,children:[s.jsx(Hr,{size:14})," Accept answer"]}),En&&s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{$0(B.id)},title:"Hide comment",children:s.jsx(Jv,{size:14})})]})]},B.id))}),!De.is_locked&&s.jsxs("form",{className:"support-comment-form",onSubmit:B=>{Ja(B)},children:[s.jsx("textarea",{value:O,onChange:B=>Z(B.target.value),placeholder:"Add a focused reply...",rows:3}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:_==="comment"||!O.trim(),children:[s.jsx(Bo,{size:15})," Reply"]})]})]})]}):s.jsxs("div",{className:"support-detail-empty",children:[s.jsx(Wc,{size:28}),s.jsx("strong",{children:"Select a Support request"}),s.jsx("span",{children:"Its discussion and staff actions will appear here."})]})})]})]}):s.jsx("section",{className:"support-page support-auth-page",children:s.jsxs("div",{className:"support-empty-hero",children:[s.jsx("span",{className:"support-hero-icon",children:s.jsx(Wc,{size:28})}),s.jsx("p",{className:"support-eyebrow",children:"LiveDesk Support"}),s.jsx("h2",{children:"Get help, report issues, and shape the product."}),s.jsx("p",{children:"Sign in to see the products attached to your account and submit a private or public request."}),s.jsxs("button",{className:"support-primary-button",type:"button",onClick:l,children:[s.jsx(Bt,{size:17})," Sign in with Google"]})]})})}function Ad(n){return!!n&&typeof n=="object"}function ew(n){let a=n;return Ad(a)&&"data"in a&&(a=a.data),Ad(a)&&"session"in a&&(a=a.session),!Ad(a)||typeof a.access_token!="string"||!a.access_token||!Ad(a.user)||typeof a.user.id!="string"||!a.user.id?null:a}function gx(n){return n?.access_token?n.refresh_token?"":"refresh-token-required":"access-token-required"}const Qc=5179,yn=Gr(`http://127.0.0.1:${Qc}`);function W0(n){const a=n.split(".").map(r=>Number(r));return a.length===4&&a.every(r=>Number.isInteger(r)&&r>=0&&r<=255)?a:[]}function K0(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function Q0(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function X0(n){const a=W0(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 Z0(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function J0(n){const a=String(n||"").trim();if(!a)return null;const r=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`tcp://${a}`;try{const l=new URL(r),c=l.hostname.replace(/^\[|\]$/g,""),d=Number(l.port);return!c||!Number.isInteger(d)||d<1||d>65535||Q0(c)?null:{host:c,port:d}}catch{return null}}function Gr(n){const a=String(n||"").trim()||`http://127.0.0.1:${Qc}`,r=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const l=new URL(r);return l.port||(l.port=String(Qc)),l.hash="",l.search="",l.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${Qc}`}}function ej(n){const a=J0(n);return a?Gr(`http://${Z0(a.host)}:${Qc}`):""}function vx(n){const r=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(l=>ej(String(l||""))).filter(Boolean);return[...new Set(r)]}function Xc(n=yn){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(K0(a.hostname))return"loopback";if(X0(a.hostname))return"local"}catch{return}}function pf(n,a=yn){const r=new URL(n,Gr(a));return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}async function Ue(n,a,r=yn){const l=Gr(r),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=Xc(l);d&&(c.targetAddressSpace=d);let m;try{m=await fetch(`${l}${n}`,c)}catch(v){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."):v}let p=null;try{p=await m.json()}catch{p=null}if(!m.ok){const v=p&&typeof p=="object"&&"error"in p?String(p.error||""):"";throw new Error(`${m.status} ${v||m.statusText}`)}return p}async function tw({baseUrl:n=yn,targetRole:a,previousRuntimePid:r=0,allowedStates:l=["running","waiting-auth"],timeoutMs:c=3e4}){const d=Date.now()+c;let m=null;for(;Date.now()<d;){try{const v=await Ue("/api/runtime/status",void 0,n),g=String(v.role||"").toLowerCase(),w=String(v.state||"").toLowerCase(),y=Number(v.runtimePid||0),b=r>1?y>1&&y!==r:y>1;if(g===a&&l.map(j=>j.toLowerCase()).includes(w)&&b)return v}catch(v){m=v}await new Promise(v=>setTimeout(v,300))}const p=m instanceof Error?` ${m.message}`:"";throw new Error(`LiveDesk runtime did not become ${a} with a new process.${p}`)}function tj(n,a=120){if(typeof window>"u")return;const r=new URL(window.location.href);r.port=String(n),r.pathname="/",r.search="",r.hash="";const l=r.toString();let c=0;const d=()=>{fetch(l,{cache:"no-store",mode:"no-cors"}).then(()=>window.location.replace(l)).catch(()=>{if(c+=1,c>=a){window.location.replace(l);return}window.setTimeout(d,250)})};d()}function kh(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 Tl(n){await navigator.clipboard.writeText(n)}function nw({size:n=22}){return s.jsxs("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[s.jsx("rect",{x:"2.5",y:"4",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.42"}),s.jsx("path",{d:"M7 16v1.5h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.42"}),s.jsx("rect",{x:"10.5",y:"2.5",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.62"}),s.jsx("path",{d:"M15 14.5V16h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.62"}),s.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"}),s.jsx("path",{d:"M12 21v1.5H9.5M16 21v1.5h2.5M9.5 22.5h9",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})]})}const nj=[{id:"docs",label:"Doc",icon:tf},{id:"support",label:"Support",icon:Wc},{id:"pricing",label:"Pricing",icon:Eo},{id:"settings",label:"Settings",icon:Hy}],xx=[0,1e3,2e3,5e3,1e4,2e4,3e4];function aj(){return typeof window>"u"?"":window.location.port==="5179"?window.location.origin:"http://127.0.0.1:5179"}async function Fc(n,a=!1){const r=a?"":sessionStorage.getItem("livedesk.client.csrf");if(r)return r;const l=await fetch(`${n}/api/runtime/status`,{cache:"no-store"}),c=await l.json().catch(()=>({}));if(!l.ok)throw new Error(c.error||`Client runtime returned HTTP ${l.status}.`);const d=String(c.csrfToken||"");return d&&sessionStorage.setItem("livedesk.client.csrf",d),d}function Ah(n){return`${Math.max(0,Math.min(100,Number(n||0))).toFixed(0)}%`}function Wm(n){return Number.isFinite(n)?`${Math.max(0,Math.min(100,Number(n))).toFixed(0)}%`:"—"}function aw(n){return Number.isFinite(n)?Ah(Number(n)):"0%"}function Dl(n){const a=Number(n);return!Number.isFinite(a)||a<0?"—":a>=1024**4?`${(a/1024**4).toFixed(a>=10*1024**4?0:1)} TB`:a>=1024**3?`${(a/1024**3).toFixed(a>=10*1024**3?0:1)} GB`:`${(a/1024**2).toFixed(0)} MB`}function yx(n){const a=Math.max(0,Number(n||0));return a>=1024**3?`${(a/1024**3).toFixed(1)} GB/s`:a>=1024**2?`${(a/1024**2).toFixed(1)} MB/s`:a>=1024?`${(a/1024).toFixed(1)} KB/s`:`${a.toFixed(0)} B/s`}function sj(n,a){const r=Number(n||0)/1073741824,l=Number(a||0)/1024**3;return l>0?`${r.toFixed(1)} / ${l.toFixed(1)} GB`:"Checking..."}function ij(n,a){return!Number.isFinite(a)||Number(a)<=0?"Dedicated memory unavailable":Number.isFinite(n)?`${Dl(n)} / ${Dl(a)}`:`${Dl(a)} available`}function rj(n){const a=Math.max(0,Math.floor(Number(n||0)/60)),r=Math.floor(a/1440),l=Math.floor(a%1440/60),c=a%60;return r>0?`${r}d ${l}h`:l>0?`${l}h ${c}m`:`${c}m`}function Nd({icon:n,label:a,value:r,detail:l,percent:c}){return s.jsxs("article",{className:"client-resource-metric",children:[s.jsxs("div",{className:"client-resource-metric-head",children:[s.jsx(n,{size:17}),s.jsx("span",{children:a}),s.jsx("strong",{children:r})]}),s.jsx("small",{title:l,children:l}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:aw(c)}})})]})}function lj(n){const a=n?.user.user_metadata||{},r=a.full_name||a.name||a.preferred_username||n?.user.email||n?.user.id||"Account";return String(r).trim()||"Account"}function oj(n){const a=n?.user.user_metadata||{},r=a.avatar_url||a.picture;return typeof r=="string"?r.trim():""}function cj({page:n,status:a}){const l={docs:{label:"DOC",title:"Using this computer",body:"This computer connects to its assigned Sync Server automatically. Keep LiveDesk running and manage screens, files, and remote control from the Hub."},pricing:{label:"PRICING",title:"LiveDesk plans",body:"Plans are based on how many computers the Hub manages. This Client computer does not need a separate subscription or setup."},settings:{label:"SETTINGS",title:"Computer preferences",body:"LiveDesk keeps the verified sign-in on this computer and reconnects to the assigned Hub automatically."}}[n];return s.jsxs("section",{className:"client-service-page",children:[s.jsx("span",{className:"client-unified-section-label",children:l.label}),s.jsx("h2",{children:l.title}),s.jsx("p",{children:l.body}),s.jsxs("div",{className:"client-service-page-card",children:[n==="docs"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Automatic connection"}),s.jsx("span",{children:"Start LiveDesk. This computer signs in, finds the Hub, and becomes available without another action."})]}),n==="pricing"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"One plan, managed at the Hub"}),s.jsx("span",{children:"Computer access follows the account and plan used by the Sync Server."})]}),n==="settings"&&s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:"Saved sign-in"}),s.jsx("span",{children:a?.auth?.persisted?"Enabled on this computer":"Sign in once to enable automatic reconnection"})]})]})]})}function uj({session:n,status:a,pin:r,error:l,roleChangeMessage:c,roleChangeBusy:d,onSignIn:m,onPinChange:p,onSubmitPin:v,onSwitchToHub:g}){const w=a?.connectionState==="connected",y=a?.system?.memoryTotalBytes?Number(a.system.memoryUsedBytes||0)/a.system.memoryTotalBytes*100:0,b=a?.system?.gpus||[],j=b.find(F=>Number.isFinite(F.usagePercent)||Number.isFinite(F.memoryTotalBytes))||b[0],C=Number.isFinite(j?.usagePercent)?Number(j?.usagePercent):null,A=Number.isFinite(j?.memoryTotalBytes)&&Number(j?.memoryTotalBytes)>0&&Number.isFinite(j?.memoryUsedBytes)?Number(j?.memoryUsedBytes)/Number(j?.memoryTotalBytes)*100:null,T=a?.system?.disks||[],k=a?.system?.network,E=k?.interfaces||[],R=[...new Set(E.map(F=>F.name).filter(Boolean))],$=E.map(F=>F.address).filter(Boolean);return s.jsxs("section",{className:"client-home-page",children:[s.jsxs("header",{className:"client-home-heading",children:[s.jsxs("div",{children:[s.jsx("p",{className:"client-unified-eyebrow",children:"THIS COMPUTER"}),s.jsx("h2",{children:a?.deviceName||"This Computer"})]}),s.jsxs("span",{className:`client-unified-role-chip ${w?"connected":""}`,children:[s.jsx(tn,{size:15})," ",w?"Online":"Connecting"]})]}),s.jsxs("div",{className:"client-home-layout",children:[s.jsxs("section",{className:"client-main-surface","aria-label":"Client computer",children:[s.jsxs("div",{className:"client-main-surface-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"SYSTEM STATUS"}),s.jsx("strong",{children:"Hardware at a glance"})]}),s.jsxs("small",{children:[s.jsx(Uy,{size:14})," Uptime ",rj(a?.system?.uptimeSeconds)]})]}),s.jsxs("div",{className:"client-system-dashboard",children:[s.jsxs("section",{className:"client-performance-panel","aria-label":"Performance",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"PERFORMANCE"}),s.jsx("strong",{children:"Live resources"})]}),s.jsx("small",{children:"Live updates"})]}),s.jsxs("div",{className:"client-live-metrics",children:[s.jsx(Nd,{icon:qy,label:"CPU",value:Ah(a?.system?.cpuUsagePercent),detail:"Current processor usage",percent:a?.system?.cpuUsagePercent}),s.jsx(Nd,{icon:OS,label:"Memory",value:Ah(y),detail:sj(a?.system?.memoryUsedBytes,a?.system?.memoryTotalBytes),percent:y}),s.jsx(Nd,{icon:BS,label:"GPU",value:Wm(C),detail:j?.name||(a?.system?.hardwareCollecting?"Detecting graphics hardware…":"Graphics usage unavailable"),percent:C}),s.jsx(Nd,{icon:nf,label:"VRAM",value:Wm(A),detail:ij(j?.memoryUsedBytes,j?.memoryTotalBytes),percent:A})]})]}),s.jsxs("section",{className:"client-storage-panel","aria-label":"Local storage",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"STORAGE"}),s.jsx("strong",{children:"Local drives"})]}),s.jsx("small",{children:T.length>0?`${T.length} ${T.length===1?"drive":"drives"}`:a?.system?.hardwareCollecting?"Detecting…":"Unavailable"})]}),s.jsxs("div",{className:"client-disk-list",children:[T.map(F=>s.jsxs("article",{className:"client-disk-row",children:[s.jsxs("div",{className:"client-disk-row-head",children:[s.jsxs("span",{children:[s.jsx(Rl,{size:16}),s.jsx("strong",{children:F.mount||"Disk"}),s.jsx("small",{children:F.name||"Local disk"})]}),s.jsx("strong",{children:Wm(F.usedPercent)})]}),s.jsxs("small",{children:[Dl(F.freeBytes)," free · ",Dl(F.totalBytes)," total"]}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:aw(F.usedPercent)}})})]},`${F.mount}-${F.name||""}`)),T.length===0&&s.jsxs("div",{className:"client-disk-empty",children:[s.jsx(Rl,{size:18}),s.jsx("span",{children:a?.system?.hardwareCollecting?"Detecting local drives…":"Storage information is not available."})]})]})]}),s.jsxs("section",{className:"client-network-panel","aria-label":"Network activity",children:[s.jsxs("div",{className:"client-system-subhead",children:[s.jsxs("div",{children:[s.jsx("span",{className:"client-unified-section-label",children:"NETWORK"}),s.jsx("strong",{children:"Live traffic"})]}),s.jsx("small",{children:R.length>0?R.join(", "):"Detecting adapter"})]}),s.jsxs("div",{className:"client-network-live",children:[s.jsxs("div",{className:"client-network-adapter",children:[s.jsx(Ro,{size:18}),s.jsxs("span",{children:[s.jsx("strong",{children:R.join(", ")||"Network"}),s.jsx("small",{children:$.join(" / ")||"Checking active connection"})]})]}),s.jsxs("div",{className:"client-network-rate download",children:[s.jsx(FS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Receive"}),s.jsx("strong",{children:yx(k?.receiveBytesPerSecond)})]})]}),s.jsxs("div",{className:"client-network-rate upload",children:[s.jsx(PS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Send"}),s.jsx("strong",{children:yx(k?.sendBytesPerSecond)})]})]}),s.jsxs("small",{className:"client-network-total",children:["Total ",Dl(k?.receivedBytes)," received / ",Dl(k?.sentBytes)," sent"]})]})]})]})]}),s.jsxs("aside",{className:"client-connection-panel",children:[s.jsx("span",{className:"client-unified-section-label",children:"LIVEDESK SERVICES"}),s.jsx("h3",{children:w?"Connected to the Hub":a?.authenticated?"Finding the Hub":"Connect this computer"}),w?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"client-unified-copy",children:"This computer is available from the LiveDesk Hub."}),s.jsxs("div",{className:"client-service-status-list",children:[s.jsxs("div",{children:[s.jsx(tn,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Screen sharing"}),s.jsx("small",{children:a?.permissions?.screenCapture?"Active":"Waiting"})]})]}),s.jsxs("div",{children:[s.jsx(Bt,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Remote control"}),s.jsx("small",{children:a?.permissions?.remoteInput?"Available":"Unavailable"})]})]}),s.jsxs("div",{children:[s.jsx(Do,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"File delivery"}),s.jsx("small",{children:a?.permissions?.files?"Ready to receive":"Unavailable"})]})]}),s.jsxs("div",{children:[s.jsx(ln,{size:17}),s.jsxs("span",{children:[s.jsx("strong",{children:"Computer audio"}),s.jsx("small",{children:a?.permissions?.audio?"Available":"Unavailable"})]})]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"client-unified-copy",children:a?.authenticated?"LiveDesk is checking the registered Hub endpoints. A temporary Hub PIN can be used as a fallback.":"Sign in once on this computer. LiveDesk saves the verified session, finds the Hub, and starts screen sharing automatically."}),!n&&!a?.authenticated?s.jsxs("button",{className:"client-unified-primary",type:"button",onClick:m,children:[s.jsx(_l,{size:16})," Sign in with Google"]}):s.jsxs("p",{className:"client-unified-success",children:[s.jsx(In,{size:16})," Signed in as ",n?.user.email||n?.user.id||a?.userEmail||a?.userId||"saved account"]}),s.jsxs("div",{className:"client-unified-pin-row",children:[s.jsx(_o,{size:16}),s.jsx("input",{value:r,onChange:F=>p(F.target.value),placeholder:"6-digit Hub PIN",inputMode:"numeric","aria-label":"6-digit Hub PIN"}),s.jsx("button",{className:"client-unified-secondary",type:"button",onClick:v,disabled:r.length!==6,children:"Connect"})]})]}),(l||a?.lastError)&&s.jsxs("p",{className:"client-unified-error",role:"alert",children:[s.jsx(Gy,{size:15})," ",l||a?.lastError]}),c&&s.jsx("p",{className:"client-unified-success",children:c}),s.jsxs("button",{className:"client-unified-secondary full",type:"button",onClick:g,disabled:d||!a?.authenticated,children:[s.jsx(nf,{size:16})," ",d?"Switching to Hub…":"Become Sync Server (Hub)"]})]})]})]})}function dj(){const[n,a]=u.useState(null),[r,l]=u.useState(null),[c,d]=u.useState(!1),[m,p]=u.useState(""),[v,g]=u.useState(""),[w,y]=u.useState(""),[b,j]=u.useState(!1),[C,A]=u.useState("computer"),[T,k]=u.useState(!1),E=u.useRef(!1),R=u.useRef(!1),$=u.useRef(!1),F=u.useRef(0),q=u.useMemo(aj,[]),L=u.useMemo(()=>lj(r),[r]),_=u.useMemo(()=>oj(r),[r]),ie=L.slice(0,1).toUpperCase()||"L",V=u.useCallback(async()=>{if(g(""),window.liveDesk?.auth?.signInWithGoogle){const D=await window.liveDesk.auth.signInWithGoogle();return D?.ok===!1?(g(D.error||"LiveDesk could not open the system browser for Google sign-in."),!1):!0}return window.location.assign(`${q}/auth/google`),!0},[q]),ne=u.useCallback(async()=>{$.current||($.current=!0,g("Your saved Google sign-in is incomplete. LiveDesk is reopening sign-in once to repair it."),await ct.auth.signOut({scope:"local"}).catch(()=>{}),l(null),await V()||($.current=!1))},[V]),Q=u.useCallback(async D=>{const K=gx(D);if(K)throw new Error(K);if(E.current)return!1;E.current=!0;try{const ce=await window.liveDesk?.auth?.persistSession?.(D);if(ce?.ok===!1)throw new Error(ce.error||"LiveDesk could not validate the desktop session.");for(let W=0;W<2;W+=1){const P=await Fc(q,W>0),me=await fetch(`${q}/api/auth/session`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":P},signal:AbortSignal.timeout(1e4),body:JSON.stringify({accessToken:D.access_token,refreshToken:D.refresh_token,expiresAt:D.expires_at,user:{id:D.user.id,email:D.user.email}})}),ge=await me.json().catch(()=>({}));if(me.status===403&&W===0){sessionStorage.removeItem("livedesk.client.csrf");continue}if(!me.ok)throw new Error(ge.error||`Client runtime returned HTTP ${me.status}.`);return g(""),!0}throw new Error("Client runtime rejected the session transfer.")}finally{E.current=!1}},[q]),J=u.useCallback(async()=>{try{const D=await fetch(`${q}/api/client/status`,{cache:"no-store"}),K=await D.json().catch(()=>({}));if(!D.ok)throw new Error(K.error||`Client runtime returned HTTP ${D.status}.`);if(K.csrfToken&&sessionStorage.setItem("livedesk.client.csrf",K.csrfToken),String(K.role||"").toLowerCase()==="hub")throw new Error("This computer is assigned to the Hub role.");a(K)}catch(D){g(D instanceof Error?D.message:String(D))}},[q]);u.useEffect(()=>{J();const D=window.setInterval(()=>{J()},2e3);return()=>window.clearInterval(D)},[J]);const le=u.useCallback(async()=>{const D=Date.now();if(!(!n?.authenticated||n.connectionState==="connected"||!["waiting","reconnecting"].includes(String(n.agent?.state||""))||D-F.current<4e3)){F.current=D;try{const K=await fetch(`${q}/api/client/reconnect`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({onlyIfWaiting:!0,reason:"app-active"})});if(!K.ok)throw new Error(`Client reconnect returned HTTP ${K.status}.`);await J()}catch(K){g(K instanceof Error?K.message:String(K))}}},[q,J,n]);u.useEffect(()=>{const D=()=>{le()},K=()=>{le()},ce=()=>{document.visibilityState==="visible"&&le()};return window.addEventListener("online",D),window.addEventListener("focus",K),document.addEventListener("visibilitychange",ce),()=>{window.removeEventListener("online",D),window.removeEventListener("focus",K),document.removeEventListener("visibilitychange",ce)}},[le]),u.useEffect(()=>{if(!c||!n||!r?.access_token||n.authenticated)return;if(gx(r)==="refresh-token-required"){ne().catch(P=>{$.current=!1,g(P instanceof Error?P.message:String(P))});return}let D=!1,K,ce=0;const W=async()=>{if(D)return;try{const me=await Q(r);if(await J(),me)return}catch(me){g(me instanceof Error?me.message:String(me))}if(D)return;const P=xx[Math.min(ce,xx.length-1)];ce+=1,K=window.setTimeout(()=>{W()},P)};return W(),()=>{D=!0,K!==void 0&&window.clearTimeout(K)}},[c,J,ne,r,n,Q]),u.useEffect(()=>{const D=new URLSearchParams(window.location.search),K=D.get("auth_error");if(!K)return;g(K),D.delete("auth_error");const ce=D.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${ce?`?${ce}`:""}${window.location.hash}`)},[]),u.useEffect(()=>{let D=!0;if(!window.liveDesk?.auth)return l(null),d(!0),J(),()=>{D=!1};const K=window.liveDesk?.auth?.onComplete?.(W=>{W.ok&&W.session?ct.auth.setSession(W.session).catch(P=>g(P instanceof Error?P.message:String(P))):W.error&&g(W.error)});(async()=>{try{const W=window.liveDesk?.auth?.getSession?await window.liveDesk.auth.getSession():await ct.auth.getSession();if(!D)return;const P=ew(W);l(P),J()}catch(W){D&&g(W instanceof Error?W.message:String(W))}finally{D&&d(!0)}})();const{data:ce}=ct.auth.onAuthStateChange((W,P)=>{D&&(l(P),d(!0),J())});return()=>{D=!1,K?.(),ce.subscription.unsubscribe()}},[J]),u.useEffect(()=>{if(!c||!n||R.current||$.current||r||n.authenticated)return;const D=new URLSearchParams(window.location.search);if(!D.has("livedesk_launch"))return;R.current=!0,D.delete("livedesk_launch");const K=D.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${K?`?${K}`:""}${window.location.hash}`),V().catch(ce=>g(ce instanceof Error?ce.message:String(ce)))},[c,r,V,n]);const Y=async()=>{k(!1),window.liveDesk?.auth?.persistSession?(await ct.auth.signOut(),(await window.liveDesk.auth.persistSession(null))?.runtimeCleared===!1&&g("Signed out locally. The LiveDesk runtime could not be reached to clear its session.")):await fetch(`${q}/api/auth/session`,{method:"DELETE",headers:{"X-LiveDesk-CSRF":await Fc(q)}}).catch(()=>{}),l(null),await J()};u.useEffect(()=>{if(!T)return;const D=ce=>{ce.target instanceof Element&&ce.target.closest(".account-popover, .rail-account")||k(!1)},K=ce=>{ce.key==="Escape"&&k(!1)};return window.addEventListener("pointerdown",D),window.addEventListener("keydown",K),()=>{window.removeEventListener("pointerdown",D),window.removeEventListener("keydown",K)}},[T]);const O=async()=>{g("");try{const D=await fetch(`${q}/api/client/pin`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({pin:m})}),K=await D.json().catch(()=>({}));if(!D.ok||K?.ok===!1)throw new Error(K?.error||"PIN could not be accepted.");p(""),await J()}catch(D){g(D instanceof Error?D.message:String(D))}},Z=async()=>{j(!0),y(""),g("");try{const D=await fetch(`${q}/api/runtime/switch-role`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await Fc(q)},body:JSON.stringify({role:"hub"})}),K=await D.json().catch(()=>({}));if(!D.ok||K?.ok===!1)throw new Error(K?.error||`Role change failed with HTTP ${D.status}.`);y("Hub role accepted. LiveDesk is restarting this computer with the Hub Wall.");const ce=Number(n?.runtimePid||0);await tw({baseUrl:q,targetRole:"hub",previousRuntimePid:ce,allowedStates:["running"]}),window.location.reload()}catch(D){g(D instanceof Error?D.message:String(D)),j(!1)}},X=!!(n?.authenticated||r);return s.jsxs("main",{className:"app-shell client-unified-shell",children:[s.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk Client tools",children:[s.jsx("div",{className:"rail-brand",title:"LiveDesk",children:s.jsx(nw,{size:25})}),s.jsx("nav",{className:"rail-tools","aria-label":"Client navigation",children:s.jsx("div",{className:"client-main-tool-slot",children:s.jsxs("button",{className:`rail-tool client-main-tool ${C==="computer"?"active":""}`,type:"button",onClick:()=>A("computer"),"aria-current":C==="computer"?"page":void 0,title:"Client",children:[s.jsx(tn,{size:19}),s.jsx("span",{children:"Client"})]})})}),s.jsxs("div",{className:"rail-footer",children:[nj.map(D=>{const K=D.icon;return s.jsxs("button",{className:`rail-tool compact ${C===D.id?"active":""}`,type:"button",onClick:()=>A(D.id),title:D.label,children:[s.jsx(K,{size:18}),s.jsx("span",{children:D.label})]},D.id)}),s.jsxs("button",{className:`rail-account ${X?"signed-in":""}`,type:"button",onClick:()=>k(D=>!D),"aria-expanded":T,"aria-haspopup":"dialog",title:X?"Account":"Sign in",children:[r&&_?s.jsx("img",{src:_,alt:L,referrerPolicy:"no-referrer"}):r?s.jsx("span",{className:"avatar-fallback",children:ie}):X?s.jsx(Bt,{size:18}):s.jsx(_l,{size:18}),s.jsx("span",{children:X?"Account":"Sign in"})]})]})]}),T&&s.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[s.jsxs("div",{className:"account-popover-head",children:[s.jsx("div",{className:"account-popover-avatar",children:r&&_?s.jsx("img",{src:_,alt:L,referrerPolicy:"no-referrer"}):r?s.jsx("span",{children:ie}):s.jsx(_l,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:r?L:X?"Saved account":"Account"}),s.jsx("p",{children:r?.user.email||n?.userEmail||n?.userId||"Not signed in"})]})]}),s.jsxs("dl",{className:"account-popover-facts",children:[s.jsx("dt",{children:"User"}),s.jsx("dd",{children:r?.user.email||n?.userEmail||n?.userId||"Not signed in"}),s.jsx("dt",{children:"Runtime"}),s.jsx("dd",{children:n?"Local app ready":"Checking local app"}),s.jsx("dt",{children:"Session"}),s.jsx("dd",{children:n?.auth?.persisted?"Saved on this computer":X?"Active for this run":"Not saved"}),s.jsx("dt",{children:"Role"}),s.jsx("dd",{children:"Client"})]}),X?s.jsxs("button",{className:"account-popover-action",onClick:()=>{Y()},type:"button",children:[s.jsx($y,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:()=>{k(!1),V()},type:"button",children:[s.jsx(_l,{size:16}),"Sign in with Google"]})]}),s.jsxs("section",{className:"desk-stage client-unified-stage",children:[s.jsx("header",{className:"topbar",children:s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(ln,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Client workspace"})]})]})}),C==="support"?s.jsx("section",{className:"client-unified-page",children:s.jsx(Jy,{session:r,currentProductKey:"livedesk",appVersion:n?.appVersion||"",onSignIn:()=>{V()}})}):C!=="computer"?s.jsx("section",{className:"client-unified-page",children:s.jsx(cj,{page:C,status:n})}):s.jsx(uj,{session:r,status:n,pin:m,error:v,roleChangeMessage:w,roleChangeBusy:b,onSignIn:()=>{V()},onPinChange:D=>p(D.replace(/\D/g,"").slice(0,6)),onSubmitPin:()=>{O()},onSwitchToHub:()=>{Z()}})]})]})}function Br(n,a,r){if(r<0||a<0||a+r>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function Km(n,a,r){let l=0;for(;Br(n,a.inputIndex,1),n[a.inputIndex]===0;)l+=1,a.inputIndex+=1;const c=l*255+r+n[a.inputIndex];return a.inputIndex+=1,c}function Md(n,a,r,l){if(Br(n,a.inputIndex,l),a.outputIndex+l>r.length)throw new Error("Invalid LZO1X block: output overrun.");r.set(n.subarray(a.inputIndex,a.inputIndex+l),a.outputIndex),a.inputIndex+=l,a.outputIndex+=l}function fj(n,a,r,l){const c=a-r;if(c<=0||l<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let d=Math.min(c,l);for(n.set(n.subarray(r,r+d),a);d<l;){const m=Math.min(d,l-d);n.copyWithin(a+d,a,a+m),d+=m}return a+l}function sw(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const r=new Uint8Array(a),l={inputIndex:0,outputIndex:0};let c=0,d=0;if(n[l.inputIndex]>=22){const m=n[l.inputIndex]-17;l.inputIndex+=1,Md(n,l,r,m),c=4}else n[l.inputIndex]>=18&&(c=n[l.inputIndex]-17,l.inputIndex+=1,Md(n,l,r,c));for(;;){Br(n,l.inputIndex,1);const m=n[l.inputIndex];l.inputIndex+=1;let p,v;if((m&192)!==0)Br(n,l.inputIndex,1),v=l.outputIndex-((n[l.inputIndex]<<3)+(m>>2&7)+1),l.inputIndex+=1,d=(m>>5)+1,p=m&3;else if((m&32)!==0){d=(m&31)+2,d===2&&(d+=Km(n,l,31)),Br(n,l.inputIndex,2);const g=n[l.inputIndex]|n[l.inputIndex+1]<<8;l.inputIndex+=2,v=l.outputIndex-((g>>2)+1),p=g&3}else if((m&16)!==0){d=(m&7)+2,d===2&&(d+=Km(n,l,7)),Br(n,l.inputIndex,2);const g=n[l.inputIndex]|n[l.inputIndex+1]<<8;if(l.inputIndex+=2,v=l.outputIndex-(((m&8)<<11)+(g>>2)),p=g&3,v===l.outputIndex)break;v-=16384}else if(c===0){let g=m+3;g===3&&(g+=Km(n,l,15)),Md(n,l,r,g),c=4;continue}else c!==4?(Br(n,l.inputIndex,1),p=m&3,v=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+1),l.inputIndex+=1,d=2):(Br(n,l.inputIndex,1),p=m&3,v=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+2049),l.inputIndex+=1,d=3);if(v<0||l.outputIndex+d+p>r.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");l.outputIndex=fj(r,l.outputIndex,v,d),c=p,Md(n,l,r,p)}if(d!==3||l.inputIndex!==n.length||l.outputIndex!==r.length)throw new Error("Invalid LZO1X block: incomplete output.");return r}const wx=16,bx=8,mj=24*1024*1024,iw=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Nh=new Uint32Array(65536);for(let n=0;n<Nh.length;n+=1){const a=Math.round((n>>11&31)*255/31),r=Math.round((n>>5&63)*255/63),l=Math.round((n&31)*255/31);Nh[n]=iw?(a|r<<8|l<<16|4278190080)>>>0:(a<<24|r<<16|l<<8|255)>>>0}function Or(n,a){return n[a]|n[a+1]<<8}function hj(n,a){const r=Number(a);if(!Number.isSafeInteger(r)||r<wx||r>mj)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const l=n instanceof Uint8Array?n:new Uint8Array(n),c=sw(l,r);if(c[0]!==76||c[1]!==68||c[2]!==53||c[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(c[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${c[4]}.`);const d=(c[5]&1)!==0,m=Or(c,6),p=Or(c,8),v=Or(c,10),g=Or(c,12);if(m<=0||p<=0||m>3840||p>2160)throw new Error(`Invalid Mode 5 frame size: ${m}x${p}.`);if(v<=0||v>256||g>8192)throw new Error(`Invalid Mode 5 tile header: ${v}/${g}.`);const w=[];let y=wx;for(let b=0;b<g;b+=1){if(y+bx>c.length)throw new Error("Mode 5 tile header is truncated.");const j=Or(c,y),C=Or(c,y+2),A=Or(c,y+4),T=Or(c,y+6);y+=bx;const k=A*T*2;if(A<=0||T<=0||A>v||T>v||j+A>m||C+T>p||y+k>c.length)throw new Error(`Invalid Mode 5 tile ${b}.`);w.push({x:j,y:C,width:A,height:T,pixels:c.subarray(y,y+k)}),y+=k}if(y!==c.length)throw new Error(`Mode 5 packet has ${c.length-y} trailing bytes.`);return{keyFrame:d,width:m,height:p,tileSize:v,tiles:w}}function pj(n,a,r,l){if(!(n instanceof Uint8ClampedArray)||n.length!==a*r*4||l.width!==a||l.height!==r)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,d=r,m=0,p=0;const v=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const g of l.tiles){const w=iw&&(g.pixels.byteOffset&1)===0?new Uint16Array(g.pixels.buffer,g.pixels.byteOffset,g.pixels.byteLength>>>1):null;let y=0;for(let b=0;b<g.height;b+=1){let j=(g.y+b)*a+g.x;for(let C=0;C<g.width;C+=1){const A=y<<1,T=w?w[y]:g.pixels[A]|g.pixels[A+1]<<8;v[j]=Nh[T],y+=1,j+=1}}c=Math.min(c,g.x),d=Math.min(d,g.y),m=Math.max(m,g.x+g.width),p=Math.max(p,g.y+g.height)}return l.tiles.length>0?{x:c,y:d,width:m-c,height:p-d}:null}const za=new WeakMap,nu=new WeakMap,Mh=new WeakMap,au=new Set,El=new Set,sf=new WeakMap,Th=new WeakMap,Eh=new WeakMap,rf=new WeakMap,rw=4,gj=2,vj=2,xj=2,yj=18,wj=40,bj=0,Sj=250,lw=80,Sx=5,jj=150,Cj=24,kj=180,Aj=1200,Nj=18,Mj=.65,Tj=2e3,Ej=500,Zh=250,Rj=globalThis.LIVEDESK_ENABLE_CANVAS_VISUAL_SAMPLING===!0;let lf=!1;function Dj(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function _j(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let zl={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:_j()};function Lj(n){n.h264DecodeAcceleration&&(zl={...zl,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(zl.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function ow(n,a=zl.h264DecodeAcceleration){const r=sf.get(n);return r?.requested===a?(r.actual!=="prefer-hardware"&&El.delete(n),r.actual):(r&&sf.delete(n),a!=="prefer-hardware"?(El.delete(n),a):El.has(n)?"prefer-hardware":El.size<zl.h264HardwareDecoderBudget?(El.add(n),"prefer-hardware"):"prefer-software")}function gf(n,a){return a!=="prefer-hardware"?!1:(sf.set(n,{requested:a,actual:"prefer-software"}),El.delete(n),!0)}function zj(n,a,r,l=64){try{let c=Th.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},Th.set(n,c));const d=Math.max(8,Math.min(64,Math.round(l))),m=Math.max(1,Math.round(d*Math.max(1,r)/Math.max(1,a)));(c.canvas.width!==d||c.canvas.height!==m)&&(c.canvas.width=d,c.canvas.height=m);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,r),0,0,d,m);const v=p.getImageData(0,0,d,m).data;let g=2166136261;for(let b=0;b<v.length;b+=4)g^=v[b],g=Math.imul(g,16777619),g^=v[b+1],g=Math.imul(g,16777619),g^=v[b+2],g=Math.imul(g,16777619);const w=(g>>>0).toString(16).padStart(8,"0"),y=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:y}}catch{return{visualHash:"",visualChanged:!0}}}function Rh(n,a,r,l=Zh,c=64,d){if(!Rj&&d)return cw(n,d);let m=Eh.get(n);m||(m={lastHash:"",initialized:!1,lastCanvasSampleAt:0},Eh.set(n,m));const p=performance.now();if(m.initialized&&l>0&&p-m.lastCanvasSampleAt<l)return{visualHash:m.lastHash,visualChanged:!1};const v=zj(n,a,r,c);return m.initialized=!0,m.lastHash=v.visualHash,m.lastCanvasSampleAt=p,v}function cw(n,a){let r=rf.get(n);r||(r={lastHash:"",initialized:!1},rf.set(n,r));const l=String(a.contentHash||""),c=!r.initialized||!l||l!==r.lastHash;return r.initialized=!0,r.lastHash=l,{visualHash:l,visualChanged:c}}function uw(n,a){const r=Mh.get(n);if(r)return r;const l=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(l){const c=l.getContextAttributes?.(),d={context:l,presentation:c?.desynchronized?"desync":"sync"};return Mh.set(n,d),d}return null}function Ij(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),r=String(n.compression||"").toLowerCase(),l=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||r==="lzo1x"||l==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||l==="application/vnd.livedesk.lz4-raw"}function Oj(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function Bj(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||r==="application/vnd.livedesk.lzo-rgb565-delta"}function jx(n,a,r){let l=r,c=a;if(l===15){let d=255;for(;d===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");d=n[c],c+=1,l+=d}}return{length:l,cursor:c}}function Fj(n,a){const r=new Uint8Array(a);let l=0,c=0;for(;l<n.length;){const d=n[l];l+=1;const m=jx(n,l,d>>4);l=m.cursor;const p=m.length;if(l+p>n.length||c+p>r.length)throw new Error("Invalid LZ4 block: literal overrun.");if(r.set(n.subarray(l,l+p),c),l+=p,c+=p,l>=n.length)break;if(l+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const v=n[l]|n[l+1]<<8;if(l+=2,v<=0||v>c)throw new Error("Invalid LZ4 block: bad match offset.");const g=jx(n,l,d&15);l=g.cursor;const w=g.length+4;if(c+w>r.length)throw new Error("Invalid LZ4 block: match overrun.");let y=c-v;for(let b=0;b<w;b+=1)r[c]=r[y],c+=1,y+=1}if(c!==r.length)throw new Error("Invalid LZ4 block: incomplete output.");return r}function Pj(n){const a=Math.max(1,Math.floor(n.width||0)),r=Math.max(1,Math.floor(n.height||0)),l=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(l==="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)),y=a*r*2,b=Math.floor(n.uncompressedByteLength||y);if(w!==2||b!==y)throw new Error(`Invalid mode2 RGB565 frame size: ${b} for ${a}x${r}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const j=sw(n.payload,y),C=new Uint8ClampedArray(a*r*4);for(let A=0,T=0;A<j.length;A+=2,T+=4){const k=j[A]|j[A+1]<<8,E=k>>11&31,R=k>>5&63,$=k&31;C[T]=E<<3|E>>2,C[T+1]=R<<2|R>>4,C[T+2]=$<<3|$>>2,C[T+3]=255}return new ImageData(C,a,r)}const m=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*r*m,Math.floor(n.uncompressedByteLength||0)),v=Fj(n.payload,p);if(m!==4)throw new Error(`Unsupported mode2 pixel size: ${m}`);const g=new Uint8ClampedArray(a*r*4);if(c==="rgba32"||c==="rgba")g.set(v.subarray(0,g.length));else for(let w=0,y=0;y<g.length;w+=4,y+=4)g[y]=v[w+2],g[y+1]=v[w+1],g[y+2]=v[w],g[y+3]=v[w+3];return new ImageData(g,a,r)}function Cx(n,a="smooth"){const r=window.VideoDecoder;if(!r||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const l=za.get(n);if(l&&l.decoder.state!=="closed"&&l.latencyMode===a)return l;l&&Is(n);let c;return c={decoder:new r({output:m=>{if(za.get(n)!==c){m.close();return}const p=Number(m.timestamp||0);c.outputSerial+=1;let v=c.pendingFrames.get(p);if(v)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const C=c.pendingFrames.entries().next().value;C&&(c.pendingFrames.delete(C[0]),v=C[1],c.timestampFallbacks+=1)}const g=m.displayWidth||m.codedWidth||n.width||960,w=m.displayHeight||m.codedHeight||n.height||540,y=Number(v?.frame.durationUs||0),b=Number(m.duration||0),j=Math.max(16,Math.min(250,(y>0?y:b||83333)/1e3));for(c.targetPaintIntervalMs=j,c.decodedFrames.push({videoFrame:m,pending:v,decodedAt:performance.now(),width:g,height:w,durationMs:j}),c.lastOutputAt=performance.now();c.decodedFrames.length>ep(c);)of(c,c.decodedFrames.shift());dw(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>Ej&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=rw&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),cf(n,c)},error:()=>{za.get(n)===c&&(gf(n,c.hardwareAcceleration),Jh(c),au.delete(n),za.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:ow(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},za.set(n,c),au.add(n),c}function Jh(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 of(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function ep(n){return n.latencyMode==="interactive"?vj:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?gj:rw}function dw(n,a=performance.now()){const r=ep(n);for(;n.decodedFrames.length>r;)of(n,n.decodedFrames.shift());const l=n.latencyMode==="interactive"?lw:Sj;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>l;)of(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function fw(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const r=a.latencyMode==="interactive"?Cj:jj,l=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,v]of a.pendingFrames.entries())c-v.queuedAt>Tj&&a.pendingFrames.delete(p);if(za.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!l&&a.lastOutputAt>0&&c-a.lastOutputAt<r)return;const d=a.inputSerial,m=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,d)}catch{za.get(n)===a&&Kd(a)}finally{a.flushInFlight=!1;const p=performance.now()-m;if(l&&p>=kj&&a.hardwareAcceleration==="prefer-hardware"){lf=!0,gf(n,a.hardwareAcceleration),Is(n);return}za.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(l||performance.now()-a.lastOutputAt>=r)&&fw(n,a)}},r)}function kx(n,a,r){const l=performance.now();try{(n.width!==r.width||n.height!==r.height)&&(n.width=r.width,n.height=r.height);const c=uw(n,a.latencyMode);if(c?.context.drawImage(r.videoFrame,0,0,r.width,r.height),r.pending){const d=performance.now(),p=a.latencyMode==="interactive"?cw(n,r.pending.frame):Rh(n,r.width,r.height,Zh,64,r.pending.frame);try{a.onPaint?.(r.pending.frame,{deviceId:r.pending.frame.deviceId,frameSeq:r.pending.frame.frameSeq,mode:r.pending.frame.frameMode||r.pending.frame.mode||r.pending.frame.codec||r.pending.frame.mimeType,width:r.width,height:r.height,byteLength:r.pending.frame.byteLength,queuedForMs:Math.max(0,l-r.pending.queuedAt),decodedForMs:Math.max(0,r.decodedAt-r.pending.queuedAt),scheduledForMs:Math.max(0,l-r.decodedAt),drawMs:Math.max(0,d-l),queueSize:r.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{r.videoFrame.close()}}function cf(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const r=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),l=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(dw(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const v=a.targetPaintIntervalMs<=wj,g=a.targetPaintIntervalMs<=20;if(g&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const A=a.decodedFrames.length>=xj,T=c-a.interactiveBufferStartedAt>=yj;if(!A&&!T){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else g||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],y=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+r:c;if(!(!v||c+Sx>=b||y>=lw)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const C=a.decodedFrames.shift();if(C)try{kx(n,a,C)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),cf(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+r:c+bj;if(!(c+Sx>=d||a.decodedFrames.length>=Math.max(1,ep(a)-1))){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const p=a.decodedFrames.shift();if(p)try{kx(n,a,p)}catch{}cf(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l)}function mw(n,a){if(za.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;)of(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,cf(n,a),!0}function Qm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of au){const a=za.get(n);if(!a||a.decoder.state==="closed"){au.delete(n);continue}mw(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Qm),window.addEventListener("focus",Qm),window.addEventListener("pageshow",Qm));function Is(n){El.delete(n),au.delete(n),rf.delete(n);const a=za.get(n);if(a){za.delete(n);try{Jh(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function Pc(n){n&&(sf.delete(n),Mh.delete(n),Eh.delete(n),Th.delete(n),rf.delete(n),nu.delete(n),Is(n))}function Kd(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),Jh(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 Td(n,a,r,l){n.decoder.configure(a),n.configured=!0,n.configKey=r,n.codec=a.codec,n.hardwareAcceleration=l,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function Hj(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const r=performance.now();if(r-a.healthSampleStartedAt<Aj)return!1;const l=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=r,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,l<Nj||c/Math.max(1,l)>=Mj?!1:(lf=!0,gf(n,a.hardwareAcceleration),Is(n),!0)}function Xm(n,a=1){if(!n)return!1;const r=za.get(n);return r?(r.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),Is(n),!0):!1}function $j(n){if(!n)return!1;const a=za.get(n);return a?mw(n,a):!1}function Uj(n,a,r,l="interactive"){Is(n);const c=performance.now(),d=hj(a.payload,a.uncompressedByteLength||0),m=String(a.streamId||"mode5");let p=nu.get(n);if(!p||p.streamId!==m||p.width!==d.width||p.height!==d.height){const A=new Uint8ClampedArray(d.width*d.height*4);for(let T=3;T<A.length;T+=4)A[T]=255;p={streamId:m,width:d.width,height:d.height,rgba:A,imageData:new ImageData(A,d.width,d.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},nu.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=pj(p.rgba,p.width,p.height,d),y=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const b=uw(n,l),j=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const C=performance.now();p.outputSerial+=1,r?.(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,C-c),decodedForMs:Math.max(0,y-c),scheduledForMs:0,drawMs:Math.max(0,C-j),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:C})}const Zm=[{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 Ax(n,a){for(let r=Math.max(0,a);r+3<n.length;r+=1)if(!(n[r]!==0||n[r+1]!==0)){if(n[r+2]===1)return{index:r,length:3};if(n[r+2]===0&&n[r+3]===1)return{index:r,length:4}}return null}function qj(n){let a=0;for(;a<n.length;){const r=Ax(n,a);if(!r)break;const l=r.index+r.length,c=Ax(n,l),d=c?.index??n.length;if(l<d&&(n[l]&31)===7){const m=[];let p=0;for(let v=l+1;v<d;v+=1){const g=n[v];if(p>=2&&g===3){p=0;continue}m.push(g),p=g===0?p+1:0}if(m.length>=3)return`avc1.${m.slice(0,3).map(v=>v.toString(16).toUpperCase().padStart(2,"0")).join("")}`}a=c?c.index:n.length}return""}function Gj(n,a,r,l,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),m=r>0?1e6/r:30,p=d*m,v=Zm.find(g=>d<=g.maxFrameSize&&p<=g.maxMacroblocksPerSecond)||Zm[Zm.length-1];return qj(l)||c||`avc1.42E0${v.code.toString(16).toUpperCase().padStart(2,"0")}`}function Vj(n,a,r,l,c="smooth"){nu.delete(n);const d=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",m=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),v=Math.max(1,Math.floor(a.durationUs||1e6/12));let g=Cx(n,c);const w=Gj(m,p,v,a.payload,g.codec),y=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&l==="prefer-hardware"&&Dj(),C=y==="mode4-h264-atlas"?"prefer-software":ow(n,c==="interactive"&&(lf||b)?"prefer-software":l),A=[a.streamId||"",a.commandId||"",m,p,w,d,C,c].join("|");g.onPaint=r,g.configured&&g.decoder.state!=="configured"&&(g.configured=!1,g.configKey=""),g.configured&&g.configKey!==A&&(Is(n),g=Cx(n,c),g.onPaint=r);const T={codec:w,codedWidth:m,codedHeight:p,hardwareAcceleration:C,optimizeForLatency:!0,avc:{format:d}};g.configured||Td(g,T,A,C);const k=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const E=Number(a.streamFrameSeq||0);if(E>0&&g.lastInputFrameSeq!==void 0){if(E<=g.lastInputFrameSeq){if(!k||E===g.lastInputFrameSeq)return;Kd(g,g.lastInputFrameSeq-E+1),Td(g,T,A,C)}if(E>g.lastInputFrameSeq+1){if(Kd(g,E-g.lastInputFrameSeq-1),!k)return;Td(g,T,A,C)}}if(E>0&&(g.lastInputFrameSeq=E),!k&&!g.keyFrameSeen)return;k&&(g.keyFrameSeen=!0);const R=Number(g.decoder.decodeQueueSize||0);if(R>8){if(g.latencyMode==="interactive"&&g.hardwareAcceleration==="prefer-hardware"){lf=!0,gf(n,g.hardwareAcceleration),Is(n);return}if(Kd(g),!k)return;Td(g,T,A,C),g.keyFrameSeen=!0}const $=g.nextChunkTimestampUs;g.nextChunkTimestampUs+=v,g.pendingFrames.set($,{frame:a,queuedAt:performance.now(),queueSize:R}),g.inputSerial+=1,g.lastInputAt=performance.now();const F=new EncodedVideoChunk({type:k?"key":"delta",timestamp:$,duration:v,data:a.payload});try{g.decoder.decode(F)}catch(q){throw Is(n),q}fw(n,g),Hj(n,g)}async function Jm(n,a,r,l,c,d="smooth"){if(Bj(a)){r()||Uj(n,a,l,d);return}if(Oj(a)){r()||Vj(n,a,l,c,d);return}if(nu.delete(n),Ij(a)){Is(n);const y=Pj(a);if(r())return;(n.width!==y.width||n.height!==y.height)&&(n.width=y.width,n.height=y.height);const b=n.getContext("2d"),j=performance.now();b?.putImageData(y,0,0);const C=performance.now(),A=Rh(n,y.width,y.height,Zh,64,a);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:y.width,height:y.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,C-j),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:zl.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:A.visualHash,visualChanged:A.visualChanged,paintedAt:C});return}Is(n);const m=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(m);if(r()){p.close();return}const v=a.width||p.width||960,g=a.height||p.height||540;(n.width!==v||n.height!==g)&&(n.width=v,n.height=g);const w=n.getContext("2d");if(w){const y=performance.now();w.clearRect(0,0,v,g),w.drawImage(p,0,0,v,g);const b=performance.now(),j=Rh(n,v,g);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:v,height:g,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-y),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:zl.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:j.visualHash,visualChanged:j.visualChanged,paintedAt:b})}p.close()}const Nx="livedesk_remote_host_targets",Yj="livedesk_entitlements",tp=new TextDecoder;function Wj(n){const r=(Array.isArray(n)?n:[n||yn]).map(l=>Gr(l||yn));return[...new Set(r.filter(Boolean))]}function Kj(){const[n,a]=u.useState(null),[r,l]=u.useState(!0);return u.useEffect(()=>{let c=!0;const d=window.liveDesk?.auth?.onComplete?.(p=>{p.ok&&p.session&&ct.auth.setSession(p.session)});(window.liveDesk?.auth?.getSession?.()||ct.auth.getSession()).then(p=>{c&&(a(ew(p)),l(!1))});const{data:{subscription:m}}=ct.auth.onAuthStateChange((p,v)=>{a(v),l(!1),window.liveDesk?.auth?.persistSession?.(v)});return()=>{c=!1,d?.(),m.unsubscribe()}},[]),{session:n,loading:r}}function Qj(n,a=!0){const[r,l]=u.useState(null),[c,d]=u.useState([]),[m,p]=u.useState(""),[v,g]=u.useState(""),[w,y]=u.useState(0),b=u.useRef(new Map),j=Array.isArray(n)?n.join(`
|
|
11
|
+
`):String(n||""),C=u.useMemo(()=>Wj(n),[j]),A=u.useMemo(()=>C.find(E=>Xc(E)==="loopback")||C[0]||yn,[C]),T=u.useCallback(async()=>{if(!a){l(null),d([]),g(""),p("");return}let E=null;const R=Date.now(),$=C.filter(F=>(b.current.get(F)||0)<=R);if($.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const F of $)try{const[q,L]=await Promise.all([Ue("/api/remote/status",void 0,F),Ue("/api/remote/devices",void 0,F)]);if(!Array.isArray(L.devices))throw new Error("Invalid Hub devices response.");b.current.delete(F),l(q),d(L.devices),g(F),p("");return}catch(q){E=q,b.current.set(F,Date.now()+1e4)}throw g(""),E||new Error("No LiveDesk Hub endpoint is reachable.")},[a,C]),k=u.useCallback(()=>{b.current.clear(),T().catch(E=>{p(E instanceof Error?E.message:String(E))}),y(E=>E+1)},[T]);return u.useEffect(()=>{if(!a){l(null),d([]),g(""),p("");return}let E=!0;const R=async()=>{try{await T()}catch(F){E&&p(F instanceof Error?F.message:String(F))}};R();const $=window.setInterval(R,2500);return()=>{E=!1,window.clearInterval($)}},[a,T,w]),{status:r,devices:c,error:m,refresh:k,hubBaseUrl:v||A,hubCandidates:C}}function Xj(n){const[a,r]=u.useState(null),[l,c]=u.useState(""),d=n?.user?.id||"",m=u.useCallback(async()=>{if(!d){r(null);return}const{data:p,error:v}=await ct.from(Nx).select("*").eq("user_id",d).maybeSingle();if(v){c(v.message);return}r(p),c("")},[d]);return u.useEffect(()=>{m()},[m]),u.useEffect(()=>{if(!d)return;const p=ct.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:Nx,filter:`user_id=eq.${d}`},v=>r(v.new)).subscribe();return()=>{ct.removeChannel(p)}},[d]),{target:a,error:l,refresh:m}}function Zj(n){const[a,r]=u.useState(null),[l,c]=u.useState(!1),[d,m]=u.useState(""),p=n?.user?.id||"",v=u.useCallback(async()=>{if(!p){r(null),m(""),c(!1);return}c(!0);const{data:w,error:y}=await ct.from(Yj).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(y){m(y.message),c(!1);return}r(w),m(""),c(!1)},[p]);u.useEffect(()=>{v()},[v]);const g=u.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:l,error:d,refresh:v}}const Zc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},Jj=2500,e1=3e4,t1=64*1024,n1=6,a1=n1,hw=new Map;function s1(n){return hw.get(n)}const Mx={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function Tx(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const r=Date.now()-a;return r>0&&r<=e1?r:0}function Ex(n,a,r=yn,l={}){const[c,d]=u.useState(new Map),[m,p]=u.useState("idle"),[v,g]=u.useState(""),[w,y]=u.useState(Zc),b=u.useRef(new Map),j=u.useRef(new Map),C=u.useRef(0),A=u.useRef(new Map),T=u.useRef({enabled:!1,token:"",reason:""}),k=u.useRef(new Set),[E,R]=u.useState(0),$=u.useRef(l.onFrame),F=u.useRef(l.onStreamReady),q=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),L=u.useMemo(()=>[...n].sort().join(","),[n]),_=Number.isFinite(l.fps)?Number(l.fps):2,ie=Number.isFinite(l.maxWidth)?Number(l.maxWidth):640,V=Number.isFinite(l.maxHeight)?Number(l.maxHeight):360,ne=Number.isFinite(l.quality)?Number(l.quality):45,Q=String(l.frameMode||l.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",J=l.streamPurpose==="control"?"control":"wall",le=l.forceRestart===!0,Y=String(l.forceRestartToken||"").trim(),O=String(l.restartReason||"").trim();T.current={enabled:le,token:Y,reason:O};const Z=u.useMemo(()=>{const me=Object.entries(l.monitorSelections||{}).filter(([ge])=>!!ge).sort(([ge],[xe])=>ge.localeCompare(xe));return JSON.stringify(Object.fromEntries(me))},[l.monitorSelections]);u.useEffect(()=>{$.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{F.current=l.onStreamReady},[l.onStreamReady]);const X=u.useCallback((me,ge="livedesk-frame-socket-release")=>{me.disposed=!0;try{me.socket.readyState===WebSocket.CONNECTING||me.socket.readyState===WebSocket.OPEN?me.socket.close(1e3,ge):me.socket.close()}catch{}},[]),D=u.useCallback(()=>{const me=[...j.current.values()].map(ge=>ge.socket);if(me.length===0){p("idle");return}if(me.some(ge=>ge.readyState===WebSocket.OPEN)){p("open");return}if(me.some(ge=>ge.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),K=u.useCallback((me,ge,xe,Ce)=>{if(ge.disposed||ge.socket.readyState!==WebSocket.OPEN)return!1;try{return ge.socket.send(JSON.stringify({...ge.payload,type:"restart-live",deviceIds:[me],forceRestart:!0,restartReason:xe,restartToken:Ce})),!0}catch{return!1}},[]),ce=u.useCallback((me,ge)=>{if(!me||me.byteLength<5)return;const xe=Date.now(),Le=new DataView(me).getUint32(0,!1);if(Le<=0||Le+4>me.byteLength)return;const ze=new Uint8Array(me,4,Le),ue=JSON.parse(tp.decode(ze));if(Math.max(Tx(ue.receivedAt),Tx(ue.capturedAt))>Jj)return;const We=new Uint8Array(me,4+Le),oe={deviceId:String(ue.deviceId||""),kind:ue.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(ue.frameSeq||0),streamFrameSeq:Number(ue.streamFrameSeq||0)||void 0,streamId:String(ue.streamId||""),commandId:ue.commandId?String(ue.commandId):void 0,sessionId:ue.sessionId?String(ue.sessionId):void 0,captureGeneration:Number(ue.captureGeneration||0)||void 0,streamPurpose:ue.streamPurpose?String(ue.streamPurpose):void 0,width:Number(ue.width||0),height:Number(ue.height||0),sourceWidth:Number(ue.sourceWidth||0)||void 0,sourceHeight:Number(ue.sourceHeight||0)||void 0,mimeType:String(ue.mimeType||"image/jpeg"),mode:ue.mode?String(ue.mode):void 0,frameMode:ue.frameMode?String(ue.frameMode):void 0,frameProfile:ue.frameProfile?String(ue.frameProfile):void 0,encoding:ue.encoding?String(ue.encoding):void 0,codec:ue.codec?String(ue.codec):void 0,compression:ue.compression?String(ue.compression):void 0,pixelFormat:ue.pixelFormat?String(ue.pixelFormat):void 0,bytesPerPixel:Number(ue.bytesPerPixel||0)||0,uncompressedByteLength:Number(ue.uncompressedByteLength||0)||0,h264Format:ue.h264Format?String(ue.h264Format):void 0,isKeyFrame:ue.isKeyFrame===!0,chunkType:ue.chunkType?String(ue.chunkType):void 0,timestampUs:Number(ue.timestampUs||0)||0,durationUs:Number(ue.durationUs||0)||0,sourceGapMs:Number(ue.sourceGapMs||0)||0,agentSendGapMs:Number(ue.agentSendGapMs||0)||0,agentSendDurationMs:Number(ue.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(ue.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(ue.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(ue.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(ue.agentFrameAgeMs||0)||0,droppedByAgent:Number(ue.droppedByAgent||0)||0,hubIngressDropped:Number(ue.hubIngressDropped||0)||0,hubClientDropped:Number(ue.hubClientDropped||0)||0,hardwareEncoder:ue.hardwareEncoder?String(ue.hardwareEncoder):void 0,platformProfile:ue.platformProfile?String(ue.platformProfile):void 0,monitorIndex:Number.isFinite(Number(ue.monitorIndex))?Number(ue.monitorIndex):void 0,monitorCount:Number.isFinite(Number(ue.monitorCount))?Number(ue.monitorCount):void 0,requestedFps:Number(ue.requestedFps||0)||0,effectiveFps:Number(ue.effectiveFps||0)||0,captureAverageMs:Number(ue.captureAverageMs||0)||0,captureP95Ms:Number(ue.captureP95Ms||0)||0,slowFrameCount:Number(ue.slowFrameCount||0)||0,captureHelperRestarts:Number(ue.captureHelperRestarts||0)||0,capturedAt:String(ue.capturedAt||""),receivedAt:String(ue.receivedAt||""),hubPacketAt:ue.hubPacketAt?String(ue.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(ue.hubPacketEpochMs))?Number(ue.hubPacketEpochMs):void 0,browserReceivedEpochMs:xe,byteLength:Number(ue.byteLength||We.byteLength),contentHash:ue.contentHash?String(ue.contentHash):void 0,captureMs:Number(ue.captureMs||0)||0,captureStageMs:Number(ue.captureStageMs||0)||0,convertMs:Number(ue.convertMs||0)||0,compressMs:Number(ue.compressMs||0)||0,captureSourceSerial:Number(ue.captureSourceSerial||0)||0,captureSourceSkipped:Number(ue.captureSourceSkipped||0)||0,deltaTileSize:Number(ue.deltaTileSize||0)||0,deltaTileCount:Number(ue.deltaTileCount||0)||0,deltaVisualTileCount:Number(ue.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(ue.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(ue.deltaTotalTiles||0)||0,payload:We};if(!oe.deviceId)return;const Ae={streamId:ge.lastFrameStreamId,commandId:ge.lastFrameCommandId,order:ge.lastFrameOrder},je=Number(oe.streamFrameSeq||oe.frameSeq||0),Ee=!!Ae.commandId&&!!oe.commandId,Re=Ae.streamId===oe.streamId&&(!Ee||Ae.commandId===oe.commandId),Fe=Ae.order;if(Re&&Fe>=je&&(Fe===je||Ee))return;ge.lastFrameStreamId=oe.streamId,ge.lastFrameCommandId=oe.commandId||"",ge.lastFrameOrder=je;const pe=q.current;pe.totalFrames+=1,pe.totalBytes+=We.byteLength,pe.sampleFrames+=1,pe.sampleBytes+=We.byteLength;const ke=!b.current.has(oe.deviceId);b.current.set(oe.deviceId,oe),ke&&d(new Map(b.current)),$.current?.(oe)},[]);u.useEffect(()=>{const me=window.setInterval(()=>{const ge=performance.now(),xe=q.current,Ce=Math.max(1,ge-xe.sampleStartedAt);y({totalFrames:xe.totalFrames,totalBytes:xe.totalBytes,framesPerSecond:xe.sampleFrames*1e3/Ce,bytesPerSecond:xe.sampleBytes*1e3/Ce,sampleMs:Ce,lastUpdatedAt:Date.now()}),d(new Map(b.current)),xe.sampleFrames=0,xe.sampleBytes=0,xe.sampleStartedAt=ge},2e3);return()=>{window.clearInterval(me)}},[]),u.useEffect(()=>{const me=L?L.split(",").filter(Boolean):[],ge=new Set(me),xe=performance.now();for(const[Ce,Le]of j.current.entries())ge.has(Ce)||(X(Le,"livedesk-device-unsubscribed"),j.current.delete(Ce),A.current.delete(Ce),b.current.delete(Ce));if(me.length===0){for(const Ce of j.current.values())X(Ce,"livedesk-no-devices");j.current.clear(),A.current.clear(),b.current=new Map,d(new Map),g(""),q.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},y(Zc),D();return}q.current.sampleStartedAt<=0&&(q.current.sampleStartedAt=xe,y({...Zc,lastUpdatedAt:Date.now()}));for(const Ce of me){const Le=l.monitorSelections?.[Ce],ze=Number.isFinite(Number(Le))?{[Ce]:Number(Le)}:{},ue={type:"subscribe",deviceIds:[Ce],autoStartLive:a,fps:_,maxWidth:ie,maxHeight:V,quality:ne,mode:Q,frameMode:Q,streamPurpose:J,monitorSelections:ze},Ye=JSON.stringify(ue),We=j.current.get(Ce);if(We){const Ee=We.socket.readyState===WebSocket.CONNECTING||We.socket.readyState===WebSocket.OPEN;if(We.payloadKey===Ye&&Ee&&!We.disposed)continue}const oe=We&&(We.socket.readyState===WebSocket.CONNECTING||We.socket.readyState===WebSocket.OPEN)&&!We.disposed?We.handoffFrom&&!We.handoffCompleted?We.handoffFrom:We:void 0;We&&We!==oe&&X(We,"livedesk-subscription-superseded");const Ae=new WebSocket(pf(`/api/remote/frames/ws?devices=${encodeURIComponent(Ce)}`,r));Ae.binaryType="arraybuffer";const je={socket:Ae,payload:ue,payloadKey:Ye,generation:C.current+1,disposed:!1,handoffFrom:oe,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};C.current=je.generation,j.current.set(Ce,je),Ae.addEventListener("open",()=>{if(je.disposed||j.current.get(Ce)!==je){X(je,"livedesk-stale-frame-socket");return}g("");const Ee=T.current,Re=Ee.enabled&&(!Ee.token||A.current.get(Ce)!==Ee.token);Ae.send(JSON.stringify({...je.payload,forceRestart:Re,restartReason:Re?Ee.reason:"",restartToken:Re?Ee.token:""})),Re&&Ee.token&&A.current.set(Ce,Ee.token);const Fe=je.handoffFrom;je.handoffFrom=void 0,je.handoffCompleted=!0,Fe&&!Fe.disposed&&X(Fe,"livedesk-subscription-replaced"),D()}),Ae.addEventListener("message",Ee=>{if(je.disposed||j.current.get(Ce)!==je)return;if(typeof Ee.data=="string"){try{const Fe=JSON.parse(Ee.data);if(Fe?.type==="RemoteFrameSubscriptionError")g(String(Fe.error||"control-stream-start-failed"));else if(Fe?.type==="RemoteFrameLiveAutoStart"){const ke=(Array.isArray(Fe.skipped)?Fe.skipped:[]).find(de=>de?.deviceId===Ce);if(ke)g(String(ke.reason||"control-stream-start-failed"));else if(Array.isArray(Fe.started)){const de=Fe.started.find(we=>we?.deviceId===Ce);de&&(g(""),de.ready===!0&&de.streamPurpose==="control"&&de.sessionId&&de.commandId&&Number(de.captureGeneration||0)>0&&F.current?.({deviceId:Ce,sessionId:String(de.sessionId),streamId:String(de.streamId||""),streamPurpose:"control",commandId:String(de.commandId),captureGeneration:Number(de.captureGeneration),monitorIndex:Number(de.monitorIndex||0)}))}}else Fe?.type==="RemoteFrameStreamReady"&&Fe.deviceId===Ce&&Fe.streamPurpose==="control"&&Fe.sessionId&&Fe.commandId&&Number(Fe.captureGeneration||0)>0&&(g(""),F.current?.({deviceId:Ce,sessionId:String(Fe.sessionId),streamId:String(Fe.streamId||""),streamPurpose:"control",commandId:String(Fe.commandId),captureGeneration:Number(Fe.captureGeneration),monitorIndex:Number(Fe.monitorIndex||0)}))}catch{}return}const Re=Ee.data instanceof ArrayBuffer?Ee.data:null;Re&&(g(""),ce(Re,je))}),Ae.addEventListener("error",()=>{je.disposed||j.current.get(Ce)!==je||p("connecting")}),Ae.addEventListener("close",()=>{const Ee=!je.disposed;je.disposed=!0;const Re=j.current.get(Ce);let Fe=!1;if(Re===je){const pe=je.handoffFrom;je.handoffFrom=void 0,pe&&!pe.disposed&&(pe.socket.readyState===WebSocket.CONNECTING||pe.socket.readyState===WebSocket.OPEN)?(j.current.set(Ce,pe),Fe=!0):j.current.delete(Ce)}if(D(),Ee&&Re===je&&!Fe){const pe=window.setTimeout(()=>{k.current.delete(pe),R(ke=>ke+1)},750);k.current.add(pe)}})}D()},[a,X,L,_,Q,ce,r,V,ie,Z,l.monitorSelections,ne,E,J,D]),u.useEffect(()=>{if(!le||!Y)return;const me=L?L.split(",").filter(Boolean):[];for(const ge of me){if(A.current.get(ge)===Y)continue;const xe=j.current.get(ge);!xe||!K(ge,xe,O,Y)||A.current.set(ge,Y)}},[L,le,Y,O,K]),u.useEffect(()=>()=>{for(const me of j.current.values())X(me,"livedesk-hook-unmount");j.current.clear();for(const me of k.current)window.clearTimeout(me);k.current.clear()},[X]);const W=u.useCallback((me,ge="browser-stale")=>{const xe=Array.isArray(me)&&me.length>0?me:L.split(",").filter(Boolean);if(xe.length===0)return!1;let Ce=!1;for(const Le of xe){const ze=j.current.get(Le);!ze||ze.socket.readyState!==WebSocket.OPEN||(Ce=K(Le,ze,ge,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||Ce)}return Ce},[L,K]),P=u.useCallback((me,ge="browser-reconnect")=>{const xe=Array.isArray(me)&&me.length>0?me:L.split(",").filter(Boolean);if(xe.length===0)return!1;let Ce=!1;for(const Le of xe){const ze=j.current.get(Le);ze&&(X(ze,`livedesk-${ge}`),j.current.delete(Le),A.current.delete(Le),b.current.delete(Le),Ce=!0)}return Ce&&d(new Map(b.current)),R(Le=>Le+1),D(),!0},[X,L,D]);return{frames:c,state:m,error:v,stats:w,restartLive:W,reconnectLive:P}}function i1(n,a,r=yn,l={}){const[c,d]=u.useState(null),[m,p]=u.useState(null),[v,g]=u.useState("idle"),[w,y]=u.useState(Zc),b=u.useRef(null),j=u.useRef(l.onFrame),C=u.useRef(null),A=u.useRef(0),T=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),k=u.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),E=u.useMemo(()=>[...new Set((l.captureDeviceIds||n).filter(Boolean))].join(","),[n,l.captureDeviceIds]),R=u.useMemo(()=>JSON.stringify(l.monitorSelections||{}),[l.monitorSelections]),$=u.useMemo(()=>({deviceIds:k.split(",").filter(Boolean),captureDeviceIds:E.split(",").filter(Boolean),fps:Number(l.fps||20),width:Number(l.width||1920),height:Number(l.height||1080),tileWidth:Number(l.tileWidth||320),tileHeight:Number(l.tileHeight||180),monitorSelections:l.monitorSelections||{}}),[E,k,R,l.fps,l.height,l.monitorSelections,l.tileHeight,l.tileWidth,l.width]),F=u.useMemo(()=>JSON.stringify($),[$]),q=u.useRef($);q.current=$;const L=a&&$.deviceIds.length>0,_=u.useCallback(V=>V.readyState!==WebSocket.OPEN?!1:(V.send(JSON.stringify({type:"configure",...q.current})),!0),[]);u.useEffect(()=>{j.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{const V=window.setInterval(()=>{const ne=T.current,Q=performance.now(),J=Math.max(1,Q-ne.sampleStartedAt);y({totalFrames:ne.totalFrames,totalBytes:ne.totalBytes,framesPerSecond:ne.sampleFrames*1e3/J,bytesPerSecond:ne.sampleBytes*1e3/J,sampleMs:J,lastUpdatedAt:Date.now()});const le=C.current;le&&le.frameSeq!==A.current&&(A.current=le.frameSeq,d(le)),ne.sampleFrames=0,ne.sampleBytes=0,ne.sampleStartedAt=Q},1e3);return()=>window.clearInterval(V)},[]),u.useEffect(()=>{if(!L){b.current?.close(),b.current=null,d(null),C.current=null,A.current=0,p(null),g("idle"),y(Zc);return}let V=!1,ne=0;const Q=()=>{if(V)return;const J=new WebSocket(pf("/api/remote/atlas/ws",r));J.binaryType="arraybuffer",b.current=J,g("connecting"),J.addEventListener("open",()=>{T.current.sampleStartedAt=performance.now(),g("open"),_(J)}),J.addEventListener("message",le=>{if(typeof le.data=="string"){try{const O=JSON.parse(le.data);O?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(O.layoutVersion||0),width:Number(O.width||1920),height:Number(O.height||1080),columns:Number(O.columns||1),rows:Number(O.rows||1),tiles:Array.isArray(O.tiles)?O.tiles:[]})}catch{}return}const Y=le.data instanceof ArrayBuffer?le.data:null;if(!(!Y||Y.byteLength<5))try{const O=Date.now(),X=new DataView(Y).getUint32(0,!1);if(X<=0||X+4>Y.byteLength)return;const D=JSON.parse(tp.decode(new Uint8Array(Y,4,X))),K=new Uint8Array(Y,4+X),ce={deviceId:String(D.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(D.frameSeq||0),streamFrameSeq:Number(D.streamFrameSeq||0)||void 0,streamId:String(D.streamId||"mode4-atlas"),commandId:D.commandId?String(D.commandId):void 0,width:Number(D.width||1920),height:Number(D.height||1080),sourceWidth:Number(D.sourceWidth||D.width||1920),sourceHeight:Number(D.sourceHeight||D.height||1080),mimeType:String(D.mimeType||"video/h264"),mode:String(D.mode||"mode4-h264-atlas"),frameMode:String(D.frameMode||"mode4-h264-atlas"),frameProfile:String(D.frameProfile||"mode4-h264-atlas-v1"),encoding:String(D.encoding||"video-atlas"),codec:String(D.codec||"h264"),compression:String(D.compression||"video/h264"),h264Format:String(D.h264Format||"annexb"),isKeyFrame:D.isKeyFrame===!0,chunkType:String(D.chunkType||""),timestampUs:Number(D.timestampUs||0),durationUs:Number(D.durationUs||0),hardwareEncoder:D.hardwareEncoder?String(D.hardwareEncoder):void 0,platformProfile:D.platformProfile?String(D.platformProfile):void 0,capturedAt:String(D.capturedAt||""),receivedAt:String(D.receivedAt||""),hubPacketAt:D.hubPacketAt?String(D.hubPacketAt):void 0,hubPacketEpochMs:Number(D.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:O,byteLength:K.byteLength,layoutVersion:Number(D.layoutVersion||0),atlasComposeMs:Number(D.atlasComposeMs||0),atlasPoolStarved:Number(D.atlasPoolStarved||0),atlasReadyTiles:Number(D.atlasReadyTiles||0),atlasTileCount:Number(D.atlasTileCount||0),atlasInputRevision:Number(D.atlasInputRevision||0),atlasSourceNewestAtEpochMs:Number(D.atlasSourceNewestAtEpochMs||0),atlasSourceOldestAtEpochMs:Number(D.atlasSourceOldestAtEpochMs||0),atlasSourceMaxAgeMs:Number(D.atlasSourceMaxAgeMs||0),payload:K},W=T.current;W.totalFrames+=1,W.totalBytes+=K.byteLength,W.sampleFrames+=1,W.sampleBytes+=K.byteLength,C.current=ce,A.current===0&&(A.current=ce.frameSeq,d(ce)),j.current?.(ce)}catch{}}),J.addEventListener("error",()=>g("error")),J.addEventListener("close",()=>{b.current===J&&(b.current=null),!V&&(g("closed"),ne=window.setTimeout(Q,1200))})};return Q(),()=>{V=!0,window.clearTimeout(ne),b.current?.close(),b.current=null}},[L,r,_]),u.useEffect(()=>{if(!L)return;const V=b.current;V&&_(V)},[F,L,_]);const ie=u.useCallback(()=>{const V=b.current;return V?_(V):!1},[_]);return{frame:c,layout:m,state:v,stats:w,refreshInputs:ie}}function r1(n,a=yn){const r=u.useRef(null),l=u.useRef(0),c=u.useRef(0),d=u.useRef(new Map),[m,p]=u.useState("idle"),[v,g]=u.useState(""),[w,y]=u.useState(Mx),b=u.useRef({totalSent:0,totalDropped:0,sampleSent:0,sampleDropped:0,sampleStartedAt:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0});u.useEffect(()=>{if(!n){r.current?.close(),r.current=null,c.current=0,p("idle"),g(""),y(Mx);return}let C=!1,A=0;const T=()=>{if(C)return;const k=new WebSocket(pf("/api/remote/input/ws",a));r.current=k,b.current.sampleStartedAt=performance.now(),p("connecting"),g(""),k.addEventListener("open",()=>{C||r.current!==k||(g(""),p("open"))}),k.addEventListener("message",E=>{if(!(C||r.current!==k||typeof E.data!="string"))try{const R=JSON.parse(E.data);if(R?.type==="RemoteInputError"){g(String(R.error||R.result?.error||"Remote input failed.")),p("error");return}if(R?.type!=="RemoteInputApplied")return;const $=Number(R.inputSeq||0),F=d.current.get($);F!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-F),d.current.delete($)),b.current.lastInputSeq=$,b.current.lastAgentApplyMs=Math.max(0,Number(R.agentApplyMs||0))}catch{}}),k.addEventListener("close",()=>{C||r.current!==k||(r.current=null,p("closed"),A=window.setTimeout(T,1200))}),k.addEventListener("error",()=>{!C&&r.current===k&&p("error")})};return T(),()=>{C=!0,window.clearTimeout(A);const k=r.current;r.current=null,k?.close(),d.current.clear()}},[n,a]),u.useEffect(()=>{if(!n)return;const C=window.setInterval(()=>{const A=performance.now(),T=b.current,k=Math.max(1,A-T.sampleStartedAt);y({totalSent:T.totalSent,totalDropped:T.totalDropped,sentPerSecond:T.sampleSent*1e3/k,droppedPerSecond:T.sampleDropped*1e3/k,bufferedAmount:r.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=A},1e3);return()=>window.clearInterval(C)},[n]);const j=u.useCallback((C,A)=>{const T=r.current;if(!T||T.readyState!==WebSocket.OPEN||!C)return!1;const k=String(A.type||"").toLowerCase(),E=k==="pointermove",$=E||k==="wheel",F=b.current;if(E&&T.bufferedAmount>t1)return F.totalDropped+=1,F.sampleDropped+=1,F.lastInputType="pointermove-drop",!1;const q=l.current+1;l.current=q;const L=Date.now(),_=!$||q-c.current>=a1;for(_&&(d.current.set(q,performance.now()),$&&(c.current=q)),E||hw.set(C,{inputSeq:q,inputType:k||"input",sentAt:performance.now()});d.current.size>256;){const ie=d.current.keys().next().value;if(ie===void 0)break;d.current.delete(ie)}return T.send(JSON.stringify({type:"input",requestId:$?"":crypto.randomUUID(),fireAndForget:$,deviceId:C,input:{...A,inputSeq:q,requestAck:_,issuedAtEpochMs:L,issuedAt:new Date(L).toISOString()}})),F.totalSent+=1,F.sampleSent+=1,F.lastInputType=k||"input",!0},[]);return{state:m,sendInput:j,stats:w,error:v}}function l1(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const Ed={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},o1=.08,c1=.25,u1=.02,Rx=300,d1=4,Rd=1500,eh=5e3,f1=2e3,m1=1e4,Dd=[0,1e3,3e3];function Dx(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function h1(n,a,r){const l=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(),m=d.includes("s16le")||d.includes("audio/l16"),p=m?2:4,v=Math.floor(r.byteLength/p),g=Math.floor(v/l),w=n.createBuffer(l,g,c),y=new DataView(r);for(let b=0;b<l;b+=1){const j=w.getChannelData(b);for(let C=0;C<g;C+=1){const T=(C*l+b)*p;j[C]=m?Math.max(-1,Math.min(1,y.getInt16(T,!0)/32768)):Math.max(-1,Math.min(1,y.getFloat32(T,!0)))}}return w}function p1(n,a,r=yn){const l=u.useRef(null),c=u.useRef(0),[d,m]=u.useState("idle"),[p,v]=u.useState(null),[g,w]=u.useState(Ed),[y,b]=u.useState("");return u.useEffect(()=>{if(!a||!n){m("idle"),v(null),w(Ed),b("");return}m("connecting"),v(null),w(Ed),b("");const j=window.AudioContext||window.webkitAudioContext;if(!j){m("unsupported"),w(Ed),b("Audio playback is not supported in this browser.");return}const C=new j;l.current=C,c.current=C.currentTime;const A=new WebSocket(pf("/api/remote/audio/ws?devices="+encodeURIComponent(n),r));A.binaryType="arraybuffer";const T=new Set,k={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(C.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let E=!1,R=0,$=!1,F=0,q=0;const L=(O=!0)=>{for(const Z of T)try{Z.stop()}catch{}T.clear(),O&&(c.current=C.currentTime+o1)},_=()=>{k.audioContextState=String(C.state),!E&&(k.audioContextState==="suspended"||k.audioContextState==="interrupted"?m("suspended"):k.audioContextState==="closed"&&(m("error"),b("The browser audio context is closed. Toggle Remote Audio off and on to recover.")))},ie=async()=>{if(E||String(C.state)==="closed")return!1;try{if(String(C.state)!=="running"&&await C.resume(),k.audioContextState=String(C.state),!E&&!$&&k.audioContextState==="running"){const O=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=Rd,Z=k.lastCaptureStatusAt>0&&performance.now()-k.lastCaptureStatusAt<=eh&&k.captureAlive&&k.helperAlive;m(O?"playing":Z?"silent":"open")}return k.audioContextState==="running"}catch(O){return E||(m("suspended"),b(O instanceof Error?"Audio playback is suspended: "+O.message:"Audio playback is suspended.")),!1}},V=async()=>{if(E||$||A.readyState!==WebSocket.OPEN)return;if(F>=Dd.length){m("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const O=F;F+=1,$=!0,k.stalledCount+=1,k.automaticRestarts+=1,m("reconnecting");try{const Z=await Ue("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},r);if(Z.ok===!1)throw new Error(Z.error||"Remote audio stop failed.");if(E)return;const X=await Ue("/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})},r);if(X.ok===!1)throw new Error(X.error||"Remote audio start failed.");const D=performance.now();R=D,k.lastPacketAt=D,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,q=D+(Dd[O+1]??3e3),b(""),E||m("open")}catch(Z){E||(q=performance.now()+(Dd[O+1]??3e3),m("error"),b(Z instanceof Error?"Remote audio restart failed: "+Z.message:"Remote audio restart failed."))}finally{$=!1}},ne=()=>{k.drops+=1},Q=window.setInterval(()=>{if(E)return;const O=performance.now(),Z=k.lastPacketAt>0?Math.max(0,O-k.lastPacketAt):R>0?Math.max(0,O-R):0,X=k.lastAcceptedAt>0?Math.max(0,O-k.lastAcceptedAt):0,D=k.lastCaptureStatusAt>0?Math.max(0,O-k.lastCaptureStatusAt):0,K=A.readyState===WebSocket.OPEN,ce=k.lastCaptureStatusAt>0,W=ce&&D<=eh,P=ce&&(!k.captureAlive||!k.helperAlive)&&D>f1,me=ce&&D>eh,ge=!ce&&R>0&&O-R>m1,xe=R>0&&(k.lastAcceptedAt<=0?O-R>Rd:X>Rd);K&&R>0&&(P||me||ge)?F>=Dd.length&&!$?(m("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!$&&O>=q?V():$||m("stalled"):K&&xe&&!$&&k.audioContextState!=="suspended"&&k.audioContextState!=="interrupted"&&m(W?"silent":"open"),w({queuedMs:Math.max(0,(c.current-C.currentTime)*1e3),browserAgeMs:k.browserAgeMs,captureAgeMs:k.captureAgeMs,captureStatusAgeMs:D,silentForMs:k.silentForMs,captureAlive:k.captureAlive,helperAlive:k.helperAlive,captureRestartCount:k.captureRestartCount,localProcessingAgeMs:k.localProcessingAgeMs,lastPacketAgeMs:Z,lastAcceptedAgeMs:X,framesReceived:k.framesReceived,drops:k.drops,resyncs:k.resyncs,pendingDecodes:k.pendingDecodes,lastFrameSeq:k.lastFrameSeq,audioContextState:k.audioContextState,stalledCount:k.stalledCount,automaticRestarts:k.automaticRestarts,lastUpdatedAt:Date.now()})},250),J=()=>{_(),(String(C.state)==="suspended"||String(C.state)==="interrupted")&&ie()},le=()=>{document.visibilityState==="visible"&&ie()},Y=()=>{ie()};return C.addEventListener("statechange",J),document.addEventListener("visibilitychange",le),window.addEventListener("pageshow",Y),window.addEventListener("pointerdown",Y),window.addEventListener("keydown",Y),m("connecting"),b(""),_(),A.addEventListener("open",()=>{E||(R=performance.now(),k.lastPacketAt=R,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,m("open"),A.send(JSON.stringify({type:"subscribe",deviceIds:[n]})),ie())}),A.addEventListener("message",O=>{if(typeof O.data=="string")return;const Z=O.data instanceof ArrayBuffer?O.data:null;if(!Z||Z.byteLength<5)return;const X=performance.now();k.lastPacketAt=X,(async()=>{try{const K=new DataView(Z).getUint32(0,!1);if(K<=0||K+4>Z.byteLength){ne();return}const ce=new Uint8Array(Z,4,K),W=JSON.parse(tp.decode(ce)),P=Z.slice(4+K),me=String(W.frameKind||W.kind||"").toLowerCase();if(W.type==="remote.audio.status"||me==="audio-status"){if(k.lastCaptureStatusAt=X,k.captureAlive=W.captureAlive===!0,k.helperAlive=W.helperAlive===!0,k.captureRestartCount=Math.max(0,Number(W.restartCount||0)||0),k.lastPcmAtEpochMs=Math.max(0,Number(W.lastPcmAtEpochMs||0)||0),k.silentForMs=Math.max(0,Number(W.silentForMs||0)||0),k.captureAgeMs=k.lastPcmAtEpochMs>0?Math.max(0,Date.now()-k.lastPcmAtEpochMs):k.silentForMs,k.captureAlive&&k.helperAlive){if(F=0,q=0,!$){b("");const xe=String(C.state)==="running",Ce=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=Rd;m(xe?Ce?"playing":"silent":"suspended")}}else $||m("stalled");return}const ge={deviceId:String(W.deviceId||""),frameSeq:Number(W.frameSeq||0),streamId:String(W.streamId||""),mimeType:String(W.mimeType||"audio/webm;codecs=opus"),sampleRate:Number(W.sampleRate||48e3),channels:Number(W.channels||2),capturedAt:String(W.capturedAt||""),receivedAt:String(W.receivedAt||""),byteLength:Number(W.byteLength||P.byteLength),payload:P};if(!ge.deviceId||E)return;if(performance.now()-X>Rx){ne();return}if(k.pendingDecodes>=d1){ne();return}k.pendingDecodes+=1;try{const xe=l1(ge.mimeType)?h1(C,ge,P):await C.decodeAudioData(P.slice(0));if(k.localProcessingAgeMs=Math.max(0,performance.now()-X),E)return;if(k.localProcessingAgeMs>Rx){ne();return}if(ge.frameSeq>0&&ge.frameSeq<=k.lastFrameSeq){ne();return}if(k.activeStreamId&&ge.streamId!==k.activeStreamId&&ge.frameSeq<=k.lastFrameSeq){ne();return}ge.streamId&&ge.streamId!==k.activeStreamId&&(k.activeStreamId=ge.streamId,k.lastFrameSeq=0,L());const Ce=C.currentTime;Math.max(0,c.current-Ce)>c1&&(L(),k.resyncs+=1);const ze=C.createBufferSource();ze.buffer=xe,ze.connect(C.destination),T.add(ze),ze.onended=()=>{T.delete(ze),ze.onended=null};const ue=Math.max(C.currentTime+u1,c.current);ze.start(ue),c.current=ue+xe.duration,k.browserAgeMs=Dx(ge.receivedAt),k.captureAgeMs=Dx(ge.capturedAt),k.lastAcceptedAt=performance.now(),k.framesReceived+=1,k.lastFrameSeq=ge.frameSeq,F=0,q=0,v(ge),ie();const Ye=String(C.state)==="running";Ye&&b(""),m(Ye?"playing":"suspended")}finally{k.pendingDecodes=Math.max(0,k.pendingDecodes-1)}}catch(D){E||(m("error"),b(D instanceof Error?D.message:String(D)))}})()}),A.addEventListener("error",()=>{E||(m("error"),b("Remote audio WebSocket error."))}),A.addEventListener("close",()=>{E||m("closed")}),()=>{E=!0,window.clearInterval(Q),C.removeEventListener("statechange",J),document.removeEventListener("visibilitychange",le),window.removeEventListener("pageshow",Y),window.removeEventListener("pointerdown",Y),window.removeEventListener("keydown",Y),L(!1),A.close(),C.close().catch(()=>{}),l.current===C&&(l.current=null)}},[n,a,r]),{state:d,lastFrame:p,stats:g,error:y}}const g1=3;function _x(n,a,r){const l=Math.max(1,Number(r)||1),c=Math.max(0,Math.min(l,Number(n)-Number(a))),d=Math.min(l/2,g1);return c<=d?0:c>=l-d?1:c/l}function v1(n,a,r){return{normalizedX:_x(n,r.left,r.width),normalizedY:_x(a,r.top,r.height)}}const ci=Object.freeze({smallDirectDeviceLimit:4,interactiveDirectFps:30,controlWallReuseMaxFps:30,scalableAtlasInputFps:8,atlasOutputFps:20,maxDirectFramesPerSecond:96,directDecodeAcceleration:"prefer-software",directLatencyMode:"interactive",configuredLatencyMode:"smooth"});function x1(n,a){const r=Math.max(0,Math.floor(Number(a)||0));return n===!0&&r>0&&r<=ci.smallDirectDeviceLimit}function Hc({mode4Enabled:n,directMode4WallEnabled:a,isMac:r}){return!n||a||r?"direct":"atlas"}function y1({mode4Enabled:n,directMode4WallEnabled:a,adaptiveFps:r,directDeviceCount:l}){const c=Math.max(1,Math.floor(Number(r)||1));if(!n)return c;if(a)return Math.max(ci.interactiveDirectFps,c);const d=Math.max(1,Math.floor(Number(l)||1));return Math.max(1,Math.min(c,Math.floor(ci.maxDirectFramesPerSecond/d)))}function w1(n,a){return n?{acceleration:ci.directDecodeAcceleration,latencyMode:ci.directLatencyMode}:{acceleration:a,latencyMode:ci.configuredLatencyMode}}const Dh={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}}},b1=[{id:"connection",label:"Connection",icon:Ro},{id:"security",label:"Security",icon:Bt},{id:"control",label:"Control",icon:tn},{id:"wall",label:"Wall",icon:tu},{id:"files-audio",label:"Files & Audio",icon:To},{id:"agent",label:"Agent",icon:Ll},{id:"advanced",label:"Advanced",icon:af}];function Cl(n,a){return n?.settings?.[a]||Dh.settings[a]}function ot({icon:n,title:a,description:r,children:l,disabled:c=!1,recommended:d=!1}){return s.jsxs("div",{className:`product-setting-row ${c?"disabled":""}`,children:[s.jsx("div",{className:"product-setting-control",children:l}),n&&s.jsx("span",{className:"product-setting-icon",children:s.jsx(n,{size:17})}),s.jsxs("div",{className:"product-setting-copy",children:[s.jsx("strong",{children:a}),d&&s.jsx("em",{children:"Recommended"}),s.jsx("small",{children:r})]})]})}function jt({checked:n,onChange:a,disabled:r=!1,label:l}){return s.jsxs("label",{className:"product-switch",children:[s.jsx("input",{"aria-label":l,type:"checkbox",checked:n,disabled:r,onChange:c=>a(c.target.checked)}),s.jsx("span",{})]})}function Yi({value:n,onChange:a,options:r,disabled:l=!1,label:c}){return s.jsx("select",{"aria-label":c,value:String(n),disabled:l,onChange:d=>a(d.target.value),children:r.map(([d,m])=>s.jsx("option",{value:d,children:m},d))})}function S1({hubUrl:n="",runtimeRole:a="hub",runtimeDeviceId:r="",sessionAccessToken:l="",initialTab:c="connection",pin:d,wall:m,control:p,agent:v,advancedExtras:g,captureGallery:w}){const[y,b]=u.useState(c),[j,C]=u.useState(null),[A,T]=u.useState("loading"),[k,E]=u.useState(""),[R,$]=u.useState("idle"),[F,q]=u.useState("");u.useEffect(()=>{let xe=!0;return T("loading"),Ue("/api/settings",void 0,n).then(Ce=>{xe&&(C({revision:Number(Ce.revision||0),updatedAt:Ce.updatedAt,settings:Ce.settings}),T("saved"))}).catch(Ce=>{xe&&(E(Ce instanceof Error?Ce.message:String(Ce)),C(Dh),T("failed"))}),()=>{xe=!1}},[n]);const L=async(xe,Ce,Le)=>{const ze=j||Dh,ue=ze,Ye={...ze,settings:{...ze.settings,[xe]:{...Cl(ze,xe),[Ce]:Le}}};C(Ye),T("saving"),E("");try{const We=await Ue("/api/settings",{method:"PATCH",body:JSON.stringify({revision:ze.revision,[xe]:{[Ce]:Le}})},n);C({revision:We.revision,updatedAt:We.updatedAt,settings:We.settings}),T("saved")}catch(We){C(ue),T("failed"),E(We instanceof Error?We.message:String(We))}},_=(xe,Ce)=>Le=>{L(xe,Ce,Le)},ie=async()=>{if(a!=="hub"||!r||!l){$("failed"),q("Sign in to this Hub before changing its runtime role.");return}$("changing"),q("");try{const xe=await Ue("/api/runtime/status",void 0,n);await Ue("/api/runtime/role",{method:"POST",headers:{Authorization:`Bearer ${l}`},body:JSON.stringify({role:"client"})},n),$("accepted"),await tw({baseUrl:n,targetRole:"client",previousRuntimePid:Number(xe.runtimePid||0),allowedStates:["running","waiting-auth"]}),tj(5179)}catch(xe){$("failed"),q(xe instanceof Error?xe.message:String(xe))}},V=Cl(j,"security"),ne=Cl(j,"connection"),Q=Cl(j,"control"),J=Cl(j,"wall"),le=Cl(j,"filesAudio"),Y=Cl(j,"agent"),O=u.useMemo(()=>V.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:V.requireEncryptedConnections&&V.requireNewDeviceApproval&&V.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."},[V]),Z=`settings-panel-${y}`,X=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"product-settings-hero",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"settings-eyebrow",children:[s.jsx(Ro,{size:14})," Connection"]}),s.jsx("h2",{children:"Connect a device"}),s.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."})]}),s.jsxs("div",{className:"product-save-state",role:"status",children:[s.jsx(Vy,{size:14})," ",A==="saving"?"Saving":A==="failed"?"Failed":A==="loading"?"Loading":"Saved"]})]}),d,s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Connection behavior"}),s.jsx("h3",{children:"New device access"})]}),s.jsx(_o,{size:20})]}),s.jsx(ot,{icon:_o,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:s.jsx(jt,{checked:!!ne.usePinToAddDevices,onChange:_("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),s.jsx(ot,{icon:Bt,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:s.jsx(jt,{checked:!!ne.approveNewDevices,onChange:_("connection","approveNewDevices"),label:"Approve new devices"})}),s.jsx(ot,{icon:ln,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:s.jsx(jt,{checked:!!ne.showConnectionNotifications,onChange:_("connection","showConnectionNotifications"),label:"Show connection notifications"})})]}),s.jsxs("section",{className:"settings-section-card runtime-role-settings",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Runtime role"}),s.jsx("h3",{children:"Use this computer as a Client"})]}),s.jsx(af,{size:20})]}),s.jsx("p",{className:"settings-help",children:"This stops the Hub listener, saves the Client role in Supabase, and restarts LiveDesk through the unified launcher."}),R==="accepted"?s.jsx("p",{className:"settings-help runtime-role-success",children:"Role change accepted. LiveDesk is restarting as Client."}):F?s.jsx("p",{className:"settings-help runtime-role-error",role:"alert",children:F}):null,s.jsx("button",{className:"settings-reset",onClick:()=>{ie()},disabled:R==="changing"||a!=="hub",type:"button",children:R==="changing"?"Switching role…":"Switch this computer to Client"})]})]}),D=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:`security-status-card ${O.tone}`,children:[s.jsxs("div",{children:[s.jsx("span",{children:"Security status"}),s.jsx("strong",{children:O.label}),s.jsx("small",{children:O.detail})]}),s.jsx(Bt,{size:28})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Access mode"}),s.jsx("h3",{children:"Who may use this Hub?"})]}),s.jsx(Ls,{size:20})]}),s.jsx(ot,{icon:Bt,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:s.jsx(Yi,{value:String(V.accessMode),onChange:_("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"]]})}),s.jsx(ot,{icon:Ro,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:s.jsx(jt,{checked:!!V.requireEncryptedConnections,onChange:_("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),s.jsx(ot,{icon:Ro,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:s.jsx(jt,{checked:!!V.allowInternetConnections,onChange:_("security","allowInternetConnections"),label:"Allow internet connections"})}),s.jsx(ot,{icon:tn,title:"Allow LAN connections",description:"Permit connections from the local network.",children:s.jsx(jt,{checked:!!V.allowLanConnections,onChange:_("security","allowLanConnections"),label:"Allow LAN connections"})}),s.jsx(ot,{icon:Bt,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:s.jsx(jt,{checked:!!V.requireNewDeviceApproval,onChange:_("security","requireNewDeviceApproval"),label:"Require approval for new devices"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Session protection"}),s.jsx("h3",{children:"End sessions safely"})]}),s.jsx(ln,{size:20})]}),s.jsx(ot,{icon:tn,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:s.jsx(jt,{checked:!!V.visibleControlIndicator,onChange:_("security","visibleControlIndicator"),label:"Show Control indicator"})}),s.jsx(ot,{icon:Ls,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:s.jsx(jt,{checked:!!V.lockOnControlEnd,onChange:_("security","lockOnControlEnd"),label:"Lock after Control ends"})}),s.jsx(ot,{icon:ln,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:s.jsx(jt,{checked:!!V.disconnectIdleControlSessions,onChange:_("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),s.jsx(ot,{icon:ln,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!V.disconnectIdleControlSessions,children:s.jsx(Yi,{value:Number(V.idleControlMinutes),onChange:xe=>_("security","idleControlMinutes")(Number(xe)),disabled:!V.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),K=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Remote use"}),s.jsx("h3",{children:"What can a connected user do?"})]}),s.jsx(tn,{size:20})]}),s.jsx(ot,{icon:tn,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:s.jsx(jt,{checked:!!Q.allowKeyboardMouse,onChange:_("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),s.jsx(ot,{icon:HS,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:s.jsx(jt,{checked:!!Q.allowSystemShortcuts,onChange:_("control","allowSystemShortcuts"),label:"System shortcuts"})}),s.jsx(ot,{icon:_o,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:s.jsx(jt,{checked:!!Q.allowClipboardText,onChange:_("control","allowClipboardText"),label:"Clipboard text sharing"})}),s.jsx(ot,{icon:ln,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!Q.allowKeyboardMouse,children:s.jsx(jt,{checked:!!Q.allowRemoteRestart,onChange:_("control","allowRemoteRestart"),disabled:!Q.allowKeyboardMouse,label:"Remote restart"})}),s.jsx(ot,{icon:tn,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:s.jsx(jt,{checked:!!Q.allowSwitchingMonitors,onChange:_("control","allowSwitchingMonitors"),label:"Switching monitors"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Session behavior"}),s.jsx("h3",{children:"Make Control predictable"})]}),s.jsx(In,{size:20})]}),s.jsx(ot,{icon:tn,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:s.jsx(jt,{checked:!!Q.openControlOnDoubleClick,onChange:_("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),s.jsx(ot,{icon:ln,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:s.jsx(jt,{checked:!!Q.startRemoteAudioWithControl,onChange:_("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),s.jsx(ot,{icon:tn,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:s.jsx(jt,{checked:!!Q.fitRemoteScreen,onChange:_("control","fitRemoteScreen"),label:"Fit remote screen"})}),s.jsx(ot,{icon:ln,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:s.jsx(jt,{checked:!!Q.keepControlReadyBetweenPages,onChange:_("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),ce=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Performance mode"}),s.jsx("h3",{children:"Let LiveDesk choose the best path"})]}),s.jsx(tu,{size:20})]}),s.jsx(ot,{icon:Ll,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:s.jsx(Yi,{value:String(J.performanceMode),onChange:_("wall","performanceMode"),label:"Performance mode",options:[["auto","Auto"],["responsive","Prioritize responsiveness"],["quality","Prioritize image quality"],["custom","Custom"]]})}),s.jsx("p",{className:"settings-help",children:"Streaming details are available under Advanced for diagnostics and development."})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Wall behavior"}),s.jsx("h3",{children:"What should the Wall show?"})]}),s.jsx(ln,{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(([xe,Ce,Le])=>s.jsx(ot,{icon:tn,title:Ce,description:Le,children:s.jsx(jt,{checked:!!J[xe],onChange:_("wall",xe),label:Ce})},xe))]})]}),W=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"File permissions"}),s.jsx("h3",{children:"Move files deliberately"})]}),s.jsx(To,{size:20})]}),s.jsx(ot,{icon:To,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:s.jsx(jt,{checked:!!le.allowFileTransfer,onChange:_("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),s.jsx(ot,{icon:tu,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!le.allowFileTransfer,children:s.jsx(jt,{checked:!!le.allowFolderSync,onChange:_("filesAudio","allowFolderSync"),disabled:!le.allowFileTransfer,label:"Allow folder sync"})}),s.jsx(ot,{icon:Bt,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:s.jsx(jt,{checked:!!le.askBeforeReceivingFiles,onChange:_("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),s.jsx(ot,{icon:To,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:s.jsx(jt,{checked:!!le.allowOverwrite,onChange:_("filesAudio","allowOverwrite"),label:"Allow overwrite"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Audio permissions"}),s.jsx("h3",{children:"Remote sound"})]}),s.jsx(ln,{size:20})]}),s.jsx(ot,{icon:ln,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:s.jsx(jt,{checked:!!le.allowRemoteAudio,onChange:_("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),s.jsx(ot,{icon:ln,title:"Start audio muted",description:"New audio sessions begin silent.",children:s.jsx(jt,{checked:!!le.startAudioMuted,onChange:_("filesAudio","startAudioMuted"),label:"Start audio muted"})}),s.jsx(ot,{icon:ln,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:s.jsx(jt,{checked:!!le.automaticallyRecoverAudio,onChange:_("filesAudio","automaticallyRecoverAudio"),label:"Automatically recover audio"})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Capture defaults"}),s.jsx("h3",{children:"Screen recording"})]}),s.jsx(tn,{size:20})]}),s.jsx(ot,{icon:ln,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:s.jsx(jt,{checked:!!le.rollingBufferEnabled,onChange:_("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),s.jsx(ot,{icon:ln,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:s.jsx(Yi,{value:String(le.recordingQuality),onChange:_("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),s.jsx(ot,{icon:ln,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:s.jsx(Yi,{value:Number(le.timelapseIntervalSeconds),onChange:xe=>_("filesAudio","timelapseIntervalSeconds")(Number(xe)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),s.jsx(ot,{icon:tn,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:s.jsx(jt,{checked:!!le.includeRemoteCursor,onChange:_("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),s.jsx(ot,{icon:To,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:s.jsx(Yi,{value:String(le.captureSaveLocation),onChange:_("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(le.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),s.jsx(ot,{icon:To,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:s.jsx(Yi,{value:String(le.captureAutoDelete),onChange:_("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),w]}),P=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Agent safety"}),s.jsx("h3",{children:"AI workstation operations"})]}),s.jsx(Ll,{size:20})]}),s.jsx(ot,{icon:Ll,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:s.jsx(jt,{checked:!!Y.enabled,onChange:_("agent","enabled"),label:"Enable AI Agent"})}),s.jsx(ot,{icon:Bt,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:s.jsx(Yi,{value:String(Y.defaultPermissionMode),onChange:_("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),s.jsx(ot,{icon:Bt,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!Y.enabled,children:s.jsx(jt,{checked:!!Y.askBeforeDestructive,onChange:_("agent","askBeforeDestructive"),disabled:!Y.enabled,label:"Ask before destructive operations"})}),s.jsx(ot,{icon:ln,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:s.jsx(jt,{checked:!!Y.keepAuditHistory,onChange:_("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),s.jsx(ot,{icon:ln,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:s.jsx(Yi,{value:Number(Y.timeoutMinutes),onChange:xe=>_("agent","timeoutMinutes")(Number(xe)),label:"Agent task timeout",options:[["1","1 minute"],["5","5 minutes"],["10","10 minutes"],["30","30 minutes"],["60","1 hour"]]})})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Detailed permissions"}),s.jsx("h3",{children:"Capabilities"})]}),s.jsx(Bt,{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(([xe,Ce])=>s.jsx(ot,{icon:Bt,title:Ce,description:xe.includes("allowCommand")||xe.includes("Installation")||xe.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:s.jsx(jt,{checked:!!Y[xe],onChange:_("agent",xe),label:Ce})},xe))]}),s.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),ge=y==="connection"?X:y==="security"?D:y==="control"?K:y==="wall"?ce:y==="files-audio"?W:y==="agent"?s.jsxs(s.Fragment,{children:[P,v]}):s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[g,s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Developer controls"}),s.jsx("h3",{children:"Streaming and diagnostics"})]}),s.jsx(af,{size:20})]}),s.jsx("p",{className:"settings-help",children:"Codec, frame rate, resolution, quality, Atlas layout, and decoder preferences are intentionally kept here."}),m,p]})]});return s.jsxs("section",{className:"settings-page",children:[s.jsx("div",{className:"settings-page-tabs",role:"tablist","aria-label":"LiveDesk settings",children:b1.map(({id:xe,label:Ce,icon:Le})=>s.jsxs("button",{className:y===xe?"active":"",id:`settings-tab-${xe}`,role:"tab","aria-selected":y===xe,"aria-controls":`settings-panel-${xe}`,tabIndex:y===xe?0:-1,onClick:()=>b(xe),type:"button",children:[s.jsx(Le,{size:16}),Ce]},xe))}),k&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:k}),s.jsx("section",{className:"settings-page-panel",id:Z,role:"tabpanel","aria-labelledby":`settings-tab-${y}`,tabIndex:0,children:ge})]})}function j1({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function C1({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function k1({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}const pw={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 Lx(n){return{...pw,...n||{}}}function A1({hubUrl:n}){const[a,r]=u.useState(pw),[l,c]=u.useState(null),[d,m]=u.useState(""),[p,v]=u.useState(""),[g,w]=u.useState(""),[y,b]=u.useState("");u.useEffect(()=>{let _=!0;return Ue("/api/settings/agent",void 0,n).then(ie=>{_&&(c(ie.settings),r(Lx(ie.settings)))}).catch(ie=>{_&&b(ie instanceof Error?ie.message:String(ie))}),()=>{_=!1}},[n]);const j=(_,ie)=>r(V=>({...V,[_]:ie})),C=_=>{c(_),r(Lx(_))},A=async()=>{v("save"),b(""),w("");try{const _={...a};d.trim()&&(_.apiKey=d.trim());const ie=await Ue("/api/settings/agent",{method:"PUT",body:JSON.stringify(_)},n);C(ie.settings),m(""),w("Agent settings saved.")}catch(_){b(_ instanceof Error?_.message:String(_))}finally{v("")}},T=async()=>{v("reset"),b("");try{const _=await Ue("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);C(_.settings),w("Codex defaults restored.")}catch(_){b(_ instanceof Error?_.message:String(_))}finally{v("")}},k=async()=>{v("test"),b(""),w("");try{const _=await Ue("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),ie=await Ue("/api/settings/agent",void 0,n);C(ie.settings),w(`Codex connection verified with ${_.connection?.modelName||"the configured model"}${_.connection?.latencyMs?` in ${_.connection.latencyMs} ms.`:"."}`)}catch(_){b(_ instanceof Error?_.message:String(_))}finally{v("")}},E=async()=>{v("clear-key"),b("");try{const _=await Ue("/api/settings/agent/api-key",{method:"DELETE"},n);C(_.settings),m(""),w("The optional OpenCode Go key was removed.")}catch(_){b(_ instanceof Error?_.message:String(_))}finally{v("")}},R=l?.codexInstallation==="installed"&&l.codexAuth==="signed-in",$=l?.securityStatus,F=$?.state||"unavailable",q=F==="verified"?"Verified":F==="configured"?"Configured":"Unavailable",L=[["Codex home",$?.isolatedCodexHome],["Environment variables",$?.restrictedEnvironment],["LiveDesk MCP only",$?.livedeskMcpOnly],["Selected-device scope",$?.selectedDeviceScopeEnforced],["Fail-closed execution",$?.failClosed]];return s.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[s.jsxs("header",{className:"agent-settings-header",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"settings-eyebrow",children:[s.jsx(ex,{size:14})," Agent AI"]}),s.jsx("h2",{children:"Codex SDK"}),s.jsx("p",{children:"Codex owns the agent reasoning loop. LiveDesk keeps the existing task manager and exposes only safe, read-only workstation tools."})]}),s.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,onChange:_=>j("enabled",_.target.checked)}),s.jsx("span",{children:"Enable Agent AI"})]})]}),y&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:y}),g&&s.jsx("div",{className:"agent-settings-alert success",role:"status",children:g}),s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Provider"}),s.jsx("h3",{children:"Codex is the default"})]}),s.jsx(_o,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Agent provider"}),s.jsxs("select",{value:a.provider,onChange:_=>j("provider",_.target.value),children:[s.jsx("option",{value:"codex",children:"Codex SDK"}),s.jsx("option",{value:"opencode-go",children:"OpenCode Go (optional legacy)"})]})]}),s.jsxs("div",{className:"agent-connection-row",children:[s.jsx("span",{className:`agent-connection-dot ${R?"connected":l?.codexAuth==="not-signed-in"?"unavailable":""}`}),s.jsx("span",{children:l?.codexInstallation==="not-installed"?"Codex SDK not installed":l?.codexAuth==="signed-in"?"Codex CLI signed in":l?.codexAuth==="not-signed-in"?"Codex CLI sign-in required":"Codex status not tested"}),s.jsxs("button",{className:"settings-reset",onClick:()=>{k()},disabled:p!==""||a.provider!=="codex",type:"button",children:[s.jsx($S,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),s.jsxs("p",{className:"settings-help",children:[s.jsx(US,{size:12})," Authentication is owned by the installed Codex CLI. LiveDesk never asks for or stores a ChatGPT token."]}),l?.codexPath&&s.jsxs("p",{className:"settings-help",children:["CLI: ",l.codexPath]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Codex runtime"}),s.jsx("h3",{children:"Model and reasoning"})]}),s.jsx(ex,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Model"}),s.jsx("input",{value:a.codexModelId,onChange:_=>j("codexModelId",_.target.value),placeholder:"Codex default",disabled:a.provider!=="codex"})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Reasoning effort"}),s.jsxs("select",{value:a.codexReasoningEffort,onChange:_=>j("codexReasoningEffort",_.target.value),disabled:a.provider!=="codex",children:[s.jsx("option",{value:"minimal",children:"Minimal"}),s.jsx("option",{value:"low",children:"Low"}),s.jsx("option",{value:"medium",children:"Medium"}),s.jsx("option",{value:"high",children:"High"}),s.jsx("option",{value:"xhigh",children:"Extra high"})]})]}),s.jsxs("div",{className:"settings-field-grid",children:[s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Task timeout (ms)"}),s.jsx("input",{type:"number",min:"30000",max:"1800000",step:"10000",value:a.codexTaskTimeoutMs,onChange:_=>j("codexTaskTimeoutMs",Number(_.target.value)),disabled:a.provider!=="codex"})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Max tool calls"}),s.jsx("input",{type:"number",min:"1",max:"100",value:a.codexMaxToolCalls,onChange:_=>j("codexMaxToolCalls",Number(_.target.value)),disabled:a.provider!=="codex"})]})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Workspace"}),s.jsx("h3",{children:"Restricted execution context"})]}),s.jsx(Bt,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Working directory"}),s.jsx("input",{value:l?.agentWorkspacePath||a.codexWorkingDirectory,readOnly:!0})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.codexResumeSessions,onChange:_=>j("codexResumeSessions",_.target.checked),disabled:a.provider!=="codex"}),s.jsx("span",{children:"Allow session resume"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.codexShowDetailedEvents,onChange:_=>j("codexShowDetailedEvents",_.target.checked),disabled:a.provider!=="codex"}),s.jsx("span",{children:"Show detailed Codex events"})]}),s.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"&&s.jsxs("section",{className:"settings-section-card agent-legacy-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Developer fallback"}),s.jsx("h3",{children:"OpenCode Go"})]}),s.jsx(_o,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{value:a.baseUrl,onChange:_=>j("baseUrl",_.target.value)})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"API key"}),s.jsx("input",{type:"password",value:d,onChange:_=>m(_.target.value),placeholder:l?.hasApiKey?l.apiKeyPreview:"Stored only in the Hub",autoComplete:"new-password"})]}),s.jsxs("div",{className:"settings-action-row",children:[s.jsxs("button",{className:"settings-reset",onClick:()=>{E()},disabled:p!==""||!l?.hasApiKey,type:"button",children:[s.jsx(Wh,{size:15})," Clear key"]}),s.jsx("span",{className:"settings-help",children:"This provider does not run the Codex MCP tool loop."})]})]}),s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Agent behavior"}),s.jsx("h3",{children:"Predictable operation"})]}),s.jsx(In,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:_=>j("deterministicParserFirst",_.target.checked)}),s.jsx("span",{children:"Use deterministic parser before Codex"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.generateSummary,onChange:_=>j("generateSummary",_.target.checked)}),s.jsx("span",{children:"Generate task summaries"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.fallbackSummary,onChange:_=>j("fallbackSummary",_.target.checked)}),s.jsx("span",{children:"Fallback to deterministic summaries"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.includeRawDeviceDetails,onChange:_=>j("includeRawDeviceDetails",_.target.checked)}),s.jsx("span",{children:"Include raw device details in summaries"})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Safety"}),s.jsx("h3",{children:"Locked execution boundary"})]}),s.jsx(Bt,{size:20})]}),["Arbitrary shell commands","PowerShell and Bash","Filesystem writes, deletes, and installs","Reboot, shutdown, and process termination","Network access and web search"].map(_=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Gy,{size:15}),s.jsx("span",{children:_}),s.jsx("strong",{children:"Blocked"})]},_)),L.map(([_])=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Bt,{size:15}),s.jsx("span",{children:_}),s.jsx("strong",{className:F==="unavailable"?"agent-safety-failed":F==="configured"?"agent-safety-configured":"agent-safety-verified",children:q})]},_)),s.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."})]})]}),s.jsxs("div",{className:"settings-action-row agent-settings-actions",children:[s.jsxs("button",{className:"settings-reset",onClick:()=>{T()},disabled:p!=="",type:"button",children:[s.jsx(Kc,{size:15})," Reset defaults"]}),s.jsxs("button",{className:"text-button primary",onClick:()=>{A()},disabled:p!=="",type:"button",children:[s.jsx(Vy,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function ui(n){const[a,r]=u.useState(n),l=u.useRef(n);return u.useEffect(()=>{if(l.current!==n){if(Array.isArray(l.current)&&Array.isArray(n)&&l.current.length===0&&n.length===0)return;l.current=n,r(n)}},[n]),[a,r]}function np(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function Fo(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}function N1(n,a="data-id"){const r=Fo(n,a);return r?r.getAttribute(a):null}function su(n,a="data-id"){const r=Fo(n,a);return r?vf(r,a):null}function vf(n,a="data-id"){const r=n.getAttribute(a);return r?M1(r):null}function On(n){return typeof n=="string"?":"+n:n}function M1(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function T1(){return{detect:()=>!0,addEvent:function(n,a,r){return n.addEventListener(a,r),()=>n.removeEventListener(a,r)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var Ia=T1();function ap(n){Object.assign(Ia,n)}function zx(n,a,r){function l(c){const d=Fo(c);if(!d)return;const m=vf(d);if(typeof a=="function")return a(m,c);let p,v=c.target;for(;v!=d;){if(p=v.dataset?v.dataset.action:null,p&&a[p]){a[p](m,c);return}v=v.parentNode}a[r]&&a[r](m,c)}Ia.addEvent(n,r,l)}function Po(n,a){zx(n,a,"click"),a.dblclick&&zx(n,a.dblclick,"dblclick")}function E1(n,a){for(let r=n.length-1;r>=0;r--)if(n[r]===a){n.splice(r,1);break}}function R1(n,a,r){for(let l=0;l<Qi.length;l++){if(l===r)continue;const c=Qi[l],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var gw=new Date,uf=!1,_d=[],Qi=[],Ix=n=>{const a=n.target;if(uf||!a.isConnected){uf=!1;return}for(let r=Qi.length-1;r>=0;r--){const{node:l,date:c,props:d}=Qi[r];if(!(c>gw)&&!l.contains(a)&&l!==a&&(R1(l,a,r)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},D1=n=>{gw=new Date,uf=!0;for(let a=Qi.length-1;a>=0;a--){const{node:r}=Qi[a];if(!r.contains(n.target)&&r!==n.target){uf=!1;break}}};function di(n,a){_d.length||(_d=[Ia.addGlobalEvent("click",Ix,n),Ia.addGlobalEvent("contextmenu",Ix,n),Ia.addGlobalEvent("mousedown",D1,n)]),typeof a!="object"&&(a={callback:a});const r={node:n,date:new Date,props:a};return Qi.push(r),{destroy(){E1(Qi,r),Qi.length||(_d.forEach(l=>l()),_d=[])}}}var Ld=n=>n.indexOf("bottom")!==-1,zd=n=>n.indexOf("left")!==-1,Id=n=>n.indexOf("right")!==-1,th=n=>n.indexOf("top")!==-1,Ox=n=>n.indexOf("fit")!==-1,$c=n=>n.indexOf("overlap")!==-1,_1=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),L1=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function z1(n,a){let r=0;const l=Ia.getTopNode(n);for(;n&&n!==l;){const c=getComputedStyle(n).position;if((c==="absolute"||c==="relative"||c==="fixed")&&(r=parseInt(getComputedStyle(n).zIndex)||0),n=n.parentNode,n===a)break}return r}var kn,ta,Uc,Wn;function vw(n,a,r="bottom",l=0,c=0){if(!n)return null;kn=l,ta=c,Uc="auto";let d=0,m=0,p=r;const v=xw(n),g=$c(r)?Ia.getTopNode(n):v;if(!v)return null;const w=v.getBoundingClientRect(),y=n.getBoundingClientRect(),b=g.getBoundingClientRect(),j=window.getComputedStyle(g),C={left:0,top:0,bottom:0,right:0};for(const $ in C){const F=`border-${$}-width`;C[$]=parseFloat(j.getPropertyValue(F))}if(a){const $=z1(a,v);d=Math.max($+1,20)}if(a){if(Wn=a.getBoundingClientRect(),Ox(r)&&(Uc=Wn.width+"px"),r!=="point")if(_1(r))Ox(r)?kn=0:(kn=b.width/2,m=1),ta=(b.height-y.height)/2;else{const $=$c(r)?0:1;kn=Id(r)?Wn.right+$:Wn.left-$,ta=Ld(r)?Wn.bottom+1:Wn.top;const F=L1(r);F&&(Id(r)||zd(r)?F==="center"?ta-=(y.height-Wn.height)/2:F==="end"&&(ta-=y.height-Wn.height):(Ld(r)||th(r))&&(F==="center"?kn-=(y.width-Wn.width)/2:F==="end"&&(kn-=y.width-Wn.width),$c(r)||(kn+=1)))}}else Wn={left:l,right:l,top:c,bottom:c};const A=(zd(r)||Id(r))&&(Ld(r)||th(r));zd(r)&&(m=2);const T=kn-y.width-b.left;a&&zd(r)&&!A&&T<0&&(kn=Wn.right,m=0,p=p.replace("left","right"));const k=kn+y.width*(1-m/2)-b.right;if(k>0)if(!Id(r))kn=b.right-C.right-y.width;else{const $=Wn.left-b.x-y.width;a&&!A&&$>=0?(kn=Wn.left-y.width,p=p.replace("right","left")):kn-=k+C.right}m&&(kn=Math.round(kn-y.width*m/2));const E=T<0||k>0||!A;th(r)&&(ta=Wn.top-y.height,a&&ta<b.y&&E&&(ta=Wn.bottom,p=p.replace("top","bottom")));const R=ta+y.height-b.bottom;return R>0&&(a&&Ld(r)&&E?(ta-=y.height+Wn.height+1,p=p.replace("bottom","top")):ta-=R+C.bottom),kn-=w.left+C.left,ta-=w.top+C.top,kn=($c(r)?kn:Math.max(kn,0))+g.scrollLeft,ta=($c(r)?ta:Math.max(ta,0))+g.scrollTop,Uc=Uc||"auto",{at:p,x:kn,y:ta,z:d,width:Uc}}function xw(n){const a=Ia.getTopNode(n);for(n&&(n=n.parentElement);n;){const r=getComputedStyle(n).position;if(n===a||r==="relative"||r==="absolute"||r==="fixed")return n;n=n.parentNode}return null}function I1(n){const a=[];let r=n;const l=Ia.getTopNode(n);for(;r&&r!==l&&!r.getAttribute("data-wx-portal-root");)getComputedStyle(r).position==="absolute"&&a.push(r),r=r.parentNode;return a}var Bx=new Date().valueOf();function sp(){return Bx+=1,Bx}function aa(n){return n<10?"0"+n:n.toString()}function O1(n){const a=aa(n);return a.length==2?"0"+a:a}function yw(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function nh(n){const a=(n.getDay()+6)%7,r=new Date(n.valueOf());r.setDate(n.getDate()+(3-a)),r.setHours(0,0,0,0);const l=new Date(r.getFullYear(),0,1),c=Math.round((r.getTime()-l.getTime())/864e5);return 1+Math.floor(c/7)}var Fx=["",""];function B1(n,a,r){switch(n){case"%d":return aa(a.getDate());case"%m":return aa(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return aa(a.getFullYear()%100);case"%Y":return a.getFullYear();case"%D":return r.dayShort[a.getDay()];case"%l":return r.dayFull[a.getDay()];case"%M":return r.monthShort[a.getMonth()];case"%F":return r.monthFull[a.getMonth()];case"%h":return aa((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return aa(a.getHours());case"%i":return aa(a.getMinutes());case"%a":return((a.getHours()>11?r.pm:r.am)||Fx)[0];case"%A":return((a.getHours()>11?r.pm:r.am)||Fx)[1];case"%s":return aa(a.getSeconds());case"%S":return O1(a.getMilliseconds());case"%W":return aa(nh(a));case"%w":{const l=r.weekStart??1;if(l===1)return aa(nh(a));const c=(a.getDay()-l+7)%7,d=(1-l+7)%7,m=new Date(a.valueOf());return m.setDate(a.getDate()+(d-c)),aa(nh(m))}case"%c":{let l=a.getFullYear()+"";return l+="-"+aa(a.getMonth()+1),l+="-"+aa(a.getDate()),l+="T",l+=aa(a.getHours()),l+=":"+aa(a.getMinutes()),l+=":"+aa(a.getSeconds()),l}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var F1=/%[a-zA-Z]/g;function Lo(n,a){return typeof n=="function"?n:function(r){return r?(r.getMonth||(r=new Date(r)),n.replace(F1,l=>B1(l,r,a))):""}}function Px(n){return n&&typeof n=="object"&&!Array.isArray(n)}function _h(n,a){for(const r in a){const l=a[r];Px(n[r])&&Px(l)?n[r]=_h({...n[r]},a[r]):n[r]=a[r]}return n}function ru(n){return{getGroup(a){const r=n[a];return l=>r&&r[l]||l},getRaw(){return n},extend(a,r){if(!a)return this;let l;return r?l=_h({...a},n):l=_h({...n},a),ru(l)}}}var P1=Zy();const H1="en-US",$1={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},U1={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},q1={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},ww={core:U1,calendar:$1,formats:q1,lang:H1},ip=u.createContext(""),bw=u.createContext({}),Os=u.createContext(null),Sw=u.createContext(null),Fn=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Sw,helpers:bw,i18n:Os,theme:ip},Symbol.toStringTag,{value:"Module"}));function jw(n){const a=u.useContext(Sw),[r]=u.useState(()=>n||a||sp());return r}function Jc({type:n="",css:a="",icon:r="",disabled:l=!1,title:c="",tooltip:d,text:m="",children:p,onClick:v}){const g=u.useMemo(()=>{let y=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+y},[n,a]),w=y=>{v&&v(y)};return s.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${g} ${r&&!p?"wx-icon":""}`,disabled:l,onClick:w,"data-tooltip-text":d,children:[r&&s.jsx("i",{className:"wx-2ZWgb4 "+r}),p||m||" "]})}function G1({id:n,label:a="",inputValue:r="",value:l=!1,onChange:c,disabled:d=!1,css:m=""}){const p=jw(n),[v,g]=ui(l),w=({target:y})=>{const b=y.checked;g(b),c&&c({value:b,inputValue:r})};return s.jsxs("div",{className:`wx-2IvefP wx-checkbox ${m}`,children:[s.jsx("input",{type:"checkbox",id:p,disabled:d,className:"wx-2IvefP wx-check",checked:v,value:r,onChange:w}),s.jsxs("label",{htmlFor:p,className:"wx-2IvefP wx-label",children:[s.jsx("span",{className:"wx-2IvefP wx-before"}),a&&s.jsx("span",{className:"wx-2IvefP wx-after",children:a})]})]})}function rp({theme:n="",target:a,children:r}){const l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(null);l.current||(l.current=document.createElement("div"));const p=u.useContext(ip);return u.useEffect(()=>{m(a||V1(c.current)||Ia.getTopNode(c.current))},[c.current]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?P1.createPortal(s.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:r}),d):null]})}function V1(n){const a=Ia.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function Y1({left:n=0,top:a=0,at:r="bottom",parent:l=null,width:c="auto",css:d="",onCancel:m,children:p,trackScroll:v=!1}){const[g,w]=u.useState(0),[y,b]=u.useState(0),[j,C]=u.useState("auto"),[A,T]=u.useState(!1),k=u.useRef(null),E=u.useRef(null),R=u.useRef(m);u.useEffect(()=>{R.current=m},[m]);function $(q){return l&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(L,_)=>(_=_*l.offsetWidth/100+"px",c.replace(L,_))):c&&c!=="auto"?c:q}const F=u.useCallback(()=>{if(!k.current)return;const q=vw(k.current,l,r,n,a);q&&(w(q.x),b(q.y),C($(q.width)))},[k,l,r,n,a,c]);return u.useLayoutEffect(()=>{const q=_=>{R.current&&_.target!==E.current&&k.current&&!k.current.contains(_.target)&&R.current(_)};let L;return requestAnimationFrame(()=>{F(),T(!0),v&&k.current&&(E.current=xw(k.current),E.current&&E.current.addEventListener("scroll",q,!0)),l&&(L=new ResizeObserver(F),L.observe(l))}),()=>{v&&E.current&&E.current.removeEventListener("scroll",q,!0),L?.disconnect()}},[]),u.useLayoutEffect(()=>{F()},[l,r,n,a]),u.useEffect(()=>{const q=L=>{R.current&&R.current(L)};if(k.current)return di(k.current,{callback:q,parent:()=>l}).destroy},[l]),s.jsx("div",{ref:k,className:["wx-37M6Fj","wx-popup",d].filter(Boolean).join(" "),style:{position:"absolute",visibility:A?"visible":"hidden",top:y+"px",left:g+"px",width:j},children:p})}function W1({position:n="bottom",align:a="start",autoFit:r=!0,onCancel:l=null,width:c="100%",css:d="",children:m}){const p=u.useRef(null),[v,g]=u.useState(n),[w,y]=u.useState(a),b=u.useRef(l);return u.useEffect(()=>{b.current=l},[l]),u.useEffect(()=>{if(r){const j=p.current;if(j){const C=j.getBoundingClientRect(),A=document.body.getBoundingClientRect();C.right>=A.right&&y("end"),C.bottom>=A.bottom&&g("top")}}},[]),u.useEffect(()=>{if(p.current){const j=C=>{b.current&&b.current(C)};return di(p.current,j).destroy}},[]),s.jsx("div",{ref:p,className:["wx-dropdown",`wx-${v}-${w}`,d||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:m})}function lp({position:n="bottom",align:a="start",autoFit:r=!0,inline:l=!1,onCancel:c,width:d="100%",children:m,...p}){const[v,g]=u.useState(void 0),w=u.useRef(null),y=u.useMemo(()=>`${n}-${a}`,[n,a]);return u.useLayoutEffect(()=>{w.current&&g(w.current.parentNode)},[]),s.jsxs(s.Fragment,{children:[v&&(l?s.jsx(W1,{onCancel:c,position:n,align:a,autoFit:r,width:d,...p,children:m}):s.jsx(rp,{children:s.jsx(Y1,{parent:v,at:y,onCancel:c,width:d,...p,children:m})})),s.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function xf(){return ru(ww)}function K1(){let n=null,a=!1,r=!1,l,c,d,m;const p=(y,b,j,C,A)=>{l=y,c=b,d=j,m=C,r=A},v=y=>{n=y,a=n!==null,d(n)},g=(y,b)=>{if(!r&&y!==null&&l){const j=l.querySelectorAll(".wx-list > .wx-item")[y];j&&(j.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(y,b)=>{const j=y===null?null:Math.max(0,Math.min(n+y,c.length-1));j!==n&&(v(j),l?g(j,b):requestAnimationFrame(()=>g(j,b)))};return{move:y=>{const b=su(y),j=c.findIndex(C=>C.id===b);j!==n&&v(j)},keydown:(y,b)=>{switch(y.code){case"Enter":a?m():v(0);break;case"Space":a||v(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":w(a?1:b||0,y);break;case"ArrowUp":w(a?-1:b||0,y);break}},init:p,navigate:w}}const Hx=10,Q1=u.memo(function({data:n,checkboxes:a,itemTemplate:r,value:l}){return s.jsxs(s.Fragment,{children:[a&&s.jsx(G1,{id:n.id,css:"wx-list-checkbox",value:l&&l.includes(n.id)}),r?np(r,{option:n}):n.label]})});function $x({visibleItems:n,visibleRange:a,navIndex:r,checkboxes:l,itemTemplate:c,value:d,measureRefCallback:m}){return n.map((p,v)=>{const g=a.start+v;return s.jsx("div",{ref:v===0?m:void 0,className:`wx-233fr7 wx-item ${g===r?"wx-focus":""}`,"data-id":p.id,children:s.jsx(Q1,{data:p,checkboxes:l,itemTemplate:c,value:d})},p.id)})}function yf({items:n=[],children:a,onSelect:r,onReady:l,virtualized:c=!1,checkboxes:d,multiselect:m,value:p,...v}){const g=u.useRef(),w=u.useRef(!1),y=u.useRef(K1()),[b,j]=u.useState(null),C=u.useRef(b),[A,T]=u.useState(0),[k,E]=u.useState(24),R=u.useRef(!1),$=(u.useContext(Os)||xf()).getGroup("core"),F=u.useRef(n);u.useEffect(()=>{F.current=n},[n]);const q=u.useRef(p);u.useEffect(()=>{q.current=p},[p]);const L=u.useRef(0);u.useEffect(()=>{L.current=k},[k]);const _=u.useCallback(W=>{W&&W.stopPropagation();const P=F.current,me=q.current,ge=C.current;let xe;const Ce=P[ge]?.id;m?me&&me.includes(Ce)?xe=me.filter(Le=>Le!==Ce):xe=[...me||[],Ce]:xe=Ce,r&&r({id:xe})},[m,r]),ie=u.useRef(_);u.useEffect(()=>{ie.current=_},[_]);const V=u.useCallback(W=>{if(g.current){let P=W*L.current-g.current.clientHeight+L.current;T(P),g.current.scrollTop=P}},[L.current]),ne=u.useCallback(W=>{g.current=W,c&&(W&&!w.current&&C.current!==null&&requestAnimationFrame(()=>{g.current&&(V(C.current),w.current=!0)}),W||(w.current=!1))},[V]),Q=u.useCallback(W=>{if(!W||R.current)return;const P=W.getBoundingClientRect().height;P&&(E(P),L.current=P,R.current=!0)},[]);u.useEffect(()=>{y.current.init(g.current,n,W=>{j(W),C.current=W},W=>ie.current(W),c)},[n,g.current,c]),u.useEffect(()=>{const W=(me,ge)=>{y.current.navigate(me,ge),V(C.current)},P=(me,ge)=>{const xe=C.current,Ce=F.current;if(xe!==0&&xe!==Ce.length-1&&(me.key==="ArrowDown"||me.key==="ArrowUp")&&me.preventDefault(),y.current.keydown(me,ge),g.current){const Le=g.current.scrollTop<=C.current*L.current,ze=g.current.scrollTop+g.current.clientHeight>=C.current*L.current+L.current;Le?ze||V(C.current):(g.current.scrollTop=C.current*L.current,T(g.current.scrollTop))}};l&&l({navigate:c?W:y.current.navigate,keydown:c?P:y.current.keydown,move:y.current.move})},[]);const J=u.useRef(0),le=u.useRef(n);le.current!==n&&(le.current=n,J.current+=1);const Y=u.useCallback(()=>{y.current.navigate(null)},[y]),O=u.useCallback(W=>{c&&T(W.target.scrollTop)},[c]),Z=u.useMemo(()=>Math.ceil((g.current?.clientHeight||0)/k),[k,A]),X=u.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const W=Math.floor(A/k),P=W+Z;return{start:Math.max(0,W-Hx),end:Math.min(n.length,P+Hx)}},[c,n,A,k,Z]),D=u.useMemo(()=>{if(!c)return n;const{start:W,end:P}=X;return n.slice(W,P).map(me=>({...me}))},[c,n,X]),K=X.start*k,ce=n.length*k;return u.useEffect(()=>{c&&T(0)},[n,c]),u.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:s.jsx(lp,{onCancel:Y,...v,children:s.jsx("div",{className:"wx-233fr7 wx-list",ref:ne,onClick:_,onMouseMove:y.current.move,onScroll:O,children:n.length?c?s.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${ce}px`},children:s.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${K}px)`},children:s.jsx($x,{visibleRange:X,visibleItems:D,navIndex:b,measureRefCallback:Q,checkboxes:d,itemTemplate:a,value:p})})}):s.jsx($x,{visibleRange:X,visibleItems:D,navIndex:b,measureRefCallback:Q,checkboxes:d,itemTemplate:a,value:p}):s.jsx("div",{className:"wx-233fr7 wx-no-data",children:$("No data")})})},J.current)}function op({value:n="",id:a,readonly:r=!1,focus:l=!1,select:c=!1,type:d="text",placeholder:m="",disabled:p=!1,error:v=!1,title:g="",tooltip:w,css:y="",icon:b="",clear:j=!1,onChange:C}){const A=jw(a),[T,k]=ui(n),E=u.useRef(null),R=u.useMemo(()=>b&&y.indexOf("wx-icon-left")===-1?"wx-icon-right "+y:y,[b,y]),$=u.useMemo(()=>b&&y.indexOf("wx-icon-left")!==-1,[b,y]);u.useEffect(()=>{const ie=setTimeout(()=>{l&&E.current&&E.current.focus(),c&&E.current&&E.current.select()},1);return()=>clearTimeout(ie)},[l,c]);const F=u.useCallback(ie=>{const V=ie.target.value;k(V),C&&C({value:V,input:!0})},[C]),q=u.useCallback(ie=>C&&C({value:ie.target.value}),[C]);function L(ie){ie.stopPropagation(),k(""),C&&C({value:""})}let _=d;return d!=="password"&&d!=="number"&&(_="text"),u.useEffect(()=>{const ie=q,V=E.current;return V.addEventListener("change",ie),()=>{V&&V.removeEventListener("change",ie)}},[q]),s.jsxs("div",{className:`wx-hQ64J4 wx-text ${R} ${v?"wx-error":""} ${p?"wx-disabled":""} ${j?"wx-clear":""}`,"data-tooltip-text":w,children:[s.jsx("input",{className:"wx-hQ64J4 wx-input",ref:E,id:A,readOnly:r,disabled:p,placeholder:m,type:_,title:g,value:T,onInput:F}),j&&!p&&T?s.jsxs(s.Fragment,{children:[s.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:L}),$&&s.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?s.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function X1({date:n,type:a,part:r,onShift:l}){const{calendar:c,formats:d}=u.useContext(Os).getRaw(),m=n.getFullYear(),p=u.useMemo(()=>{switch(a){case"month":return Lo(d.monthYearFormat,c)(n);case"year":return Lo(d.yearFormat,c)(n);case"duodecade":{const{start:g,end:w}=yw(m),y=Lo(d.yearFormat,c);return`${y(new Date(g,0,1))} - ${y(new Date(w,11,31))}`}default:return""}},[n,a,m,c,d]);function v(){l&&l({diff:0,type:a})}return s.jsxs("div",{className:"wx-8HQVQV wx-header",children:[r!=="right"?s.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-left",onClick:()=>l&&l({diff:-1,type:a})}):s.jsx("span",{className:"wx-8HQVQV wx-spacer"}),s.jsx("span",{className:"wx-8HQVQV wx-label",onClick:v,children:p}),r!=="left"?s.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-right",onClick:()=>l&&l({diff:1,type:a})}):s.jsx("span",{className:"wx-8HQVQV wx-spacer"})]})}function cp({onClick:n,children:a}){return s.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function Z1({value:n,current:a,part:r="",markers:l=null,css:c="",onCancel:d,onChange:m}){const p=(u.useContext(Os)||xf()).getRaw().calendar,v=(p.weekStart||7)%7,g=p.dayShort.slice(v).concat(p.dayShort.slice(0,v)),w=(F,q,L)=>new Date(F.getFullYear(),F.getMonth()+(q||0),F.getDate()+(L||0));let y=r!=="normal";function b(F){const q=F.getDay();return q===0||q===6}function j(){const F=w(a,0,1-a.getDate());return F.setDate(F.getDate()-(F.getDay()-(v-7))%7),F}function C(){const F=w(a,1,-a.getDate());return F.setDate(F.getDate()+(6-F.getDay()+v)%7),F}const A=u.useRef(0);function T(F,q){q.timeStamp!==A.current&&(A.current=q.timeStamp,q.stopPropagation(),m&&m(new Date(F)),d&&d())}const k=u.useMemo(()=>r=="normal"?[n?w(n).valueOf():0]:n?[n.start?w(n.start).valueOf():0,n.end?w(n.end).valueOf():0]:[0,0],[r,n]),E=u.useMemo(()=>{const F=j(),q=C(),L=a.getMonth();let _=[];for(let ie=F;ie<=q;ie.setDate(ie.getDate()+1)){const V={day:ie.getDate(),in:ie.getMonth()===L,date:ie.valueOf()};let ne="";if(ne+=V.in?"":" wx-inactive",ne+=k.indexOf(V.date)>-1?" wx-selected":"",y){const Q=V.date==k[0],J=V.date==k[1];Q&&!J?ne+=" wx-left":J&&!Q&&(ne+=" wx-right"),V.date>k[0]&&V.date<k[1]&&(ne+=" wx-inrange")}if(ne+=b(ie)?" wx-weekend":"",l){const Q=l(ie);Q&&(ne+=" "+Q)}_.push({...V,css:ne})}return _},[a,k,y,l]),R=u.useRef(null);let $=u.useRef({});return $.current.click=T,u.useEffect(()=>{Po(R.current,$.current)},[]),s.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[s.jsx("div",{className:"wx-398RBS wx-weekdays",children:g.map(F=>s.jsx("div",{className:"wx-398RBS wx-weekday",children:F},F))}),s.jsx("div",{className:"wx-398RBS wx-days",ref:R,children:E.map(F=>s.jsx("div",{className:`wx-398RBS wx-day ${F.css} ${F.in?"":"wx-out"}`,"data-id":F.date,children:F.day},F.date))})]})}function J1({value:n,current:a,part:r,onCancel:l,onChange:c,onShift:d}){const m=u.useRef(new Date),[p,v]=ui(n||m.current),[g,w]=ui(a||m.current),y=u.useContext(Os).getRaw().calendar,b=y.monthShort||[],j=u.useMemo(()=>g.getMonth(),[g]),C=u.useCallback((k,E)=>{if(k!=null){E.stopPropagation();const R=new Date(g);R.setMonth(k),w(R),d&&d({current:R})}r==="normal"&&v(new Date(g)),l&&l()},[g,r,d,l]),A=u.useCallback(()=>{const k=new Date(Cw(p,r)||g);k.setMonth(g.getMonth()),k.setFullYear(g.getFullYear()),c&&c(k)},[p,g,r,c]),T=u.useCallback(k=>{const E=k.target.closest("[data-id]");if(E){const R=parseInt(E.getAttribute("data-id"),10);C(R,k)}},[C]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-34U8T8 wx-months",onClick:T,children:b.map((k,E)=>s.jsx("div",{className:"wx-34U8T8 wx-month"+(j===E?" wx-current":""),"data-id":E,children:k},E))}),s.jsx("div",{className:"wx-34U8T8 wx-buttons",children:s.jsx(cp,{onClick:A,children:y.done})})]})}const ah="wx-1XEF33",eC=({value:n,current:a,onCancel:r,onChange:l,onShift:c,part:d})=>{const m=u.useContext(Os).getRaw().calendar,[p,v]=ui(a),[g,w]=ui(n),y=u.useMemo(()=>p.getFullYear(),[p]),b=u.useMemo(()=>{const{start:k,end:E}=yw(y),R=[];for(let $=k;$<=E;++$)R.push($);return R},[y]),j={click:C};function C(k,E){if(k){E.stopPropagation();const R=new Date(p);R.setFullYear(k),v(R),c&&c({current:R})}d==="normal"&&w(new Date(p)),r&&r()}function A(){const k=new Date(Cw(g,d)||p);k.setFullYear(p.getFullYear()),l&&l(k)}const T=u.useRef(null);return u.useEffect(()=>{T.current&&Po(T.current,j)},[]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ah+" wx-years",ref:T,children:b.map((k,E)=>s.jsx("div",{className:ah+` wx-year ${y==k?"wx-current":""} ${E===0?"wx-prev-decade":""} ${E===11?"wx-next-decade":""}`,"data-id":k,children:k},E))}),s.jsx("div",{className:ah+" wx-buttons",children:s.jsx(cp,{onClick:A,children:m.done})})]})},Ux={month:{component:Z1,next:nC,prev:tC},year:{component:J1,next:sC,prev:aC},duodecade:{component:eC,next:rC,prev:iC}};function tC(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function nC(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function aC(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function sC(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function iC(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function rC(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Cw(n,a){let r;if(a==="normal")r=n;else{const{start:l,end:c}=n;a==="left"?r=l:a=="right"?r=c:r=l&&c}return r}const lC=["clear","today"];function oC(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function cC({value:n,current:a,onCurrentChange:r,part:l="normal",markers:c=null,buttons:d,css:m="",onShift:p,onChange:v}){const g=u.useContext(Os).getGroup("calendar"),[w,y]=u.useState("month"),b=Array.isArray(d)?d:d?lC:[],j=(E,R)=>{E.preventDefault(),v&&v({value:R})},C=()=>{w==="duodecade"?y("year"):w==="year"&&y("month")},A=E=>{const{diff:R,current:$}=E;if(R===0){w==="month"?y("year"):w==="year"&&y("duodecade");return}if(R){const F=Ux[w];r(R>0?F.next(a):F.prev(a))}else $&&r($);p&&p()},T=E=>{y("month"),v&&v({select:!0,value:E})},k=u.useMemo(()=>Ux[w].component,[w]);return s.jsx("div",{className:`wx-2Gr4AS wx-calendar ${l!=="normal"&&l!=="both"?"wx-part":""} ${m}`,children:s.jsxs("div",{className:"wx-2Gr4AS wx-wrap",children:[s.jsx(X1,{date:a,part:l,type:w,onShift:A}),s.jsxs("div",{children:[s.jsx(k,{value:n,current:a,onCurrentChange:r,part:l,markers:c,onCancel:C,onChange:T,onShift:A}),w==="month"&&b.length>0&&s.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(E=>s.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:s.jsx(cp,{onClick:R=>j(R,oC(E)),children:g(E)})},E))})]})]})})}function up(n){let{words:a=null,optional:r=!1,children:l}=n,c=u.useContext(Os);const d=u.useMemo(()=>{let m=c;return(!m||!m.extend)&&(m=ru(ww)),a!==null&&(m=m.extend(a,r)),m},[a,r,c]);return s.jsx(Os.Provider,{value:d,children:l})}function qx(n,a,r,l){if(!n||l){const c=a?new Date(a):new Date;c.setDate(1),r(c)}else if(n.getDate()!==1){const c=new Date(n);c.setDate(1),r(c)}}const uC=["clear","today"];function kw({value:n,current:a,markers:r=null,buttons:l=uC,css:c="",onChange:d}){const[m,p]=ui(n),[v,g]=ui(a);u.useEffect(()=>{qx(v,m,g,!1)},[m,v]);const w=u.useCallback(b=>{const j=b.value;j?(p(new Date(j)),qx(v,new Date(j),g,!0)):p(null),d&&d({value:j?new Date(j):null})},[d,v]),y=u.useCallback(b=>{g(b)},[g]);return v?s.jsx(up,{children:s.jsx(cC,{value:m,current:v,markers:r,buttons:l,css:c,onChange:w,onCurrentChange:y})}):null}function dC(n){return n||(n={}),n.width||(n.width="unset"),n}const fC=["clear","today"];function mC({value:n,id:a,disabled:r=!1,error:l=!1,placeholder:c="",format:d="",buttons:m=fC,css:p="",title:v="",tooltip:g,editable:w=!1,clear:y=!1,onChange:b,dropdown:j={}}){const{calendar:C,formats:A}=(u.useContext(Os)||xf()).getRaw(),T=d||A?.dateFormat;let k=typeof T=="function"?T:Lo(T,C);const[E,R]=u.useState(n),[$,F]=u.useState(!1);u.useEffect(()=>{R(n)},[n]);function q(){F(!1)}function L(V){const ne=V===E||V&&E&&V.valueOf()===E.valueOf()||!V&&!E;R(V),ne||b&&b({value:V}),setTimeout(q,1)}const _=u.useMemo(()=>E?k(E):"",[E,k]);function ie({value:V,input:ne}){if(!w&&!y||ne)return;let Q=typeof w=="function"?w(V):V?new Date(V):null;Q=isNaN(Q)?E||null:Q||null,L(Q)}return u.useEffect(()=>{const V=q;return window.addEventListener("scroll",V),()=>window.removeEventListener("scroll",V)},[]),s.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>F(!0),children:[s.jsx(op,{css:`wx-date-input ${p}`,title:v,tooltip:g,value:_,id:a,readonly:!w,disabled:r,error:l,placeholder:c,onInput:q,onChange:ie,icon:"wxi-calendar",clear:y}),$&&!r&&s.jsx(lp,{onCancel:q,...dC(j),children:s.jsx(kw,{buttons:m,value:E,onChange:V=>L(V.value)})})]})}function hC({value:n="",options:a=[],textOptions:r=null,placeholder:l="",disabled:c=!1,error:d=!1,title:m="",tooltip:p,textField:v="label",clear:g=!1,css:w="",children:y,onChange:b,dropdown:j={}}){const C=u.useRef(null),A=u.useRef(null);let[T,k]=ui(n);function E(L){C.current=L.navigate,A.current=L.keydown}const R=u.useMemo(()=>T||T===0?(r||a).find(L=>L.id===T):null,[T,r,a]),$=u.useCallback(({id:L})=>{(L||L===0)&&(k(L),C.current(null),b&&b({value:L}))},[k,b]),F=u.useCallback(L=>{L.stopPropagation(),k(""),b&&b({value:""})},[k,b]),q=u.useCallback(()=>a.findIndex(L=>L.id===T),[a,T]);return s.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${y?"":"wx-2YgblL wx-nowrap"}`,title:m,onClick:()=>C.current(q()),onKeyDown:L=>A.current(L,q()),tabIndex:0,"data-tooltip-text":p,children:[s.jsx("div",{className:"wx-2YgblL wx-label",children:R?y?y(R):R[v]:l?s.jsx("span",{className:"wx-2YgblL wx-placeholder",children:l}):" "}),g&&!c&&T?s.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:F}):s.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&s.jsx(yf,{items:a,onReady:E,onSelect:$,...j,children:({option:L})=>y?y(L):L[v]})]})}const pC=({options:n=[],value:a="",css:r="",children:l,onChange:c})=>{const[d,m]=u.useState(a),p=v=>{m(v),c&&c({value:v})};return u.useEffect(()=>{m(a)},[a]),s.jsx("div",{className:`wx-0hMO7P wx-segmented ${r}`,children:n.map(v=>s.jsx("button",{className:`wx-0hMO7P wx-segment ${v.css} ${v.id===d?"wx-selected":""}`,title:v.title,onClick:()=>p(v.id),"data-tooltip-text":v.tooltip,children:l?np(l,{option:v}):s.jsxs(s.Fragment,{children:[v.icon&&s.jsx("i",{className:`wx-0hMO7P wx-icon ${v.icon} ${v.label?"":"wx-only"}`}),v.label&&s.jsx("span",{className:"wx-0hMO7P wx-label",children:v.label})]})},v.id))})};function gC({notice:n={}}){function a(){n.remove&&n.remove()}return s.jsxs("div",{className:`wx-11sNg5 wx-notice wx-${n.type?n.type:""}`,role:"status","aria-live":"polite",children:[s.jsx("div",{className:"wx-11sNg5 wx-text",children:n.text}),s.jsx("div",{className:"wx-11sNg5 wx-button",children:s.jsx("i",{className:"wx-11sNg5 wxi-close",onClick:a})})]})}function vC({data:n=[]}){return s.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>s.jsx(gC,{notice:a},a.id))})}function Lh({title:n="",buttons:a=["cancel","ok"],header:r,children:l,footer:c,css:d="",onConfirm:m,onCancel:p}){const v=(u.useContext(Os)||xf()).getGroup("core"),g=u.useRef(null);u.useEffect(()=>{g.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const j=b.target.tagName;if(j==="TEXTAREA"||j==="BUTTON")return;m&&m({event:b});break}case"Escape":p&&p({event:b});break}}function y(b,j){const C={event:b,button:j};j==="cancel"?p&&p(C):m&&m(C)}return s.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:g,tabIndex:0,onKeyDown:w,children:s.jsxs("div",{className:"wx-1FxkZa wx-window",children:[r||(n?s.jsx("div",{className:"wx-1FxkZa wx-header",children:n}):null),s.jsx("div",{children:l}),c||a&&s.jsx("div",{className:"wx-1FxkZa wx-buttons",children:a.map(b=>s.jsx("div",{className:"wx-1FxkZa wx-button",children:s.jsx(Jc,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:j=>y(j,b),children:v(b)})},b))})]})})}function xC({children:n},a){const[r,l]=u.useState(null),[c,d]=u.useState([]);return u.useImperativeHandle(a,()=>({showModal:m=>{const p={...m};return l(p),new Promise((v,g)=>{p.resolve=w=>{l(null),v(w)},p.reject=w=>{l(null),g(w)}})},showNotice:m=>{m={...m},m.id=m.id||sp(),m.remove=()=>d(p=>p.filter(v=>v.id!==m.id)),m.expire!=-1&&setTimeout(m.remove,m.expire||5100),d(p=>[...p,m])}}),[]),s.jsxs(s.Fragment,{children:[n,r&&s.jsx(Lh,{title:r.title,buttons:r.buttons,onConfirm:r.resolve,onCancel:r.reject,children:r.message}),s.jsx(vC,{data:c})]})}const yC=u.forwardRef(xC);function wC(n){let{children:a}=n,r=u.useRef();const l=u.useMemo(()=>({showNotice:c=>r.current.showNotice(c),showModal:c=>r.current.showModal(c)}),[]);return s.jsx(bw.Provider,{value:l,children:s.jsx(yC,{ref:r,children:a})})}const bC=({value:n=!1,type:a="",icon:r="",disabled:l=!1,iconActive:c="",onClick:d,title:m="",tooltip:p,css:v="",text:g="",textActive:w="",children:y,active:b,onChange:j})=>{const[C,A]=ui(n),T=u.useMemo(()=>(C?"pressed":"")+(a?" "+a:""),[C,a]),k=u.useCallback(E=>{let R=!C;d&&d(E),E.defaultPrevented||(A(R),j&&j({value:R}))},[C,d,j]);return C&&b?s.jsx(Jc,{title:m,tooltip:p,text:C&&w||g,css:v,type:T,icon:C&&c||r,onClick:k,disabled:l,children:np(b,{value:C})}):y?s.jsx(Jc,{title:m,tooltip:p,text:C&&w||g,css:v,type:T,icon:C&&c||r,onClick:k,disabled:l,children:y}):s.jsx(Jc,{title:m,tooltip:p,text:C&&w||g,css:v,type:T,icon:C&&c||r,onClick:k,disabled:l})};function SC(){return s.jsx(s.Fragment,{})}function Gx(n){const{fonts:a=!0,children:r}=n;return s.jsx(ip.Provider,{value:"willow",children:s.jsxs(s.Fragment,{children:[r&&r&&s.jsx("div",{className:"wx-theme wx-willow-theme",children:r}),a&&s.jsxs(s.Fragment,{children:[s.jsx("link",{rel:"preconnect",href:"https://cdn.svar.dev",crossOrigin:"true"}),s.jsx(SC,{}),s.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}ap(Ia);const dp={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 Aw=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 jC=class{constructor(n){const a={id:0,$level:0,data:[],parent:null},r=new Map;r.set(0,a),this._pool=r,n&&n.length&&this.parse(n,0)}parse(n,a){const r=this._pool;for(let c=0;c<n.length;c++){const d=n[c];d.parent=d.parent||a,d.data=null,r.set(d.id,d)}for(let c=0;c<n.length;c++){const d=n[c],m=r.get(d.parent);m&&(m.data||(m.data=[]),m.data.push(d))}const l=r.get(a);this.setLevel(l,l.$level+1,!1)}add(n,a){const r=this._pool.get(n.parent||0);n.$level=r.$level+1,this._pool.set(n.id,n),r.data?a===-1?r.data=[...r.data,n]:Vx(r,a,n):r.data=[n]}addAfter(n,a){if(!a)return this.add(n,-1);const r=this.byId(a),l=this.byId(r.parent),c=Od(l,r.id)+1;n.parent=l.id,n.$level=l.$level+1,this.add(n,c)}remove(n){const a=this._pool.get(n);this._remove(a);const r=this._pool.get(a.parent);r.data=r.data.filter(l=>l.id!=n),this._clearBranch(r)}_remove(n){n.data&&n.data.forEach(a=>this._remove(a)),this._pool.delete(n.id)}update(n,a){let r=this._pool.get(n);const l=this._pool.get(r.parent),c=Od(l,r.id);r={...r,...a},l&&c>=0&&(l.data[c]=r,l.data=[...l.data]),this._pool.set(r.id,r)}move(n,a,r){const l=this._pool.get(n),c=a==="child",d=this._pool.get(r),m=d.$level+(c?1:0);if(!l||!d)return;const p=this._pool.get(l.parent),v=c?d:this._pool.get(d.parent);v.data||(v.data=[]);const g=Od(p,l.id);CC(p,g);const w=c?v.data.length:Od(v,d.id)+(a==="after"?1:0);if(Vx(v,w,l),p.id===v.id&&g===w)return null;l.parent=v.id,l.$level!==m&&(l.$level=m,this.setLevel(l,m+1,!0)),this.update(l.id,l),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&&Nw(a,n),n}byId(n){return this._pool.get(n)}getBranch(n){return this._pool.get(n).data}forEach(n){this._pool.forEach((a,r)=>{r!==0&&n(a)})}eachChild(n,a){const r=this.byId(a);!r||!r.data||r.data.forEach((l,c)=>{n(this.byId(l.id),c),this.eachChild(n,l.id)})}setLevel(n,a,r){n.data&&(n.data=n.data.map(l=>(r&&(l={...l},this._pool.set(l.id,l)),l.$level=a,l.data&&this.setLevel(l,a+1,r),l)))}};function Nw(n,a){n.forEach(r=>{a.push(r),r.open===!0&&Nw(r.data,a)})}function CC(n,a){const r=[...n.data];r.splice(a,1),n.data=r}function Vx(n,a,r){const l=[...n.data];l.splice(a,0,r),n.data=l}function Od(n,a){return n?.data.findIndex(r=>r.id===a)}var Mw=2,kC=class{constructor(a){a&&(this._writable=a.writable,this._async=a.async),this._values={},this._state={}}setState(a,r=0){const l={};return this._wrapProperties(a,this._state,this._values,"",l,r),l}getState(){return this._values}getReactive(){return this._state}_wrapProperties(a,r,l,c,d,m){for(const p in a){const v=r[p],g=l[p],w=a[p];if(v&&(g===w&&typeof w!="object"||w instanceof Date&&g instanceof Date&&g.getTime()===w.getTime()))continue;const y=c+(c?".":"")+p;v?(v.__parse(w,y,d,m)&&(l[p]=w),m&Mw?d[y]=v.__trigger:v.__trigger()):(w&&w.__reactive?r[p]=this._wrapNested(w,w,y,d):r[p]=this._wrapWritable(w),l[p]=w),d[y]=d[y]||null}}_wrapNested(a,r,l,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,r,l,c,0),d.__parse=(m,p,v,g)=>(this._wrapProperties(m,d,r,p,v,g),!1),d}_wrapWritable(a){const r=[],l=function(){for(let c=0;c<r.length;c++)r[c](a)};return{subscribe:c=>(r.push(c),this._async?setTimeout(c,1,a):c(a),()=>{const d=r.indexOf(c);d>=0&&r.splice(d,1)}),__trigger:()=>{r.length&&(this._async?setTimeout(l,1):l())},__parse:function(c){return a=c,!0}}}};function Yx(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var AC=class{constructor(a,r,l,c){typeof a=="function"?this._setter=a:this._setter=a.setState.bind(a),this._routes=r,this._parsers=l,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(d=>{d.in.forEach(m=>{const p=this._triggers.get(m)||[];p.push(d),this._triggers.set(m,p)}),d.out.forEach(m=>{const p=this._sources.get(m)||{};d.in.forEach(v=>p[v]=!0),this._sources.set(m,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(m=>Tw(m,this._sources,1)))}),this._bus=c}init(a){const r={};for(const l in a)if(this._prev[l]!==a[l]){const c=this._parsers[l];r[l]=c?c(a[l]):a[l]}this._prev=this._prev?{...this._prev,...a}:{...a},this.setState(r),this._bus&&this._bus.exec("init-state",r)}setStateAsync(a){const r=this._setter(a,Mw);return this._async?Object.assign(this._async.signals,r):this._async={signals:r,timer:setTimeout(this._applyState.bind(this),1)},r}_applyState(){const a=this._async;if(a){this._async=null,this._triggerUpdates(a.signals,[]);for(const r in a.signals){const l=a.signals[r];l&&l()}}}setState(a,r=[]){const l=this._setter(a);return this._triggerUpdates(l,r),l}_triggerUpdates(a,r){const l=Object.keys(a),c=!r.length;r=r||[];for(let d=0;d<l.length;d++){const m=l[d],p=this._triggers.get(m);p&&p.forEach(v=>{r.indexOf(v)==-1&&r.push(v)})}c&&this._execNext(r)}_execNext(a){for(;a.length;){a.sort((l,c)=>l.length<c.length?1:-1);const r=a[a.length-1];a.splice(a.length-1),r.exec(a)}}};function Tw(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>Tw(d,a,r+1));return Math.max(...c)}var NC=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(a,r,l){let c=this._handlers[a];c?l&&l.intercept?c.unshift(r):c.push(r):c=this._handlers[a]=[r],l&&l.tag&&this._tag.set(r,l.tag)}intercept(a,r,l){this.on(a,r,{...l,intercept:!0})}detach(a){for(const r in this._handlers){const l=this._handlers[r];for(let c=l.length-1;c>=0;c--)this._tag.get(l[c])===a&&l.splice(c,1)}}async exec(a,r){const l=this._handlers[a];if(l)for(let c=0;c<l.length;c++){const d=l[c](r);if(d===!1||d&&d.then&&await d===!1)return}return this._nextHandler&&await this._nextHandler.exec(a,r),r}setNext(a){return this._nextHandler=a}};const Ao=1024;function iu(n){return n<Ao?`${n} B`:n<Ao**2?`${(n/Ao).toFixed(1)} KB`:n<Ao**3?`${(n/Ao**2).toFixed(1)} MB`:`${(n/Ao**3).toFixed(1)} GB`}function Wx(n,a){a||(a={key:"name",order:"asc"});const r=n.filter(m=>m.type==="folder"),l=n.filter(m=>m.type!=="folder"),c=r.sort(Kx(a)),d=l.sort(Kx(a));return[...c,...d]}function MC(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 TC(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 Kx({key:n,order:a}){const r=a==="asc"?MC:TC;return(l,c)=>r(l[n],c[n])}function fp(n,a){const r=n==="/"?1:n.split("/").length;return r>=a.length?null:a[r].id}function EC(n){return n.length>1?n[n.length-2].id:null}let RC=class extends jC{constructor(a){const r={id:"/",name:"My files",open:!0,$level:1,parent:0,ext:"",type:"folder"};super([r]),this.parse(a,"/")}parse(a,r,l){!a||!a.length||(a.forEach(c=>this.parseId(c,l?r:void 0)),super.parse(a,r))}parseId(a,r){if(a.parent===0)return;const l=a.id,c=l.lastIndexOf("/");if(a.parent=r??(c===0?"/":l.slice(0,c)),a.name=l.slice(c+1),a.type=a.type||"file",a.type!=="folder"){const d=a.name.lastIndexOf("."),m=d!==-1?a.name.slice(d+1):"";a.ext=m!=="new"?m?.toLocaleLowerCase():""}}getParents(a){const r=[];let l=this.byId(a);if(!l)return r;for(;l.id!==0;)r.push(l),l=this.byId(l.parent);return r.reverse()}findFiles(a,r="/"){const l=[],c=a.toLocaleLowerCase();return this.eachChild(d=>{d.name.toLowerCase().indexOf(c)!==-1&&l.push(d)},r),l}add(a,r){const l=this.byId(a.parent||"/"),c=a.data?[...a.data]:null;a.data=null,super.add(a,r??l.data?l.data.length:0),c&&c.forEach(d=>this.add(d))}renameFiles(a,r,l){const c=this.byId(a),d=this.normalizeFile(c,r),m=[];return d.data?.forEach(p=>m.push(this.renameFiles(p.id,d.id,l))),m.length&&(d.data=m),l[a]=d.id,d}copyFiles(a,r,l){const c={};return a.forEach(d=>{const m=this.renameFiles(d,r,c);this.add(m),l&&this.remove(d),c[d]=m.id}),c}moveFiles(a,r){if(this.byId(a[0]).parent!==r)return this.copyFiles(a,r,!0)}serialize(a="/"){const r=[],l=this.byId(a);return l?(l.data?.forEach(c=>{const{id:d,date:m,type:p,size:v,lazy:g}=c,w={id:d,date:m,type:p??"file"};g&&(w.lazy=g),v&&(w.size=v),r.push(w);const y=this.serialize(d);y.length&&r.push(...y)}),r):null}normalizeFile(a,r){const l=a.name,c=l.lastIndexOf("."),d=c!==-1?l.slice(c+1):"",m=d?`.${d}`:"";let p=c!==-1?l.slice(0,c):l,v=r+(r==="/"?"":"/")+p;for(;this.byId(v+m);){const g=".new";v+=g,p+=g}return{...a,id:v+m,name:p+m,parent:r,ext:d.toLocaleLowerCase()}}},DC=class extends kC{in;_router;constructor(a){super({writable:a,async:!1});const r=[];for(let d=0;d<2;d++)r.push({in:["data",`panels.${d}.path`],out:[`panels.${d}._crumbs`],exec:m=>{const{data:p,panels:v}=this.getState(),g=[];g[d]={_crumbs:p.getParents(v[d].path)},this.setState({panels:g},m)}}),r.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:m=>{const{data:p,panels:v,search:g}=this.getState();let w;g?w=p.findFiles(g,v[d].path):w=p.byId(v[d].path)?.data||[];const{path:y,_sorts:b}=v[d];w=Wx(w,b[y]);const j=[];j[d]={_files:w},this.setState({panels:j},m)}}),r.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:m=>{const{data:p,panels:v}=this.getState(),g=[];v[d].selected.forEach(C=>{const A=p.byId(C);A&&g.push(A)});const{path:w,_sorts:y}=v[d],b=Wx(g,y[w]),j=[];j[d]={_selected:b},this.setState({panels:j},m)}});this._router=new AC(super.setState.bind(this),r,{data:d=>new RC(d)});const l=this.in=new NC;l.on("select-file",({id:d,toggle:m,range:p,panel:v,type:g})=>{const{panels:w,activePanel:y}=this.getState();typeof v>"u"&&(v=y),d||(m=p=!1);let b=[...w[v].selected];if(m){const C=b.indexOf(d);C===-1?b.push(d):b.splice(C,1)}else if(p&&w[v]._lastSelected){const C=w[v]._files;let A=C.findIndex(E=>E.id==w[v]._lastSelected),T=C.findIndex(E=>E.id==d);T<A&&([A,T]=[T,A]);const k=C.slice(A,T+1).map(E=>E.id);b=[...new Set([...b,...k])]}else b=d?[d]:[];const j=[];j[v]={selected:b,_lastSelected:d,_selectNavigation:g==="navigation"},this.setState({panels:j})}),l.on("set-path",({id:d,panel:m,selected:p})=>{const{data:v,activePanel:g}=this.getState(),w=v.byId(d);if(w){const y=[];typeof m>"u"&&(m=g),y[m]={path:d},this.setState({panels:y}),l.exec("select-file",{panel:m}),p&&p.forEach(b=>l.exec("select-file",{id:b,panel:m,toggle:!0})),w.lazy&&l.exec("request-data",{id:d})}}),l.on("provide-data",({id:d,data:m})=>{const{mode:p,data:v}=this.getState(),g=v.byId(d);g&&(g.lazy||(g.data=[]),g.lazy=!1,v.parse(m,d,p==="search"),this.setState({data:v}))}),l.on("open-tree-folder",({id:d,mode:m})=>{const{data:p}=this.getState();p.update(d,{open:m}),this.setState({data:p})}),l.on("show-preview",({mode:d})=>{this.setState({preview:d})}),l.on("rename-file",d=>{const{id:m,name:p}=d,{data:v,panels:g}=this.getState(),w=v.byId(m);if(w.name!==p){w.name=p;const y=v.normalizeFile(w,w.parent);d.newId=y.id,y.data=null,v.add(y);let b={[m]:y.id};w.data?.forEach(C=>b={...v.moveFiles([C.id],y.id),...b});const j=g.map(C=>({selected:C.selected,_crumbs:C._crumbs,_lastSelected:C._lastSelected,_sorts:C._sorts}));v.remove(m),this._updatePanels(j,b),this.setState({data:v,panels:j})}}),l.on("create-file",d=>{const{file:m,parent:p}=d,{data:v}=this.getState(),g=v.normalizeFile(m,p);g.type=m.type||"file",d.newId=g.id,v.add(g),this.setState({data:v}),l.exec("select-file",{id:g.id})}),l.on("delete-files",({ids:d})=>{const{data:m,panels:p}=this.getState(),v=p.map(g=>({selected:g.selected,_crumbs:g._crumbs,_lastSelected:g._lastSelected,_sorts:g._sorts}));d.forEach(g=>m.remove(g)),this._updatePanels(v,{}),this.setState({data:m,panels:v})}),l.on("copy-files",d=>{const{ids:m,target:p}=d;if(this._isPlacedIntoSelf(m,p)){console.error("You cannot copy a folder into itself"),d.skipProvider=!0;return}const{data:v,panels:g,activePanel:w}=this.getState(),y=v.copyFiles(m,p);d.newIds=m.map(b=>y[b]),this.setState({data:v}),g[w].path==p&&(l.exec("select-file",{}),m.forEach(b=>{l.exec("select-file",{id:y[b],toggle:!0})}))}),l.on("move-files",d=>{const{ids:m,target:p}=d;if(this._isPlacedIntoSelf(m,p)){console.error("You cannot move a folder into itself"),d.skipProvider=!0;return}const{data:v,panels:g,activePanel:w}=this.getState(),y=v.moveFiles(m,p);if(y){d.newIds=m.map(j=>y[j]);const b=g.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));this._updatePanels(b,y,!0),this.setState({data:v,panels:b}),g[w].path==p&&(l.exec("select-file",{}),m.forEach(j=>{l.exec("select-file",{id:y[j],toggle:!0})}))}});let c=null;l.on("filter-files",({text:d})=>{if(!d){c&&this.setState({...c});return}l.exec("select-file",{});const{panels:m,mode:p}=this.getState();c||(c={panels:m,mode:p,search:""}),this.setState({mode:"search",search:d})}),l.on("set-mode",({mode:d})=>{const{activePanel:m}=this.getState(),p=[];p[m]={_selectNavigation:!1};const v={mode:d,search:"",panels:p};c=null,this.setState(v)}),l.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),l.on("sort-files",({key:d,order:m,panel:p,path:v})=>{const{activePanel:g,panels:w}=this.getState();p=p??g,v=v??w[p].path;const y=[];y[p]={_sorts:{...w[p]._sorts,[v]:{key:d,order:m}}},this.setState({panels:y})}),this.initOnce()}initOnce(){const a=[];for(let l=0;l<2;l++)a[l]=Yx({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[l]});const r={panels:Yx(a),data:[],search:""};this._router.init(r)}init(a){const r={...a};this._router.init(r)}setState(a,r){return this._router.setState(a,r)}getFile(a){const{data:r}=this.getState();return r.byId(a)||null}serialize(a){const{data:r}=this.getState();return r.serialize(a)}_updatePanels(a,r,l){const{data:c}=this.getState();a.forEach(d=>{const m=[];d.selected.forEach(g=>{c.byId(g)?m.push(g):!l&&r[g]&&m.push(r[g])}),d.selected=m,c.byId(d._lastSelected)||(d._lastSelected=l?null:r[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(g=>{c.byId(g)?p[g]=d._sorts[g]:r[g]&&!l&&(p[r[g]]=d._sorts[g])}),d._sorts=p;const v=d._crumbs[d._crumbs.length-1];v?.id!=="/"&&(r[v.id]?d.path=r[v.id]:c.byId(v.id)||(d.path="/"))})}_isPlacedIntoSelf(a,r){return a.some(l=>l===r||this.getState().data.getParents(r).some(c=>c.id===l))}};function _C(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 LC(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}function zC(n,a="data-id"){const r=LC(n,a);return r?r.getAttribute(a):null}new Date().valueOf();function IC(n,a){const{api:r}=a;function l(d,m){const p=a.getPanel(),v=p.selected,g=m.ctrlKey||m.metaKey,w=m.shiftKey;let y;const b=v?.[0]?r.getFile(v[0]):null;v?.length?v.length>1?y=a.menuOptions("multiselect"):y=a.menuOptions(b.type,b):y=a.menuOptions("body");const j=`${g?"ctrl+":""}${w?"shift+":""}${d}`,C=y?y.find(T=>T.hotkey?.toLowerCase()===j):!1,A=a.performAction;if(C)switch(j){case"ctrl+c":A("copy");break;case"ctrl+x":A("move");break;case"ctrl+v":A("paste",b);break;case"delete":A("delete");break;case"ctrl+r":m.preventDefault(),A("rename",b);break;case"ctrl+d":m.preventDefault(),A("download",b);break;default:C.handler?.({context:b})}switch(d){case"enter":{if(g||w)break;const{_crumbs:T,_selectNavigation:k}=p;if(k){const E=EC(T);if(E){const R=fp(E,T);r.exec("set-path",{id:E,selected:[R]})}}else if(v.length===1){const E=r.getFile(v[0]);E&&r.exec(E.type==="folder"?"set-path":"open-file",{id:E.id})}break}case"arrowup":case"arrowleft":{const{_files:T,_selected:k,path:E,_selectNavigation:R}=p;let $;if(k.length){const F=k.at(0).id,q=T.findIndex(L=>L.id===F);if(q!==-1){const L=q-1;T[L]?$=T[L].id:E!=="/"&&!(g||w)&&r.exec("select-file",{type:"navigation"})}}else{if(R)break;if(E!=="/"){r.exec("select-file",{type:"navigation"});break}$=T.at(0)?.id}$&&r.exec("select-file",{id:$,toggle:g,range:w});break}case"arrowdown":case"arrowright":{const{_files:T,_selected:k,path:E,_selectNavigation:R}=p;let $;if(k.length){const F=k.at(-1).id,q=T.findIndex(L=>L.id===F);if(q!==-1){const L=q+1;T[L]&&($=T[L].id)}}else{if(E!=="/"&&!R){r.exec("select-file",{type:"navigation"});break}$=T.at(0)?.id}$&&r.exec("select-file",{id:$,toggle:g,range:w});break}}}function c(d){const m=d.code.replace("Key","").toLowerCase();l(m,d),m=="tab"&&setTimeout(()=>{const p=document.activeElement;p.className.indexOf("table")!=-1&&r.exec("set-active-panel",{panel:+zC(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function OC(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}function BC(n,a="data-id"){const r=n.getAttribute(a);return r?FC(r):null}function FC(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function PC(){return{detect:()=>!0,addEvent:function(n,a,r){return n.addEventListener(a,r),()=>n.removeEventListener(a,r)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var HC=PC();new Date().valueOf();function Ew(n){const[a,r]=u.useState(n),l=u.useRef(n);return u.useEffect(()=>{if(l.current!==n){if(Array.isArray(l.current)&&Array.isArray(n)&&l.current.length===0&&n.length===0)return;l.current=n,r(n)}},[n]),[a,r]}function $C(n,a,r){const[l,c]=u.useState(()=>a);return n||console.warn(`Writable ${r} is not defined`),u.useEffect(()=>n?n.subscribe(m=>{c(()=>m)}):void 0,[n]),l}function nt(n,a){const r=n.getState(),l=n.getReactiveState();return $C(l[a],r[a],a)}function UC(n,a){const r=u.useRef(a);r.current=a;const[l,c]=u.useState(1);return u.useEffect(()=>n.subscribe(m=>{r.current=m,c(p=>p+1)}),[n]),[r.current,l]}function vs(n,a){const r=n.getState(),l=n.getReactiveState();return UC(l[a],r[a])}function Rw(n){const a={};return n.split(";").forEach(r=>{const[l,c]=r.split(":");if(c){let d=l.trim();d.indexOf("-")&&(d=d.replace(/-([a-z])/g,(m,p)=>p.toUpperCase())),a[d]=c.trim()}}),a}function Dw(n){let a=n,r=[];return{subscribe:p=>{r.push(p),p(a)},unsubscribe:p=>{r=r.filter(v=>v!==p)},set:p=>{a=p,r.forEach(v=>v(a))},update:p=>{a=p(a),r.forEach(v=>v(a))}}}function Qx(n,a,r){function l(c){const d=OC(c);if(!d)return;const m=BC(d);if(typeof a=="function")return a(m,c);let p,v=c.target;for(;v!=d;){if(p=v.dataset?v.dataset.action:null,p&&a[p]){a[p](m,c);return}v=v.parentNode}a[r]&&a[r](m,c)}return HC.addEvent(n,r,l)}function qC(n,a){const r=[Qx(n,a,"click")];return a.dblclick&&r.push(Qx(n,a.dblclick,"dblclick")),()=>{r.forEach(l=>l())}}function _w(n,a){return n.map((r,l)=>{const c=a(r,l);return r.data&&r.data.length&&(c.data=_w(r.data,a)),c}).filter(Boolean)}function Lw(n,a){const r=[];return n.forEach(l=>{if(l.data){const c=Lw(l.data,a);c.length&&r.push({...l,data:c})}else a(l)&&r.push(l)}),r}function GC(n){return _w(n,(a,r)=>{const l={...a,id:a.id||sp()};return l.type&&(l.comp=l.type),l.comp==="separator"&&n[r-1]?.comp==="separator"?null:l})}const zw={};function VC(n){return zw[n]||n}function YC(n,a){zw[n]=a}function WC({onClick:n,onShow:a,option:r}){const l=u.useRef(null),c=u.useCallback(()=>{a(r.data?r.id:!1,l.current)},[a,r]),d=u.useCallback(p=>{if(r.data){p.stopPropagation(),a(r.id,l.current);return}n(p)},[n,a,r]),m=u.useMemo(()=>r&&r.comp?VC(r.comp):null,[r]);return s.jsxs("div",{ref:l,className:`wx-cDCz9rZQ wx-option ${r.css||""} ${r.disabled?"wx-disabled":""}`,"data-id":On(r.id),onMouseEnter:c,onClick:d,children:[r.icon?s.jsx("i",{className:`wx-cDCz9rZQ wx-icon ${r.icon}`}):null,r.comp?m?s.jsx(m,{item:r,option:r}):null:s.jsxs("span",{className:"wx-cDCz9rZQ wx-value",children:[" ",r.text," "]}),r.subtext?s.jsx("span",{className:"wx-cDCz9rZQ wx-subtext",children:r.subtext}):null,r.data?s.jsx("i",{className:"wx-cDCz9rZQ wx-sub-icon wxi-angle-right"}):null]})}function mp({options:n,left:a=0,top:r=0,at:l="bottom",parent:c=null,mount:d=null,context:m=null,css:p="",onClick:v,onCancel:g}){const[w,y]=u.useState(-1e4),[b,j]=u.useState(-1e4),[C,A]=u.useState(20),[T,k]=u.useState(),E=u.useRef(null),[R,$]=u.useState(!1),[F,q]=u.useState(null),L=u.useCallback(()=>{const le=vw(E.current,c,l,a,r);le&&(y(le.x),j(le.y),k(le.width));let Y=le?.z??20;const O=c?I1(c):[];let Z=0;for(const X of O){const D=parseInt(getComputedStyle(X).zIndex,10);D>Z&&(Z=D)}Z>=Y&&(Y=Z+1),A(Y)},[c,l,a,r]);u.useEffect(()=>{d&&d(L)},[]);const _=u.useCallback(()=>{$(!1)},[]),ie=u.useCallback((le,Y)=>{$(le),q(Y)},[]),V=u.useMemo(()=>GC(n),[n]);u.useEffect(()=>{L()},[c,L]);const ne=u.useRef(v),Q=u.useRef(g),J=u.useRef(c);return u.useEffect(()=>{ne.current=v},[v]),u.useEffect(()=>{Q.current=g},[g]),u.useEffect(()=>{J.current=c},[c]),u.useEffect(()=>{if(!E.current)return;function le(Y){Q.current?Q.current(Y):ne.current&&ne.current({action:null,option:null})}return di(E.current,{callback:le,modal:!0,parent:()=>J.current}).destroy},[]),s.jsx("div",{ref:E,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:T,zIndex:C},onMouseLeave:_,children:V.map(le=>s.jsxs(u.Fragment,{children:[le.comp==="separator"?s.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):s.jsx(WC,{option:le,onShow:ie,onClick:Y=>{if(!le.data&&!Y.defaultPrevented){const O={context:m,action:le,option:le,event:Y};le.handler&&le.handler(O),v&&v(O),Y.stopPropagation()}}}),le.data&&R===le.id?s.jsx(mp,{css:p,options:le.data,at:"right-overlap",parent:F,context:m,onClick:v,onCancel:g}):null]},le.id))})}const Iw=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:v,onClick:g}=n,[w,y]=u.useState(null),[b,j]=u.useState(null),[C,A]=u.useState(0),[T,k]=u.useState(0),E=u.useRef(null),R=u.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),$=u.useMemo(()=>w!==null&&m?Lw(r,_=>m(_,w)):r,[w,m,r]);function F(_){j(null),g&&g(_)}function q(_){if(E.current===_){E.current=null;return}j(null),g&&g({action:null,option:null})}const L=u.useCallback((_,ie)=>{if(!_){j(null);return}if(_.defaultPrevented)return;const V=_.target;if(V&&V.dataset&&V.dataset.menuIgnore)return;if(b&&b===V){j(null),_.preventDefault();return}A(_.clientX+1),k(_.clientY+1);let ne=typeof ie<"u"?ie:su(V,R);c&&(ne=c(ne,_),!ne)||(y(ne),j(V),E.current=_.nativeEvent||_,_.preventDefault())},[b,R,c]);return u.useImperativeHandle(a,()=>({show:L}),[L]),s.jsxs(s.Fragment,{children:[v?s.jsx("span",{onClick:L,"data-menu-ignore":"true",children:typeof v=="function"?v():v}):null,b?s.jsx(rp,{children:s.jsx(mp,{css:p,at:l,top:T,left:C,parent:b,context:w,onClick:F,onCancel:q,options:$},b)}):null]})}),KC=u.forwardRef(function(n,a){const{options:r,at:l="bottom",css:c="",children:d,onClick:m}=n,[p,v]=u.useState(null),g=u.useRef(null);function w(C){v(null),m&&m(C)}function y(C){if(g.current===C){g.current=null;return}v(null),m&&m({action:null,option:null})}const b=u.useCallback(C=>{v(C.target),g.current=C.nativeEvent||C,C.preventDefault()},[]);u.useImperativeHandle(a,()=>({show:b}),[b]);function j(C){let A=C.target;for(;!A.dataset.menuIgnore;)v(A),A=A.parentNode}return s.jsxs(s.Fragment,{children:[s.jsx("span",{onClick:j,"data-menu-ignore":"true",children:d}),p?s.jsx(rp,{children:s.jsx(mp,{css:c,at:l,parent:p,options:r,onClick:w,onCancel:y})}):null]})}),QC=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:v,onClick:g}=n,w=u.useRef(null),y=u.useCallback((b,j)=>{w.current.show(b,j)},[]);return u.useImperativeHandle(a,()=>({show:y}),[y]),s.jsxs(s.Fragment,{children:[v?s.jsx("span",{onContextMenu:y,"data-menu-ignore":"true",children:v}):null,s.jsx(Iw,{css:p,at:l,options:r,resolver:c,dataKey:d,filter:m,ref:w,onClick:g})]})}),XC={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 ZC=class{constructor(a,r,l,c,d){this.setFiles=a,this.setReady=r,this.setSignal=l,this.setDrag=c,d&&d.length&&this.setFiles(d)}open(a){this.setSignal(["click",a||{}])}getState(){let a="server";const r=this.files;for(let l=0;l<r.length;l++){if(r[l].status==="client")return"client";r[l].status==="error"&&(a="error")}return a}droparea(a,r){r=r||{};const l=()=>{r.dragEnter&&r.dragEnter(),this.setDrag(!0)},c=()=>{r.dragLeave&&r.dragLeave(),this.setDrag(!1)},d=p=>{p.preventDefault()},m=p=>{p.preventDefault(),this.setDrag(!1),this.setSignal(["drop",r,p]),r.dragLeave&&r.dragLeave(),r.drop&&r.drop()};return a.addEventListener("dragenter",l),a.addEventListener("dragleave",c),a.addEventListener("dragover",d,!0),a.addEventListener("drop",m,!0),()=>{a.removeEventListener("dragenter",l),a.removeEventListener("dragleave",c),a.removeEventListener("dragover",d,!0),a.removeEventListener("drop",m,!0)}}updateFile(a,r){const l=this.files.findIndex(d=>d.id===a);if(l===-1)return;const c=[...this.files];return c[l]={...c[l],...r},this.files=c,this.setFiles(this.files),this.files[l]}deleteFile(a){this.files=this.files.filter(r=>r.id!==a),this.setFiles(this.files)}addFile(a,r){r?this.files=[...this.files,a]:this.files=[a],this.setFiles(this.files)}deleteAll(){this.files=[],this.setFiles(this.files)}};function Ow(n){const[a,r]=u.useState([]),[l,c]=u.useState(Promise.resolve(null)),[d,m]=u.useState(null),[p,v]=u.useState(!1),g=u.useRef();return g.current||(g.current=new ZC(r,c,m,v,n)),g.current.files=a,g.current.ready=l,g.current.signal=d,g.current.drag=p,g.current}function JC(n,a){{if(n){const r=n.getGroup(a);if(r)return r}return ru(XC).getGroup(a)}}const ek=()=>Math.random().toString(36).substr(2,9),tk=({data:n,accept:a="",multiple:r=!0,folder:l=!1,uploadURL:c="",apiOnly:d=!1,disabled:m=!1,children:p,onChange:v,onUpload:g})=>{const w=u.useRef(null),y=u.useRef(null),[b,j]=u.useState({}),C=Ow(),A=n||C,T=u.useContext(Fn.i18n),k=JC(T,"uploader");u.useEffect(()=>{w.current&&l&&(w.current.webkitdirectory=!0)},[l]),u.useEffect(()=>{if(!d&&y.current&&!m)return A.droparea(y.current)},[d,m,y]);const E=V=>{const ne=new FormData;return ne.append("upload",V.file),fetch(c,{method:"POST",body:ne}).then(Q=>Q.json()).then(Q=>({id:V.id,...Q}),()=>({id:V.id,status:"error"})).catch(Q=>(console.log(Q),{id:V.id,status:"error"}))},R=(V,ne)=>{const Q=A.updateFile(V,ne),J={...Q,status:A.getState()};Q&&Q.uploaded&&Q.uploaded(J),g&&g(J),Q.temp&&A.deleteFile(Q.id)},$=V=>{if(!V)return;const ne=typeof c=="function"?c(V):E(V);A.setReady(ne.then(Q=>{Q.status=Q.status||"server",R(V.id,Q)}).catch(Q=>{R(V.id,{status:"error",error:Q})}))},F=(V,ne)=>{const Q={...ne||b,id:ek(),status:"client",name:V.name,file:V};Q.selected&&Q.selected(Q),v&&v(Q),A.addFile(Q,r),$(Q),w.current&&(w.current.value="")},q=(V,ne,Q)=>{V.isFile?V.file(J=>{F(J,Q)}):V.isDirectory&&V.createReader().readEntries(J=>{J.forEach(le=>{q(le,ne+le.name+"/",Q)})})},L=V=>{Array.from(V.target.files).forEach(ne=>F(ne))},_=(V,ne)=>{Array.from(V.dataTransfer.items).forEach(Q=>{const J=Q.webkitGetAsEntry();J&&q(J,"",ne)})},ie=()=>{w.current&&w.current.click()};return u.useEffect(()=>{if(A.signal){const[V,ne,Q]=A.signal;j(ne),V==="click"?ie():V==="drop"&&_(Q,ne),A.setSignal(null)}},[A.signal]),d?s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:r,disabled:m}),p]}):s.jsxs("div",{className:`wx-at1A8tb8 wx-label ${A.drag?"wx-active":""} ${m?"wx-disabled":""}`,ref:y,children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:L,accept:a,multiple:r,disabled:m}),p||s.jsx("div",{className:"wx-at1A8tb8 wx-dropzone",children:s.jsxs("span",{children:[k("Drop files here or")," ",s.jsx("span",{className:"wx-at1A8tb8 wx-action",onClick:ie,children:k("select files")})]})})]})};new Date().valueOf();function nk(n,a){if(Object.keys(n).length!==Object.keys(a).length)return!1;for(const r in a){const l=n[r],c=a[r];if(!wf(l,c))return!1}return!0}function wf(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 r=n.length-1;r>=0;r--)if(!wf(n[r],a[r]))return!1;return!0}else return nk(n,a);return n===a}function zh(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(zh);const a={};for(const r in n)a[r]=zh(n[r]);return a}var Bw=2,ak=class{constructor(n){n&&(this._writable=n.writable,this._async=n.async),this._values={},this._state={}}setState(n,a=0){const r={};return this._wrapProperties(n,this._state,this._values,"",r,a),r}getState(){return this._values}getReactive(){return this._state}_wrapProperties(n,a,r,l,c,d){for(const m in n){const p=a[m],v=r[m],g=n[m];if(p&&(v===g&&typeof g!="object"||g instanceof Date&&v instanceof Date&&v.getTime()===g.getTime()))continue;const w=l+(l?".":"")+m;p?(p.__parse(g,w,c,d)&&(r[m]=g),d&Bw?c[w]=p.__trigger:p.__trigger()):(g&&g.__reactive?a[m]=this._wrapNested(g,g,w,c):a[m]=this._wrapWritable(g),r[m]=g),c[w]=c[w]||null}}_wrapNested(n,a,r,l){const c=this._wrapWritable(n);return this._wrapProperties(n,c,a,r,l,0),c.__parse=(d,m,p,v)=>(this._wrapProperties(d,c,a,m,p,v),!1),c}_wrapWritable(n){const a=[],r=function(){for(let l=0;l<a.length;l++)a[l](n)};return{subscribe:l=>(a.push(l),this._async?setTimeout(l,1,n):l(n),()=>{const c=a.indexOf(l);c>=0&&a.splice(c,1)}),__trigger:()=>{a.length&&(this._async?setTimeout(r,1):r())},__parse:function(l){return n=l,!0}}}},sk=class{constructor(n,a,r,l){typeof n=="function"?this._setter=n:this._setter=n.setState.bind(n),this._routes=a,this._parsers=r,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(c=>{c.in.forEach(d=>{const m=this._triggers.get(d)||[];m.push(c),this._triggers.set(d,m)}),c.out.forEach(d=>{const m=this._sources.get(d)||{};c.in.forEach(p=>m[p]=!0),this._sources.set(d,m)})}),this._routes.forEach(c=>{c.length=Math.max(...c.in.map(d=>Fw(d,this._sources,1)))}),this._bus=l}init(n){const a={};for(const r in n)if(this._prev[r]!==n[r]){const l=this._parsers[r];a[r]=l?l(n[r]):n[r]}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,Bw);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 r=n.signals[a];r&&r()}}}setState(n,a=[]){const r=this._setter(n);return this._triggerUpdates(r,a),r}_triggerUpdates(n,a){const r=Object.keys(n),l=!a.length;a=a||[];for(let c=0;c<r.length;c++){const d=r[c],m=this._triggers.get(d);m&&m.forEach(p=>{a.indexOf(p)==-1&&a.push(p)})}l&&this._execNext(a)}_execNext(n){for(;n.length;){n.sort((r,l)=>r.length<l.length?1:-1);const a=n[n.length-1];n.splice(n.length-1),a.exec(n)}}};function Fw(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>Fw(d,a,r+1));return Math.max(...c)}var ik=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(n,a,r){let l=this._handlers[n];l?r&&r.intercept?l.unshift(a):l.push(a):l=this._handlers[n]=[a],r&&r.tag&&this._tag.set(a,r.tag)}intercept(n,a,r){this.on(n,a,{...r,intercept:!0})}detach(n){for(const a in this._handlers){const r=this._handlers[a];for(let l=r.length-1;l>=0;l--)this._tag.get(r[l])===n&&r.splice(l,1)}}async exec(n,a){const r=this._handlers[n];if(r)for(let l=0;l<r.length;l++){const c=r[l](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 rk(n){return a=>a[n]}function lk(n){return(a,r)=>a[n]=r}function qr(n,a){return(a.getter||rk(a.id))(n)}function sh(n,a,r){return(a.setter||lk(a.id))(n,r)}function ok(n,a){const r=document.createElement("a");r.href=URL.createObjectURL(n),r.download=a,document.body.appendChild(r),r.click(),document.body.removeChild(r)}function Ur(n,a){let r=qr(n,a)??"";return a.template?r=a.template(r,n,a):a.optionsMap&&(Array.isArray(r)?r=r.map(l=>a.optionsMap.get(l)).join(", "):r=a.optionsMap.get(r)),typeof r>"u"?"":r+""}function ck(n,a){const r=/\n|"|;|,/;let l="";const c=a.rows||`
|
|
12
|
+
`,d=a.cols||" ",m=n._columns,p=n.flatData;a.header!==!1&&m[0].header&&(l=Xx("header",m,l,d,c));for(let v=0;v<p.length;v++){const g=[];for(let w=0;w<m.length;w++){let y=Ur(p[v],m[w]);r.test(y)&&(y='"'+y.replace(/"/g,'""')+'"'),g.push(y)}l+=(l?c:"")+g.join(d)}return a.footer!==!1&&m[0].footer&&(l=Xx("footer",m,l,d,c)),l}function Xx(n,a,r,l,c){const d=/\n|"|;|,/;for(let m=0;m<a[0][n].length;m++){const p=[];for(let v=0;v<a.length;v++){let g=(a[v][n][m].text||"")+"";d.test(g)&&(g='"'+g.replace(/"/g,'""')+'"'),p.push(g)}r+=(r?c:"")+p.join(l)}return r}const uk="portrait",dk=100,fk="a4",mk={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function hk(n,a){const r=[];let l=[],c=0;const d=n.filter(p=>!p.hidden),m=pk(a);return d.forEach((p,v)=>{c+p.width<=m?(c+=p.width,l.push(p)):(l.length&&r.push(l),l=[p],c=p.width),v===d.length-1&&l.length&&r.push(l)}),r}function Zx(n,a,r){const l=[];return n.forEach((c,d)=>{const m=c[a];for(let p=0;p<r.length;p++){l[p]||(l[p]=[]);const v={...m[p]};if(l[p][d]!==null){if(!d&&!v.rowspan&&!v.colspan){let g=1,w=n[d+g][a][p],y=v.width;for(;!w.rowspan&&!w.colspan;)g++,w=n[d+g][a][p],y+=w.width;v.colspan=g,v.width=y,v.height=r[p]}if(l[p].push(v),!v.collapsed&&v.colspan>1){let g=v.colspan-1;if(v.colspan+d>n.length){const w=v.colspan-(v.colspan+d-n.length);v.colspan=w,v.width=n.slice(d,d+g+1).reduce((y,b)=>y+b.width,0),w>1&&(g=w-1)}for(let w=0;w<g;w++)l[p].push(null)}if(v.rowspan>1){const g=v.rowspan;for(let w=1;w<g;w++)l[p+w]||(l[p+w]=[]),l[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<l.length;p++){const v=l[p],g=v[d];if(g&&g.collapsed){if(v[d]=null,!p)break}else{const w=g||v.findLast(y=>y?.colspan>=1);w&&(w.colspan=w.colspan-1,w.width=w.width-c.width)}}}),l.map(c=>c.filter(d=>d&&d.colspan!==0))}function pk(n){const{mode:a,ppi:r,paper:l}=n,{width:c,height:d}=mk[l];return gk(a==="portrait"?c:d,r)}function gk(n,a){return n*a}function vk(n={}){const{mode:a,ppi:r,paper:l}=n;return{mode:a||uk,ppi:r||dk,paper:l||fk}}function Pw(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 xk(n,a,r){let l=n[r.id];if(r.filter.type==="richselect"&&l){const c=r.filter.config?.options||a.find(({id:d})=>d==r.id).options;c&&(l=c.find(({id:d})=>d==l).label)}return l??""}const Jx=["resize-column","hide-column","update-cell"],yk=["delete-row","update-row","update-cell"],wk=["move-item"],bk=["resize-column","move-item"];class Sk{undo=[];redo=[];progress={};in;getState;setState;_previousValues={};constructor(a,r,l){this.in=a,this.getState=r,this.setState=l,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:r}=a,{data:l}=this.getPrev(),c=l.findIndex(d=>d.id===r);return{action:"add-row",data:{id:r,row:l[c],before:c<l.length-1?l[c+1].id:void 0},source:{action:"delete-row",data:a}}}},"update-cell":{handler:a=>{const{id:r,column:l}=a,c=this.getRow(r),d=this.getColumn(l),m=qr(c,d);return wf(m,a.value)?null:{action:"update-cell",data:{id:r,column:l,value:m},source:{action:"update-cell",data:a}}}},"update-row":{handler:a=>{const{id:r,row:l}=a,c=this.getRow(r);for(const d in l)Object.keys(c).includes(d)||(c[d]=void 0);return{action:"update-row",data:{id:r,row:c},source:{action:"update-row",data:a}}}},"copy-row":{handler:a=>{const{id:r}=a,{data:l}=this.getState(),c=l.findIndex(m=>m.id===r),d=l[c];return{action:"delete-row",data:{id:r},source:{action:"add-row",data:{id:r,row:d,before:c<l.length-1?l[c+1].id:void 0}}}}},"resize-column":{handler:a=>{const{id:r,width:l}=a,c=this.getColumn(r),{_sizes:d}=this.getState();return{action:"resize-column",data:{id:r,width:c.width??d.columnWidth},source:{action:"resize-column",data:{id:r,width:l}}}}},"hide-column":{handler:a=>{const{id:r}=a,l=this.getColumn(r);return{action:"hide-column",data:{id:r,mode:l.hidden},source:{action:"hide-column",data:a}}}},"collapse-column":{handler:a=>{const{id:r,row:l,mode:c}=a;return{action:"collapse-column",data:{id:r,row:l,mode:typeof c=="boolean"?!c:c},source:{action:"collapse-column",data:a}}}},"move-item":{handler:a=>{const{id:r,target:l,mode:c}=a,{flatData:d}=this.getPrev(),m=d.findIndex(p=>p.id===r);return{action:"move-item",data:{id:r,target:d[m+(m?-1:1)].id,mode:m?"after":"before"},source:{action:"move-item",data:{id:r,target:l,mode:c}}}}},"open-row":{handler:a=>{const{id:r,nested:l}=a;return{action:"close-row",data:{id:r,nested:l},source:{action:"open-row",data:a}}}},"close-row":{handler:a=>{const{id:r,nested:l}=a;return{action:"open-row",data:{id:r,nested:l},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 r in a)this.in.intercept(r,l=>{if(!(l.eventSource==="undo"||l.eventSource==="redo"||l.skipUndo)){if(bk.includes(r)){(l.inProgress&&!this.progress[r]||typeof l.inProgress!="boolean")&&(wk.includes(r)&&this.setPrev("flatData"),Jx.includes(r)&&this.setPrev("columns")),this.progress[r]=l.inProgress;return}yk.includes(r)&&this.setPrev("data"),Jx.includes(r)&&this.setPrev("columns")}}),this.in.on(r,l=>{if(l.eventSource==="undo"||l.eventSource==="redo"||l.skipUndo||l.inProgress)return;const c=a[r].handler(l);c&&this.addToHistory(c)})}setPrev(a){this._previousValues[a]=zh(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:r}=this.getPrev();return this.getState().tree?this.getTreeRow(r,a):r.find(l=>l.id===a)}getTreeRow(a,r){for(let l=0;l<a.length;l++){if(a[l].id===r)return a[l];if(a[l].data){const c=this.getTreeRow(a[l].data,r);if(c)return c}}return null}getColumn(a){const{columns:r}=this.getPrev();return r.find(l=>l.id===a)}}function Hw(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function jk(n,a){return-Hw(n,a)}function Ck(n,a){if(typeof a.sort=="function")return function(l,c){const d=a.sort(l,c);return n==="asc"?d:-d};const r=n==="asc"?Hw:jk;return function(l,c){return r(qr(l,a),qr(c,a))}}function kk(n,a){if(!n||!n.length)return;const r=n.map(l=>{const c=a.find(d=>d.id==l.key);return Ck(l.order,c)});return n.length===1?r[0]:function(l,c){for(let d=0;d<r.length;d++){const m=r[d](l,c);if(m!==0)return m}return 0}}const Bd=28,Ak=20;function Nk(){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 df(n,a,r,l,c){const d=document.createElement("div"),m=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let v,g;m.className=a,d.classList.add(`wx-${r}-theme`),d.style.cssText=`height:auto;position:absolute;top:0px;left:100px;overflow:hidden;width=${c};white-space:nowrap;`,d.appendChild(m),p.appendChild(d),typeof n!="object"&&(n=[n]);for(let w=0;w<n.length;w++){m.innerText=n[w]+"";const y=d.getBoundingClientRect(),b=Math.ceil(y.width)+(l&&l.length?l[w]:0),j=Math.ceil(y.height);v=Math.max(v||0,b),g=Math.max(g||0,j)}return d.remove(),{width:v,height:g}}function ey(n,a,r,l,c){const d=[];for(let m=0;m<n.length;m++){const p=n[m][a],v=p.length;for(let g=0;g<v;g++){const{text:w,vertical:y,collapsed:b,rowspan:j,css:C}=p[g];if(!w){d[g]=Math.max(d[g]||0,l);continue}let A=0;if(y&&!b){let T=`wx-measure-cell-${a}`;if(T+=C?` ${C}`:"",A=df(w,T,c).width,(j>1||!p[g+1])&&r>g+1){const k=j||r-g,E=d.slice(g,g+k).reduce((R,$)=>R+$,0);if(E<A){const R=Math.ceil((A-E)/k);for(let $=g;$<g+k;$++)d[$]=(d[$]||l)+R}continue}}d[g]=Math.max(d[g]||l,A)}}return d}function Mk(n,a,r){const l=[],c=[];let d="wx-measure-cell-body";d+=n.css?` ${n.css}`:"";for(let m=0;m<a.length;m++){const p=a[m],v=Ur(p,n);v&&(l.push(v),n.treetoggle?c.push(a[m].$level*Bd+(a[m].$count?Bd:0)+(n.draggable?Bd:0)):n.draggable&&c.push(Bd))}return df(l,d,r,c).width}function Tk(n,a){const r="wx-measure-cell-header",l=n.sort?Ak:0;let c=n.header;if(typeof c=="string")return df(c,r,a).width+l;let d;Array.isArray(c)||(c=[c]);for(let m=0;m<c.length;m++){const p=c[m],v=typeof p=="string"?p:p.text,g=r+(typeof p=="string"?"":` ${p.css}`);let w=df(v,g,a).width;m===c.length-1&&(w+=l),d=Math.max(d||0,w)}return d}const Ek={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&&Dk(n,a):!0,multiselect:(n,a)=>!a||a?.length===0?!0:Array.isArray(n)?n?.some(r=>a.includes(r)):n&&a.includes(n)};function $w(n){return Ek[n]}function Rk(n,a){const r=[];for(const l in n){const c=a.find(v=>v.id==l),{config:d,type:m}=c.header.find(v=>v.filter).filter,p=n[l];r.push(v=>{const g=qr(v,c);return d?.handler?d.handler(g,p):$w(m)(g,p)})}return l=>{for(let c=0;c<r.length;c++)if(!r[c](l))return!1;return!0}}function Dk(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let _k=class extends ak{in;_router;_branches;_xlsxWorker;_historyManager;constructor(a){super({writable:a,async:!1});const r={rowHeight:37,columnWidth:160,headerHeight:36,footerHeight:36};this._router=new sk(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:m,_skin:p}=this.getState(),v=this.copyColumns(d),g=v.reduce((b,j)=>Math.max(j.header.length,b),0),w=v.reduce((b,j)=>Math.max(j.footer.length,b),0);v.forEach(this.setCollapsibleColumns);const y=this.normalizeSizes(v,m,g,w,p);for(let b=0;b<v.length;b++)this.normalizeColumns(v,b,"header",g,y),this.normalizeColumns(v,b,"footer",w,y);this.setState({_columns:v,_sizes:y},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:m,dynamic:p,_filterIds:v}=this.getState(),g=v&&new Set(v),w=m?this.flattenRows(d,[],v):g?d.filter(b=>g.has(b.id)):d,y=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:y},c)}}],{sizes:c=>({...r,...c})});const l=this.in=new ik;l.on("close-editor",({ignore:c})=>{const{editor:d}=this.getState();d&&(c||l.exec("update-cell",d),this.setState({editor:null}))}),l.on("open-editor",({id:c,column:d})=>{let m=this.getState().editor;m&&l.exec("close-editor",{});const p=this.getRow(c),v=d?this.getColumn(d):this.getNextEditor(p);if(v?.editor){let g=v.editor;if(typeof g=="function"&&(g=g(p,v)),!g)return;m={column:v.id,id:c,value:qr(p,v)??"",renderedValue:Ur(p,v),type:g.type||g},typeof g=="object"&&g.config&&(m.config=g.config,g.config.options&&(m.options=g.config.options)),v.options&&!m.options&&(m.options=v.options),this.setState({editor:m})}}),l.on("editor",({value:c})=>{let d=this.getState().editor;if(d){d={...d},d.value=c;const m=this.getColumn(d.column),p={...this.getRow(d.id)};sh(p,m,c),d.renderedValue=Ur(p,m),this.setState({editor:d})}}),l.on("add-row",c=>{const d=this.getState();let{data:m}=d;const{select:p,_filterIds:v}=d,{row:g,before:w,after:y,select:b}=c;if(c.id=g.id=c.id||g.id||Fd(),w||y){const C=w||y,A=m.findIndex(T=>T.id===C);m=[...m],m.splice(A+(y?1:0),0,c.row)}else m=[...m,c.row];const j={data:m};v&&(j._filterIds=[...v,c.id]),this.setState(j),!(typeof b=="boolean"&&!b)&&(b||p)&&l.exec("select-row",{id:g.id,show:!0})}),l.on("delete-row",c=>{const{data:d,selectedRows:m,focusCell:p,editor:v}=this.getState(),{id:g}=c,w={data:d.filter(y=>y.id!==g)};this.isSelected(g)&&(w.selectedRows=m.filter(y=>y!==g)),v?.id===g&&(w.editor=null),this.setState(w),p?.row===g&&this.in.exec("focus-cell",{eventSource:"delete-row"})}),l.on("update-cell",c=>{const d=this.getState();let{data:m}=d;m=[...m];const{tree:p}=d,{id:v,column:g,value:w}=c,y=this.getColumn(g);if(p){const b={...this._branches[v]};sh(b,y,w);const j=this.updateTreeRow(b);b.$parent===0&&(m=j)}else{const b=m.findIndex(C=>C.id===v),j={...m[b]};sh(j,y,w),m[b]=j}this.setState({data:m})}),l.on("update-row",c=>{let{data:d}=this.getState();const{id:m,row:p}=c,v=d.findIndex(g=>g.id===m);d=[...d],d[v]={...d[v],...p},this.setState({data:d})}),l.on("select-row",({id:c,toggle:d,range:m,mode:p,show:v,column:g})=>{const w=this.getState(),{focusCell:y}=w;let{selectedRows:b}=w;if(b.length||(m=d=!1),m){const{data:j}=this.getState();let C=j.findIndex(T=>T.id===b[b.length-1]),A=j.findIndex(T=>T.id===c);C>A&&([C,A]=[A,C]),j.slice(C,A+1).forEach(T=>{this.isSelected(T.id)||b.push(T.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;b=b.filter(j=>j!==c)}else if(d){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),y?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),v&&this.in.exec("scroll",{row:c,column:g})}),this.in.on("focus-cell",c=>{const{row:d,column:m,eventSource:p}=c,{_columns:v,split:g}=this.getState();d&&m?(this.setState({focusCell:{row:d,column:m}}),p!=="click"&&((!g.left||v.findIndex(w=>w.id===c.column)>=g.left)&&(!g.right||v.findIndex(w=>w.id===c.column)<v.length-g.right)?this.in.exec("scroll",{row:d,column:m}):this.in.exec("scroll",{row:d}))):this.setState({focusCell:null})}),l.on("resize-column",c=>{const{id:d,auto:m,maxRows:p,inProgress:v}=c;if(v===!1)return;let g=c.width||0;const w=[...this.getState().columns],y=this.getColumn(d);if(m){if(m==="data"||m===!0){const{flatData:b,_skin:j}=this.getState();let C=b.length;p&&(C=Math.min(p,C));const A=b.slice(0,C);g=Mk(y,A,j)}if(m==="header"||m===!0){const{_skin:b}=this.getState();g=Math.max(Tk(y,b),g)}}y.width=Math.max(17,g),delete y.flexgrow,this.setState({columns:w})}),l.on("hide-column",c=>{const{id:d,mode:m}=c,p=[...this.getState().columns],v=this.getColumn(d),g=p.reduce((w,y)=>w+(y.hidden?0:1),0);!m||g>1?(v.hidden=!v.hidden,this.setState({columns:p})):c.skipUndo=!0}),l.on("sort-rows",c=>{const{key:d,add:m,sort:p}=c,v=this.getState(),{columns:g,data:w,tree:y}=v;if(p){const E=[...w];E.sort(p),this.setState({data:E});return}const{order:b="asc"}=c;let j=v.sortMarks;const C=Object.keys(j),A=C.length;!m||!A||A===1&&j[d]?j={[d]:{order:b}}:(A===1&&(j[C[0]]={...j[C[0]],index:0}),j={...j,[d]:{order:b,index:typeof m=="number"?m:j[d]?.index??A}});const T=Object.keys(j).sort((E,R)=>j[E].index-j[R].index).map(E=>({key:E,order:j[E].order}));this.setState({sortMarks:j});const k=kk(T,g);if(k){const E=[...w];y?this.sortTree(E,k):E.sort(k),this.setState({data:E})}}),l.on("filter-rows",c=>{const{value:d,key:m,filter:p}=c;if(!Object.keys(c).length){this.setState({filterValues:{},_filterIds:null});return}const v=this.getState(),{data:g,tree:w,_columns:y}=v;let b=v.filterValues;const j={};m&&(b={...b,[m]:d},j.filterValues=b);const C=p??Rk(b,y);let A=[];w?A=this.filterTree(g,C,A):g.forEach(T=>{C(T)&&A.push(T.id)}),j._filterIds=A,this.setState(j)}),l.on("collapse-column",c=>{const{id:d,row:m,mode:p}=c,v=[...this.getState().columns],g=this.getColumn(d).header,w=Array.isArray(g)?g[m]:g;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:v}))}),l.on("move-item",c=>{const{id:d,inProgress:m}=c;let{target:p,mode:v="after"}=c;const{data:g,flatData:w,tree:y}=this.getState(),b=w.findIndex(A=>A.id===d);let j;if(v==="up"||v==="down"){if(v==="up"){if(b===0)return;j=b-1,v="before"}else if(v==="down"){if(b===w.length-1)return;j=b+1,v="after"}p=w[j]&&w[j].id}else j=w.findIndex(A=>A.id===p);if(b===-1||j===-1||m===!1)return;let C;y||(C=this.moveItem(d,p,g,v)),this.setState({data:y?this.normalizeTreeRows(C):C})}),l.on("copy-row",c=>{const{id:d,target:m,mode:p="after"}=c,v=this.getState(),{flatData:g,_filterIds:w}=v;let{data:y}=v;const b=this.getRow(d);if(!b)return;const j={...b,id:Fd()};c.id=j.id;const C=g.findIndex(T=>T.id===m);if(C===-1)return;y.splice(C+(p==="after"?1:0),0,j),y=[...y];const A={data:y};w&&(A._filterIds=[...w,j.id]),this.setState(A)}),l.on("open-row",c=>{const{id:d,nested:m}=c;this.toggleBranch(d,!0,m)}),l.on("close-row",c=>{const{id:d,nested:m}=c;this.toggleBranch(d,!1,m)}),l.on("export-data",c=>new Promise((d,m)=>{const p=c.format||"csv",v=`${c.fileName||"data"}.${p}`;if(p==="csv"){const g=ck(this.getState(),c.csv||{});c.download!==!1?ok(new Blob(["\uFEFF"+g],{type:"text/csv"}),v):c.result=g,d(!0)}else m()})),l.on("hotkey",({key:c,event:d,isInput:m})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:v,select:g}=this.getState();if(d.preventDefault(),m)return;const w=v?v.column:this._getFirstVisibleColumn()?.id,y=v?this.getPrevRow(v.row)?.id:p[p.length-1]?.id;w&&y&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:y}));break}case"arrowdown":{const{flatData:p,focusCell:v,select:g}=this.getState();if(d.preventDefault(),m)return;const w=v?v.column:this._getFirstVisibleColumn()?.id,y=v?this.getNextRow(v.row)?.id:p[0]?.id;w&&y&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:y}));break}case"arrowright":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const v=this.getNextColumn(p.column,!0)?.id;v&&this.in.exec("focus-cell",{row:p.row,column:v,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const v=this.getPrevColumn(p.column,!0)?.id;v&&this.in.exec("focus-cell",{row:p.row,column:v,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:v,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let y=p.id,b=this.getNextEditor(this.getRow(y),this.getColumn(w));if(!b){const j=this.getNextRow(y);j&&(y=j.id,b=this.getNextEditor(j))}b&&(this.in.exec("open-editor",{id:y,column:b.id}),this.in.exec("focus-cell",{row:y,column:b.id,eventSource:"key"}),g&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else v&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:v,select:g}=this.getState();if(p){d.preventDefault();const w=p.column;let y=p.id,b=this.getPrevEditor(this.getRow(y),this.getColumn(w));if(!b){const j=this.getPrevRow(y);j&&(y=j.id,b=this.getPrevEditor(j))}b&&(this.in.exec("open-editor",{id:y,column:b.id}),this.in.exec("focus-cell",{row:y,column:b.id,eventSource:"key"}),g&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else v&&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:v}=this.getState();!p&&v&&this.in.exec("open-editor",{id:v.row,column:v.column});break}case"enter":{const{focusCell:p,tree:v}=this.getState();if(!m&&v&&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:v}=this.getState();if(!p&&v){d.preventDefault();const g=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:v.row,column:g,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:v,flatData:g,select:w}=this.getState();if(!p&&v){d.preventDefault();const y=g[0]?.id,b=this._getFirstVisibleColumn()?.id;y&&b&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),w&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"end":{const{editor:p,focusCell:v}=this.getState();if(!p&&v){d.preventDefault();const g=this._getLastVisibleColumn()?.id,w=v.row;this.in.exec("focus-cell",{row:w,column:g,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:v,flatData:g,select:w}=this.getState();if(!p&&v){d.preventDefault();const y=g.at(-1).id,b=this._getLastVisibleColumn()?.id;y&&b&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),w&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),l.on("scroll",c=>{const{_columns:d,split:m,_sizes:p,flatData:v,dynamic:g,_rowHeightFromData:w}=this.getState();let y=-1,b=-1,j=0,C=0;if(c.column){y=0;const A=d.findIndex(T=>T.id===c.column);j=d[A].width;for(let T=m.left??0;T<A;T++){const k=d[T];k.hidden||(y+=k.width)}}if(c.row&&!g){const A=v.findIndex(T=>T.id===c.row);A>=0&&(w?(b=v.slice(0,A).reduce((T,k)=>T+(k.rowHeight||p.rowHeight),0),C=v[A].rowHeight):b=p.rowHeight*A)}this.setState({scroll:{top:b,left:y,width:j,height:C||p.rowHeight}})}),l.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)}),l.on("print",c=>{const d=vk(c);this.setState({_print:d}),this.setStateAsync({_print:null})}),l.on("undo",()=>{this._historyManager?.handleUndo()}),l.on("redo",()=>{this._historyManager?.handleRedo()}),this.initOnce()}getXlsxWorker(a){if(!this._xlsxWorker){const r=window.URL.createObjectURL(new Blob([`importScripts('${a}');`],{type:"text/javascript"}));this._xlsxWorker=new Promise(l=>{const c=new Worker(r);c.addEventListener("message",d=>{d.data.type==="init"&&l(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=Nk()),a.columns&&a.columns.forEach(r=>{r.options&&(r.optionsMap=new Map(r.options.map(l=>[l.id,l.label])))}),wf(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 Sk(this.in,this.getState.bind(this),this.setState.bind(this))),this._router.init({...a})}setState(a,r){return this._router.setState(a,r)}setStateAsync(a){this._router.setStateAsync(a)}getRow(a){const{tree:r}=this.getState();return r?this._branches[a]:this.getState().data.find(l=>l.id===a)}getRowIndex(a,r){return r||(r=this.getState().flatData),r.findIndex(l=>l.id===a)}getNextRow(a){const r=this.getState().flatData,l=this.getRowIndex(a,r);return r[l+1]}getPrevRow(a){const r=this.getState().flatData,l=this.getRowIndex(a,r);return r[l-1]}getColumn(a){return this.getState().columns.find(r=>r.id===a)}getNextColumn(a,r){const l=this.getState()._columns,c=l.findIndex(d=>d.id===a);return r?this._getFirstVisibleColumn(c+1):l[c+1]}getPrevColumn(a,r){const l=this.getState()._columns,c=l.findIndex(d=>d.id===a);return r?this._getLastVisibleColumn(c-1):l[c-1]}_getFirstVisibleColumn(a){const r=this.getState()._columns;let l=a??0;for(;l<r.length&&(r[l]?.hidden||r[l]?.collapsed);)l++;return r[l]}_getLastVisibleColumn(a){const r=this.getState()._columns;let l=a??r.length-1;for(;l<r.length&&(r[l]?.hidden||r[l]?.collapsed);)l--;return r[l]}isCellEditable(a,r){const{editor:l,hidden:c}=r;return!l||c?!1:typeof l=="function"?l(a,r):!0}getNextEditor(a,r){let l=this.getState().columns;if(r){const c=l.findIndex(d=>d.id===r.id);l=l.slice(c+1)}return l.find(c=>this.isCellEditable(a,c))}getPrevEditor(a,r){let l=this.getState().columns;if(r){const c=l.findLastIndex(d=>d.id===r.id);l=l.slice(0,c)}return l.findLast(c=>this.isCellEditable(a,c))}toggleBranch(a,r,l){let c=this._branches[a],{data:d}=this.getState();if(d=[...d],a!==0){c={...c,open:r};const m=this.updateTreeRow(c);c.$parent===0&&(d=m)}l&&c.data?.length&&c.data.forEach(m=>{const p=this.toggleKids(m,r,l);a===0&&(d=p)}),this.setState({data:d})}toggleKids(a,r,l){a={...a,open:r};const c=this.updateTreeRow(a);return l&&a.data?.length&&a.data.forEach(d=>{this.toggleKids(d,r,l)}),c}updateTreeRow(a){const r=a.id;this._branches[r]=a;const l=this._branches[a.$parent],c=l.data.findIndex(d=>d.id===r);return l.data=[...l.data],l.data[c]=a,l.data}isSelected(a){return this.getState().selectedRows.indexOf(a)!==-1}findAndRemove(a,r){for(let l=0;l<a.length;l++){if(a[l].id===r)return a.splice(l,1)[0];if(a[l].data){const c=[...a[l].data],d=this.findAndRemove(c,r);if(d)return a[l]={...a[l],data:c},d}}return null}insertItem(a,r,l,c){for(let d=0;d<a.length;d++){if(a[d].id===r){const m=a[d],p=c==="before"?d:d+1;if(m.data){if(c==="before"){const v=d>0?a[d-1]:null;return v?.data&&v.open?a[d-1]={...v,data:[...v.data,l]}:a.splice(p,0,l),!0}else if(m.open)return a[d]={...m,data:[l,...m.data]},!0}return a.splice(p,0,l),!0}if(a[d].data&&(a[d]={...a[d],data:[...a[d].data]},this.insertItem(a[d].data,r,l,c)))return!0}return!1}moveItem(a,r,l,c){const d=[...l],m=this.findAndRemove(d,a);return this.insertItem(d,r,m,c),d}copyColumns(a){const r=[];for(let l=0;l<a.length;l++){const c={...a[l]};this.copyHeaderFooter(c,"header"),this.copyHeaderFooter(c,"footer"),r[l]=c}return r}copyHeaderFooter(a,r){let l=a[r];l=Array.isArray(l)?[...l]:[l],l.forEach((c,d)=>{l[d]=typeof c=="string"?{text:c}:{...c}}),a[r]=l}setCollapsibleColumns(a,r,l){let c=a.header;for(let d=0;d<c.length;d++){const m=c[d];if(m.collapsible&&m.collapsed){if(m.collapsible!=="first"){a.collapsed=!0,a.width=36,m.vertical=!0;const v=c.length-d;c=c.slice(0,d+1),c[d].rowspan=v}const p=m.colspan;if(p){const v=c[d+1];let g=1;v&&v.colspan&&!v.collapsed&&(g=v.colspan);for(let w=g;w<p;w++){const y=l[r+w];y&&(y.hidden=!0)}}}}}normalizeColumns(a,r,l,c,d){const m=a[r];m.width||(m.width=m.flexgrow?17:d.columnWidth),m._colindex=r+1;const p=m[l],v=d[`${l}RowHeights`];for(let g=0;g<c;g++){const w=p[g];w.id=m.id,g===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-g):c-g);for(let y=1;y<w.rowspan;y++){p.splice(g+y,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[r+b][l].splice(g+y,0,{})}if(w.rowspan){const y=(w.rowspan===c?v:v.slice(g,w.rowspan+g)).reduce((b,j)=>b+j,0);w.height=y,g+w.rowspan!=c&&w.height--}if(w.colspan){let y=m.width,b=m.flexgrow||0;const j=w.colspan;for(let C=1;C<j;C++){const A=a[r+C];A&&(A.hidden?w.colspan-=1:A.flexgrow?b+=A.flexgrow:y+=A.width||d.columnWidth),b?w.flexgrow=b:w.width=y}}else w.width=m.width,w.flexgrow=m.flexgrow;l==="header"&&w.filter&&typeof w.filter=="string"&&(w.filter={type:w.filter})}p.length>c&&(p.length=c),m[l]=p}normalizeRows(a){for(let r=0;r<a.length;r++)a[r].id||(a[r].id=Fd());return a}normalizeTreeRows(a,r,l){return!r&&!l&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=Fd()),c.$level=r||0,c.$parent=l||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,r){a.sort(r),a.forEach(l=>{l.data&&this.sortTree(l.data,r)})}filterTree(a,r,l){return a.forEach(c=>{r(c)&&l.push(c.id),c.data&&this.filterTree(c.data,r,l)}),l}flattenRows(a,r,l){const c=r;return a.forEach(d=>{(!l||l.includes(d.id))&&c.push(d),d.data?.length&&d.open!==!1&&this.flattenRows(d.data,c,l)}),c}createFilter(a){const{_columns:r}=this.getState(),l=[];for(const c in a){const d=r.find(g=>g.id==c),{config:m,type:p}=d.header.find(g=>g.filter).filter,v=a[c];l.push(g=>{const w=qr(g,d);return m?.handler?m.handler(w,v):$w(p)(w,v)})}return c=>{for(let d=0;d<l.length;d++)if(!l[d](c))return!1;return!0}}searchRows(a,r){a=a.trim().toLowerCase();const l={};if(!a)return l;const{flatData:c,columns:d}=this.getState(),m=r?d.filter(p=>r[p.id]):d;return c.forEach(p=>{const v={};m.forEach(g=>{const w=Ur(p,g);String(w).toLowerCase().includes(a)&&(v[g.id]=!0)}),Object.keys(v).length&&(l[p.id]=v)}),l}normalizeSizes(a,r,l,c,d){const m=ey(a,"header",l,r.headerHeight,d),p=ey(a,"footer",c,r.footerHeight,d),v=m.reduce((w,y)=>w+y,0),g=p.reduce((w,y)=>w+y,0);return{...r,headerRowHeights:m,footerRowHeights:p,headerHeight:v,footerHeight:g}}},Lk=new Date().valueOf();function Fd(){return"temp://"+Lk++}function zk(n,a="data-id"){let r=n;for(!r.tagName&&n.target&&(r=n.target);r;){if(r.getAttribute&&r.getAttribute(a))return r;r=r.parentNode}return null}new Date().valueOf();var Ik=class{constructor(){this.store=new Map}configure(n,a){this.node=a;for(const r in n)if(n[r]){const l=r.toLowerCase().replace(/[ ]/g,""),c=n[r];this.store.set(l,c)}}},zo=[],Ok={subscribe:n=>{Bk();const a=new Ik;return zo.push(a),n(a),()=>{const r=zo.findIndex(l=>l===a);r>=0&&zo.splice(r,1)}}},ty=!1;function Bk(){ty||(ty=!0,document.addEventListener("keydown",n=>{if(zo.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 r=n.code.replace("Key","").toLocaleLowerCase();n.key===" "&&(r="space"),a.push(r);const l=a.join("+");for(let c=zo.length-1;c>=0;c--){const d=zo[c],m=d.store.get(l)||d.store.get(r);m&&d.node.contains(n.target)&&m(n,{key:l,evKey:r})}}}))}const Fk={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 Pk(n,{keys:a,exec:r}){if(!a)return;function l(m){const p=m.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||zk(p,"data-header-id")?.classList.contains("wx-filter")||!!p.closest(".wx-cell.wx-editor")}const c={};for(const m in a){const p=a[m];typeof p<"u"&&(typeof p=="function"?c[m]=p:p&&(c[m]=v=>{const g=l(v);r({key:m,event:v,isInput:g})}))}const d=Ok.subscribe(m=>{m.configure(c,n)});return{destroy:()=>{d()}}}function Hk(n,a){let r=null;a.scroll.subscribe(l=>{if(!l||l===r)return;r=l;const{left:c,top:d,height:m,width:p}=l,v=a.getHeight(),g=a.getWidth(),w=a.getScrollMargin();if(d>=0){const y=n.scrollTop;d<y?n.scrollTop=d:d+m>y+v&&(n.scrollTop=d-v+m)}if(c>=0){const y=n.scrollLeft;c<y?n.scrollLeft=c:c+p>y+g-w&&(n.scrollLeft=c-g+p+w)}}),a.scrollLeft?.subscribe?.(l=>{requestAnimationFrame(()=>{Math.abs(n.scrollLeft-l)>1&&(n.scrollLeft=l)})}),a.scrollTop?.subscribe?.(l=>{requestAnimationFrame(()=>{Math.abs(n.scrollTop-l)>1&&(n.scrollTop=l)})})}const Za=u.createContext(null);function $k(n,a){const r=new ResizeObserver(l=>{requestAnimationFrame(()=>a(l[0].contentRect))});return r.observe(n.parentNode),{destroy(){r.disconnect()}}}const ny=5,Uk=700;function Qd(n){const a=n.getBoundingClientRect(),r=document.body,l=a.top+r.scrollTop-r.clientTop||0,c=a.left+r.scrollLeft-r.clientLeft||0;return{y:Math.round(l),x:Math.round(c),width:n.offsetWidth,height:n.offsetHeight}}function Ih(n,a){const r=Qd(a);return{x:n.clientX-r.x,y:n.clientY-r.y}}function qk(n,a){const r=a.current;let l=null,c,d,m=!1,p=!1;const v=document.createElement("DIV");v.className="wx-drag-zone",v.setAttribute("tabindex",-1);function g(){clearTimeout(c),c=null}function w(L){const _=Fo(L);_&&(l={container:v,sourceNode:L.target,from:vf(_),pos:Ih(L,n)},d=l.pos,y(L))}function y(L){if(!l)return;const _=l.pos=Ih(L,n);if(!m){if(!p&&!L?.target?.getAttribute("draggable-data")&&Math.abs(d.x-_.x)<ny&&Math.abs(d.y-_.y)<ny)return;if(F(L)===!1)return q()}if(p){const ie=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,V=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;l.targetNode=document.elementFromPoint(L.pageX-ie,L.pageY-V)}else l.targetNode=L.target;r.move&&r.move(L,l),v.style.left=-(l.offset?l.offset.x:0)+"px",v.style.top=l.pos.y+(l.offset?l.offset.y:0)+"px"}function b(L){v.parentNode&&v.parentNode.removeChild(v),v.innerHTML="",m&&r.end&&r.end(L,l),l=d=null,q()}function j(L){r.getReorder&&!r.getReorder()||L.button===0&&($(L),window.addEventListener("mousemove",C),window.addEventListener("mouseup",A),w(L))}function C(L){y(L)}function A(L){b(L)}function T(L){if(r.getReorder&&!r.getReorder())return;c=setTimeout(()=>{p=!0,w(L.touches[0])},Uk),$(L);function _(){c&&g(),L.target.removeEventListener("touchmove",k),L.target.removeEventListener("touchend",_),b(L)}L.target.addEventListener("touchmove",k),L.target.addEventListener("touchend",_),n.addEventListener("contextmenu",E)}function k(L){m?(L.preventDefault(),y(L.touches[0])):c&&g()}function E(L){if(m||c)return L.preventDefault(),!1}function R(L){L.preventDefault()}function $(L){if(!r.getDraggableInfo)return;const{hasDraggable:_}=r.getDraggableInfo();(!_||L.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function F(L){if(m=!0,r.start){if(r.start(L,l)===!1)return!1;n.appendChild(v),document.body.style.cursor="move"}}function q(L){m=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",A),L&&(n.removeEventListener("mousedown",j),n.removeEventListener("touchstart",T),n.removeEventListener("dragstart",R))}return n.addEventListener("mousedown",j),n.addEventListener("touchstart",T),n.addEventListener("dragstart",R),{destroy(){q(!0)}}}const Gk=.004;function Vk(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function Yk(n,a,r,l){const{node:c,left:d,top:m,bottom:p,sense:v,xScroll:g,yScroll:w}=l,y=Ih(n,c);r.scrollState||(r.scrollState=Vk());let b=0,j=0;y.x<d+v?b=-1:y.x>a.width-v&&(b=1),y.y<m+Math.round(v/2)?j=-1:y.y>a.height-p-Math.round(v/2)&&(j=1),(r.scrollState.dirX!==b||r.scrollState.dirY!==j)&&(Uw(r),r.scrollState.dirX=b,r.scrollState.dirY=j),(g&&r.scrollState.dirX!==0||w&&r.scrollState.dirY!==0)&&Wk(r,l,{x:r.scrollState.dirX,y:r.scrollState.dirY})}function Wk(n,a,r){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(Kk,15,n,a,r)},250))}function Uw(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function Kk(n,a,r){const{x:l,y:c}=r;n.scrollSpeedFactor+=Gk,l!==0&&Xk(n,a,l),c!==0&&Qk(n,a,c)}function Qk(n,a,r){const l=a.node.scrollTop;qw(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollTop",a)}function Xk(n,a,r){const l=a.node.scrollLeft;qw(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollLeft",a)}function qw(n,a,r){r.node[a]=n}function bf(n,a,r,l,c,d){const m={};return n&&(m.width=`${n}px`,m.minWidth=`${n}px`),a&&(m.flexGrow=a),d&&(m.height=`${d}px`),r&&(m.position="sticky",r.left&&(m.left=`${l}px`),r.right&&(m.right=`${c}px`)),m}function Gw(n,a,r){let l="";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),l+=d?"wx-shadow ":"wx-fixed "}return l+=a.rowspan>1?"wx-rowspan ":"",l+=a.colspan>1?"wx-colspan ":"",l+=a.vertical?"wx-vertical ":"",l+=r?r(n)+" ":"",l}function Zk(n){const{row:a,column:r,cellStyle:l=null,columnStyle:c=null,children:d,focusable:m}=n,p=u.useContext(Za),v=nt(p,"focusCell"),g=nt(p,"search"),w=nt(p,"reorder"),y=u.useMemo(()=>g?.rows[a.id]&&g.rows[a.id][r.id],[g,a.id,r.id]),b=u.useMemo(()=>bf(r.width,r.flexgrow,r.fixed,r.left,r.right),[r.width,r.flexgrow,r.fixed,r.left,r.right]);function j(F,q){let L="wx-cell";return L+=r.fixed?" "+(r.fixed===-1?"wx-shadow":"wx-fixed"):"",L+=F?" "+F(r):"",L+=q?" "+q(a,r):"",L+=r.treetoggle?" wx-tree-cell":"",L}const C=u.useMemo(()=>j(c,l),[c,l,r,a]),A=u.useMemo(()=>typeof r.draggable=="function"?r.draggable(a,r)!==!1:r.draggable,[r,a]),T=u.useRef(null);u.useEffect(()=>{T.current&&m&&v?.row===a.id&&v?.column===r.id&&T.current.focus()},[v,m,a.id,r.id]);const k=u.useCallback(()=>{m&&!v&&p.exec("focus-cell",{row:a.id,column:r.id,eventSource:"focus"})},[p,m,v,a.id,r.id]);function E(F){const q=new RegExp(`(${g.value.trim()})`,"gi");return String(F).split(q).map(L=>({text:L,highlight:q.test(L)}))}const R=u.useMemo(()=>{const F=r.fixed&&r.fixed.left===-1||r.fixed.right===-1,q=r.fixed&&r.fixed.right;return[C,F?"wx-shadow":"",q?"wx-fixed-right":""].filter(Boolean).join(" ")},[C,r]),$=r.cell;return s.jsxs("div",{className:"wx-TSCaXsGV "+R,ref:T,onFocus:k,style:b,"data-row-id":On(a.id),"data-col-id":On(r.id),tabIndex:m?"0":"-1",role:"gridcell","aria-colindex":r._colindex,"aria-readonly":r.editor?void 0:!0,children:[w&&r.draggable?A?s.jsx("i",{"draggable-data":"true",className:"wx-TSCaXsGV wx-draggable wxi-drag"}):s.jsx("i",{className:"wx-TSCaXsGV wx-draggable-stub"}):null,r.treetoggle?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{marginLeft:`${a.$level*28}px`}}),a.$count?s.jsx("i",{"data-action":"toggle-row",className:`wx-TSCaXsGV wx-table-tree-toggle wxi-menu-${a.open!==!1?"down":"right"}`}):null]}):null,$?s.jsx($,{api:p,row:a,column:r,onAction:({action:F,data:q})=>p.exec(F,q)}):d?d():y?s.jsx("span",{children:E(Ur(a,r)).map(({highlight:F,text:q},L)=>F?s.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:q},L):s.jsx("span",{children:q},L))}):Ur(a,r)]})}function ay(n,a){let r,l;function c(p){r=p.clientX,n.style.opacity=1,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",d),window.addEventListener("mouseup",m),a&&a.down&&a.down(n)}function d(p){l=p.clientX-r,a&&a.move&&a.move(l)}function m(){n.style.opacity="",document.body.style.cursor="",document.body.style.userSelect="",a&&a.up&&a.up(l),window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",m)}return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c)}}}function Jk({filter:n,column:a,action:r,filterValue:l}){function c({value:d}){r({value:d,key:a.id})}return s.jsx(op,{...n.config??{},value:l,onChange:c})}function eA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Za),d=nt(c,"flatData"),m=u.useMemo(()=>n?.config?.options||a?.options||v(),[n,a,d]),p=u.useMemo(()=>n?.config?.template,[n]);function v(){const y=[];return d.forEach(b=>{const j=qr(b,a);y.includes(j)||y.push(j)}),y.map(b=>({id:b,label:b}))}function g({value:y}){r({value:y,key:a.id})}function w(y){y.key!=="Tab"&&y.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:w,children:s.jsx(hC,{placeholder:"",clear:!0,...n?.config??{},options:m,value:l,onChange:g,children:y=>p?p(y):y.label})})}function tA({filter:n,column:a,action:r,filterValue:l}){function c({value:d}){r({value:d,key:a.id})}return s.jsx("div",{className:"wx-aaaK5VYO",style:{width:"100%"},children:s.jsx(mC,{placeholder:"",clear:!0,...n?.config??{},value:l,onChange:c})})}function Vw(n){const{value:a,options:r=[],placeholder:l="",clear:c=!1,text:d=null,template:m=null,cell:p=null,dropdown:v={},autoOpen:g=!1,onChange:w,onAction:y}=n,[b,j]=Ew(a||[]),C=u.useMemo(()=>(b||[]).map(V=>r.find(ne=>ne.id===V)).filter(Boolean),[b,r]),A=u.useRef(null),T=u.useRef(null),[k,E]=u.useState(null),R=()=>{const V=b||[];if(!V.length)return 0;const ne=r.find(Q=>V.includes(Q.id));return ne?r.indexOf(ne):0};function $(V){T.current=V.navigate,E(()=>V.keydown),g&&V.navigate(R())}u.useEffect(()=>{g&&(A.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function F({id:V}){j(V),w&&w({value:V})}function q(V){V.stopPropagation(),j([]),w&&w({value:[]})}function L(){T.current?.(R())}function _(){T.current?.(null)}function ie(V){k?.(V,R())}return s.jsxs("div",{ref:A,className:"wx-multiselect wx-aadNNOwy",onClick:L,onKeyDown:ie,tabIndex:0,children:[s.jsx("div",{className:"wx-label wx-aadNNOwy",children:m?m(C):p?s.jsx(p,{data:C,onAction:y}):d?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):C.length?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:C.map(V=>V.label).join(", ")}):l?s.jsx("span",{className:"wx-placeholder wx-aadNNOwy",children:l}):" "}),c&&b?.length?s.jsx("i",{className:"wx-icon wxi-close wx-aadNNOwy",onClick:q}):s.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),s.jsx(yf,{items:r,onReady:$,onSelect:F,multiselect:!0,checkboxes:!0,value:b||[],onCancel:_,...v,children:({option:V})=>s.jsx("div",{className:"wx-option wx-aadNNOwy",children:m?m(V):p?s.jsx(p,{data:V,onAction:y}):V.label})})]})}function nA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Fn.i18n)?.getGroup("grid")||ru(dp).getGroup("grid"),d=u.useMemo(()=>({clear:!0,...n?.config||{}}),[n]),m=u.useMemo(()=>d.options||a.options,[d,a]),p=u.useMemo(()=>{const w=l?.length;return w?w<3?l.map(y=>a.optionsMap.get(y)).join(", "):w+" "+c("selected"):""},[l,a,c]);function v({value:w}){r({value:w,key:a.id})}function g(w){w.key!=="Tab"&&w.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:g,children:s.jsx(Vw,{placeholder:"",...d,options:m,value:l||[],text:p,onChange:v})})}const aA={text:Jk,richselect:eA,datepicker:tA,multiselect:nA};function sA({filter:n,column:a}){const r=u.useContext(Za),l=nt(r,"filterValues");function c(m){r.exec("filter-rows",m)}const d=u.useMemo(()=>aA[n.type],[n.type]);return s.jsx(d,{filter:n,column:a,action:c,filterValue:l[a.id]})}function iA(n){const{cell:a,column:r,row:l,lastRow:c,sortRow:d,columnStyle:m,bodyHeight:p,hasSplit:v}=n,g=u.useContext(Za),w=nt(g,"sortMarks"),y=u.useMemo(()=>w?w[r.id]:void 0,[w,r.id]),b=u.useRef(),j=u.useCallback(le=>{b.current=a.flexgrow?le.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),C=u.useCallback((le,Y)=>{g.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+le),inProgress:Y})},[g,a.id]),A=u.useCallback(le=>C(le,!0),[C]),T=u.useCallback(le=>C(le,!1),[C]),k=u.useCallback(le=>{if(!r.sort||a.filter)return;let Y=y?.order;Y&&(Y=Y==="asc"?"desc":"asc"),g.exec("sort-rows",{key:a.id,add:le.ctrlKey||le.metaKey,order:Y})},[g,a.id,a.filter,r.sort,y?.order]),E=u.useCallback(le=>{le&&le.stopPropagation(),g.exec("collapse-column",{id:a.id,row:l})},[g,a.id,l]),R=u.useCallback(le=>{le.key==="Enter"&&E()},[E]),$=u.useCallback(le=>{le.key==="Enter"&&!a.filter&&k(le)},[k,a.filter]),F=u.useMemo(()=>a.collapsed&&r.collapsed,[a.collapsed,r.collapsed]),q=u.useMemo(()=>F&&!v&&a.collapsible!=="header",[F,v,a.collapsible]),L=u.useMemo(()=>q?{top:-p/2,position:"absolute"}:{},[q,p]),_=u.useMemo(()=>bf(a.width,a.flexgrow,r.fixed,r.left,a.right??r.right,a.height+(F&&q?p:0)),[a.width,a.flexgrow,r.fixed,r.left,a.right,r.right,a.height,F,q,p]),ie=u.useMemo(()=>Gw(r,a,m),[r,a,m]),V=u.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([le])=>le!=="cell")),[a]),ne=`wx-cell ${ie} ${a.css||""} wx-collapsed`,Q=["wx-cell",ie,a.css||"",a.filter?"wx-filter":"",r.fixed&&r.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),J=u.useRef(null);return u.useEffect(()=>{const le=J.current;if(!le)return;const Y=ay(le,{down:j,move:A,up:T});return()=>{typeof Y=="function"&&Y()}},[j,A,T,ay]),F?s.jsx("div",{className:"wx-RsQD74qC "+ne,style:_,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:E,"data-header-id":On(r.id),children:s.jsx("div",{className:"wx-RsQD74qC wx-text",style:L,children:a.text||""})}):s.jsxs("div",{className:"wx-RsQD74qC "+Q,style:_,onClick:k,"data-header-id":On(r.id),tabIndex:!a._hidden&&r.sort&&!a.filter?0:void 0,role:"columnheader","aria-colindex":r._colindex,"aria-colspan":a.colspan>1?a.colspan:void 0,"aria-rowspan":a.rowspan>1?a.rowspan:void 0,"aria-sort":!y?.order||a.filter?"none":y?.order==="asc"?"ascending":"descending",onKeyDown:$,children:[a.collapsible?s.jsx("div",{className:"wx-RsQD74qC wx-collapse",role:"button","aria-label":a.collapsed?"Expand column":"Collapse column","aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:E,children:s.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const le=a.cell;return s.jsx(le,{api:g,cell:V(),column:r,row:l,onAction:({action:Y,data:O})=>g.exec(Y,O)})})():a.filter?s.jsx(sA,{filter:a.filter,column:r}):s.jsx("div",{className:"wx-RsQD74qC wx-text",children:a.text||""}),r.resize&&c&&!a._hidden?s.jsx("div",{className:"wx-RsQD74qC wx-grip",role:"presentation","aria-label":"Resize column",ref:J,onClick:le=>le.stopPropagation(),children:s.jsx("div",{})}):null,d?s.jsx("div",{className:"wx-RsQD74qC wx-sort",children:y?s.jsxs(s.Fragment,{children:[typeof y.index<"u"?s.jsx("div",{className:"wx-RsQD74qC wx-order",children:y.index+1}):null,s.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${y.order==="asc"?"up":"down"}`})]}):null}):null]})}function rA({cell:n,column:a,row:r,columnStyle:l}){const c=u.useContext(Za),d=u.useMemo(()=>bf(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]),m=u.useMemo(()=>Gw(a,n,l),[a,n,l]),p=u.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([g])=>g!=="cell")),[n]),v=`wx-6Sdi3Dfd wx-cell ${m||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return s.jsx("div",{className:v,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?Kh.createElement(n.cell,{api:c,cell:p(),column:a,row:r,onAction:({action:g,data:w})=>c.exec(g,w)}):s.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function sy({deltaLeft:n,contentWidth:a,columns:r,type:l="header",columnStyle:c,bodyHeight:d}){const m=u.useContext(Za),p=nt(m,"_sizes"),v=nt(m,"split"),g=u.useMemo(()=>p?.[`${l}RowHeights`],[p,l]),w=u.useMemo(()=>{let A=[];if(r&&r.length){const T=r[0][l].length;for(let k=0;k<T;k++){let E=0;A.push([]),r.forEach((R,$)=>{const F={...R[l][k]};E||A[k].push(F),F.colspan>1?E=F.colspan-1:E&&E--})}}return A},[r,l]),y=u.useMemo(()=>v?.left||v?.right,[v]);function b(A){return r.find(T=>T.id===A)}function j(A,T){let k=T;return A.rowspan&&(k+=A.rowspan-1),k===w.length-1}function C(A,T,k){if(!k.sort)return!1;for(let E=w.length-1;E>=0;E--){const R=k.header[E];if(!R.filter&&!R._hidden)return T===E}return j(A,T)}return s.jsx("div",{className:`wx-sAsPVaUK wx-${l}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((A,T)=>s.jsx("div",{className:l==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${g?.[T]}px`,display:"flex"},role:"row",children:A.map(k=>{const E=b(k.id);return l==="header"?s.jsx(iA,{cell:k,columnStyle:c,column:E,row:T,lastRow:j(k,T),bodyHeight:d,sortRow:C(k,T,E),hasSplit:y},k.id):s.jsx(rA,{cell:k,columnStyle:c,column:b(k.id),row:T},k.id)})},T))})}function lA({overlay:n}){const a=u.useContext(Za);function r(c){return typeof c=="function"}const l=n;return s.jsx("div",{className:"wx-1ty666CQ wx-overlay",children:r(n)?s.jsx(l,{onAction:({action:c,data:d})=>a.exec(c,d)}):n})}function oA(n){const{editor:a,onSave:r,onApply:l}=n,[c,d]=u.useState(a?.value||""),{type:m="text"}=u.useMemo(()=>a?.config||{},[a]),p=u.useRef(null);u.useEffect(()=>{p.current&&p.current.focus()},[]),u.useEffect(()=>{if(!p.current)return;const w=di(p.current,()=>r(!0));return()=>w.destroy()},[r]);function v(){p.current&&(d(p.current.value),l(p.current.value))}function g({key:w}){w==="Enter"&&r()}return s.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:v,onKeyDown:g,ref:p,type:m,value:c})}function cA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d,m]=u.useState(n?.value),[p,v]=u.useState(n?.renderedValue),[g,w]=u.useState(n?.options||[]),y=u.useMemo(()=>n?.config?.template,[n]),b=u.useMemo(()=>n?.config?.cell,[n]),j=u.useMemo(()=>n?.config?.dropdown||{},[n]),C=u.useMemo(()=>({trackScroll:!0,...j}),[j]),A=u.useMemo(()=>(g||[]).findIndex(L=>L.id===d),[g,d]),T=u.useRef(null),k=u.useRef(null),E=u.useCallback(L=>{T.current=L.navigate,k.current=L.keydown,T.current(A)},[A,T]),R=u.useCallback(L=>{const _=L?.target?.value??"";v(_);const ie=_?(n?.options||[]).filter(V=>(V.label||"").toLowerCase().includes(_.toLowerCase())):n?.options||[];w(ie),ie.length?T.current(-1/0):T.current(null)},[n]),$=u.useRef(null);u.useEffect(()=>{$.current&&$.current.focus()},[]);const F=u.useRef(r);u.useEffect(()=>{F.current=r},[r]),u.useEffect(()=>{if(!$.current)return;const L=di($.current,()=>F.current(!0));return()=>L.destroy()},[]),u.useEffect(()=>{m(n?.value),v(n?.renderedValue),w(n?.options||[])},[n]);const q=u.useCallback(({id:L})=>{l(L),r()},[l,r]);return s.jsxs(s.Fragment,{children:[s.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:$,value:p??"",onChange:R,onKeyDown:L=>k.current?k.current(L,A):void 0}),s.jsx(yf,{items:g,onReady:E,onSelect:q,...C,onCancel:c,children:({option:L})=>y?y(L):b?s.jsx(b,{data:L,onAction:a}):L.label})]})}function uA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d]=u.useState(()=>n.value||new Date),{template:m,cell:p,dropdown:v={}}=n?.config||{},g=u.useMemo(()=>({trackScroll:!0,width:"auto",...v}),[v]);function w({value:C}){l(C),r()}const y=u.useRef(null),[b,j]=u.useState(null);return u.useEffect(()=>{y.current&&y.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!b)return;const C=di(b,()=>r(!0));return()=>C.destroy()},[b,r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:y,tabIndex:0,onClick:c,onKeyDown:C=>C.preventDefault(),children:m?m(d):p?s.jsx(p,{data:n.value,onAction:a}):s.jsx("span",{className:"wx-lNWNYUb6 wx-text",children:n.renderedValue})}),s.jsx(lp,{...g,onCancel:c,children:s.jsx("div",{ref:j,className:"wx-lNWNYUb6",children:s.jsx(kw,{value:d,onChange:w,buttons:n.config?.buttons})})})]})}function dA(n){const{editor:a}=n,r=n.onAction??n.onaction,l=n.onSave??n.onsave,c=n.onApply??n.onapply,d=n.onCancel??n.oncancel,m=a.config||{},{dropdown:p={}}=m,v=u.useMemo(()=>({trackScroll:!0,...p}),[p]),[g]=u.useState(a.options.find(R=>R.id===a.value)),[w]=u.useState(a.value),[y]=u.useState(a.options),b=u.useMemo(()=>y.findIndex(R=>R.id===w),[y,w]);function j({id:R}){c(R),l()}let C;const[A,T]=u.useState();function k(R){C=R.navigate,T(()=>R.keydown),C(b)}const E=u.useRef(null);return u.useEffect(()=>{E.current&&E.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!E.current)return;const R=di(E.current,()=>l(!0));return()=>R.destroy()},[l]),s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:E,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:R=>{A(R,b),R.preventDefault()},children:m.template?m.template(g):m.cell?(()=>{const R=m.cell;return s.jsx(R,{data:g,onAction:r})})():s.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),s.jsx(yf,{items:y,onReady:k,onSelect:j,...v,onCancel:d,children:({option:R})=>m.template?m.template(R):m.cell?(()=>{const $=m.cell;return s.jsx($,{data:R,onAction:r})})():R.label})]})}function fA(n){const{editor:a,onAction:r,onSave:l,onApply:c}=n,d=a?.config||{},m=a?.options??[],p=a?.value||[],v=a?.renderedValue,g=u.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function w({value:b}){c(b)}const y=u.useRef(null);return u.useEffect(()=>{if(!y.current)return;const b=di(y.current,()=>l(!0));return()=>b.destroy()},[l]),s.jsx("div",{ref:y,className:"wx-value wx-aacZ4gNU",onClick:()=>l(!0),children:s.jsx(Vw,{value:p,options:m,text:v,template:d.template,cell:d.cell,clear:d.clear,dropdown:g,autoOpen:!0,onChange:w,onAction:r})})}const mA={text:oA,combo:cA,datepicker:uA,richselect:dA,multiselect:fA};function hA({column:n,row:a}){const r=u.useContext(Za),l=nt(r,"editor"),c=u.useCallback((C,A)=>{r.exec("close-editor",{ignore:C}),A&&r.exec("focus-cell",{...A,eventSource:"click"})},[r]),d=u.useCallback(C=>{const A=C?null:{row:l?.id,column:l?.column};c(!1,A)},[l,c]),m=u.useCallback(()=>{c(!0,{row:l?.id,column:l?.column})},[l,c]),p=u.useCallback(C=>{r.exec("editor",{value:C})},[r]),v=u.useCallback(C=>{C.key==="Enter"&&l&&(n.editor.type==="multiselect"?p(l.value):m())},[l,n.editor,m,p]),g=u.useMemo(()=>bf(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=u.useMemo(()=>{let C=n.editor;if(typeof C=="function"&&(C=C(a,n)),!C)return null;let A=typeof C=="string"?C:C.type;return mA[A]},[n,a]),y=u.useRef(null);u.useEffect(()=>{y.current&&typeof g=="string"&&y.current.setAttribute("style",g)},[g]);const b=typeof a.$parent<"u"?"gridcell":"cell",j=typeof a.$parent<"u"?!n.editor:void 0;return s.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:y,style:typeof g=="object"&&g!==null?g:void 0,role:b,"aria-readonly":j,tabIndex:-1,onClick:C=>C.stopPropagation(),onDoubleClick:C=>C.stopPropagation(),onKeyDown:v,children:w?s.jsx(w,{editor:l,onSave:d,onApply:p,onCancel:m,onAction:({action:C,data:A})=>r.exec(C,A)}):null})}function iy(n){const{columns:a,type:r,columnStyle:l}=n,c=u.useContext(Za),{filterValues:d,_columns:m,_sizes:p}=c.getState();function v(g){return l?" "+l(g):""}return s.jsx(s.Fragment,{children:a.map((g,w)=>s.jsx("tr",{children:g.map(y=>{const b=m.find(A=>A.id===y.id),j=`wx-print-cell-${r}${v(b)}${y.filter?" wx-print-cell-filter":""}${y.vertical?" wx-vertical":""}`,C=y.cell;return s.jsx("th",{style:Rw(Pw(y,p.columnWidth)),className:"wx-Gy81xq2u "+j,rowSpan:y.rowspan,colSpan:y.colspan,children:C?s.jsx(C,{api:c,cell:Object.fromEntries(Object.entries(y).filter(([A])=>A!=="cell")),column:b,row:w}):y.filter?s.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:xk(d,m,y)}):s.jsx("div",{className:"wx-Gy81xq2u wx-text",children:y.text??""})},y.id)})},w))})}function pA(n){const{columns:a,rowStyle:r,columnStyle:l,cellStyle:c,header:d,footer:m,reorder:p}=n,v=u.useContext(Za),{flatData:g,_sizes:w}=v.getState(),y=d&&Zx(a,"header",w.headerRowHeights),b=m&&Zx(a,"footer",w.footerRowHeights);function j(A,T){let k="";return k+=l?" "+l(T):"",k+=c?" "+c(A,T):"",k}function C(A,T){return typeof T.draggable=="function"?T.draggable(A,T)!==!1:T.draggable}return s.jsxs("table",{className:`wx-8NTMLH0z wx-print-grid ${a.some(A=>A.flexgrow)?"wx-flex-columns":""}`,children:[d?s.jsx("thead",{children:s.jsx(iy,{columns:y,type:"header",columnStyle:l})}):null,s.jsx("tbody",{children:g.map((A,T)=>s.jsx("tr",{className:"wx-8NTMLH0z wx-row"+(r?" "+r(A):""),style:{height:`${A.rowHeight||w.rowHeight}px`},children:a.map(k=>k.collapsed?null:s.jsxs("td",{className:`wx-8NTMLH0z wx-print-cell wx-cell ${j(A,k)}`,style:Rw(Pw(k,w.columnWidth)),children:[p&&k.draggable?s.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:C(A,k)?s.jsx("i",{className:"wx-8NTMLH0z wxi-drag"}):null}):null,k.treetoggle?s.jsxs(s.Fragment,{children:[s.jsx("span",{style:{marginLeft:A.$level*28+"px"}}),A.$count?s.jsx("i",{className:`wx-8NTMLH0z wx-print-grid-tree-toggle wxi-menu-${A.open!==!1?"down":"right"}`}):null]}):null,k.cell?(()=>{const E=k.cell;return s.jsx(E,{api:v,row:A,column:k})})():s.jsx("span",{children:Ur(A,k)})]},k.id))},T))}),m?s.jsx("tfoot",{children:s.jsx(iy,{columns:b,type:"footer",columnStyle:l})}):null]})}function gA(n){const{config:a,...r}=n,l=u.useContext(Za),{_skin:c,_columns:d}=l.getState(),m=u.useMemo(()=>hk(d,a),[]),p=u.useRef(null);return u.useEffect(()=>{const v=document.body;v.classList.add("wx-print");const g=p.current;if(!g)return;const w=g.cloneNode(!0);v.appendChild(w);const y=`@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(y)),window.print(),b.remove(),v.classList.remove("wx-print"),w.remove()},[]),s.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:m.map((v,g)=>s.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:s.jsx(pA,{columns:v,...r})},g))})}function vA(n){const{header:a,footer:r,overlay:l,multiselect:c,onreorder:d,rowStyle:m,columnStyle:p,cellStyle:v,autoRowHeight:g,resize:w,clientWidth:y,clientHeight:b,responsiveLevel:j,hotkeys:C}=n,A=u.useContext(Za),T=nt(A,"dynamic"),k=nt(A,"_columns"),E=nt(A,"flatData"),R=nt(A,"split"),$=nt(A,"_sizes"),[F,q]=vs(A,"selectedRows"),L=nt(A,"select"),_=nt(A,"editor"),ie=nt(A,"scrollLeft"),V=nt(A,"scrollTop"),ne=nt(A,"tree"),Q=nt(A,"focusCell"),J=nt(A,"_print"),le=nt(A,"undo"),Y=nt(A,"reorder"),O=nt(A,"_rowHeightFromData"),[Z,X]=u.useState(0);u.useEffect(()=>{X(ft())},[]);const[D,K]=u.useState(0),ce=u.useMemo(()=>(k||[]).some(te=>!te.hidden&&te.flexgrow),[k]),W=u.useMemo(()=>$?.rowHeight||0,[$]),P=u.useRef(null),[me,ge]=u.useState(null),[xe,Ce]=u.useState(null),Le=u.useMemo(()=>{let te=[],Ne=0;return R&&R.left&&(te=(k||[]).slice(0,R.left).filter(He=>!He.hidden).map(He=>({...He})),te.forEach(He=>{He.fixed={left:1,leftSize:R.left},He.left=Ne,Ne+=He.width}),te.length&&(te[te.length-1].fixed.left=-1)),{columns:te,width:Ne}},[R,k]),ze=u.useMemo(()=>{let te=[],Ne=0;if(R&&R.right){te=(k||[]).slice(R.right*-1).filter(He=>!He.hidden).map(He=>({...He}));for(let He=te.length-1;He>=0;He--){const at=te[He];at.fixed={right:1},at.right=Ne,Ne+=at.width}te.length&&(te[0].fixed={right:-1})}return{columns:te,width:Ne}},[R,k]),ue=u.useMemo(()=>{const te=(k||[]).slice(R?.left||0,(k||[]).length-(R?.right??0)).filter(Ne=>!Ne.hidden);return te.forEach(Ne=>{Ne.fixed=0}),te},[k,R]),Ye=u.useMemo(()=>(k||[]).reduce((te,Ne)=>(Ne.hidden||(te+=Ne.width),te),0),[k]),We=1;function oe(te,Ne,He){let at=Ne,Kt=te;if(ue.length){let Tt=ue.length;for(let Xe=te;Xe>=0;Xe--)ue[Xe][He].forEach(rt=>{rt.colspan>1&&Xe>te-rt.colspan&&Xe<Tt&&(Tt=Xe)});if(Tt!==ue.length&&Tt<te){for(let Xe=Tt;Xe<te;Xe++)at-=ue[Xe].width;Kt=Tt}}return{index:Kt,delta:at}}const Ae=u.useMemo(()=>{let te,Ne,He;const at=ie||0,Kt=(ie||0)+(y||0);let Tt=0,Xe=0,rt=0,Qt=0;ue.forEach((on,Xt)=>{at>rt&&(Tt=Xt,Qt=rt),rt=rt+on.width,Kt>rt&&(Xe=Xt+We)});const $t={header:0,footer:0};for(let on=Xe;on>=Tt;on--)["header","footer"].forEach(Xt=>{ue[on]&&ue[on][Xt].forEach(xs=>{const ys=xs.colspan;if(ys&&ys>1){const mi=ys-(Xe-on+1);mi>0&&($t[Xt]=Math.max($t[Xt],mi))}})});const Dt=oe(Tt,Qt,"header"),Pt=oe(Tt,Qt,"footer"),Ut=Dt.delta,_t=Dt.index,hn=Pt.delta,ns=Pt.index;return ce&&Ye>(y||0)?te=Ne=He=[...Le.columns,...ue,...ze.columns]:(te=[...Le.columns,...ue.slice(Tt,Xe+1),...ze.columns],Ne=[...Le.columns,...ue.slice(_t,Xe+$t.header+1),...ze.columns],He=[...Le.columns,...ue.slice(ns,Xe+$t.footer+1),...ze.columns]),{data:te||[],header:Ne||[],footer:He||[],d:Qt,df:hn,dh:Ut}},[ue,Le,ze,ie,y,ce,Ye]),je=u.useMemo(()=>a&&$?.headerHeight||0,[a,$]),Ee=u.useMemo(()=>r&&$?.footerHeight||0,[r,$]),Re=u.useMemo(()=>y&&b?Ye>=y:!1,[y,b,Ye]),[Fe,pe]=u.useState(!1),ke=u.useMemo(()=>(b||0)-je-Ee-(Re?Z:0),[b,je,Ee,Re,Z]),de=u.useMemo(()=>Math.ceil((ke||0)/(W||1))+1,[ke,W]),we=u.useRef([]),[Ge,tt]=u.useState(0),[wn,Qe]=u.useState(void 0),ht=u.useMemo(()=>{let te=0,Ne=0;const He=2,at=V||0;if(g){let Xe=at;for(;Xe>0;)Xe-=we.current[te]||W,te++;Ne=at-Xe;for(let rt=Math.max(0,te-He-1);rt<te;rt++)Ne-=we.current[te-rt]||W;te=Math.max(0,te-He)}else{if(O){let Xe=0,rt=0;for(let Pt=0;Pt<(E||[]).length;Pt++){const Ut=E[Pt].rowHeight||W;if(rt+Ut>at){Xe=Pt;break}rt+=Ut}te=Math.max(0,Xe-He);for(let Pt=0;Pt<te;Pt++)Ne+=E[Pt].rowHeight||W;let Qt=0,$t=0;for(let Pt=Xe+1;Pt<(E||[]).length;Pt++){const Ut=E[Pt].rowHeight||W;if(Qt++,$t+Ut>ke)break;$t+=Ut}const Dt=Math.min(T?T.rowCount:(E||[]).length,Xe+Qt+He);return{d:Ne,start:te,end:Dt}}te=Math.floor(at/(W||1)),te=Math.max(0,te-He),Ne=te*(W||0)}const Kt=T?T.rowCount:(E||[]).length,Tt=Math.min(Kt,te+(de||0)+He);return{d:Ne,start:te,end:Tt}},[g,O,V,W,T,E,de,ke]),St=u.useMemo(()=>{const te=T?T.rowCount:(E||[]).length;if(g)return Ge+ht.d+(te-(wn||0))*(W||0);if(!O)return te*(W||0);let Ne=0;for(let He=0;He<te;He++)Ne+=E[He]?.rowHeight||W;return Ne},[T,E,W,g,O,Ge,ht.d,wn]),Tn=u.useRef({});Tn.current={clientWidth:y,clientHeight:b,fullHeight:St,headerHeight:je,footerHeight:Ee,fullWidth:Ye,SCROLLSIZE:Z};const Oe=u.useCallback(()=>{const te=Tn.current;pe(te.clientWidth&&te.clientHeight?te.fullHeight+te.headerHeight+te.footerHeight>=te.clientHeight-(te.fullWidth>=te.clientWidth?te.SCROLLSIZE:0):!1)},[]);u.useEffect(()=>{const te=requestAnimationFrame(Oe);return()=>window.cancelAnimationFrame(te)},[D,Oe]),u.useEffect(()=>{Oe()},[b,Oe]);const Ft=u.useMemo(()=>ce&&Ye<=(y||0)?(y||0)-0-(Fe?Z:0):Ye,[ce,Ye,y,Fe,Z,Re]),Gt=u.useMemo(()=>ce&&Ye<=(y||0)?y||0:Ft<(y||0)?Ye+(Fe?Z:0):-1,[ce,Ye,y,Ft,Fe,Z]),pt=u.useRef({});u.useEffect(()=>{if(T&&(pt.current.start!==ht.start||pt.current.end!==ht.end)){const{start:te,end:Ne}=ht;pt.current={start:te,end:Ne},A&&A.exec&&A.exec("request-data",{row:{start:te,end:Ne}})}},[T,ht,A]);const it=u.useMemo(()=>T?E||[]:(E||[]).slice(ht.start,ht.end),[T,E,ht]),nn=u.useMemo(()=>(F||[]).filter(te=>(it||[]).some(Ne=>Ne.id===te)),[q,it]),Mt=u.useMemo(()=>ht.start,[ht.start]),De=u.useRef({top:V,left:ie});De.current={top:V,left:ie};const En=u.useCallback(te=>{const Ne=te.target.scrollTop,He=te.target.scrollLeft,at=De.current;(Ne!==at.top||He!==at.left)&&A.exec("scroll-to",{top:Ne,left:He})},[A]),Xi=u.useCallback(te=>{te.shiftKey&&te.preventDefault(),P.current&&P.current.focus&&P.current.focus()},[]),fn=u.useCallback(()=>!!(k||[]).find(te=>!!te.draggable),[k]),Pn=u.useRef(null),pa=u.useRef(null),Ja=u.useRef({dblclick:(te,Ne)=>{const He={id:te,column:su(Ne,"data-col-id")};A.exec("open-editor",He)},click:(te,Ne)=>{if(Ne.target.closest("input")||Pn.current)return;const He=su(Ne,"data-col-id");if(Q?.id!==te&&A.exec("focus-cell",{row:te,column:He,eventSource:"click"}),L===!1)return;const at=c&&(Ne.ctrlKey||Ne.metaKey),Kt=c&&Ne.shiftKey;(at||F.length>1||!F.includes(te))&&A.exec("select-row",{id:te,toggle:at,range:Kt})},"toggle-row":te=>{const Ne=A.getRow(te);A.exec(Ne.open!==!1?"close-row":"open-row",{id:te})},"ignore-click":()=>!1}),Rn=u.useMemo(()=>({top:je,bottom:Ee,left:Le.width,xScroll:Re,yScroll:Fe,sense:g&&xe?xe.offsetHeight:Math.max($?.rowHeight||0,40),node:P.current&&P.current.firstElementChild}),[je,Ee,Le.width,Re,Fe,g,xe,$]);function es(te,Ne){const{container:He,sourceNode:at,from:Kt}=Ne;if(fn()&&!at.getAttribute("draggable-data"))return!1;ge(Kt),ne&&A.getRow(Kt).open&&A.exec("close-row",{id:Kt,nested:!0});const Tt=Fo(at),Xe=Tt.cloneNode(!0);Xe.classList.remove("wx-selected"),Xe.querySelectorAll("[tabindex]").forEach(Dt=>Dt.setAttribute("tabindex","-1")),He.appendChild(Xe),Ce(Xe);const rt=(ie||0)-Ae.d,Qt=Fe?Z:0;He.style.width=Math.min((y||0)-Qt,ce&&Ye<=(y||0)?Ft:Ft-Qt)+rt+"px";const $t=Qd(Tt);Ne.offset={x:rt,y:-Math.round($t.height/2)},pa.current||(pa.current=te.clientY)}function Ie(te,Ne){const{from:He}=Ne,at=Ne.pos,Kt=Qd(P.current);at.x=Kt.x;const Tt=Rn.top;if(at.y<Tt)at.y=Tt;else{const Xe=Kt.height-(Re&&Z>0?Z:Math.round(Rn.sense/2))-Rn.bottom;at.y>Xe&&(at.y=Xe)}if(P.current.contains(Ne.targetNode)){const Xe=Fo(Ne.targetNode),rt=Xe&&vf(Xe);if(rt&&rt!==He){Ne.to=rt;const Qt=g?xe?.offsetHeight:$?.rowHeight;if(xe&&((V||0)===0||at.y>Tt+Qt-1)){const $t=Xe.getBoundingClientRect(),Dt=Qd(xe).y,Pt=$t.y,Ut=Dt>Pt?-1:1,_t=Ut===1?"after":"before",hn=A.getState().flatData,ns=Math.abs(hn.findIndex(Xt=>Xt.id===He)-hn.findIndex(Xt=>Xt.id===rt)),on=ns!==1?_t==="before"?"after":"before":_t;if(ns===1&&(Ut===-1&&te.clientY>pa.current||Ut===1&&te.clientY<pa.current))return;pa.current=te.clientY,A.exec("move-item",{id:He,target:rt,mode:on,inProgress:!0})}}d&&d({event:te,context:Ne})}Yk(te,Kt,Ne,Rn)}function fi(te,Ne){const{from:He,to:at}=Ne;A.exec("move-item",{id:He,target:at,inProgress:!1}),Pn.current=setTimeout(()=>{Pn.current=0},1),ge(null),Ce(null),pa.current=null,Uw(Ne)}function ft(){const te=document.createElement("div");te.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(te);const Ne=te.offsetWidth-te.clientWidth;return document.body.removeChild(te),Ne}const ts=u.useMemo(()=>Gt>0?{width:`${Gt}px`}:void 0,[Gt]),Vt=u.useRef(null);function Bs(){Promise.resolve().then(()=>{let te=0,Ne=Mt;const He=Vt.current;He&&(Array.from(He.children).forEach((at,Kt)=>{we.current[Mt+Kt]=at.offsetHeight,te+=at.offsetHeight,Ne++}),tt(te),Qe(Ne))})}u.useEffect(()=>{it&&g&&Bs()},[it,g,Mt]);let[B,$e]=u.useState();u.useEffect(()=>{if(Q&&(!L||!nn.length||nn.includes(Q.row)))$e({...Q});else if(it.length&&Ae.data.length){if(!B||nn.length&&!nn.includes(B.row)||it.findIndex(te=>te.id===B.row)===-1||Ae.data.findIndex(te=>te.id===B.column&&!te.collapsed)===-1){const te=nn[0]||it[0].id,Ne=Ae.data.findIndex(He=>!He.collapsed);$e(Ne!==-1?{row:te,column:Ae.data[Ne].id}:null)}}else $e(null)},[Q]);const mt=u.useRef(null);u.useEffect(()=>{const te=P.current;if(!te)return;const Ne=$k(te,w);return()=>{typeof Ne=="function"&&Ne()}},[w]);const an=u.useRef({});Object.assign(an.current,{start:es,move:Ie,end:fi,getReorder:()=>Y,getDraggableInfo:()=>({hasDraggable:fn()})}),u.useEffect(()=>{const te=P.current;return te?qk(te,an).destroy:void 0},[Y,P.current]),u.useEffect(()=>{const te=P.current;return te?Pk(te,{keys:C!==!1&&{...Fk,"ctrl+z":le,"ctrl+y":le,...C},exec:Ne=>A.exec("hotkey",Ne)}).destroy:void 0},[A,le,C]);const mn=u.useRef({scroll:A.getReactiveState().scroll,scrollLeft:A.getReactiveState().scrollLeft,scrollTop:A.getReactiveState().scrollTop});mn.current.getWidth=()=>(y||0)-(Fe?Z:0),mn.current.getHeight=()=>ke,mn.current.getScrollMargin=()=>Le.width+ze.width,u.useEffect(()=>{Hk(mt.current,mn.current)},[]);const Fs=u.useRef(null);u.useEffect(()=>{const te=Fs.current;if(!te)return;const Ne=[];Ne.push(di(te,()=>Q&&A.exec("focus-cell",{eventSource:"click"})).destroy),Ne.push(qC(te,Ja.current)),K(te.clientHeight);const He=new ResizeObserver(()=>{K(te.clientHeight)});return He.observe(te),Ne.push(()=>He.disconnect()),()=>Ne.forEach(at=>at())},[]);const ia=`wx-grid ${j?`wx-responsive-${j}`:""}`;return u.useEffect(()=>{Q&&(it.some(te=>te.id===Q.row)&&Ae.data.some(te=>te.id===Q.column&&!te.collapsed)||A.exec("focus-cell",{eventSource:"destroy"}))},[Q,it,Ae.data,A]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-4VuBwK2D "+ia,style:{"--header-height":`${je}px`,"--footer-height":`${Ee}px`,"--split-left-width":`${Le.width}px`,"--split-right-width":`${ze.width}px`},children:s.jsx("div",{ref:P,className:"wx-4VuBwK2D wx-table-box",style:ts,role:ne?"treegrid":"grid","aria-colcount":Ae.data.length,"aria-rowcount":it.length,"aria-multiselectable":ne&&c?!0:void 0,tabIndex:-1,children:s.jsxs("div",{ref:mt,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:Re?"scroll":"hidden",overflowY:Fe?"scroll":"hidden"},onScroll:En,children:[a?s.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:s.jsx(sy,{contentWidth:Ft,deltaLeft:Ae.dh,columns:Ae.header,columnStyle:p,bodyHeight:ke-+r})}):null,s.jsxs("div",{ref:Fs,className:"wx-4VuBwK2D wx-body",style:{width:`${Ft}px`,height:`${St}px`},onMouseDown:te=>Xi(te),children:[l?s.jsx(lA,{overlay:l}):null,s.jsx("div",{ref:Vt,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${ht.d}px`,paddingLeft:`${Ae.d}px`},children:it.map((te,Ne)=>{const He=F.indexOf(te.id)!==-1,at=me===te.id,Kt="wx-row"+(g?" wx-autoheight":"")+(m?" "+m(te):"")+(He?" wx-selected":"")+(at?" wx-inactive":""),Tt=g?{minHeight:`${te.rowHeight||W}px`}:{height:`${te.rowHeight||W}px`};return s.jsx("div",{className:"wx-4VuBwK2D "+Kt,"data-id":On(te.id),"data-context-id":On(te.id),style:Tt,role:"row","aria-rowindex":Ne,"aria-expanded":te.open,"aria-level":ne?te.$level+1:void 0,"aria-selected":ne?He:void 0,tabIndex:-1,children:Ae.data.map(Xe=>Xe.collapsed?s.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},Xe.id):_?.id===te.id&&_.column===Xe.id?s.jsx(hA,{row:te,column:Xe},Xe.id):s.jsx(Zk,{row:te,column:Xe,columnStyle:p,cellStyle:v,reorder:Y,focusable:B?.row===te.id&&B?.column===Xe.id},Xe.id))},te.id)})})]}),r&&(E||[]).length?s.jsx(sy,{type:"footer",contentWidth:Ft,deltaLeft:Ae.df,columns:Ae.footer,columnStyle:p}):null]})})}),J?s.jsx(gA,{config:J,rowStyle:m,columnStyle:p,cellStyle:v,header:a,footer:r,reorder:Y}):null]})}const xA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),yA=u.forwardRef(function({data:n=[],columns:a=[],rowStyle:r=null,columnStyle:l=null,cellStyle:c=null,selectedRows:d,select:m=!0,multiselect:p=!1,header:v=!0,footer:g=!1,dynamic:w=null,overlay:y=null,reorder:b=!1,onReorder:j=null,autoRowHeight:C=!1,sizes:A,split:T,tree:k=!1,autoConfig:E=!1,init:R=null,responsive:$=null,sortMarks:F,undo:q=!1,hotkeys:L=null,filterValues:_,...ie},V){const ne=u.useRef();ne.current=ie;const Q=u.useMemo(()=>new _k(Dw),[]),J=u.useMemo(()=>Q.in,[Q]),le=u.useRef(null);le.current===null&&(le.current=new Aw((ze,ue)=>{const Ye="on"+xA(ze);ne.current&&ne.current[Ye]&&ne.current[Ye](ue)}),J.setNext(le.current));const Y=u.useMemo(()=>({getState:Q.getState.bind(Q),getReactiveState:Q.getReactive.bind(Q),getStores:()=>({data:Q}),exec:J.exec,setNext:ze=>(le.current=le.current.setNext(ze),le.current),intercept:J.intercept.bind(J),on:J.on.bind(J),detach:J.detach.bind(J),getRow:Q.getRow.bind(Q),getColumn:Q.getColumn.bind(Q)}),[Q,J]),[O,Z]=u.useState(0),[X,D]=u.useState(0),[K,ce]=u.useState(null),[W,P]=u.useState(null),me=u.useMemo(()=>{if(E&&!a.length&&n.length){const ze=n[0],ue=[];for(let Ye in ze)if(Ye!=="id"&&Ye[0]!=="$"){let We={id:Ye,header:Ye[0].toUpperCase()+Ye.slice(1)};typeof E=="object"&&(We={...We,...E}),ue.push(We)}return ue}return(W&&W.columns)??a},[E,a,n,W]),ge=u.useMemo(()=>(W&&W.sizes)??A,[W,A]),xe=u.useCallback(ze=>{if(Z(ze.width),D(ze.height),$){const ue=Object.keys($).map(Number).sort((Ye,We)=>Ye-We).find(Ye=>ze.width<=Ye)??null;ue!==K&&(P($[ue]),ce(ue))}},[$,K]),Ce=u.useContext(Fn.theme),Le=u.useRef(0);return u.useEffect(()=>{if(!Le.current)R&&R(Y);else{const ze=Q.getState();Q.init({data:n,columns:me,split:T||ze.split,sizes:ge||ze.sizes,selectedRows:d||ze.selectedRows,dynamic:w,tree:k,sortMarks:F||ze.sortMarks,filterValues:_||ze.filterValues,undo:q,reorder:b,_skin:Ce,_select:m})}Le.current++},[Q,n,me,T,ge,d,w,k,F,_,q,b,Ce,m,R,Y]),Le.current===0&&Q.init({data:n,columns:me,split:T||{left:0},sizes:ge||{},selectedRows:d||[],dynamic:w,tree:k,sortMarks:F||{},filterValues:_||{},undo:q,reorder:b,_skin:Ce,select:m}),u.useImperativeHandle(V,()=>({...Y}),[Y]),s.jsx(Za.Provider,{value:Y,children:s.jsx(up,{words:dp,optional:!0,children:s.jsx(vA,{header:v,footer:g,overlay:y,rowStyle:r,columnStyle:l,cellStyle:c,onReorder:j,multiselect:p,autoRowHeight:C,clientWidth:O,clientHeight:X,responsiveLevel:K,resize:xe,hotkeys:L})})})});ap(Ia);const Bn=u.createContext(null),hp=u.createContext(null),pp=u.createContext(null);function wA({children:n}){const a=u.useContext(Fn.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=u.useContext(Bn),[c]=vs(l,"panels"),d=nt(l,"activePanel"),m=c[d].path,[p,v]=u.useState(null),[g,w]=u.useState(null),[y,b]=u.useState(""),[j,C]=u.useState(""),[A,T]=u.useState(!1);function k(){const F=y.trim();if(!F){T(!0);return}p.add?l.exec("create-file",{file:{...p.item,name:F},parent:m}):j!==F&&l.exec("rename-file",{id:p.item.id,name:F}),E()}function E(){v(null),T(null),C(""),b("")}function R(){l.exec("delete-files",{ids:g.selected}),w(null)}const $=u.useMemo(()=>({showPrompt(F){const q=F.item.name||(F.item.type==="folder"?r("New folder"):`${r("New file")}.txt`);C(q),b(q),v({...F})},showConfirm(F){w({...F})}}),[r]);return s.jsxs(hp.Provider,{value:$,children:[s.jsx(wC,{children:n}),p?s.jsx(Lh,{title:r(`Enter ${p.item.type} name`),onConfirm:k,onCancel:E,children:s.jsx(op,{error:A,select:!0,focus:!0,value:y,onChange:({value:F})=>b(F)})}):null,g?s.jsx(Lh,{title:r("Are you sure you want to delete these items:"),onConfirm:R,onCancel:()=>w(null),children:g.selected?s.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:g.selected.map((F,q)=>s.jsx("li",{children:F},q))}):null}):null]})}let ry={"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 bA(n){const a=n.lastIndexOf("."),r=a>0&&a<n.length-1?Math.min(10,n.length-a):Math.min(5,n.length),l=n.slice(0,-r),c=n.slice(-r);return[l,c]}function SA({item:n}){const a=u.useContext(Bn),r=u.useContext(Fn.i18n).getGroup("filemanager"),l=u.useContext(Bn).templates,[c]=vs(a,"panels"),d=nt(a,"activePanel"),m=nt(a,"mode"),p=c[d].selected,v=u.useMemo(()=>l.preview(n,214,163),[l,n]),g=u.useMemo(()=>l.icon(n,"big"),[l,n]),[w,y]=u.useMemo(()=>bA(n.name),[n.name]);return s.jsx(s.Fragment,{children:n.id==="/wx-filemanager-parent-link"?m!=="search"?s.jsx("div",{className:"wx-GAOa4kDV wx-back-item",children:s.jsxs("div",{className:`wx-GAOa4kDV wx-back ${n.navigation?"wx-selected":""}`,"data-id":On("/wx-filemanager-parent-link"),children:[s.jsx("i",{className:"wx-GAOa4kDV wxi-arrow-left"}),s.jsx("span",{children:r("Back to parent folder")})]})}):null:s.jsxs("div",{className:`wx-GAOa4kDV wx-item ${p?.length&&p.indexOf(n.id)>=0?"wx-selected":""}`,"data-id":On(n.id),children:[v?s.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-preview",children:s.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:r("A miniature file preview"),src:v})}):g?s.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:s.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:g})}):s.jsx("div",{className:"wx-GAOa4kDV wx-preview",children:s.jsx("i",{className:`wx-GAOa4kDV wxi-${n.type}`})}),n.type==="folder"?s.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[s.jsxs("div",{className:"wx-GAOa4kDV wx-folder-name",children:[s.jsx("span",{className:"wx-GAOa4kDV wx-type",children:r("Folder")}),s.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[s.jsx("span",{children:w}),s.jsx("span",{children:y})]})]}),s.jsx("div",{"data-action-id":On(n.id),className:"wx-GAOa4kDV wx-more",children:s.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]}):s.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[s.jsx("div",{className:"wx-GAOa4kDV wx-file-name",children:s.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[s.jsx("span",{children:w}),s.jsx("span",{children:y})]})}),s.jsx("div",{"data-action-id":On(n.id),className:"wx-GAOa4kDV wx-more",children:s.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function Yw(){const n=u.useContext(Bn),a=u.useContext(Fn.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),[l]=vs(n,"panels"),c=nt(n,"activePanel"),d=nt(n,"mode"),m=l[c]._files,p=l[c].selected,v=l[c].path,g=l[c]._crumbs,w=l[c]._selectNavigation,y=u.useCallback((E,R)=>{const $=R&&(R.ctrlKey||R.metaKey),F=R&&R.shiftKey;if(E==="/wx-filemanager-parent-link"){if(p.length&&($||F))return;n.exec("select-file",{type:"navigation"});return}let q=E==="body"&&R?null:E;const L=R.target.className.indexOf("wx-more")!==-1||R.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:q,toggle:$&&!L,range:F&&!L,panel:c})},1)},[n,p,c]),b=u.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]),j=u.useCallback(E=>{if(E==="/wx-filemanager-parent-link")return b();d==="search"&&n.exec("filter-files",{text:""});const R=m.find($=>$.id===E);R&&(R.type=="folder"?n.exec("set-path",{id:R.id,panel:c}):n.exec("open-file",{id:R.id}))},[n,b,d,m,c]),C=u.useCallback((E,R)=>{(!p?.length||!p.filter($=>$?.id===E).length>0)&&y(E,R)},[p,y]),A=u.useMemo(()=>v!=="/"?[{id:"/wx-filemanager-parent-link",name:r("Back to parent folder"),navigation:w},...m]:m,[v,r,w,m]),T=u.useRef(null),k=u.useRef();return u.useEffect(()=>{T.current&&(k.current?(k.current.click=y,k.current._dblclick=j,k.current.context=C):(k.current={click:y,dblclick:E=>k.current._dblclick(E),_dblclick:j,context:C},Po(T.current,k.current)))},[y,j,C]),d=="search"&&!A.length?s.jsx("div",{className:"wx-iyjASZCY wx-not-found",children:s.jsx("div",{className:"wx-iyjASZCY wx-not-found-text",children:r("Looks like nothing is here")})}):s.jsx("div",{tabIndex:0,className:"wx-iyjASZCY "+("wx-cards"+(v!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":On("body"),ref:T,children:A.map(E=>s.jsx(SA,{item:E},E.id))})}function Il({name:n="",spin:a=!1,onClick:r}){return s.jsx("i",{"data-menu-ignore":"true",className:`wx-uwcvNSAG wx-icon wxi-${n} ${a?"wx-spin":""} ${r?"wx-clickable":""}`,onClick:()=>{r&&r()}})}function jA(){const n=u.useContext(Fn.i18n).getGroup("filemanager"),a=u.useContext(Bn),r=nt(a,"activePanel"),[l]=vs(a,"panels"),c=u.useMemo(()=>l[r]._crumbs,[l,r]);function d(){a.exec("filter-files",{text:""})}return s.jsxs("div",{className:"wx-GDJvtROw wx-search",children:[s.jsxs("div",{className:"wx-GDJvtROw wx-toolbar",children:[s.jsx("div",{className:"wx-GDJvtROw wx-back-icon",children:s.jsx(Il,{name:"angle-left",onClick:d})}),s.jsxs("div",{className:"wx-GDJvtROw wx-text",children:[n("Search results in")," ",Array.isArray(c)&&c.map((m,p)=>s.jsxs(u.Fragment,{children:[p?"/":null,m.id=="/"?n(m.name):m.name]},p))]})]}),s.jsx(Yw,{})]})}function ih({narrowMode:n,extraInfo:a}){const r=u.useContext(Bn),{preview:l,icon:c}=r.templates,d=u.useContext(Fn.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>Lo("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[v,g]=vs(r,"panels"),w=nt(r,"activePanel"),y=nt(r,"preview"),b=nt(r,"search"),j=u.useMemo(()=>{const L=v&&w!=null&&v[w]?._selected?.length||0;return b&&!L},[b,g,w]),C=u.useMemo(()=>{const L=v&&w!=null?v[w]:null;return L?j?L._files:L._selected:[]},[j,g,w]),A=u.useCallback((L,_)=>(L?`${L} ${m(L>1?"folders":"folder")} `:"")+(_?`${_} ${m(_>1?"files":"file")}`:""),[m]),T=u.useCallback(()=>{r.exec("show-preview",{mode:!y})},[r,y]),k=u.useCallback(L=>L.type==="folder"?m("Folder"):L.ext||m("Unknown file"),[m]),E=u.useMemo(()=>{let L,_,ie,V,ne,Q,J,le;if(C.length===1&&!j){_=C[0],L=_.name;const Y=l(_,400,500);Y?(ie=Y,V=""):(V=c(_,"big"),ie=""),ne=_.type!=="folder"}else{if(_=ne=null,L="",C.length){let Y=0,O=0,Z=0,X=[],D;C.forEach(ce=>{typeof ce.size>"u"&&(D=!0,Y=void 0),D||(Y+=ce.size),X.push(k(ce)),ce.type==="folder"?O++:Z++});const K=new Set(X);Q=K.size>1?m("multiple"):[...K][0],J=A(O,Z),le=Y,j||(L=m("Multiple files"))}V=c({type:j?"search":C.length?"multiple":"none"},"big"),ie=""}return{name:L,item:_,previewSrc:ie,iconSrc:V,showDownloadIcon:ne,type:Q,totalCount:J,totalSize:le}},[C,j,l,c,m,k,A]),R=u.useCallback(()=>{r.exec("download-file",{id:C[0].id})},[r,C]),$=u.useCallback(async L=>{if(!a||!L)return null;try{return await a(L)}catch(_){return console.log(_),null}},[a]),[F,q]=u.useState(null);return u.useEffect(()=>{let L=!1;return q(null),Promise.resolve($(E.item)).then(_=>{L||q(_)}).catch(()=>{L||q(null)}),()=>{L=!0}},[$,E.item]),s.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:C&&C.length?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"wx-O0BTtRrH wx-preview",children:[s.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-name",children:E.name}),s.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[E.showDownloadIcon?s.jsx(Il,{name:"download",onClick:R}):null,n?s.jsx(Il,{name:"close",onClick:T}):null]})]}),E.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:E.previewSrc,alt:m("A miniature file preview")})}):E.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:E.iconSrc,alt:m("A miniature file preview")})}):s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:E.item?s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${E.item.type}`}):s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${j?"search":"file-multiple-outline"}`})})]}),s.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-title",children:m(j?"Found":"Information")}),s.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[E.item?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:k(E.item)}),typeof E.item.size<"u"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Size")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:iu(E.item.size)})]}):null,s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Date")}),s.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(E.item.date)," "]})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Count")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:E.totalCount}),s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:E.type}),typeof E.totalSize<"u"?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Size")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:iu(E.totalSize)})]}):null]}),F?Object.entries(F).map(([L,_])=>s.jsxs(Kh.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:L}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:_})]},L)):null]})]})]}):s.jsxs("div",{className:"wx-O0BTtRrH wx-no-info-panel",children:[s.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-name",children:E.name}),s.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?s.jsx(Il,{name:"close",onClick:T}):null})]}),s.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:s.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[E.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:E.previewSrc,alt:m("A miniature file preview")})}):E.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:E.iconSrc,alt:m("A miniature file preview")})}):s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${j?"search":"message-question-outline"}`})}),s.jsx("span",{className:"wx-O0BTtRrH wx-text",children:j?"":m("Select file or folder to view details")})]})})]})})}function Ww({panel:n}){const a=u.useContext(Bn),r=u.useContext(Fn.i18n),l=u.useMemo(()=>r.getGroup("filemanager"),[r]),[c,d]=vs(a,"panels"),m=u.useMemo(()=>c[n]._files,[d,n]),p=u.useMemo(()=>c[n]._crumbs||[],[d,n]);function v(C){const A=fp(C,p);a.exec("set-path",{id:C,panel:n,...A&&{selected:[A]}})}const[g,w]=u.useState(null);u.useEffect(()=>{m&&w(null)},[m]);function y(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=u.useRef(null),j=u.useRef();return u.useEffect(()=>{j.current?j.current.click=v:(j.current={click:v},Po(b.current,j.current))},[v]),s.jsxs("div",{className:"wx-SNY5LTYx wx-breadcrumbs","data-menu-ignore":"true",ref:b,children:[s.jsx("div",{className:"wx-SNY5LTYx wx-refresh-icon",children:s.jsx(Il,{name:"refresh",spin:!!g,onClick:y})}),p.map((C,A)=>s.jsxs(Kh.Fragment,{children:[A?s.jsx(Il,{name:"angle-right"}):null,s.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":On(C.id),"data-menu-ignore":"true",children:C.id=="/"?l(C.name):C.name})]},A))]})}function CA({row:n}){const a=u.useContext(Fn.i18n),[r]=u.useState(()=>a.getGroup("filemanager")),l=u.useContext(Bn).templates,[c]=u.useState(()=>l.icon(n,"small"));return s.jsx("div",{className:"wx-qgAqG6sL wx-name-cell",children:n.id==="/wx-filemanager-parent-link"?s.jsxs(s.Fragment,{children:[s.jsx("i",{className:"wx-qgAqG6sL wxi-arrow-left"}),s.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",r("Back to parent folder")]})]}):s.jsxs(s.Fragment,{children:[c?s.jsx("img",{className:"wx-qgAqG6sL wx-icon",alt:"",src:c,height:"24px",width:"24px"}):s.jsx("i",{className:`wx-qgAqG6sL wxi-${n.type}`}),s.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",n.name," "]})]})})}function Kw({children:n}){const a=u.useContext(Bn),r=nt(a,"activePanel"),l=u.useContext(pp),c=u.useRef(null);let d=u.useRef({});return d.current.drop=()=>{const m=c.current,p=N1(m,"data-panel");p&&p!=r&&a.exec("set-active-panel",{panel:p*1})},d.current.dragEnter=()=>{const m=c.current;m&&m.classList.toggle("wx-active")},d.current.dragLeave=()=>{const m=c.current;m&&m.classList.toggle("wx-active")},u.useEffect(()=>{const m=c.current;return l.droparea(m,d.current)},[]),s.jsx("div",{className:"wx-LT9X7tb7 wx-upload-area",ref:c,children:n})}function Oh({panel:n,active:a=!1,onClick:r,onContextMenu:l}){const c=u.useContext(Bn),d=u.useContext(Fn.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>Lo("%d %M %Y",d.getRaw().calendar),[d]),[v]=vs(c,"panels"),g=v[n].selected,w=v[n].path,y=v[n]._crumbs,b=v[n]._sorts,j=v[n]._selectNavigation,C=v[n]._files,A=u.useMemo(()=>[{id:"name",header:m("Name"),flexgrow:3,sort:!0,resize:!0,cell:CA},{id:"size",header:m("Size"),width:100,sort:!0,resize:!0,template:Q=>typeof Q=="number"?iu(Q):""},{id:"date",header:m("Date"),width:120,sort:!0,resize:!0,template:Q=>Q?p(Q):""}],[m,p]),T=u.useRef(null),k=u.useRef(null),E=u.useMemo(()=>j?["/wx-filemanager-parent-link"]:[...g],[j,g]);function R(Q,J){if(J&&J.target&&J.target.className&&J.target.className.indexOf("wx-grip")!==-1)return;const le=J&&(J.ctrlKey||J.metaKey),Y=J&&J.shiftKey;if(Q==="/wx-filemanager-parent-link"){if(g.length&&(le||Y))return;c.exec("select-file",{type:"navigation"});return}let O=Q==="body"&&J?null:Q;!T.current&&!k.current?c.exec("select-file",{id:O,toggle:le,range:Y,panel:n}):(T.current=null,k.current=null)}function $(){y.length>1&&c.exec("set-path",{id:y[y.length-2].id,panel:n,selected:[y[y.length-1].id]})}function F(Q){if(Q==="/wx-filemanager-parent-link")return $();const J=C.find(le=>le.id===Q);J&&(J.type==="folder"?c.exec("set-path",{id:J.id,panel:n}):c.exec("open-file",{id:J.id}))}function q(Q){const J=Q.key,le=b[w];let Y=le?"asc":"desc";le&&le.key===J&&(Y=le.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:J,order:Y,panel:n,path:w})}function L(Q){Q.intercept("sort-rows",J=>(T.current=!0,q(J),!1)),Q.intercept("select-row",()=>!1),Q.on("resize-column",()=>k.current=!0),Q.intercept("hotkey",()=>!1)}const _=u.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:m("Back to parent folder")},...C]:C,[w,C,m]),ie=u.useMemo(()=>{if(_&&b&&b[w]){const{key:Q,order:J}=b[w];return{[Q]:{order:J}}}},[_,b,w]),V=u.useRef(null),ne=u.useRef();return u.useEffect(()=>{ne.current?(ne.current.click=R,ne.current._dblclick=F):(ne.current={click:R,dblclick:Q=>ne.current._dblclick(Q),_dblclick:F},Po(V.current,ne.current))},[R,F]),s.jsxs("div",{onClick:r,onContextMenu:l,className:"wx-SSaVhET7 wx-wrapper",children:[s.jsx(Ww,{panel:n}),s.jsx("div",{"data-id":On("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:V,children:s.jsx(Kw,{children:s.jsx(yA,{init:L,data:_,columns:A,selectedRows:E,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:ie})})})]})}function kA(){const n=u.useContext(Bn),a=nt(n,"activePanel");function r(l){n.exec("set-active-panel",{panel:l})}return s.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":On("body"),children:[s.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:s.jsx(Oh,{panel:0,active:a==0,onClick:()=>r(0),onContextMenu:()=>r(0)})}),s.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":1,children:s.jsx(Oh,{panel:1,active:a==1,onClick:()=>r(1),onContextMenu:()=>r(1)})})]})}function Qw({folderIcon:n=!1,folder:a={}}){const r=u.useContext(Bn),[l,c]=vs(r,"panels"),d=nt(r,"activePanel"),m=u.useMemo(()=>l[d].path,[c,d]),p=u.useContext(Fn.i18n),v=u.useMemo(()=>p.getGroup("filemanager"),[p]),g=u.useMemo(()=>!!a.data?.find(j=>j.type==="folder"),[a]),w=u.useMemo(()=>a.id=="/"?v(a.name):a.name,[a,v]),y=u.useMemo(()=>a.$level>1?(a.$level-1)*20:0,[a]),b=a.open;return s.jsxs(s.Fragment,{children:[s.jsxs("li",{"data-id":On(a.id),className:`wx-NYfhvGIt wx-folder${m===a.id?" wx-selected":""}`,style:{paddingLeft:`${y}px`},children:[g?s.jsx("i",{className:`wx-NYfhvGIt wx-toggle wxi-${b?"angle-down":"angle-right"}`,"data-action":"toggle"}):s.jsx("span",{className:"wx-NYfhvGIt wx-toggle-placeholder"}),s.jsx("i",{className:"wx-NYfhvGIt "+(n||"wxi-folder")}),s.jsxs("span",{className:"wx-NYfhvGIt wx-name",children:[" ",w," "]})]}),b&&a.data&&a.data.length&&g?s.jsx(s.Fragment,{children:a.data.map(j=>j.type==="folder"?s.jsx(Qw,{folder:j},j.id):null)}):null]})}function AA(){const n=u.useContext(Bn),[a,r]=vs(n,"data"),[l,c]=vs(n,"panels"),d=nt(n,"activePanel"),m=u.useMemo(()=>l[d]._crumbs,[c,d]),p=u.useCallback(j=>{n.exec("open-tree-folder",{id:j,mode:!a.byId(j).open})},[n,r]),v=u.useCallback(j=>{const C=fp(j,m);n.exec("set-path",{id:j,panel:d,...C&&{selected:[C]}})},[n,m,d]),[g,w]=u.useState([]);u.useEffect(()=>{w(a.byId(0).data)},[r]);const y=u.useRef(null),b=u.useRef();return u.useEffect(()=>{b.current?(b.current.click=v,b.current.toggle=p):(b.current={click:v,toggle:p},Po(y.current,b.current))},[v,p]),s.jsx("ul",{ref:y,className:"wx-LyHJ6R6A",children:g.map(j=>j.type==="folder"?s.jsx(Qw,{folder:j},j.id):null)})}function NA(){const n=u.useContext(Bn),a=u.useContext(Fn.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=nt(n,"drive"),c=l?l.used:"",d=l?l.total:"";return c&&d?s.jsxs("div",{className:"wx-DetSyKGG wx-drive",children:[s.jsx("progress",{value:c,max:d,className:"wx-DetSyKGG wx-progress"}),s.jsxs("p",{children:[iu(c)," ",r("of")," ",iu(d)," ",r("used")]})]}):null}function MA({option:n}){const a=u.useContext(Fn.i18n).getGroup("filemanager"),r=u.useContext(pp),l=u.useCallback(()=>{r.open({})},[r]);return s.jsx("div",{className:"wx-9XiKcxq5 wx-upload-button",onClick:l,children:s.jsx("span",{children:a(n.text)})})}function TA({readonly:n,menuOptions:a}){const r=u.useContext(Fn.i18n).getGroup("filemanager"),{showPrompt:l}=u.useContext(hp);u.useEffect(()=>{YC("upload",MA)},[]);function c({action:m}){m&&(m.id==="add-file"?l({item:{type:"file",size:0,date:new Date},add:!0}):m.id==="add-folder"&&l({item:{type:"folder",date:new Date},add:!0}))}const d=u.useMemo(()=>a("add").map(m=>(m.text=r(m.text),m)),[a,r]);return s.jsxs("div",{className:"wx-FlucfALM wx-wrapper",children:[!n&&s.jsx("div",{className:"wx-FlucfALM wx-button",children:s.jsx(KC,{options:d,at:"bottom-fit",onClick:c,children:s.jsx(Jc,{type:"primary block",children:r("Add New")})})}),s.jsx("div",{className:"wx-FlucfALM wx-tree",children:s.jsx(AA,{})}),s.jsx(NA,{})]})}function EA({value:n="",onSearch:a}){const[r,l]=Ew(n),c=u.useContext(Fn.i18n).getGroup("filemanager"),d=u.useRef(null),m=u.useMemo(()=>r!==""?"wxi-close":"wxi-search",[r]);function p(g){const w=g.target.value;l(w),a&&a({value:w})}function v(){l(""),d.current&&d.current.focus(),a&&a({value:""})}return s.jsxs("div",{className:"wx-lUZMtgT1 wx-search-input",children:[s.jsx("i",{className:`wx-lUZMtgT1 wx-icon ${m}`,onClick:v}),s.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:r,onInput:p,placeholder:c("Search")})]})}function RA({narrowMode:n=!1,onShowTree:a}){const r=u.useContext(Bn),l=u.useContext(Fn.i18n).getGroup("filemanager"),c=nt(r,"mode"),d=nt(r,"preview"),m=nt(r,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function v({value:y}){r.exec("set-mode",{mode:y})}function g(y){y.preventDefault(),r.exec("show-preview",{mode:!d})}function w(y){r.exec("filter-files",{text:y.value})}return s.jsxs("div",{className:"wx-5PZQQztG wx-toolbar",children:[s.jsxs("div",{className:"wx-5PZQQztG wx-left "+(n?"wx-left-narrow":""),children:[n?c==="panels"||c==="search"?null:s.jsx("div",{className:"wx-5PZQQztG wx-sidebar-icon","data-id":On("toggle-tree"),children:s.jsx(Il,{onClick:()=>a&&a(),name:"subtask"})}):s.jsx("div",{className:"wx-5PZQQztG wx-name",children:l("Files")}),s.jsx(EA,{onSearch:w,value:m})]}),s.jsxs("div",{className:"wx-5PZQQztG wx-right",children:[n?null:s.jsx("div",{className:"wx-5PZQQztG wx-preview-icon",children:s.jsx(bC,{onClick:g,value:d,children:s.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),s.jsx("div",{className:"wx-5PZQQztG wx-modes",children:s.jsx(pC,{value:c,options:p,onChange:v})})]})]})}function DA(){const n=u.useContext(Bn),a=nt(n,"activePanel");return s.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[s.jsx(Ww,{panel:a}),s.jsx(Kw,{children:s.jsx(Yw,{})})]})}function _A({readonly:n=!1,menuOptions:a,extraInfo:r}){const l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(void 0),[p,v]=u.useState(void 0),[g,w]=u.useState(!1),y=Ow(),b=u.useContext(Bn),{showPrompt:j,showConfirm:C}=u.useContext(hp),A=u.useContext(Fn.i18n),T=u.useMemo(()=>A.getGroup("filemanager"),[A]),k=nt(b,"mode"),E=nt(b,"preview"),R=nt(b,"activePanel"),[$,F]=vs(b,"panels"),q=u.useMemo(()=>($&&R!=null?$[R]:null)?.selected??[],[F,R]),L=u.useMemo(()=>($&&R!=null?$[R]:null)?.path,[F,R]),[_,ie]=u.useState([]);u.useEffect(()=>{const K=l.current;if(!K)return;const ce=new ResizeObserver(W=>{const P=W[0]?.borderBoxSize?.[0]?.inlineSize;typeof P=="number"&&v(P<768)});return ce.observe(K),()=>{ce.disconnect()}},[]);const V=u.useCallback(()=>{w(K=>!K)},[]),ne=u.useCallback(K=>{p&&su(K)!=="toggle-tree"&&w(!1)},[p]);u.useEffect(()=>{const K=c.current;if(K)return di(K,ne).destroy},[ne]),u.useEffect(()=>{const K=c.current;if(!K)return;const ce=new ResizeObserver(()=>{K&&m(K.clientWidth)});return ce.observe(K),K&&m(K.clientWidth),()=>{ce.disconnect()}},[]);const Q=u.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),J=u.useCallback(K=>{let ce=p?[Q]:[];return K==="file"&&(ce=[...ce,...a().filter(W=>W.id==="download")]),ce},[p,Q,a]),le=u.useRef(null),Y=u.useCallback((K,ce,W)=>{const P=W?[ce.id]:q;switch(K){case"download":b.exec("download-file",{id:ce.id});break;case"copy":case"move":le.current={action:K,ids:P};break;case"paste":le.current&&b.exec(le.current.action==="copy"?"copy-files":"move-files",{ids:le.current.ids,target:ce?.type==="folder"?ce.id:L});break;case"rename":j({item:ce});break;case"delete":C({selected:P});break;case"preview":b.exec("show-preview",{mode:!E});break}},[b,q,L,j,C,E]),O=u.useCallback(()=>$?.[R],[$,R]);u.useEffect(()=>{const K=l.current;if(!K)return;const ce=IC(K,{api:b,menuOptions:n?J:a,performAction:Y,getPanel:O});return()=>{typeof ce=="function"?ce():ce&&typeof ce.destroy=="function"&&ce.destroy()}},[b,n,J,a,Y,O]);const Z=u.useCallback((K,ce)=>{const W=K?b.getFile(K):null,P=ce.target.closest(".tree-item.folder");let me;if(n)me=J(W?.type);else{switch(K){case"body":me=a(K);break;default:if(W)if(!P&&q.length>1)me=p?[Q,...a("multiselect")]:a("multiselect");else if(K==="/")me=a("folder",W).filter(ge=>ge.id==="paste");else{const ge=a(W.type,W);ge&&(me=p?[Q,...ge]:ge)}}k==="search"&&(me=me?.filter(ge=>ge.id!=="paste"))}if(W?.id&&(!q.length||!q.some(ge=>ge===W.id))&&!P&&b.exec("select-file",{id:W.id}),me?.length)return me.forEach(ge=>{P&&(ge.hotkey=""),ge.text&&(ge.text=T(ge.text)),ge.hotkey&&(ge.subtext=ge.hotkey)}),ie(me),W||{}},[b,n,J,a,q,p,Q,k,T]),X=u.useCallback(K=>{const{action:ce,context:W}=K;ce&&Y(ce.id,W,!ce.hotkey)},[Y]);async function D(K){await Promise.resolve();const{name:ce,size:W}=K.file;b.exec("create-file",{file:{name:ce,size:W,date:new Date,file:K.file},parent:L})}return s.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:l,"data-menu-ignore":"false",children:p&&E?s.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:s.jsx(ih,{narrowMode:p,extraInfo:r})}):s.jsxs(s.Fragment,{children:[s.jsx(RA,{narrowMode:p,onShowTree:V}),s.jsx(QC,{dataKey:"id",at:"point",options:_,resolver:Z,onClick:X,children:s.jsxs(Iw,{dataKey:"actionId",options:_,resolver:Z,onClick:X,children:[s.jsx(tk,{data:y,apiOnly:!0,uploadURL:D}),s.jsx(pp.Provider,{value:y,children:s.jsx("div",{className:"wx-RJbNonjJ wx-content-wrapper wx-flex",children:k!=="panels"&&k!=="search"?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-RJbNonjJ "+["wx-sidebar",p?"wx-sidebar-narrow":"",g?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:s.jsx(TA,{readonly:n,menuOptions:a})}),s.jsxs("div",{className:"wx-RJbNonjJ wx-content",style:{width:`calc(100% - ${d||0}px - 10px)`},children:[s.jsx("div",{className:`wx-RJbNonjJ wx-content-item${E?"":"-fit"}`,"data-id":On("body"),children:k==="table"?s.jsx(Oh,{panel:R}):s.jsx(DA,{})}),E?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(ih,{extraInfo:r})}):null]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`wx-RJbNonjJ wx-content-item${E?"":"-fit"}`,children:k==="panels"?s.jsx(kA,{}):s.jsx(jA,{})}),E?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(ih,{extraInfo:r})}):null]})})})]})})]})})}const LA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function zA(n,a){const{type:r,ext:l}=n;if(r==="folder")return!1;let c;return r&&r!=="file"&&ry[r]?c=r:l?c=ry[l]?l:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const IA=u.forwardRef(function(n,a){const{data:r=[],mode:l="cards",drive:c=null,preview:d=!1,panels:m=null,activePanel:p=0,readonly:v=!1,menuOptions:g=_C,extraInfo:w=null,init:y=null,icons:b=zA,previews:j=null,...C}=n,A=u.useRef();A.current=C;const T=u.useMemo(()=>new DC(Dw),[]),k=u.useMemo(()=>T.in,[T]),E=u.useRef(null);E.current===null&&(E.current=new Aw((F,q)=>{const L="on"+LA(F);A.current&&A.current[L]&&A.current[L](q)}),k.setNext(E.current));const R=u.useMemo(()=>({getState:T.getState.bind(T),getReactiveState:T.getReactive.bind(T),getStores:()=>({data:T}),exec:k.exec,setNext:F=>(E.current=E.current.setNext(F),E.current),intercept:k.intercept.bind(k),on:k.on.bind(k),detach:k.detach.bind(k),getFile:T.getFile.bind(T),serialize:T.serialize.bind(T),templates:{preview:j||(()=>null),icon:b==="simple"?(()=>null):b}}),[T,k]),$=u.useRef(0);return u.useEffect(()=>{if(!$.current)y&&y(R);else{const F=T.getState();T.init({data:r,mode:l,drive:c,preview:d,panels:m||F.panels||[],activePanel:p})}$.current++},[T,r,l,c,d,m,p,y,R]),$.current===0&&T.init({data:r,mode:l,drive:c,preview:d,panels:m||[],activePanel:p}),u.useImperativeHandle(a,()=>({...R}),[R]),s.jsx(Bn.Provider,{value:R,children:s.jsx(up,{words:dp,optional:!0,children:s.jsx(wA,{children:s.jsx(_A,{readonly:v,menuOptions:g,extraInfo:w})})})})});function OA({fonts:n=!0,children:a}){return a?s.jsx(Gx,{fonts:n,children:a}):s.jsx(Gx,{fonts:n})}ap(Ia);function gp(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function lu(n,a,r){const l=gp(n,r);if(!Array.isArray(l[a]))throw new Error(`Invalid Hub ${r} response: ${a} must be an array.`);return l[a]}function BA(n,a,r){const l=gp(n,r);if(!l[a]||typeof l[a]!="object"||Array.isArray(l[a]))throw new Error(`Invalid Hub ${r} response: ${a} must be an object.`);return l[a]}async function FA(n,a=!1){return lu(await Ue(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function rh(n,a){const r=await Ue(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:BA(r,"folder","filesystem entries"),entries:lu(r,"entries","filesystem entries")}}async function PA(n,a){return Ue("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function HA(n,a,r,l){return Ue("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:r})},l)}async function $A(n,a=!1){const r=await Ue(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:lu(r,"jobs","file transfer jobs")}}async function UA(n,a){return Ue(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function qA(n,a){return Ue(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function ly(n){return lu(await Ue("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function GA(n,a){return Ue("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function VA(n,a,r){return Ue(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},r)}async function YA(n,a){return Ue(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function WA(n,a,r,l){const c=await Ue(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:r})},l),d=gp(c,"shared folder sync");return{ok:d.ok===!0,jobs:lu(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function KA(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 oy(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;return`${r.toFixed(l===0||r>=100?0:1)} ${a[l]}`}function Xd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function QA(n){const a=n.filter(r=>Xd(r)==="local");return a.find(r=>/\bC:/i.test(`${r.name} ${r.displayPath||""}`))||a[0]||n[0]||null}function XA({hubUrl:n,roots:a,loading:r,error:l,onRefreshRoots:c,onImportFiles:d,onImportFolder:m,onSelectionChange:p,onShareItem:v,onAddSyncFolder:g,onNotice:w}){const y=u.useRef(null),b=u.useRef("/"),j=u.useRef(0),C=u.useRef([]),A=u.useRef(new Map),[T,k]=u.useState(null),[E,R]=u.useState([]),[$,F]=u.useState([]),[q,L]=u.useState(0),[_,ie]=u.useState(null),[V,ne]=u.useState(!1),[Q,J]=u.useState(""),[le,Y]=u.useState(new Set),O=a.find(oe=>oe.id===T)||null,Z=E[E.length-1]||null,X=O?Z?.svarPath||`/${O.name}`:null,D=X;u.useEffect(()=>{C.current=E,b.current=D||"/"},[D,E]);const K=u.useMemo(()=>(A.current.clear(),!O||!D||E.length===0?[]:(E.forEach(oe=>A.current.set(oe.svarPath,oe.hubId)),[...E.map((oe,Ae)=>({id:oe.svarPath,parent:Ae===0?"/":E[Ae-1].svarPath,type:"folder",name:oe.name,date:oe.modifiedAt?new Date(oe.modifiedAt):void 0,lazy:!1})),...$.map(oe=>{const Ae=`${D}/${oe.name}`;return A.current.set(Ae,oe.id),{id:Ae,parent:D,name:oe.name,type:oe.type==="file"?"file":"folder",...oe.type==="file"?{size:oe.size}:{},date:oe.modifiedAt?new Date(oe.modifiedAt):void 0,lazy:oe.type!=="file"&&oe.hasChildren===!0,displayPath:oe.displayPath,locked:oe.locked,driveType:oe.driveType,totalBytes:oe.totalBytes,freeBytes:oe.freeBytes}})])),[O,$,D,E]),ce=oe=>A.current.get(String(oe))||String(oe),W=oe=>KA({...oe,id:ce(String(oe.id)),parent:ce(String(oe.parent))}),P=async(oe,Ae)=>{const je=oe[oe.length-1];if(!je)return;const Ee=++j.current;ne(!0),J("");try{const Re=await rh(je.hubId,n);if(Ee!==j.current)return;if(!Array.isArray(Re.entries))throw new Error("Invalid Hub filesystem entries response.");const Fe={...je,displayPath:Re.folder.displayPath||je.displayPath,modifiedAt:Re.folder.modifiedAt||je.modifiedAt},pe=[...oe.slice(0,-1),Fe];C.current=pe,R(pe),F(Re.entries),L(ke=>ke+1)}catch(Re){if(Ee!==j.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:je.hubId,error:Re}),J(Re instanceof Error?`${Ae}: ${Re.message}`:`${Ae}: Unable to read this folder.`)}finally{Ee===j.current&&ne(!1)}},me=async oe=>{const Ae={svarPath:`/${oe.name}`,hubId:oe.id,name:oe.name,displayPath:oe.displayPath,modifiedAt:oe.modifiedAt},je=++j.current;k(oe.id),C.current=[Ae],R([Ae]),b.current=Ae.svarPath,F([]),J(""),ne(!0),ie(oe.id),Y(Ee=>{const Re=new Set(Ee);return Re.delete(oe.id),Re});try{const Ee=await rh(oe.id,n);if(je!==j.current)return;if(!Array.isArray(Ee.entries))throw new Error("Invalid Hub filesystem entries response.");const Re={...Ae,displayPath:Ee.folder.displayPath||Ae.displayPath,modifiedAt:Ee.folder.modifiedAt||Ae.modifiedAt};C.current=[Re],R([Re]),F(Ee.entries),L(Fe=>Fe+1)}catch(Ee){if(je!==j.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:oe.id,error:Ee}),Y(Re=>new Set(Re).add(oe.id)),J(Ee instanceof Error?`${oe.name}: ${Ee.message}`:`${oe.name}: Unable to read this drive.`),w(Ee instanceof Error?`${oe.name}: ${Ee.message}`:`${oe.name}: Unable to read this drive.`)}finally{je===j.current&&(ie(null),ne(!1))}},ge=oe=>{const Ae=C.current;oe<0||oe>=Ae.length||oe===Ae.length-1||P(Ae.slice(0,oe+1),Ae[oe].name)},xe=(oe,Ae)=>{if(oe.type!=="folder")return;const je=C.current,Ee=je.findIndex(Fe=>Fe.svarPath===Ae);if(Ee<0)return;const Re={svarPath:`${Ae}/${oe.name}`,hubId:oe.id,name:oe.name,displayPath:oe.displayPath,modifiedAt:oe.modifiedAt};P([...je.slice(0,Ee+1),Re],oe.name)},Ce=()=>ge(C.current.length-2),Le=oe=>{if(oe.key!=="Enter"&&oe.code!=="Enter"&&oe.code!=="NumpadEnter"||oe.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const je=y.current;if(!je)return;const Ee=je.getState().panels?.flatMap(Fe=>Fe.selected||[])||[];if(Ee.length!==1)return;const Re=je.getFile(String(Ee[0]));Re?.type==="folder"&&(oe.preventDefault(),oe.stopPropagation(),xe(W(Re),String(Re.parent||b.current)))};u.useEffect(()=>{const oe=a.find(Ae=>Ae.id===T)||QA(a);if(Y(Ae=>new Set([...Ae].filter(je=>a.some(Ee=>Ee.id===je)))),!oe){k(null),C.current=[],R([]),F([]);return}me(oe)},[a]);const ze=oe=>{y.current=oe,oe.on("request-data",async({id:Ae})=>{const je=String(Ae),Ee=ce(je);try{const Re=await rh(Ee,n);if(!Array.isArray(Re.entries))throw new Error("Invalid Hub filesystem entries response.");const Fe=Re.entries.map(pe=>{const ke=`${je}/${pe.name}`;return A.current.set(ke,pe.id),{id:ke,parent:je,name:pe.name,type:pe.type==="file"?"file":"folder",...pe.type==="file"?{size:pe.size}:{},date:pe.modifiedAt?new Date(pe.modifiedAt):void 0,lazy:pe.type!=="file"&&pe.hasChildren===!0,displayPath:pe.displayPath,locked:pe.locked,driveType:pe.driveType,totalBytes:pe.totalBytes,freeBytes:pe.freeBytes}});await oe.exec("provide-data",{id:je,data:Fe})}catch(Re){console.error("[LiveDesk FS] nested getEntries failed",{id:Ee,error:Re}),w(Re instanceof Error?Re.message:"Unable to read this folder.")}}),oe.intercept("set-path",({id:Ae})=>{const je=String(Ae),Ee=C.current.findIndex(Fe=>Fe.svarPath===je);if(Ee>=0)return ge(Ee),!1;const Re=oe.getFile(je);if(Re?.type==="folder")return xe(W(Re),String(Re.parent||b.current)),!1}),oe.intercept("open-file",()=>!1),oe.on("select-file",()=>{window.setTimeout(()=>{const Ee=(oe.getState().panels?.flatMap(Re=>Re.selected||[])||[]).map(Re=>oe.getFile(Re)).filter(Boolean).map(Re=>W(Re));p(Ee.map(Re=>Re.id),Ee)},0)})},ue=(oe,Ae)=>{const je=Ae?W(Ae):null,Ee=()=>{const Re=je?.type==="file"?String(Ae?.parent||b.current):String(Ae?.id||b.current);y.current?.exec("request-data",{id:Re})};return oe==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Ee},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w("Select a file or folder to view its properties.")}]:oe==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(y.current?.getState().panels?.flatMap(Fe=>Fe.selected||[])||[]).forEach(Fe=>{const pe=y.current?.getFile(Fe);pe&&v(W(pe))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Ee}]:je?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>v(je)},...je.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>g(je)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{Tl(je.displayPath||je.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Ee},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${je.name}
|
|
13
|
+
${je.displayPath||""}`)}]:[]},Ye=async()=>{try{await c()}catch(oe){w(oe instanceof Error?oe.message:"Unable to refresh Hub drives.")}},We=[{id:"local",label:"Local drives",icon:Rl,roots:a.filter(oe=>Xd(oe)==="local")},{id:"removable",label:"Removable drives",icon:qS,roots:a.filter(oe=>Xd(oe)==="removable")},{id:"network",label:"Network drives",icon:Qh,roots:a.filter(oe=>Xd(oe)==="network")}];return s.jsxs("section",{className:"hub-file-explorer-panel","aria-label":"Hub file explorer",children:[s.jsxs("div",{className:"hub-file-explorer-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Hub file explorer"}),s.jsxs("strong",{children:[s.jsx(Rl,{size:16})," Browse files on this Hub"]})]}),s.jsxs("div",{className:"hub-file-explorer-heading-actions",children:[s.jsx("button",{className:"icon-button",onClick:d,title:"Import files from this browser",type:"button",children:s.jsx(Yy,{size:16})}),s.jsx("button",{className:"icon-button",onClick:m,title:"Import folder from this browser",type:"button",children:s.jsx(GS,{size:16})}),s.jsx("button",{className:"icon-button",onClick:()=>{Ye()},title:"Refresh drives",type:"button",children:s.jsx(Oo,{size:16})})]})]}),r?s.jsxs("div",{className:"hub-file-explorer-state",children:[s.jsx(Rl,{size:24}),s.jsx("strong",{children:"Connecting to LiveDesk Hub file system..."})]}):l?s.jsxs("div",{className:"hub-file-explorer-state error",role:"alert",children:[s.jsx(Ls,{size:24}),s.jsx("strong",{children:l})]}):s.jsxs("div",{className:"hub-file-explorer-content",children:[s.jsxs("aside",{className:"hub-file-explorer-drive-sidebar","aria-label":"Hub drives",children:[s.jsxs("div",{className:"hub-drive-sidebar-title",children:[s.jsx(Rl,{size:15}),s.jsx("strong",{children:"This PC"})]}),We.map(oe=>oe.roots.length>0&&s.jsxs("section",{className:"hub-drive-group",children:[s.jsxs("h3",{children:[s.jsx(oe.icon,{size:13}),oe.label]}),s.jsx("div",{className:"hub-drive-list",children:oe.roots.map(Ae=>{const je=oe.icon,Ee=le.has(Ae.id)||Ae.locked===!0;return s.jsxs("button",{className:`hub-drive-item ${T===Ae.id?"active":""} ${Ee?"unavailable":""}`,onClick:()=>{me(Ae)},"aria-pressed":T===Ae.id,type:"button",children:[s.jsx("span",{className:"hub-drive-item-icon",children:s.jsx(je,{size:16})}),s.jsxs("span",{className:"hub-drive-item-copy",children:[s.jsx("strong",{children:Ae.name}),s.jsx("small",{children:Ae.displayPath||Ae.name}),s.jsxs("em",{children:[oy(Ae.freeBytes||0)," free / ",oy(Ae.totalBytes||0)]})]}),_===Ae.id?s.jsx($r,{className:"hub-drive-item-status spin",size:15}):Ee?s.jsx(tx,{className:"hub-drive-item-status",size:15}):null]},Ae.id)})})]},oe.id)),a.length===0&&s.jsxs("div",{className:"hub-drive-sidebar-empty",children:[s.jsx(Ls,{size:17}),s.jsx("span",{children:"No drives available."})]})]}),s.jsxs("div",{className:"hub-file-explorer-browser",children:[s.jsxs("div",{className:"hub-file-explorer-navigation",children:[s.jsx("nav",{className:"hub-file-explorer-breadcrumbs","aria-label":"Current Hub folder",children:E.map((oe,Ae)=>s.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[Ae>0&&s.jsx(Xh,{size:13,"aria-hidden":"true"}),s.jsx("button",{className:`hub-file-explorer-breadcrumb ${Ae===E.length-1?"current":""}`,onClick:()=>ge(Ae),"aria-current":Ae===E.length-1?"location":void 0,type:"button",children:oe.name})]},oe.svarPath))}),s.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[V&&s.jsx($r,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),s.jsx("button",{className:"icon-button",onClick:Ce,disabled:E.length<=1||V,title:"Back to parent folder",type:"button",children:s.jsx(Py,{size:16})})]})]}),Q&&s.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[s.jsx(tx,{size:15}),s.jsx("span",{children:Q})]}),s.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:Le,children:s.jsx(OA,{fonts:!1,children:s.jsx(IA,{data:K,panels:X?[{path:X,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:ze,icons:"simple",menuOptions:ue},`${O?.id||"no-root"}:${q}`)})})]})]})]})}class ZA extends u.Component{state={error:null};static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,r){console.error("[LiveDesk] Share Files runtime error",a,r.componentStack)}render(){return this.state.error?s.jsxs("section",{className:"file-share-error-boundary",role:"alert",children:[s.jsx(hf,{size:24}),s.jsx("strong",{children:"Share Files could not be opened."}),s.jsx("span",{children:this.state.error.message||"An unexpected file explorer error occurred."}),s.jsxs("button",{className:"text-button",onClick:this.props.onRetry,type:"button",children:[s.jsx(Oo,{size:15})," Retry"]})]}):this.props.children}}function JA(n){return n.deviceName||n.hostname||n.deviceId}function eN({devices:n,mode:a,selectedIds:r,onModeChange:l,onToggle:c}){const d=new Set(r);return s.jsxs("section",{className:"distribution-targets",children:[s.jsxs("div",{className:"file-share-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Target"}),s.jsx("strong",{children:a==="all"?`${n.length} connected`:`${r.length} selected`})]}),s.jsxs("div",{className:"file-share-tabs compact","aria-label":"File transfer targets",children:[s.jsxs("button",{className:a==="all"?"active":"",onClick:()=>l("all"),type:"button",children:[s.jsx(Wy,{size:14})," All connected"]}),s.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>l("selected"),type:"button",children:[s.jsx(tn,{size:14})," Selected"]})]})]}),s.jsx("div",{className:"file-share-device-list","aria-label":"Connected workstation targets",children:n.length===0?s.jsx("div",{className:"file-share-empty-inline",children:"No connected workstations."}):n.map(m=>{const p=a==="all"||d.has(m.deviceId);return s.jsxs("label",{className:`file-share-device-option ${p?"selected":""}`,children:[s.jsx("input",{type:"checkbox",checked:p,disabled:a==="all",onChange:()=>c(m.deviceId)}),s.jsx(tn,{size:20,"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:JA(m)}),s.jsxs("small",{children:["Slot ",m.slotNumber?String(m.slotNumber).padStart(3,"0"):"-"," / ",m.platform||"unknown OS"]})]}),s.jsx(In,{size:17,"aria-hidden":"true"})]},m.deviceId)})})]})}function tN(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;return`${r.toFixed(l===0||r>=100?0:1)} ${a[l]}`}function nN({folders:n,loading:a,busy:r,canSync:l,onSyncAll:c,onSync:d,onToggleAuto:m,onRemove:p,onAdd:v}){return s.jsxs("section",{className:"file-share-sync-panel",children:[s.jsxs("div",{className:"file-share-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Hub folders"}),s.jsx("strong",{children:"Continuous sync"})]}),s.jsxs("button",{className:"text-button compact",onClick:c,disabled:r||!l||n.length===0,type:"button",children:[s.jsx(Vd,{size:15})," ",r?"Syncing":"Sync all"]})]}),a?s.jsx("div",{className:"file-share-empty-state",children:"Loading Hub sync folders..."}):n.length===0?s.jsxs("button",{className:"file-share-empty-state interactive",onClick:v,type:"button",children:[s.jsx(Vd,{size:28}),s.jsx("strong",{children:"Add a selected Hub folder"}),s.jsx("span",{children:"Hub keeps the manifest and can sync while this browser is closed."})]}):s.jsx("div",{className:"file-share-sync-list",children:n.map(g=>s.jsxs("article",{className:`file-share-sync-row state-${g.status}`,children:[s.jsx("div",{className:"file-share-sync-icon",children:s.jsx(Vd,{size:19})}),s.jsxs("div",{className:"file-share-sync-info",children:[s.jsx("strong",{children:g.name}),s.jsx("span",{children:g.displayPath}),s.jsxs("small",{children:[g.fileCount," files / ",tN(g.totalBytes)," · ",g.lastSyncedAt?`Last sync ${kh(g.lastSyncedAt)} ago`:g.message||"Not synced yet"]})]}),s.jsxs("label",{className:"file-share-auto-sync",children:[s.jsx("input",{type:"checkbox",checked:g.autoSync,onChange:()=>m(g)}),s.jsx("span",{children:"Auto"})]}),s.jsxs("button",{className:"text-button compact",onClick:()=>d(g),disabled:r||!l||g.status==="syncing",type:"button",children:[s.jsx(Oo,{size:14})," Sync now"]}),s.jsx("button",{className:"icon-button",onClick:()=>p(g),title:"Remove sync folder",type:"button",children:s.jsx(Wh,{size:15})})]},g.id))})]})}function aN(n){const r=(n.targetMode==="all"?n.devices.map(l=>l.deviceId):n.selectedTargetIds).length>0;return s.jsxs("aside",{className:"file-share-distribution-panel",children:[s.jsxs("div",{className:"file-share-distribution-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Distribution"}),s.jsx("strong",{children:"Hub → workstations"})]}),s.jsx(Bo,{size:18})]}),s.jsxs("div",{className:"file-share-tabs",role:"tablist","aria-label":"Distribution mode",children:[s.jsx("button",{className:n.tab==="send"?"active":"",onClick:()=>n.onTabChange("send"),role:"tab","aria-selected":n.tab==="send",type:"button",children:"Send"}),s.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"?s.jsxs(s.Fragment,{children:[s.jsx(eN,{devices:n.devices,mode:n.targetMode,selectedIds:n.selectedTargetIds,onModeChange:n.onTargetModeChange,onToggle:n.onTargetToggle}),s.jsxs("label",{className:"file-share-destination",children:[s.jsx("span",{children:"Destination folder"}),s.jsxs("div",{children:[s.jsx(Do,{size:15}),s.jsx("input",{value:n.remoteDirectory,onChange:l=>n.onRemoteDirectoryChange(l.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),s.jsx("small",{children:"Blank uses Desktop/LiveDeskFiles."})]}),s.jsxs("div",{className:"file-share-selection-summary",children:[s.jsx("span",{children:"Selected"}),s.jsx("strong",{children:n.selectedSummary})]}),s.jsxs("button",{className:"file-share-share-button",onClick:n.onShare,disabled:!n.canShare,type:"button",children:[s.jsx(Bo,{size:17})," Share selected"]}),s.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[s.jsx(Do,{size:16})," Add selected folder to Sync"]})]}):s.jsx(nN,{folders:n.folders,loading:n.foldersLoading,busy:n.syncBusy,canSync:r,onSyncAll:n.onSyncAll,onSync:n.onSync,onToggleAuto:n.onToggleAuto,onRemove:n.onRemove,onAdd:n.onAddFolder})]})}function sN(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;return`${r.toFixed(l===0||r>=100?0:1)} ${a[l]}`}function cy(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 uy(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 dy(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function iN({hubUrl:n,devices:a,localFeatureAccess:r,upgradeNotice:l,remoteDirectory:c,onRemoteDirectoryChange:d,targetMode:m,selectedTargetIds:p,onTargetModeChange:v,onTargetToggle:g,filePickerRef:w,folderPickerRef:y,onBrowserFileImport:b,onBrowserFolderImport:j,onNotice:C,onTransferChange:A}){const T=Array.isArray(a)?a:[],[k,E]=u.useState([]),[R,$]=u.useState(!0),[F,q]=u.useState(""),[L,_]=u.useState([]),[ie,V]=u.useState([]),[ne,Q]=u.useState(null),[J,le]=u.useState(!1),[Y,O]=u.useState([]),[Z,X]=u.useState(!0),[D,K]=u.useState(!1),[ce,W]=u.useState("send"),[P,me]=u.useState([]),ge=u.useRef(new Set),xe=u.useMemo(()=>m==="all"?T.map(de=>de.deviceId):p.filter(de=>T.some(we=>we.deviceId===de)),[T,p,m]),Ce=P.find(de=>!dy(de.state)),Le=ie.length===1&&ie[0].type==="folder"?ie[0]:null,ze=ie.length===0?"Select files or folders from the Hub explorer.":J?"Calculating selection size...":ne?`${ne.files} files, ${ne.folders} folders · ${sN(ne.totalBytes)}`:`${ie.length} item${ie.length===1?"":"s"} selected`,ue=de=>{A({id:de.jobId,state:de.state,progress:cy(de),message:uy(de)})},Ye=u.useCallback(async()=>{const de=await FA(n,!0);return E(de),q(""),de},[n]),We=async()=>{try{const we=(await $A(n,!0)).jobs||[],Ge=await Promise.all([...ge.current].map(async Qe=>{try{return await UA(Qe,n)}catch{return null}})),tt=[...we,...Ge.filter(Boolean)],wn=[...new Map(tt.map(Qe=>[Qe.jobId,Qe])).values()];me(wn),wn.forEach(ue),wn.filter(Qe=>dy(Qe.state)).forEach(Qe=>ge.current.delete(Qe.jobId))}catch{}};u.useEffect(()=>{let de=!0;$(!0),q(""),Promise.all([Ye(),ly(n).then(Ge=>{de&&O(Ge)})]).catch(Ge=>{de&&(q(Ge instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),C(Ge instanceof Error?Ge.message:"Hub file system is unavailable."))}).finally(()=>{de&&($(!1),X(!1))}),We();const we=window.setInterval(()=>{We()},800);return()=>{de=!1,window.clearInterval(we)}},[n,Ye]),u.useEffect(()=>{if(L.length===0){Q(null);return}let de=!1;return le(!0),PA(L,n).then(we=>{de||Q(we)}).catch(we=>{de||C(we instanceof Error?we.message:"Unable to calculate selected size.")}).finally(()=>{de||le(!1)}),()=>{de=!0}},[n,L.join("|")]);const oe=(de,we)=>{_(de),V(we)},Ae=de=>{de.forEach(we=>ge.current.add(we.jobId)),me(we=>[...new Map([...we,...de].map(Ge=>[Ge.jobId,Ge])).values()]),de.forEach(ue)},je=async()=>{if(!r){C(l);return}if(L.length===0){C("Select files or folders from the Hub explorer.");return}if(xe.length===0){C("Choose at least one connected workstation.");return}if(Ce){C("A Hub transfer is already running.");return}try{const de=await HA(L,xe,c.trim(),n);ge.current.add(de.jobId),C("Hub transfer queued."),await We()}catch(de){C(de instanceof Error?de.message:"Unable to start Hub transfer.")}},Ee=async de=>{const we=de||Le;if(!we||we.type!=="folder"){C("Select one folder to add it to Sync.");return}try{const Ge=await GA(we.id,n);O(tt=>[...tt.filter(wn=>wn.id!==Ge.folder.id),Ge.folder]),W("sync"),C(`${we.name} is ready for Hub sync.`)}catch(Ge){C(Ge instanceof Error?Ge.message:"Unable to add the Hub folder to Sync.")}},Re=async de=>{if(xe.length===0){C("Choose at least one connected workstation.");return}K(!0),O(we=>we.map(Ge=>Ge.id===de.id?{...Ge,status:"syncing"}:Ge));try{const we=await WA(de.id,xe,c.trim(),n);Ae(we.jobs||[]),C(we.jobs?.length?"Hub sync queued.":"No changed files to sync.");const Ge=await ly(n);O(Ge)}catch(we){C(we instanceof Error?we.message:"Unable to sync the Hub folder."),O(Ge=>Ge.map(tt=>tt.id===de.id?{...tt,status:"error",message:"Sync failed"}:tt))}finally{K(!1)}},Fe=async()=>{K(!0);try{for(const de of Y)await Re(de)}finally{K(!1)}},pe=async de=>{try{const we=await VA(de.id,{autoSync:!de.autoSync},n);O(Ge=>Ge.map(tt=>tt.id===de.id?we.folder:tt))}catch(we){C(we instanceof Error?we.message:"Unable to update auto sync.")}},ke=async de=>{try{await YA(de.id,n),O(we=>we.filter(Ge=>Ge.id!==de.id))}catch(we){C(we instanceof Error?we.message:"Unable to remove the sync folder.")}};return s.jsxs("section",{className:"livedesk-file-explorer",children:[s.jsx("input",{ref:w,className:"hidden-file-input",type:"file",multiple:!0,onChange:de=>{de.currentTarget.files&&b(de.currentTarget.files),de.currentTarget.value=""}}),s.jsx("input",{ref:y,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:de=>{de.currentTarget.files&&j(de.currentTarget.files),de.currentTarget.value=""}}),s.jsx("div",{className:"file-share-workspace",children:s.jsxs(ZA,{onRetry:()=>window.location.reload(),children:[s.jsx(XA,{hubUrl:n,roots:k,loading:R,error:F,onRefreshRoots:Ye,onImportFiles:()=>w.current?.click(),onImportFolder:()=>y.current?.click(),onSelectionChange:oe,onShareItem:de=>{_([de.id]),V([de]),W("send")},onAddSyncFolder:de=>{_([de.id]),V([de]),Ee(de)},onNotice:C}),s.jsx(aN,{devices:T,targetMode:m,selectedTargetIds:p,onTargetModeChange:v,onTargetToggle:g,remoteDirectory:c,onRemoteDirectoryChange:d,selectedEntries:ie,selectedSummary:ze,canShare:r&&!Ce&&L.length>0&&xe.length>0&&!J,onShare:()=>{je()},canAddSync:!!Le,onAddSync:()=>{Ee()},tab:ce,onTabChange:W,folders:Y,foldersLoading:Z,syncBusy:D,onSyncAll:()=>{Fe()},onSync:de=>{Re(de)},onToggleAuto:de=>{pe(de)},onRemove:de=>{ke(de)},onAddFolder:()=>{Ee()}})]})}),Ce&&s.jsx("footer",{className:"file-share-workspace-footer",children:s.jsxs("span",{children:[uy(Ce)," · ",cy(Ce),"% ",s.jsx("button",{className:"icon-button",onClick:()=>{qA(Ce.jobId,n).then(de=>{me(we=>we.map(Ge=>Ge.jobId===de.jobId?de:Ge)),ue(de)})},title:"Cancel transfer",type:"button",children:s.jsx(zs,{size:14})})]})})]})}const rN=u.forwardRef(function({value:a,onChange:r,onSubmit:l,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:m,disabled:p=!1},v){return s.jsxs("form",{className:"agents-composer",onSubmit:g=>{g.preventDefault(),l()},children:[s.jsxs("button",{className:`agents-suggested-trigger ${d?"active":""}`,type:"button","aria-label":m===void 0?"Open Suggested tasks":`Open Suggested tasks (${m} available)`,"aria-expanded":d,onClick:c,disabled:p,children:[s.jsx(VS,{size:17}),m!==void 0&&s.jsx("span",{className:"agents-suggested-count","aria-hidden":"true",children:m})]}),s.jsx("textarea",{ref:v,value:a,onChange:g=>r(g.target.value.slice(0,4e3)),placeholder:"Ask LiveDesk to work across your machines...","aria-label":"Ask LiveDesk",rows:2,disabled:p}),s.jsxs("button",{className:"agents-run-button",type:"submit",disabled:p||!a.trim(),children:[p?s.jsx($r,{className:"spin",size:16}):s.jsx(Bo,{size:16}),p?"Running":"Run"]})]})}),lN=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function Xw(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function Bh(n){return n.connected!==!0?!1:n.synthetic===!0?!0:!n.channels||n.channels.control===!0}function oN(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function cN(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 uN(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Xa(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Pd(n){const a=Xa(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 dN(n){const a=Xa(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function fN(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function ff(n,a){if(a.error)return a.error;const r=uN(a.data),l=fN(a.result||"");if(!r)return l||a.stage||a.status;if(n==="system.health"){const c=typeof r.machine=="string"?r.machine:"",d=Pd(r.freeMemoryBytes),m=Pd(r.totalMemoryBytes),p=Xa(r.totalMemoryBytes)&&Xa(r.freeMemoryBytes)!==null?`${Math.round(Xa(r.freeMemoryBytes)/Xa(r.totalMemoryBytes)*100)}% RAM free`:"";return[c,d&&m?`RAM ${d}/${m}`:"",p,typeof r.platform=="string"?r.platform:""].filter(Boolean).join(" · ")||l||a.status}if(n==="disk.status"){const c=typeof r.root=="string"?r.root:"",d=Pd(r.freeBytes),m=Xa(r.totalBytes)&&Xa(r.freeBytes)!==null?`${Math.round(Xa(r.freeBytes)/Xa(r.totalBytes)*100)}% free`:"";return[c,d&&`${d} free`,m].filter(Boolean).join(" · ")||l||a.status}if(n==="gpu.status"){const c=typeof r.name=="string"&&r.name?r.name:"No GPU provider",d=dN(r.usageRatio),m=Xa(r.temperatureC)!==null?`${Math.round(Xa(r.temperatureC))}°C`:"",p=Pd(r.freeMemoryBytes);return[c,d&&`GPU ${d}`,m,p&&`${p} free`].filter(Boolean).join(" · ")||l||a.status}if(n==="process.list"){const c=Xa(r.count);return c!==null?`${c} matching process${c===1?"":"es"}`:l||a.status}if(n==="network.status"){const c=Array.isArray(r.adapters)?r.adapters.length:null;return c!==null?`${c} active adapter${c===1?"":"s"}`:l||a.status}return l||a.stage||a.status}function fy(n,a){const r=ff(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||""} ${r}`)}function mN({state:n,operation:a}){const r=n.status==="completed"?Hr:n.status==="failed"||n.status==="cancelled"?zs:n.status==="running"?$r:Ky,l=n.status==="running"?n.stage||"Working":n.status==="completed"?a?ff(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return s.jsxs("div",{className:`agent-target-row status-${n.status}`,"data-agent-target-id":n.deviceId,children:[s.jsx("span",{className:"agent-target-status","aria-hidden":"true",children:s.jsx(r,{size:15})}),s.jsx("strong",{children:n.deviceName}),s.jsx("span",{className:"agent-target-state",children:n.status[0].toUpperCase()+n.status.slice(1)}),s.jsx("small",{children:l})]})}function hN({operation:n,states:a,status:r,onCancel:l,onRetry:c,busy:d=!1}){const m=["running","queued"].includes(r),[p,v]=u.useState(!1),[g,w]=u.useState("all"),y=u.useMemo(()=>({total:a.length,completed:a.filter(R=>R.status==="completed").length,failed:a.filter(R=>R.status==="failed").length,running:a.filter(R=>R.status==="running").length,queued:a.filter(R=>R.status==="queued").length,cancelled:a.filter(R=>R.status==="cancelled").length}),[a]),b=a.filter(R=>fy(n,R)),j=b.filter(R=>R.status==="completed").length,C=y.failed>0,A=b.length>0,T=a.filter(R=>g==="issues"?fy(n,R):g==="running"?R.status==="running"||R.status==="queued":g==="completed"?R.status==="completed":g==="failed"?R.status==="failed":!0),k=A&&!m||r==="completed-with-failures"?"Completed with issues":r[0]?.toUpperCase()+r.slice(1),E=a.filter(R=>R.status==="completed").map(R=>ff(n,R)).filter(Boolean).filter((R,$,F)=>F.indexOf(R)===$).slice(0,2);return s.jsxs("section",{className:"agent-task-block","aria-label":"Task execution",children:[s.jsxs("div",{className:"agent-task-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:"LiveDesk Agent"}),s.jsx("strong",{children:cN(n)})]}),s.jsx("span",{className:`agent-task-status status-${A?"completed-with-failures":r}`,children:k})]}),s.jsxs("div",{className:"agent-task-summary","aria-label":"Task summary",children:[s.jsxs("strong",{children:[y.total," targets"]}),s.jsxs("span",{className:"summary-completed",children:[y.completed," completed"]}),y.running>0&&s.jsxs("span",{className:"summary-running",children:[y.running," running"]}),y.queued>0&&s.jsxs("span",{children:[y.queued," queued"]}),C&&s.jsxs("span",{className:"summary-failed",children:[y.failed," failed"]}),j>0&&s.jsxs("span",{className:"summary-cancelled",children:[j," warning"]}),y.cancelled>0&&s.jsxs("span",{className:"summary-cancelled",children:[y.cancelled," cancelled"]})]}),E.length>0&&s.jsxs("div",{className:"agent-task-result-preview",title:E.join(" · "),children:[s.jsx("span",{children:"Result"}),E.join(" · ")]}),s.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((R,$)=>{const F=R.status==="completed"?"✓":R.status==="failed"?"×":R.status==="cancelled"?"!":R.status==="running"?"…":"·";return s.jsxs("span",{className:`agent-target-chip status-${R.status}`,title:`${R.deviceName}: ${ff(n,R)}`,"aria-label":`${$+1}. ${R.deviceName}: ${R.status}`,children:[s.jsx("b",{children:String($+1).padStart(2,"0")}),s.jsx("span",{children:F})]},R.deviceId)})}),a.length>0&&s.jsx("div",{className:"agent-task-details-toggle",children:s.jsxs("button",{type:"button",onClick:()=>v(R=>!R),"aria-expanded":p,children:[p?s.jsx(YS,{size:14}):s.jsx(Qy,{size:14}),p?"Hide details":"Show details"]})}),p&&s.jsxs("div",{className:"agent-task-details",children:[s.jsx("div",{className:"agent-task-filters",role:"tablist","aria-label":"Task result filter",children:["all","issues","running","completed","failed"].map(R=>s.jsx("button",{className:g===R?"active":"",onClick:()=>w(R),role:"tab","aria-selected":g===R,type:"button",children:R==="all"?"All":R==="issues"?"Issues only":R[0].toUpperCase()+R.slice(1)},R))}),s.jsx("div",{className:"agent-task-rows",children:T.length>0?T.map(R=>s.jsx(mN,{operation:n,state:R},R.deviceId)):s.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(m||C)&&s.jsxs("div",{className:"agent-task-actions",children:[m&&l&&s.jsxs("button",{onClick:l,disabled:d,type:"button",children:[s.jsx(WS,{size:14})," Cancel"]}),!m&&C&&c&&s.jsxs("button",{onClick:c,disabled:d,type:"button",children:[s.jsx(Kc,{size:14})," Retry failed"]})]})]})}function pN(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function gN({approval:n,busy:a=!1,onApprove:r,onReject:l}){return s.jsxs("article",{className:"agent-approval-card","aria-label":"Agent approval required",children:[s.jsxs("div",{className:"agent-approval-head",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Approval required"}),s.jsx("strong",{children:n.toolName})]}),s.jsx("span",{className:`agent-approval-risk risk-${n.risk}`,children:n.risk})]}),s.jsx("p",{children:n.description}),s.jsx("pre",{children:pN(n.arguments)}),s.jsxs("small",{children:["Permission: ",n.permissionMode," · Scope: selected devices only · Expires in 5 minutes"]}),s.jsxs("div",{className:"agent-approval-actions",children:[s.jsxs("button",{className:"reject",disabled:a,onClick:l,type:"button",children:[s.jsx(zs,{size:14})," Reject"]}),s.jsxs("button",{disabled:a,onClick:()=>r("once"),type:"button",children:[s.jsx(Hr,{size:14})," Once"]}),s.jsx("button",{disabled:a,onClick:()=>r("same-action-this-run"),type:"button",children:"Allow same action"}),s.jsx("button",{disabled:a,onClick:()=>r("category-this-run"),type:"button",children:"Allow category"})]}),s.jsxs("div",{className:"agent-approval-scope",children:[s.jsx(hf,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function vN(n){return n==="queued"?"Request queued":n==="checking-codex"?"Checking Codex":n==="preparing-tools"?"Preparing tools":n==="thinking"?"Preparing answer":n==="tool-running"?"Working on computers":n==="recovering"?"Retrying safely":n==="waiting-approval"?"Waiting for approval":"Working"}function xN({items:n,onCancel:a,onRetry:r,busyBatchId:l,approvals:c,onApprove:d,onReject:m,busyApprovalId:p,progress:v}){const g=u.useRef(null),w=u.useRef(!0),y=u.useRef(""),b=n[n.length-1];return u.useLayoutEffect(()=>{const j=g.current;j&&(b?.type==="user"&&b.id!==y.current&&(w.current=!0),y.current=b?.id||"",w.current&&(j.scrollTop=j.scrollHeight))},[c,n,b?.id,b?.type,v?.message,v?.stage]),s.jsxs("section",{className:"agents-conversation","aria-live":"polite",ref:g,onScroll:j=>{const C=j.currentTarget;w.current=C.scrollHeight-C.scrollTop-C.clientHeight<72},children:[c.filter(j=>j.status==="pending").map(j=>s.jsx(gN,{approval:j,busy:p===j.approvalId,onApprove:C=>d(j,C),onReject:()=>m(j)},j.approvalId)),n.length===0&&s.jsxs("div",{className:"agents-empty-conversation",children:[s.jsx("strong",{children:"Ask LiveDesk to work across your machines."}),s.jsx("span",{children:"Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."})]}),n.map(j=>{if(j.type==="task"){const C=j;return s.jsx(hN,{operation:C.operation,states:C.states,status:C.status,onCancel:()=>a(C.batchId,C.agentRunId),onRetry:()=>r(C.batchId),busy:l===C.batchId},C.id)}return s.jsxs("article",{className:`agents-message ${j.type}`,children:[s.jsx("span",{children:j.type==="user"?"You":"LiveDesk Agent"}),s.jsx("p",{children:j.text})]},j.id)}),v&&s.jsxs("article",{className:"agents-message agent agents-progress-message",role:"status",children:[s.jsxs("span",{children:[s.jsx($r,{"aria-hidden":"true",size:15}),vN(v.stage)]}),s.jsx("p",{children:v.message})]})]})}const my=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],xn=["windows","macos","linux"],Fr={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:xn},"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:xn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:xn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:xn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:xn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:xn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:xn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:xn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:xn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:xn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:xn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:xn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:xn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:xn}};new Set(Object.keys(Fr));const yN={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","문제해결","복구","장애"]},hy=["low","medium","high","critical"];function wN(n){return n.reduce((a,r)=>{const l=Fr[r].risk;return hy.indexOf(l)>hy.indexOf(a)?l:a},"low")}function bN(n){return xn.filter(a=>n.every(r=>Fr[r].supportedPlatforms.includes(a)))}function Be(n,a,r,l,c,d,m={}){const p=m.description||l,v=c.flatMap(w=>w.split(".")),g=[...new Set([...yN[a],...d,...v])];return{id:n,category:a,title:r,prompt:l,description:p,requiredOperations:c,risk:m.risk||wN(c),targetSupport:m.targetSupport||"single-or-multiple",supportedPlatforms:m.supportedPlatforms||bN(c),keywords:g,recommended:m.recommended??!1,enabled:!0}}const Zw=[Be("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}),Be("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}),Be("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}),Be("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}),Be("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}),Be("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}),Be("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}),Be("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}),Be("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","높은 사용량"]),Be("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Be("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Be("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"]),Be("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","디스크"]),Be("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Be("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","경고"]),Be("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"]),Be("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","실행 중"]),Be("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"]),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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","서비스 상태"]),Be("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"}),Be("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"]),Be("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"}),Be("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"}),Be("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"]),Be("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"]),Be("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"}),Be("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"]),Be("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"}),Be("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"}),Be("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","구성"]),Be("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"]),Be("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"}),Be("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"}),Be("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"]),Be("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"}),Be("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"}),Be("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"]}),Be("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"]}),Be("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"]}),Be("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"}),Be("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"}),Be("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"}),Be("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"]),Be("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"}),Be("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Be("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Be("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Be("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"]),Be("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"]),Be("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"]),Be("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Be("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"]),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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"}),Be("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","장애 보고서"])],lh={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 SN(n,a){return n==="safe-auto"?lh:n==="full-access"?{...lh,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{...lh,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function jN(n,a,r){const l=SN(a,r),c=n.requiredOperations.map(d=>l[Fr[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(m=>l[Fr[m].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${Fr[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=>Fr[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function CN(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 kN(n,a,r){const l=new Set(r);return n.filter(c=>c.connected&&(a==="all"||l.has(c.deviceId)))}function AN(n,a){const r=CN(n.platform);if(!r||!a.supportedPlatforms.includes(r))return!1;const l=n.capabilities?.agentTools;return!Array.isArray(l)||l.length===0?a.requiredOperations.every(c=>Fr[c].readOnly):a.requiredOperations.every(c=>l.includes(c))}function Jw(n,a,r,l,c,d){const m=jN(n,c,d),p=kN(a,r,l),v=p.map(j=>j.deviceId),g={...m,available:!1,availableDeviceIds:[],unsupportedDeviceIds:v,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(m.state==="blocked")return g;const w=p.filter(j=>AN(j,n)),y=w.map(j=>j.deviceId),b=v.filter(j=>!y.includes(j));return w.length===0?{...g,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...g,available:!0,availableDeviceIds:y,unsupportedDeviceIds:b}}function NN(n,a,r,l,c,d){return n.filter(m=>m.enabled&&Jw(m,a,r,l,c,d).available).length}const oh="livedesk.agentPromptRecent",ch="livedesk.agentPromptFavorites",MN={Recommended:Ll,"Health & capacity":ln,"Processes & services":JS,"AI workloads":qy,"Files & configuration":ZS,"Software & automation":af,"Network & connectivity":Qh,"Power & maintenance":Bt,"Troubleshooting & recovery":XS};function py(n){if(typeof window>"u")return[];try{const a=JSON.parse(window.localStorage.getItem(n)||"[]");return Array.isArray(a)?a.filter(r=>typeof r=="string"):[]}catch{return[]}}function Hd(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function uh(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 TN(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 EN(n,a,r){if(!r.trim())return!0;const l=r.trim().toLowerCase();return[n.title,n.prompt,n.description,n.category,n.risk,a.label,...n.keywords,...n.requiredOperations,...n.supportedPlatforms].join(" ").toLowerCase().includes(l)}function RN(n){return`permission-${n}`}function DN(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function _N(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function LN({devices:n,targetMode:a,selectedIds:r,permissionMode:l,customCategories:c,onSelectPrompt:d,onClose:m}){const[p,v]=u.useState(""),[g,w]=u.useState("all"),[y,b]=u.useState(()=>py(oh)),[j,C]=u.useState(()=>py(ch)),[A,T]=u.useState(0),[k,E]=u.useState(""),R=u.useRef(null),$=u.useRef(null),F=u.useMemo(()=>Zw.filter(Y=>Y.enabled),[]),q=u.useMemo(()=>new Map(F.map(Y=>[Y.id,Jw(Y,n,a,r,l,c)])),[c,n,l,r,a,F]),L=u.useMemo(()=>[...q.values()].filter(Y=>Y.available).length,[q]),_=u.useMemo(()=>n.filter(Y=>Y.connected&&(a==="all"||r.includes(Y.deviceId))).length,[n,r,a]),ie=u.useMemo(()=>{const Y=F.filter(O=>EN(O,q.get(O.id),p));return g==="recent"?y.map(O=>Y.find(Z=>Z.id===O)).filter(O=>!!O):g==="favorites"?j.map(O=>Y.find(Z=>Z.id===O)).filter(O=>!!O):g==="all"?Y:Y.filter(O=>{const Z=q.get(O.id);return g==="read-only"?Z.state==="read-only":g==="auto"?Z.state==="auto":g==="approval"?Z.state==="approval":g==="full-access"?Z.state==="full-access":g==="available"?Z.available:g==="unavailable"?!Z.available:O.category===g})},[q,j,g,y,p,F]),V=u.useMemo(()=>g!=="all"?[{category:uh(g),templates:ie}]:my.map(Y=>({category:Y,templates:ie.filter(O=>O.category===Y)})).filter(Y=>Y.templates.length>0),[g,ie]);u.useEffect(()=>{T(Y=>Math.min(Y,Math.max(0,ie.length-1)))},[ie.length]),u.useEffect(()=>{Hd(oh,y)},[y]),u.useEffect(()=>{Hd(ch,j)},[j]),u.useEffect(()=>{$.current?.focus();const Y=Z=>{Z.target instanceof Node&&!R.current?.contains(Z.target)&&m()},O=Z=>{Z.key==="Escape"&&(Z.preventDefault(),m())};return document.addEventListener("pointerdown",Y),document.addEventListener("keydown",O),()=>{document.removeEventListener("pointerdown",Y),document.removeEventListener("keydown",O)}},[m]);const ne=Y=>{const O=q.get(Y.id);if(!O.available){E(O.reason||"This task is not available for the current targets and permission policy.");return}const Z=[Y.id,...y.filter(X=>X!==Y.id)].slice(0,10);b(Z),Hd(oh,Z),d(Y.prompt),m()},Q=Y=>{C(O=>{const Z=O.includes(Y)?O.filter(X=>X!==Y):[Y,...O];return Hd(ch,Z),Z})},J=Y=>{Y.key==="ArrowDown"?(Y.preventDefault(),T(O=>Math.min(O+1,Math.max(0,ie.length-1)))):Y.key==="ArrowUp"?(Y.preventDefault(),T(O=>Math.max(O-1,0))):Y.key==="Enter"&&ie[A]&&(Y.preventDefault(),ne(ie[A]))};let le=-1;return s.jsxs("section",{className:"agents-suggested-tasks",ref:R,"aria-label":"Suggested tasks",children:[s.jsxs("header",{className:"agents-suggested-header",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"agents-suggested-title",children:[s.jsx(Ll,{size:15})," Suggested tasks"]}),s.jsxs("small",{children:[L," available · ",F.length," total. Choose a task, edit it, then run it."]})]}),s.jsx("button",{className:"agents-suggested-close",type:"button","aria-label":"Close suggested tasks",onClick:m,children:s.jsx(zs,{size:16})})]}),s.jsxs("label",{className:"agents-suggested-search",children:[s.jsx(KS,{size:15,"aria-hidden":"true"}),s.jsx("input",{ref:$,value:p,onChange:Y=>v(Y.target.value),onKeyDown:J,placeholder:"Search tasks...","aria-label":"Search suggested tasks"})]}),s.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",...my].map(Y=>{const O=Y==="recent"?Uy:Y==="favorites"?jh:Y==="all"?Ll:Y==="available"?In:Y==="unavailable"?QS:Y==="read-only"||Y==="auto"||Y==="approval"||Y==="full-access"?Bt:MN[Y];return s.jsxs("button",{className:g===Y?"active":"",type:"button",title:uh(Y),"aria-label":uh(Y),"aria-pressed":g===Y,onClick:()=>{w(Y),T(0),E("")},children:[s.jsx(O,{size:12})," ",TN(Y)]},Y)})}),k&&s.jsx("div",{className:"agents-suggested-notice",role:"status",children:k}),s.jsxs("div",{className:"agents-suggested-list",role:"listbox","aria-label":"Suggested tasks",children:[V.map(Y=>s.jsxs("div",{className:"agents-suggested-group",children:[s.jsx("strong",{children:Y.category}),Y.templates.map(O=>{le+=1;const Z=le===A,X=j.includes(O.id),D=q.get(O.id),K=D.availableDeviceIds.length+D.unsupportedDeviceIds.length||_,ce=D.available?`Available on ${D.availableDeviceIds.length} of ${K} target${K===1?"":"s"}`:`Unavailable: ${D.reason||"not supported by the current targets"}`;return s.jsxs("div",{className:`agents-suggested-item ${Z?"active":""} ${D.available?"":"unavailable"}`,children:[s.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Z,"aria-disabled":!D.available,onClick:()=>ne(O),children:[s.jsx("span",{children:O.title}),s.jsx("small",{className:"agents-suggested-description",children:O.description}),s.jsxs("span",{className:"agents-suggested-meta",children:[s.jsx("em",{children:O.category}),s.jsx("em",{className:RN(D.state),children:D.label}),s.jsx("em",{className:`risk-${O.risk}`,children:DN(O.risk)}),s.jsx("em",{children:O.supportedPlatforms.map(_N).join(" · ")}),s.jsx("em",{className:D.available?"availability-ok":"availability-unavailable",children:ce}),D.available&&D.unsupportedDeviceIds.length>0&&s.jsxs("em",{className:"availability-warning",children:["Unsupported on ",D.unsupportedDeviceIds.length]})]})]}),s.jsx("button",{className:`agents-suggested-favorite ${X?"favorite":""}`,type:"button","aria-label":X?`Remove ${O.title} from favorites`:`Add ${O.title} to favorites`,"aria-pressed":X,onClick:()=>Q(O.id),children:s.jsx(jh,{size:14,fill:X?"currentColor":"none"})})]},O.id)})]},Y.category)),ie.length===0&&s.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function zN({devices:n,mode:a,selectedIds:r,onModeChange:l,onToggle:c,permissionMode:d,onPermissionModeChange:m}){const p=n.filter(Bh),v=r.filter(g=>p.some(w=>w.deviceId===g)).length;return s.jsxs("section",{className:"agents-target-picker","aria-label":"Agent targets",children:[s.jsxs("div",{className:"agents-target-toolbar",children:[s.jsx("span",{className:"agents-section-label",children:"Targets"}),s.jsxs("div",{className:"agents-target-modes",children:[s.jsxs("button",{className:a==="all"?"active":"",onClick:()=>l("all"),type:"button",children:[s.jsx(Wy,{size:14})," All connected ",s.jsx("small",{children:p.length})]}),s.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>l("selected"),type:"button",children:[s.jsx(Hr,{size:14})," Selected ",v]})]}),s.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[s.jsx(hf,{size:14}),s.jsx("span",{children:"Permission"}),s.jsxs("select",{value:d,onChange:g=>m(g.target.value),"aria-label":"Agent permission mode",children:[s.jsx("option",{value:"ask",children:"Ask"}),s.jsx("option",{value:"safe-auto",children:"Safe Auto"}),s.jsx("option",{value:"full-access",children:"Full Access"}),s.jsx("option",{value:"custom",children:"Custom"})]}),s.jsx(Qy,{size:13,"aria-hidden":"true"})]})]}),s.jsx("div",{className:"agents-target-list",children:n.length===0?s.jsx("span",{className:"agents-target-empty",children:"No workstations discovered."}):n.map(g=>{const w=Bh(g),y=a==="all"?w:r.includes(g.deviceId);return s.jsxs("label",{className:`agents-target-option ${y?"selected":""} ${w?"":"offline"}`,children:[s.jsx("input",{type:"checkbox",checked:y,disabled:!w||a==="all",onChange:()=>c(g.deviceId)}),s.jsx("span",{className:"agents-target-icon",children:s.jsx(tn,{size:15})}),s.jsxs("span",{children:[s.jsx("strong",{children:Xw(g)}),s.jsx("small",{children:w?"Ready":g.connected?"Agent reconnecting":"Offline"})]}),y&&s.jsx(Hr,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},g.deviceId)})})]})}async function IN(n,a){return Ue("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function ON(n,a){return Ue("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function BN(n,a){return Ue(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function FN(n,a){return Ue(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function PN(n){return Ue("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function HN(n,a,r,l){return Ue(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/approve`,{method:"POST",body:JSON.stringify({scope:l})},n)}async function $N(n,a,r,l="User rejected this action."){return Ue(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify({reason:l})},n)}async function UN(n,a,r){return Ue(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:r})},n)}async function qN(n,a){return Ue("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function GN(n,a){return Ue("/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 VN(n,a){return Ue(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function YN(n,a){return Ue(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function WN(n,a){return Ue(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function kl(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function $d(n,a){const r=new Map(a.map(l=>[l.deviceId,Xw(l)]));return n.results.map(l=>({deviceId:l.deviceId,deviceName:l.deviceName||r.get(l.deviceId)||l.deviceId,status:oN(l.status),stage:l.stage||(l.status==="running"?"Checking processes":void 0),result:l.result,data:l.data,error:l.error,sequence:Number.isSafeInteger(l.sequence)?l.sequence:0}))}function KN(n,a){const r=new Map(a.map(l=>[l.deviceId,l]));return n.map(l=>{const c=r.get(l.deviceId);return!c||c.sequence<=l.sequence?l:c})}function QN(n,a){const r=a.filter(d=>d.status==="completed"),l=a.filter(d=>d.status==="failed");if(n.operation==="process.list"){const m=`${r.filter(p=>{const v=p.result||"";return!/not running|no process/i.test(v)&&/running|online|found/i.test(v)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return l.length>0?`${m}
|
|
14
|
+
${l.map(p=>`${p.deviceName}는 ${p.error||"응답하지 않았습니다."}`).join(`
|
|
15
|
+
`)}`:m}return l.length>0?`${r.length}대 완료, ${l.length}대 실패했습니다.`:`${r.length}대 작업이 완료되었습니다.`}const XN={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 ZN(n){return n==="safe-auto"?"Safe Auto":n==="full-access"?"Full Access":n==="custom"?"Custom":"Ask"}function JN(n){return n.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase())}function eM(n){const a=n instanceof Error?n.message:String(n);return/agent-ai-disabled/i.test(a)?"Enable AI Agent in Settings before running commands.":/agent-no-target-devices|agent-target-not-connected|device-not-connected/i.test(a)?"The selected workstation is reconnecting. Wait until its Agent status is Ready and try again.":/codex-auth-required/i.test(a)?"Codex sign-in is required on the Hub. Open Settings > Agent and test the Codex connection.":a}function tM({hubUrl:n,devices:a,launchRequest:r}){const[l,c]=u.useState("all"),[d,m]=u.useState([]),[p,v]=u.useState(""),[g,w]=u.useState([]),[y,b]=u.useState(""),[j,C]=u.useState(""),[A,T]=u.useState(""),[k,E]=u.useState("safe-auto"),[R]=u.useState("custom-default"),[$,F]=u.useState(XN),[q,L]=u.useState([]),[_,ie]=u.useState(""),[V,ne]=u.useState(!1),[Q,J]=u.useState(null),[le,Y]=u.useState(!1),[O,Z]=u.useState(""),[X,D]=u.useState(!1),[K,ce]=u.useState(null),W=u.useRef(null),P=u.useRef(new Set),me=u.useRef(new Set),ge=u.useRef(new Set),xe=u.useMemo(()=>a.filter(Bh).map(pe=>pe.deviceId),[a]),Ce=u.useMemo(()=>NN(Zw,a,l,d,k,$),[$,a,k,d,l]);u.useEffect(()=>{r?.deviceId&&(c("selected"),m([r.deviceId]),v(r.instruction),D(!1),window.requestAnimationFrame(()=>{W.current?.focus(),W.current?.setSelectionRange(r.instruction.length,r.instruction.length)}))},[r]);const Le=u.useCallback(pe=>{const ke=$d(pe,a);if(w(de=>de.map(we=>we.type==="task"&&we.batchId===pe.batchId?{...we,states:KN(we.states,ke),status:pe.status}:we)),!["running","queued"].includes(pe.status)&&!P.current.has(pe.batchId)){P.current.add(pe.batchId);const de=kl("agent-summary");w(we=>[...we,{type:"agent",id:de,text:QN(pe,ke)}]),pe.operation&&qN(n,{instruction:pe.instructionPreview,operation:pe.operation,total:ke.length,completed:ke.filter(we=>we.status==="completed").length,failed:ke.filter(we=>we.status==="failed").length,results:ke.map(we=>({deviceName:we.deviceName,status:we.status,result:we.result,error:we.error}))}).then(we=>{!we.ok||!we.summary||w(Ge=>Ge.map(tt=>tt.type==="agent"&&tt.id===de?{...tt,text:we.summary}:tt))}).catch(()=>{}),b(we=>we===pe.batchId?"":we)}},[a,n]),ze=u.useCallback(async pe=>{const ke=await VN(n,pe);return Le(ke),ke},[n,Le]),ue=u.useCallback((pe,ke)=>{ge.current.has(pe.batchId)||(ge.current.add(pe.batchId),w(de=>[...de,{type:"task",id:kl("task"),batchId:pe.batchId,agentRunId:ke,operation:pe.operation||"diagnostics.collect",instruction:pe.instructionPreview,states:$d(pe,a),status:pe.status}])),Le(pe)},[a,Le]),Ye=u.useCallback(async pe=>{const ke=await BN(n,pe);for(const we of ke.taskBatches||[])ue(we,pe);L(ke.approvals||[]);const de=["running","queued","waiting-approval"].includes(ke.status);if(ce(de?{runId:pe,stage:ke.stage||ke.status,message:ke.progressMessage||(ke.status==="waiting-approval"?"Review the requested action to continue.":"Codex is preparing the answer.")}:we=>we?.runId===pe?null:we),!de&&!me.current.has(pe)){me.current.add(pe);const we=[ke.error,ke.errorMessage].filter(Boolean).join(" — "),Ge=ke.finalResponse?.trim()||(ke.status==="cancelled"?"Codex 작업을 취소했습니다.":we?`Codex 작업이 완료되지 않았습니다: ${we}`:"Codex 작업이 완료되었습니다.");w(tt=>[...tt,{type:ke.status==="failed"?"error":"agent",id:kl("agent-run-result"),text:Ge}])}return ke},[ue,n]);u.useEffect(()=>{if(!y)return;let pe=!0;const ke=async()=>{try{const we=await ze(y);pe&&!["running","queued"].includes(we.status)&&b("")}catch(we){pe&&Z(we instanceof Error?we.message:String(we))}};ke();const de=window.setInterval(()=>{ke()},800);return()=>{pe=!1,window.clearInterval(de)}},[y,ze]),u.useEffect(()=>{if(!j)return;let pe=!0;const ke=async()=>{try{const we=await Ye(j);pe&&!["running","queued","waiting-approval"].includes(we.status)&&(C(""),Y(!1))}catch(we){pe&&Z(we instanceof Error?we.message:String(we))}};ke();const de=window.setInterval(()=>{ke()},800);return()=>{pe=!1,window.clearInterval(de)}},[j,Ye]);const We=async(pe="",ke,de=!1)=>{const we=(pe||p).trim();if(!we||y||j)return;let Ge=null;const tt=ke||(l==="all"?xe:d.filter(Qe=>xe.includes(Qe)));if(tt.length===0){Z("Select at least one connected workstation.");return}if(k==="full-access"&&!le&&!de){J({instruction:we,targetIds:tt});return}if(w(Qe=>[...Qe,{type:"user",id:kl("user"),text:we}]),v(""),D(!1),Z(""),tt.length===0){w(Qe=>[...Qe,{type:"error",id:kl("no-targets"),text:"연결된 대상 장비를 하나 이상 선택해 주세요."}]);return}if(!Ge){try{if(k==="custom"){const ht=await UN(n,R,$);if(!ht.ok)throw new Error(ht.error||"Custom Agent policy could not be saved.")}const Qe=await ON(n,{instruction:we,deviceIds:tt,permissionMode:k,customPolicyId:R});if(!Qe.ok||!Qe.runId)throw new Error(Qe.error||"Codex Agent run could not be started.");L(Qe.approvals||[]),ce({runId:Qe.runId,stage:Qe.stage||Qe.status||"queued",message:Qe.progressMessage||"Codex request queued on the Hub."}),C(Qe.runId);return}catch(Qe){try{const ht=await IN(n,we);ht.ok&&ht.plan&&(Ge={operation:ht.plan.operation,query:ht.plan.targetQuery})}catch{w(ht=>[...ht,{type:"error",id:kl("unsupported"),text:eM(Qe)}])}}if(!Ge)return}try{const Qe=await GN(n,{instruction:we,deviceIds:tt,operation:Ge.operation,targetQuery:Ge.query});if(!Qe.ok||!Qe.batch||!Qe.batchId)throw new Error(Qe.error||"작업을 만들지 못했습니다.");const ht={type:"task",id:kl("task"),batchId:Qe.batchId,operation:Ge.operation,instruction:we,states:$d(Qe.batch,a),status:Qe.batch.status};ge.current.add(Qe.batchId),w(St=>[...St,ht]),b(Qe.batchId)}catch(Qe){Z(Qe instanceof Error?Qe.message:String(Qe))}},oe=async(pe,ke)=>{ie(pe.approvalId);try{const de=await HN(n,pe.runId,pe.approvalId,ke);if(!de.ok)throw new Error(de.error||"Agent approval could not be applied.");await Ye(pe.runId)}catch(de){Z(de instanceof Error?de.message:String(de))}finally{ie("")}},Ae=async pe=>{ie(pe.approvalId);try{const ke=await $N(n,pe.runId,pe.approvalId);if(!ke.ok)throw new Error(ke.error||"Agent approval could not be rejected.");await Ye(pe.runId)}catch(ke){Z(ke instanceof Error?ke.message:String(ke))}finally{ie("")}},je=async(pe,ke)=>{T(pe);try{if(ke){const we=await FN(n,ke);for(const Ge of we.taskBatches||[])Le(Ge);C(Ge=>Ge===ke?"":Ge),ce(Ge=>Ge?.runId===ke?null:Ge);return}const de=await YN(n,pe);Le(de),b(we=>we===pe?"":we)}catch(de){Z(de instanceof Error?de.message:String(de))}finally{T("")}},Ee=async()=>{if(!(V||!y&&!j)){ne(!0);try{const pe=await PN(n);if(!pe.ok)throw new Error(pe.error||"모든 Agent 작업을 취소하지 못했습니다.");b(""),C(""),ce(null),L([]),w(ke=>ke.map(de=>de.type==="task"&&["queued","running"].includes(de.status)?{...de,status:"cancelled",states:de.states.map(we=>["queued","running"].includes(we.status)?{...we,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:we)}:de))}catch(pe){Z(pe instanceof Error?pe.message:String(pe))}finally{ne(!1)}}},Re=async pe=>{T(pe);try{const ke=await WN(n,pe);if(!ke.ok||!ke.batch||!ke.batchId)throw new Error(ke.error||"재시도하지 못했습니다.");P.current.delete(ke.batchId),w(de=>de.map(we=>we.type==="task"&&we.batchId===pe?{...we,batchId:ke.batchId,states:$d(ke.batch,a),status:ke.batch.status}:we)),b(ke.batchId)}catch(ke){Z(ke instanceof Error?ke.message:String(ke))}finally{T("")}},Fe=pe=>{v(pe),D(!1),window.requestAnimationFrame(()=>W.current?.focus())};return s.jsxs("section",{className:"agents-page",children:[s.jsxs("div",{className:"agents-workspace",children:[(y||j)&&s.jsxs("div",{className:"agents-page-status",children:[s.jsxs("span",{children:[xe.length," workstations · ",ZN(k)]}),s.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{Ee()},disabled:V,children:V?"Stopping…":"Stop all"})]}),Q&&s.jsx("div",{className:"agents-permission-modal-backdrop",role:"presentation",children:s.jsxs("section",{className:"agents-permission-modal",role:"dialog","aria-modal":"true","aria-labelledby":"full-access-title",children:[s.jsx("span",{className:"agents-permission-modal-icon",children:s.jsx(hf,{size:20})}),s.jsx("h3",{id:"full-access-title",children:"Confirm Full Access"}),s.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."}),s.jsxs("div",{className:"agents-permission-modal-actions",children:[s.jsx("button",{type:"button",onClick:()=>J(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"danger",onClick:()=>{const pe=Q;J(null),Y(!0),We(pe.instruction,pe.targetIds,!0)},children:"Run with Full Access"})]})]})}),O&&s.jsx("div",{className:"agents-error",role:"alert",children:O}),s.jsx(xN,{items:g,onCancel:je,onRetry:Re,busyBatchId:A,approvals:q,onApprove:oe,onReject:Ae,busyApprovalId:_,progress:K}),s.jsxs("div",{className:"agents-composer-shell",children:[X&&s.jsx(LN,{devices:a,targetMode:l,selectedIds:d,permissionMode:k,customCategories:$,onSelectPrompt:Fe,onClose:()=>D(!1)}),s.jsx(rN,{ref:W,value:p,onChange:v,onSubmit:()=>{We()},onOpenSuggestedTasks:()=>D(pe=>!pe),suggestedOpen:X,suggestedTaskCount:Ce,disabled:!!y||!!j})]})]}),s.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[s.jsx(zN,{devices:a,mode:l,selectedIds:d,onModeChange:c,onToggle:pe=>m(ke=>ke.includes(pe)?ke.filter(de=>de!==pe):[...ke,pe]),permissionMode:k,onPermissionModeChange:pe=>{E(pe),pe!=="full-access"&&Y(!1)}}),k==="custom"&&s.jsxs("section",{className:"agents-custom-policy","aria-label":"Custom Agent permissions",children:[s.jsxs("div",{className:"agents-custom-policy-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"agents-section-label",children:"Custom policy"}),s.jsx("strong",{children:"Choose what Codex may do automatically."})]}),s.jsx("span",{children:"Denied actions never reach a device."})]}),s.jsx("div",{className:"agents-custom-policy-grid",children:lN.map(pe=>s.jsxs("label",{children:[s.jsx("span",{children:JN(pe)}),s.jsxs("select",{value:$[pe],onChange:ke=>F(de=>({...de,[pe]:ke.target.value})),children:[s.jsx("option",{value:"allow",children:"Allow automatically"}),s.jsx("option",{value:"ask",children:"Ask every time"}),s.jsx("option",{value:"deny",children:"Deny"})]})]},pe))})]})]})]})}function eb(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function tb(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function nb(n,a,r){const l=encodeURIComponent(JSON.stringify({kind:a.kind,fileName:a.fileName,mimeType:n.type||"application/octet-stream",durationMs:a.durationMs,target:eb(a.target)})),c=await fetch(`${Gr(r)}/api/captures?metadata=${l}`,{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream"},body:n,cache:"no-store"});if(!c.ok)throw new Error(await tb(c));return await c.json()}async function nM(n,a){return await Ue("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:eb(n.target)})},a)}async function aM(n,a,r,l){const c=await fetch(`${Gr(l)}/api/capture-sessions/${encodeURIComponent(n)}/chunks/${a}`,{method:"PUT",headers:{"Content-Type":r.type||"application/octet-stream"},body:r,cache:"no-store"});if(!c.ok)throw new Error(await tb(c));return await c.json()}async function sM(n,a,r){return await Ue(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},r)}async function gy(n,a){await Ue(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function iM(n){return await Ue("/api/captures",void 0,n)}function vy(n,a){return`${Gr(a)}/api/captures/${encodeURIComponent(n)}/content`}async function rM(n,a){return await Ue(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function lM({hubUrl:n,onToast:a}){const[r,l]=u.useState([]),[c,d]=u.useState(!0),m=u.useCallback(async()=>{d(!0);try{l((await iM(n)).captures||[])}catch(v){a(v instanceof Error?v.message:String(v))}finally{d(!1)}},[n,a]);u.useEffect(()=>{m()},[m]);const p=async v=>{const g=vy(v.id,n);if(navigator.share)try{await navigator.share({title:v.fileName,url:g});return}catch{}window.open(g,"_blank","noopener,noreferrer")};return s.jsxs("section",{className:"capture-gallery",children:[s.jsxs("header",{children:[s.jsxs("div",{children:[s.jsx("span",{className:"settings-eyebrow",children:"Capture Gallery"}),s.jsx("h2",{children:"Saved captures"})]}),s.jsxs("button",{className:"text-button",onClick:()=>{m()},type:"button",children:[s.jsx(Oo,{size:15})," Refresh"]})]}),c?s.jsx("p",{className:"settings-help",children:"Loading captures..."}):r.length===0?s.jsx("p",{className:"settings-help",children:"No captures saved yet."}):s.jsx("div",{className:"capture-gallery-grid",children:r.map(v=>{const g=vy(v.id,n);return s.jsxs("article",{className:"capture-gallery-card",children:[v.mimeType.startsWith("image/")?s.jsx("img",{src:g,alt:v.target.label}):s.jsx("video",{src:g,controls:!0,preload:"metadata"}),s.jsxs("div",{className:"capture-gallery-card-body",children:[s.jsx("strong",{children:v.fileName}),s.jsxs("small",{children:[v.target.label," · ",new Date(v.createdAt).toLocaleString()," · ",Math.ceil(v.sizeBytes/1024)," KB"]}),s.jsxs("div",{children:[s.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(g,"_blank","noopener,noreferrer"),type:"button",children:s.jsx(e0,{size:15})}),s.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${g}?download=1`,download:v.fileName,children:s.jsx(Yh,{size:15})}),s.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(v)},type:"button",children:s.jsx(t0,{size:15})}),s.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${v.fileName}?`)&&rM(v.id,n).then(()=>m()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:s.jsx(Wh,{size:15})})]})]})]},v.id)})})]})}function Ud(n){if(!n)return"";const a=Math.max(0,Math.floor((Date.now()-n)/1e3)),r=Math.floor(a/3600),l=Math.floor(a%3600/60),c=a%60;return r>0?`${String(r).padStart(2,"0")}:${String(l).padStart(2,"0")}:${String(c).padStart(2,"0")}`:`${String(l).padStart(2,"0")}:${String(c).padStart(2,"0")}`}function xy({controller:n,compact:a=!1,onFirstRollingUse:r,onError:l}){const{state:c,settings:d,videoSupported:m}=n,p=async y=>{try{await y()}catch(b){l?.(b instanceof Error?b.message:String(b))}},v=async()=>{if(d.rollingEnabled){n.setRollingEnabled(!1);return}(r?await r():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 · ${Ud(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${Ud(c.timelapseStartedAt)}`:`Start timelapse · ${d.timelapseIntervalSeconds}s interval`;return s.jsxs("div",{className:`capture-toolbar ${a?"compact":""} ${c.recording?"recording-active":""}`,"aria-label":"Capture actions",children:[s.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:s.jsx(n0,{size:17})}),s.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":g,title:g,disabled:!m||c.busy||c.timelapse,onClick:()=>{p(c.recording?n.stopRecording:n.startRecording)},type:"button",children:c.recording?s.jsxs(s.Fragment,{children:[s.jsx(nx,{size:14,fill:"currentColor"}),s.jsx("span",{children:Ud(c.recordingStartedAt)})]}):s.jsx(Ky,{size:18})}),s.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:!m||c.recording||c.timelapse||c.busy||c.bufferEnabled&&c.bufferSeconds<1,onClick:()=>c.bufferEnabled?void p(n.saveLast30Seconds):void v(),type:"button",children:[s.jsx(a0,{size:17}),s.jsx("small",{children:"30s"})]}),s.jsx("button",{className:`capture-action ${c.timelapse?"timelapse-active":""}`,"aria-label":w,title:w,disabled:!m||c.busy||c.recording,onClick:()=>{p(c.timelapse?n.stopTimelapse:n.startTimelapse)},type:"button",children:c.timelapse?s.jsxs(s.Fragment,{children:[s.jsx(nx,{size:14,fill:"currentColor"}),s.jsx("span",{children:Ud(c.timelapseStartedAt)})]}):s.jsx(s0,{size:17})})]})}async function oM(n,a={}){const r=n.filter(y=>y.canvas&&y.canvas.width>0&&y.canvas.height>0),l=Math.max(320,a.maxWidth||1920),c=Math.max(180,a.maxHeight||1080),d=r.length<=1?1:r.length<=4?2:r.length<=9?3:4,m=Math.max(1,Math.ceil(Math.max(1,r.length)/d)),p=Math.floor(l/d),v=Math.floor(c/m),g=document.createElement("canvas");g.width=Math.max(320,p*d),g.height=Math.max(180,v*m);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 y=0;y<r.length;y+=1){const b=r[y],j=y%d,C=Math.floor(y/d),A=j*p,T=C*v,k=b.canvas,E=Math.min(p/k.width,v/k.height),R=Math.max(1,Math.floor(k.width*E)),$=Math.max(1,Math.floor(k.height*E)),F=A+Math.floor((p-R)/2),q=T+Math.floor((v-$)/2);w.drawImage(k,F,q,R,$),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(A,T+v-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,A+9,T+v-9))}return g}function cM(n){return n?.signature||"none"}function uM(n){return n?.label||"No capture target"}function yy(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function dM(){const n=new Date,a=r=>String(r).padStart(2,"0");return`${n.getFullYear()}${a(n.getMonth()+1)}${a(n.getDate())}_${a(n.getHours())}${a(n.getMinutes())}${a(n.getSeconds())}`}function fM(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":`${fM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${dM()}.png`}async function hM(n,a,r){const l=await new Promise((d,m)=>n.toBlob(p=>p?d(p):m(new Error("Screenshot could not be encoded.")),"image/png")),c=await nb(l,{kind:"screenshot",fileName:mM(a),target:a},r);try{await navigator.clipboard.write([new ClipboardItem({"image/png":l})])}catch{}return c.capture}function ab(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function pM(n,a){const r=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_"),l=a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall";return n==="timelapse"?`LiveDesk_Timelapse_${l}_${r}.webm`:`LiveDesk_Recording_${l}_${r}.webm`}async function sb(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=ab();if(!a)throw new Error("This browser does not support WebM recording.");const r=n.kind||"recording",l=await nM({kind:r,fileName:pM(r,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:r==="timelapse"?2e6:4e6}),m=performance.now();let p=0,v=!1,g=null,w=Promise.resolve();return d.ondataavailable=y=>{if(!y.data||y.data.size===0)return;const b=p++;w=w.then(()=>aM(l.sessionId,b,y.data,n.hubUrl).then(()=>{})).catch(j=>{g=g||(j instanceof Error?j:new Error(String(j))),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(!v){if(v=!0,await new Promise(y=>{d.addEventListener("stop",()=>y(),{once:!0}),d.stop()}),c.getTracks().forEach(y=>y.stop()),await w,g)throw await gy(l.sessionId,n.hubUrl).catch(()=>{}),g;await sM(l.sessionId,Math.max(0,performance.now()-m),n.hubUrl)}},cancel:async()=>{v||(v=!0,d.stop(),c.getTracks().forEach(y=>y.stop()),await gy(l.sessionId,n.hubUrl).catch(()=>{}))}}}class gM{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,r){if(this.recorder&&this.targetSignature===r.signature)return;if(this.stop(),typeof MediaRecorder>"u"||typeof a.captureStream!="function")throw new Error("This browser does not support Last 30s.");const l=ab();if(!l)throw new Error("This browser does not support WebM recording.");this.targetSignature=r.signature,this.stream=a.captureStream(20),this.recorder=new MediaRecorder(this.stream,{mimeType:l,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 m=this.segments.shift();this.totalBytes-=m.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(r=>r.stop()),this.stream=null,this.segments=[],this.totalBytes=0,this.startedAt=0}async save(a,r){if(this.segments.length===0)throw new Error("The Last 30s buffer is not ready yet.");const l=new Blob(this.segments.map(m=>m.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 nb(l,{kind:"last-30s",fileName:d,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},r)}}async function vM(n,a,r,l,c){const d=await sb({canvas:n,target:a,kind:"timelapse",fps:30,frameRequests:!0,hubUrl:l,onError:c});d.requestFrame?.();const m=window.setInterval(()=>d.requestFrame?.(),Math.max(5,r)*1e3);return{stop:async()=>{window.clearInterval(m),await d.stop()},cancel:async()=>{window.clearInterval(m),await d.cancel()}}}const ib="livedesk.captureSettings";function xM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(ib)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function yM(n){const[a,r]=u.useState(xM),[l,c]=u.useState(0),[d,m]=u.useState(0),[p,v]=u.useState(0),[g,w]=u.useState(!1),y=u.useRef(void 0),b=u.useRef(!1),j=u.useRef(""),C=u.useRef(null),A=u.useRef(null),T=u.useRef(null),k=u.useRef(null),E=u.useRef(new gM),R=n.sourceRegistry.resolveCurrentTarget(),$=cM(R),F=uM(R),q=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;u.useEffect(()=>{if(localStorage.setItem(ib,JSON.stringify(a)),!b.current)return;const X=JSON.stringify(a);X!==j.current&&(j.current=X,Ue("/api/settings",{method:"PATCH",body:JSON.stringify({revision:y.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(D=>{y.current=Number(D.revision||y.current||0)}).catch(()=>{}))},[n.hubUrl,a]),u.useEffect(()=>{let X=!0;return Ue("/api/settings",void 0,n.hubUrl).then(D=>{if(!X)return;const K=D.settings?.filesAudio||{},ce=typeof K.rollingBufferEnabled=="boolean"?K.rollingBufferEnabled:a.rollingEnabled,W=K.recordingQuality==="high"?"high":"standard",P=[5,10,30,60].includes(Number(K.timelapseIntervalSeconds))?Number(K.timelapseIntervalSeconds):a.timelapseIntervalSeconds,me=typeof K.includeRemoteCursor=="boolean"?K.includeRemoteCursor:a.includeRemoteCursor,ge={rollingEnabled:ce,recordingQuality:W,timelapseIntervalSeconds:P,includeRemoteCursor:me};y.current=Number(D.revision||0),j.current=JSON.stringify(ge),b.current=!0,r(ge)}).catch(()=>{b.current=!0}),()=>{X=!1}},[n.hubUrl]);const L=u.useCallback(async X=>{if(X.sourceCanvas&&X.sourceCanvas.width>0&&X.sourceCanvas.height>0)return{target:yy(X),canvas:X.sourceCanvas,cleanup:()=>{}};const D=await n.sourceRegistry.composeWall(X.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let K=!1;const ce=window.setInterval(async()=>{if(K)return;const W=await n.sourceRegistry.composeWall(X.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!W||K||((D.width!==W.width||D.height!==W.height)&&(D.width=W.width,D.height=W.height),D.getContext("2d")?.drawImage(W,0,0))},100);return{target:yy(X),canvas:D,cleanup:()=>{K=!0,window.clearInterval(ce)}}},[n.sourceRegistry]);u.useEffect(()=>{const X=E.current;if(!a.rollingEnabled||!R||!q){X.stop(),v(0);return}let D=!1,K=null;return(async()=>{try{if(K=await L(R),D)return;await X.start(K.canvas,K.target);const W=window.setInterval(()=>v(Math.round(X.seconds)),500),P=()=>{window.clearInterval(W),K?.cleanup()};X.__cleanup=P}catch(W){D||n.onToast(W instanceof Error?W.message:String(W))}})(),()=>{D=!0,X.stop(),X.__cleanup?.(),X.__cleanup=void 0,v(0)}},[L,n.onToast,a.rollingEnabled,$,q]);const _=u.useCallback(X=>r(D=>({...D,rollingEnabled:X})),[]),ie=u.useCallback(X=>r(D=>({...D,recordingQuality:X})),[]),V=u.useCallback(X=>r(D=>({...D,timelapseIntervalSeconds:X})),[]),ne=u.useCallback(async()=>{const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let D=null;try{D=await L(X),await hM(D.canvas,D.target,n.hubUrl),n.onToast("Screenshot saved")}finally{D?.cleanup(),w(!1)}},[L,n.hubUrl,n.onToast,n.sourceRegistry]),Q=u.useCallback(async()=>{if(T.current)throw new Error("Stop the timelapse before recording.");const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");const D=await L(X),K=await sb({canvas:D.canvas,target:D.target,fps:X.type==="control"?30:15,hubUrl:n.hubUrl,onError:ce=>n.onToast(ce.message)});A.current=D.cleanup,C.current=K,c(Date.now()),n.onToast("Recording started")},[L,n.hubUrl,n.onToast,n.sourceRegistry]),J=u.useCallback(async()=>{const X=C.current;if(X){w(!0);try{await X.stop(),n.onToast("Recording saved")}finally{C.current=null,A.current?.(),A.current=null,c(0),w(!1)}}},[n.onToast]),le=u.useCallback(async()=>{if(C.current||T.current)throw new Error("Last 30s is unavailable during a recording.");const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await E.current.save(X,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),Y=u.useCallback(async()=>{if(C.current)throw new Error("Stop the recording before starting a timelapse.");const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");const D=await L(X),K=await vM(D.canvas,D.target,a.timelapseIntervalSeconds,n.hubUrl,ce=>n.onToast(ce.message));k.current=D.cleanup,T.current=K,m(Date.now()),n.onToast("Timelapse started")},[L,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),O=u.useCallback(async()=>{const X=T.current;if(X){w(!0);try{await X.stop(),n.onToast("Timelapse saved")}finally{T.current=null,k.current?.(),k.current=null,m(0),w(!1)}}},[n.onToast]);return u.useEffect(()=>{const X=D=>{!C.current&&!T.current||(D.preventDefault(),D.returnValue="")};return window.addEventListener("beforeunload",X),()=>window.removeEventListener("beforeunload",X)},[]),u.useEffect(()=>()=>{E.current.stop(),C.current?.cancel(),T.current?.cancel(),A.current?.(),k.current?.()},[]),{state:u.useMemo(()=>({recording:!!C.current,recordingStartedAt:l,timelapse:!!T.current,timelapseStartedAt:d,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:g,targetLabel:F}),[p,g,l,a.rollingEnabled,F,d]),settings:a,videoSupported:q,targetKey:$,setRollingEnabled:_,setRecordingQuality:ie,setTimelapseInterval:V,takeScreenshot:ne,startRecording:Q,stopRecording:J,saveLast30Seconds:le,startTimelapse:Y,stopTimelapse:O}}const wM=120,bM=999,Gc=5,Vc=30,SM=Number.POSITIVE_INFINITY,rb="livedesk.remoteDirectory",Fh="livedesk.localHubAccessEnabled",lb="livedesk.streamSettings",Ph=16,ob="livedesk.controlStreamSettings",Hh=6,cb="livedesk.wallMonitorSelections",ub=1,dh=512*1024,$h="".trim(),db="".trim(),wy="livedesk-adsense-script",fh=!!$h&&!!db,jM=1e3/60,mh=1500,CM=650,kM=1800,AM=650,NM=2500,by=1500,Sy=15e3,MM=6e4,jy=240,TM=1024,EM=480,RM=270,Cy="LiveDesk clients are updating. Hub will restart after every client reconnects.",hh="LiveDesk is restarting with the latest Hub.";function DM(n,a){if(a.deviceId!==n.deviceId)return!1;const r=Number(a.browserReceivedEpochMs);if(!Number.isFinite(r)||r<n.startedAtEpochMs)return!1;const l=Number(a.monitorIndex);if(Number.isFinite(l)&&Math.floor(l)!==n.monitorIndex)return!1;const c=String(a.frameMode||a.mode||"").trim().toLowerCase();return!c||c===n.frameMode}const Al={free:{name:"Free",price:"$0",limit:Gc,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:Vc,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:SM,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},fb={"mode1-jpeg":5,"mode3-h264-hw":30,"mode4-h264-atlas":20};function _s(n,a){return`${n}:${a}`}const ha={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:fb["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},_a={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function Zd(n,a){if(n.length===0)return 0;const r=[...n].sort((c,d)=>c-d),l=Math.max(0,Math.min(r.length-1,Math.ceil(r.length*a)-1));return r[l]}function vp(n,a){n.push(a),n.length>jy&&n.splice(0,n.length-jy)}function ky(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 Ay(n,a,r){if(n.lastAt!==void 0){const l=Math.max(0,a-n.lastAt);n.intervalCount+=1,n.intervalSumMs+=l,n.minIntervalMs=Math.min(n.minIntervalMs,l),n.maxIntervalMs=Math.max(n.maxIntervalMs,l),vp(n.intervalSamplesMs,l)}if(n.lastFrameSeq!==void 0){const l=r-n.lastFrameSeq;l!==1&&(n.seqGapCount+=1,n.maxSeqGap=Math.max(n.maxSeqGap,Math.abs(l)))}n.lastAt=a,n.lastFrameSeq=r}function Ny(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 _M(){const[n,a]=u.useState({framesPerSecond:0,averageIntervalMs:0,p95IntervalMs:0,maxIntervalMs:0,longTaskCount:0,longTaskMs:0});return u.useEffect(()=>{let r=0,l=performance.now(),c=0,d=0,m=[],p=0,v=0,g=null;const w=b=>{document.visibilityState==="visible"?(c+=1,d>0&&vp(m,Math.max(0,b-d)),d=b):d=0,r=window.requestAnimationFrame(w)};try{g=new PerformanceObserver(b=>{for(const j of b.getEntries())p+=1,v+=j.duration}),g.observe({entryTypes:["longtask"]})}catch{g=null}r=window.requestAnimationFrame(w);const y=window.setInterval(()=>{const b=performance.now(),j=Math.max(1,b-l),C=m.reduce((A,T)=>A+T,0);a({framesPerSecond:c*1e3/j,averageIntervalMs:m.length>0?C/m.length:0,p95IntervalMs:Zd(m,.95),maxIntervalMs:m.length>0?Math.max(...m):0,longTaskCount:p,longTaskMs:v}),l=b,c=0,m=[],p=0,v=0},1e3);return()=>{window.cancelAnimationFrame(r),window.clearInterval(y),g?.disconnect()}},[]),n}function My(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function LM(n){return Number.isFinite(n)?String(n):"30+"}const Jd=[{id:"mode4-h264-atlas",label:"Mode 4",detail:"Hub H.264 Atlas"},{id:"mode3-h264-hw",label:"Mode 3",detail:"H.264 hardware"}],Uh=[{id:"prefer-software",label:"Software low latency"},{id:"prefer-hardware",label:"Hardware decode"},{id:"no-preference",label:"Browser auto"}],zM=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"}],ef=[{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}],ph=ef.filter(n=>n.width>=1280),gh=[{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}],xp=[1,2,5,8,12,20,30],IM=[20,30,60],Ty=[45,60,75,90],Ey={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},sa={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:ci.maxDirectFramesPerSecond,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},Ry=2200,OM=8e3,BM=3500,FM=7e3,PM=2,HM=2600,$M=4200,UM=750,qM=2,Dy=4200;function _y(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function eu(n,a){const r=n.capabilities?.[a];return typeof r=="boolean"?r:/^(1|true|yes|on)$/i.test(String(r||"").trim())}function ma(n){return n.deviceName||n.hostname||n.deviceId}function GM(){return"npx -y --prefer-online livedesk@latest client"}function VM(){return"npx -y --prefer-online livedesk@latest"}function YM(){try{return localStorage.getItem(rb)||""}catch{return""}}function WM(){try{return localStorage.getItem(Fh)==="1"}catch{return!1}}function No(n){try{n?localStorage.setItem(Fh,"1"):localStorage.removeItem(Fh)}catch{}}function gs(n,a,r,l){const c=Number(n);return Number.isFinite(c)?Math.max(a,Math.min(r,Math.round(c))):l}function qh(n){const a=String(n||"").trim();return Jd.some(r=>r.id===a)?a:ha.frameMode}function mf(n){const a=String(n||"").trim();return Uh.some(r=>r.id===a)?a:ha.h264DecodeAcceleration}function Gh(n){return n==="mode3-h264-hw"?n:_a.frameMode}function mb(n){return fb[n]||12}function hb(n){return n==="mode3-h264-hw"?30:n==="mode4-h264-atlas"?20:30}function Vh(n,a){return gs(n,1,hb(a),mb(a))}function Ol(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function fa(n){const a=Ol(n.status),r=Ol(a.screens),l=Ol(n.capabilities),c=[a.monitorCount,a.screenCount,r.count,l.monitorCount,l.screenCount];for(const d of c){const m=Number(d);if(Number.isFinite(m)&&m>0)return Math.max(1,Math.min(64,Math.floor(m)))}return 1}function Pr(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function KM(n){const a=Ol(n.status),l=[Ol(a.screens).displays,a.displays,a.monitors];for(const c of l)if(!(!Array.isArray(c)||c.length===0))return c.map(d=>Ol(d));return[]}function pb(n,a){const r=KM(n),l=r.find(v=>Number(v.index)===a)||r[a]||r[0]||{},c=Pr(l.width),d=Pr(l.height),m=[l.name,l.displayName,l.deviceName,l.id].find(v=>typeof v=="string"&&v.trim()),p=typeof m=="string"?m.trim():`Display ${a+1}`;return{index:a,name:p,width:c,height:d,primary:l.primary===!0||l.isPrimary===!0}}function QM(n){const a=fa(n);return Array.from({length:a},(r,l)=>pb(n,l))}function XM(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 gb(n,a){const r=pb(n,a);if(r.width>0&&r.height>0)return{width:r.width,height:r.height};const l=Ol(n.status),c=Pr(l.screenWidth||l.width),d=Pr(l.screenHeight||l.height);return c>0&&d>0?{width:c,height:d}:null}function vb(n){if(!n)return null;const a=Pr(n.sourceWidth)||Pr(n.width),r=Pr(n.sourceHeight)||Pr(n.height);return a>0&&r>0?{width:a,height:r}:null}function ZM(n,a,r){const d=((typeof a?.monitorIndex=="number"?Da(a.monitorIndex,Math.max(1,a.monitorCount||1)):r)===r?vb(a):null)||gb(n,r);return d?Math.max(.25,Math.min(4,d.width/d.height)):16/9}const qd=16/9;function Da(n,a){const r=Math.max(1,Math.min(64,Math.floor(Number(a)||1))),l=Math.floor(Number(n));return Number.isFinite(l)?Math.max(0,Math.min(r-1,l)):0}function JM(){try{const n=localStorage.getItem(cb);if(!n)return{};const a=JSON.parse(n),r=a&&typeof a=="object"&&!Array.isArray(a)?a.selections:void 0;if(Number(a?.version)!==ub||!r||typeof r!="object"||Array.isArray(r))return{};const l={};for(const[c,d]of Object.entries(r)){const m=c.trim(),p=Math.floor(Number(d));!m||!Number.isFinite(p)||(l[m]=Math.max(0,Math.min(63,p)))}return l}catch{return{}}}function eT(n){try{localStorage.setItem(cb,JSON.stringify({version:ub,selections:n}))}catch{}}function tT(){try{const n=JSON.parse(localStorage.getItem(lb)||"{}"),a=Number(n.version);if(![Ph,15,14,13,12,11].includes(a))return ha;const r=qh(n.frameMode),l=gs(n.maxWidth,320,3840,ha.maxWidth),c=gs(n.maxHeight,180,2160,ha.maxHeight);return{frameMode:r,h264DecodeAcceleration:mf(n.h264DecodeAcceleration),fps:a<Ph&&r==="mode3-h264-hw"?ha.fps:Vh(n.fps,r),maxWidth:l,maxHeight:c,atlasTileWidth:Number(n.atlasTileWidth)>=480?480:320,atlasTileHeight:Number(n.atlasTileHeight)>=270?270:180,atlasTileSizeMode:n.atlasTileSizeMode==="fixed"?"fixed":"auto",quality:gs(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 nT(n){try{localStorage.setItem(lb,JSON.stringify({...n,version:Ph}))}catch{}}function aT(){try{const n=JSON.parse(localStorage.getItem(ob)||"{}"),a=Number(n.version);if(![Hh,5,4,3,2,1].includes(a))return _a;const r=gs(n.fps,20,60,_a.fps),l=a<Hh;return{frameMode:l?_a.frameMode:Gh(n.frameMode),h264DecodeAcceleration:l?_a.h264DecodeAcceleration:mf(n.h264DecodeAcceleration),fps:l?_a.fps:r,maxWidth:gs(n.maxWidth,1280,3840,_a.maxWidth),maxHeight:gs(n.maxHeight,720,2160,_a.maxHeight),quality:gs(n.quality,20,95,_a.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:_a.showScreenStatus}}catch{return _a}}function sT(n){try{localStorage.setItem(ob,JSON.stringify({...n,version:Hh}))}catch{}}function vh(n,a){return n.length!==a.length?!1:n.every((r,l)=>r===a[l])}function xh(n){return[...new Set(n.filter(Boolean))].sort()}function iT(n){return sa.fallbackVisibleCounts[n]||sa.fallbackVisibleCounts.large}function rT(n,a,r){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 l=Ey[a]||Ey.large;return{maxWidth:Math.min(n.maxWidth,l.maxWidth),maxHeight:Math.min(n.maxHeight,l.maxHeight)}}function lT(n,a=sa.minFps){const r=[...xp].sort((c,d)=>c-d),l=Math.max(a,Math.floor(n/2));return[...r].reverse().find(c=>c<n&&c>=a)||l}function oT(n,a){return[...xp].sort((l,c)=>l-c).find(l=>l>n&&l<=a)||a}function Yc(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let r=n,l=0;for(;r>=1024&&l<a.length-1;)r/=1024,l+=1;const c=l===0||r>=100?0:1;return`${r.toFixed(c)} ${a[l]}`}function Ly(n){if(!Number.isFinite(n)||!n||n<=0)return"0GB";const a=1024**4,r=1024**3;return n>=a?`${Math.max(1,Math.round(n/a))}TB`:`${Math.max(1,Math.round(n/r))}GB`}function yh(n,a){if(!Number.isFinite(n)||!n||n<=0)return"not reported";const r=Math.max(0,n-Math.max(0,Number(a||0)));return`${Ly(r)} / ${Ly(n)}`}function cT(n){const a=new Uint8Array(n),r=32768;let l="";for(let c=0;c<a.length;c+=r){const d=a.subarray(c,c+r);l+=String.fromCharCode(...d)}return btoa(l)}function zy(n){return Array.from(n).filter(a=>a.size>=0).map(a=>{const r=a.webkitRelativePath||a.name;return{file:a,relativePath:r,fingerprint:`${a.size}:${a.lastModified}`}})}function uT(n){return n===1?"middle":n===2?"right":"left"}function Iy(n,...a){for(const r of a){const l=n?.[r];if(typeof l=="string"&&l.trim())return l.trim()}return""}function Oy(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=bM?a:0}const dT={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function fT(n,a,r){if(n==="online")return"Online";if(n==="busy")return"Busy";if(n==="stale")return"Stale";if(n==="offline")return"Offline";if(r==="failed")return"Task failed";const l=n==="critical"?"critical":"warn",c=a.find(m=>m.state===l)||a.find(m=>m.state==="critical"||m.state==="warn");if(!c)return n==="critical"?"Issue":"Check";const d=dT[c.id]||c.label;return c.value&&c.value!=="-"?`${d} ${c.value}`:d}function Sf(n,a){const r=a.split(".");let l=n;for(const c of r){if(l==null)return;if(Array.isArray(l)){const d=Number(c);l=Number.isInteger(d)?l[d]:void 0;continue}if(typeof l=="object"){l=l[c];continue}return}return l}function sn(n,...a){for(const r of a){const l=Sf(n,r),c=Number(l);if(Number.isFinite(c))return c}}function La(n,...a){for(const r of a){const l=Sf(n,r);if(typeof l=="string"&&l.trim())return l.trim();if(typeof l=="number"&&Number.isFinite(l))return String(l)}return""}function mT(n,...a){for(const r of a){const l=Sf(n,r);if(typeof l=="boolean")return l;if(/^(1|true|yes|on|online|running|ready)$/i.test(String(l||"").trim()))return!0;if(/^(0|false|no|off|offline|stopped|missing)$/i.test(String(l||"").trim()))return!1}}function Wi(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function wh(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return Wi((n-Math.max(0,a))/n)}function Mo(n){return n===void 0?"-":`${Math.round(n*100)}%`}function bh(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 Nl(n,a=.92,r=.78){return n===void 0?"unknown":n>=a?"critical":n>=r?"warn":"good"}function xb(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 Gd(n,a,r){const l=Sf(n,`tools.${a}`),c=La(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),d=mT(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),m=La(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=La(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let v="unknown";return c==="busy"?v="busy":["online","running","ready","active"].includes(c)||d===!0?v="online":(["offline","stopped","missing","not-found"].includes(c)||d===!1||l===!1)&&(v="offline"),{id:a,label:r,status:v,detail:v==="offline"?"offline":m||(p?`:${p}`:v==="unknown"?"not reported":v)}}function yb(n){const a=n.status||{},r=sn(a,"cpu.cores","cpuCores","processorCount"),l=sn(a,"loadavg.0","cpu.load1"),c=Wi(sn(a,"cpu.usedRatio","cpu.usageRatio","cpu.ratio","cpu.usedPct","cpu.usagePct","cpu.percent")??(r&&l!==void 0?l/Math.max(1,r):void 0)),d=sn(a,"memory.totalBytes","totalMem"),m=sn(a,"memory.freeBytes","freeMem"),p=Wi(sn(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??wh(d,m),v=sn(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),g=sn(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=Wi(sn(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??wh(v,g),y=sn(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=Wi(sn(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),j=La(a,"gpu.name","gpu.model","accelerators.gpu.name"),C=sn(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),A=sn(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),T=Wi(sn(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??wh(C,A),k=sn(a,"gpu.temperatureC","thermal.gpuC"),E=Wi(sn(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),R=La(a,"npu.name","npu.model","accelerators.npu.name"),$=sn(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),F=sn(a,"network.rxMbps","network.receiveMbps","network.downMbps"),q=sn(a,"network.txMbps","network.transmitMbps","network.upMbps"),L=sn(a,"network.latencyMs","network.rttMs"),_=Wi(sn(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),ie=La(a,"network.link","network.interface","network.name"),V=y===void 0?void 0:Wi((y-35)/60),ne=La(a,"workload.role","role","lane")||(eu(n,"aiAssist")?"Agent worker":eu(n,"taskDispatch")?"Task worker":"Local machine"),Q=La(n.latestTask,"status")||La(a,"workload.status")||"idle",J=La(n.latestTask,"title","instructionPreview")||La(a,"workload.title"),le=La(n.latestTask,"resultSummary","error","instructionPreview")||La(a,"workload.summary"),Y=[Gd(a,"ollama","Ollama"),Gd(a,"lmStudio","LM Studio"),Gd(a,"comfyui","ComfyUI"),Gd(a,"stableDiffusion","Stable Diffusion")],O=Y.some(W=>W.status!=="unknown"),Z=Date.parse(n.lastSeenAt||n.connectedAt||""),X=Number.isFinite(Z)?Date.now()-Z:0;let D="online";n.connected?X>5*6e4?D="stale":(y??0)>=86||(k??0)>=88||(c??0)>=.94||(b??0)>=.96||(T??0)>=.96||(E??0)>=.96||(p??0)>=.94||(w??0)>=.94||(L??0)>=200||Q==="failed"?D="critical":(y??0)>=78||(k??0)>=80||(c??0)>=.82||(b??0)>=.86||(T??0)>=.88||(E??0)>=.86||(p??0)>=.82||(w??0)>=.86||(L??0)>=80?D="warn":(["queued","running","targeted"].includes(Q)||Y.some(W=>W.status==="busy"))&&(D="busy"):D="offline";const K=Y.filter(W=>W.status==="online"||W.status==="busy").length,ce=[{id:"cpu",label:"CPU",value:Mo(c),detail:r?`${r} cores`:l!==void 0?`load ${l.toFixed(1)}`:"not reported",ratio:c,state:Nl(c,.92,.78)},{id:"memory",label:"RAM",value:Mo(p),detail:yh(d,m),ratio:p,state:Nl(p,.92,.78)},{id:"disk",label:"DISK",value:Mo(w),detail:yh(v,g),ratio:w,state:Nl(w,.92,.82)},{id:"gpu",label:"GPU",value:Mo(b),detail:j||(C&&A!==void 0?`${Yc(A)} VRAM free`:k!==void 0?`${Math.round(k)}C`:"not reported"),ratio:b,state:k!==void 0&&k>=88?"critical":k!==void 0&&k>=80?"warn":Nl(b,.96,.86)},{id:"vram",label:"VRAM",value:Mo(T),detail:yh(C,A),ratio:T,state:Nl(T,.96,.88)},{id:"npu",label:"NPU",value:E!==void 0?Mo(E):$!==void 0?`${Math.round($)} TOPS`:"-",detail:R||($!==void 0?"neural engine":"not reported"),ratio:E,state:Nl(E,.96,.86)},{id:"temp",label:"TEMP",value:y===void 0?"-":`${Math.round(y)}C`,detail:K>0?`${K} local tools`:`uptime ${xb(sn(a,"uptimeSec"))}`,ratio:V,state:y===void 0?"unknown":y>=86?"critical":y>=78?"warn":"good"},{id:"network",label:"NET",value:bh(F)||(L!==void 0?`${Math.round(L)}ms`:ie||"-"),detail:bh(q)?`${bh(q)} up`:ie||"not reported",ratio:_,state:L!==void 0&&L>=200?"critical":L!==void 0&&L>=80?"warn":Nl(_,.9,.75)}];return{state:D,label:fT(D,ce,Q),role:ne,taskLabel:J||(Q==="idle"?"idle":Q),taskStatus:Q,taskSummary:le,tools:O?Y:Y.map(W=>({...W,detail:"not reported"})),metrics:ce}}const hT=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],pT=[{id:"wall",label:"Wall",icon:tu,accent:"blue"},{id:"control",label:"Control",icon:Yd,accent:"red"},{id:"share-files",label:"Share Files",icon:Vd,accent:"green"},{id:"agents",label:"Agents",icon:qc,accent:"violet"},{id:"sync-server",label:"Sync Server",icon:Wd,accent:"blue"}],gT=[{id:"doc",label:"Doc",icon:tf,accent:"amber"},{id:"support",label:"Support",icon:Wc,accent:"violet"},{id:"pricing",label:"Pricing",icon:Eo,accent:"green"}];function vT(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 rn(n){return vT(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 Ml(n){return n.map(a=>rn(a))}function na(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:rn(n.title),intro:rn(n.intro),sections:[{title:rn(n.managerTitle),body:rn(n.managerBody),points:Ml(n.managerPoints)},{title:rn(n.clientTitle),body:rn(n.clientBody),points:Ml(n.clientPoints)},{title:rn(n.syncTitle),body:rn(n.syncBody),points:Ml(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:rn(n.agentTitle),body:rn(n.agentBody),points:Ml(n.agentPoints)}]:[],{title:rn(n.platformTitle),body:rn(n.platformBody),points:Ml(n.platformPoints)}],sync:{title:rn(n.syncTitle),body:rn(n.syncBody),points:Ml(n.syncPoints)},firewall:{title:rn(n.firewallTitle),body:rn(n.firewallBody),points:Ml(n.firewallPoints)},commands:{title:rn(n.commandsTitle),body:rn(n.commandsBody),manager:rn(n.managerCommandLabel),primary:rn(n.clientCommandLabel),slot:rn(n.slotCommandLabel),manual:rn(n.manualCommandLabel)}}}const Io={ko:na({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가 꺼져 있으면 실시간 온라인 알림을 기다리고 적응형 간격으로 다시 확인합니다.",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 3 H.264와 Mode 4 H.264 Atlas를 사용합니다. Mode 2는 Mode 4의 내부 Atlas 입력에만 한정되며 Wall/Control fallback으로 사용되지 않습니다.","원격 오디오는 선택한 장비가 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:na({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 waits for a live online signal and falls back to adaptive retries.",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 uses Mode 3 H.264 and Mode 4 H.264 Atlas. Mode 2 is restricted to internal Mode 4 Atlas input and is never used as a Wall or Control fallback.","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:na({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 はオンライン通知を待ち、適応型の間隔で再確認します。",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":na({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 会等待上线通知,并以自适应间隔重新检查。",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":na({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 會等待上線通知,並以自適應間隔重新檢查。",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:na({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 espera una señal en tiempo real y vuelve a comprobar con intervalos adaptativos.",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:na({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:na({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, wartet der Client auf ein Live-Signal und prüft mit adaptiven Intervallen erneut.",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":na({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 aguarda um sinal em tempo real e verifica novamente em intervalos adaptativos.",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:na({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:na({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:na({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:na({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:na({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:na({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:na({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ı"})},xT=Object.entries(Io).map(([n,a])=>({id:n,label:a.languageName}));function yT(){if(typeof navigator>"u")return"en";const n=navigator.languages?.length?navigator.languages:[navigator.language];for(const a of n){const r=a.toLowerCase();if(Io[a])return a;if(r.startsWith("zh-tw")||r.startsWith("zh-hk"))return"zh-TW";if(r.startsWith("pt"))return"pt-BR";const l=r.split("-")[0];if(Io[l])return l}return"en"}function By({index:n}){const a=n+1;return s.jsx("article",{className:"device-tile placeholder-tile","aria-label":`Empty slot ${a}`,children:s.jsxs("div",{className:"tile-screen","aria-hidden":"true",children:[s.jsx("span",{className:"slot-grid","aria-hidden":"true"}),s.jsxs("span",{className:"empty-screen",children:[s.jsx(tn,{size:24}),s.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function wT(n){if(!n)return!1;const a=String(n.platform||"").trim().toLowerCase();return Ki(a)&&n.capabilities?.screenRecordingPermission===!1}function Ki(n){const a=String(n||"").trim().toLowerCase();return a==="macos"||a==="darwin"||a==="mac"||a==="macosx"}function Fy(n){if(!n)return!1;const a=String(n.capabilities?.liveCaptureConcurrency||"").trim().toLowerCase();return a==="exclusive"?!0:a==="parallel"?!1:Ki(n.platform)}function Sh({device:n,frame:a,selected:r,controlEnabled:l,showStatus:c,monitorIndex:d,monitorCount:m,onSelect:p,onFocusDevice:v,onOpenControl:g,onCycleMonitor:w,onCanvasReady:y,sendInput:b,updateIndicator:j,presentationReady:C,showPresentationSpinner:A=!1}){const T=u.useRef(null),k=u.useRef(null),E=u.useRef(0),R=u.useRef(null),$=yb(n),F=["cpu","gpu","memory","vram"].map(P=>$.metrics.find(me=>me.id===P)).filter(P=>!!P),q=Da(d,m),L=m>1,_=C??!!a,ie=wT(n)&&!_,V=A&&n.connected&&!_&&!ie,ne=ZM(n,a,q),Q=ne>=qd?100:ne/qd*100,J=ne>=qd?qd/ne*100:100,le={"--screen-aspect":ne.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,Q)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,J)).toFixed(3)}%`},Y=u.useCallback(P=>{T.current=P,y(n.deviceId,P)},[n.deviceId,y]),O=P=>{const me=P.currentTarget.getBoundingClientRect();return v1(P.clientX,P.clientY,me)},Z=P=>({shiftKey:P.shiftKey,ctrlKey:P.ctrlKey,altKey:P.altKey,metaKey:P.metaKey}),X=u.useCallback(()=>{R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)},[]),D=u.useCallback(()=>{const P=k.current;if(!P)return;k.current=null;const me=Number(P.input.normalizedX),ge=Number(P.input.normalizedY);if(!Number.isFinite(me)||!Number.isFinite(ge))return;b(n.deviceId,{...P.input,normalizedX:me,normalizedY:ge})&&(E.current=performance.now())},[n.deviceId,b]),K=u.useCallback(()=>{R.current===null&&(R.current=window.requestAnimationFrame(()=>{R.current=null,D()}))},[D]);u.useEffect(()=>()=>{X(),k.current=null},[X]);const ce=(P,me)=>{if(!l)return;const ge={type:me,monitorIndex:q,...O(P),button:uT(P.button),...Z(P)};if(me==="pointermove"){const xe=performance.now();k.current={input:ge},xe-E.current>=jM&&(X(),D()),K();return}k.current&&(X(),D()),b(n.deviceId,ge)},W=u.useCallback(P=>{const me=document.activeElement;me instanceof HTMLElement&&P.contains(me)&&me.classList.contains("monitor-cycle-button")&&me.blur()},[]);return s.jsx("article",{className:`device-tile ${r?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:le,children:s.jsxs("div",{className:`tile-screen ${_?"has-frame":"is-empty"}`,role:"button",tabIndex:l?-1:0,"aria-pressed":r,onClick:P=>{P.target instanceof Element&&P.target.closest(".monitor-cycle")||l||p()},onKeyDown:P=>{P.target instanceof Element&&P.target.closest(".monitor-cycle")||l||(P.key==="Enter"||P.key===" ")&&(P.preventDefault(),p())},onDoubleClick:P=>{P.target instanceof Element&&P.target.closest(".monitor-cycle")||(P.preventDefault(),g())},onPointerLeave:P=>W(P.currentTarget),children:[s.jsx("span",{className:`screen-content ${_?"has-frame":"is-empty"}`,children:s.jsx("canvas",{ref:Y,className:`remote-canvas ${_?"has-frame":"is-empty"}`,tabIndex:l?0:-1,onPointerDown:P=>{l&&(P.preventDefault(),P.stopPropagation(),v(),P.currentTarget.focus(),P.currentTarget.setPointerCapture(P.pointerId),ce(P,"pointerdown"))},onPointerMove:P=>{l&&P.preventDefault(),ce(P,"pointermove")},onPointerLeave:P=>{l&&(ce(P,"pointermove"),X(),D())},onPointerUp:P=>{l&&(P.preventDefault(),P.stopPropagation(),ce(P,"pointerup"),P.currentTarget.hasPointerCapture(P.pointerId)&&P.currentTarget.releasePointerCapture(P.pointerId))},onPointerCancel:P=>{P.currentTarget.hasPointerCapture(P.pointerId)&&P.currentTarget.releasePointerCapture(P.pointerId)},onWheel:P=>{l&&(P.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:q,...O(P),deltaX:P.deltaX,deltaY:P.deltaY,...Z(P)}))},onKeyDown:P=>{l&&(P.preventDefault(),P.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:q,key:P.key,code:P.code,keyCode:P.keyCode||P.which||0,location:P.location,text:P.key.length===1?P.key:"",repeat:P.repeat,...Z(P)}))},onKeyUp:P=>{l&&(P.preventDefault(),P.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:q,key:P.key,code:P.code,keyCode:P.keyCode||P.which||0,location:P.location,text:P.key.length===1?P.key:"",repeat:!1,...Z(P)}))},onContextMenu:P=>l&&P.preventDefault()})}),!_&&s.jsx("span",{className:"empty-screen",children:s.jsx(tn,{size:26})}),V&&s.jsxs("span",{className:"wall-presentation-loading",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"wall-presentation-spinner","aria-hidden":"true"}),s.jsx("strong",{children:"Preparing video"})]}),ie&&s.jsxs("span",{className:"wall-presentation-loading permission-required",role:"status","aria-live":"polite",children:[s.jsx(Bt,{size:24,"aria-hidden":"true"}),s.jsx("strong",{children:"Screen Recording permission required"}),s.jsx("small",{children:"Allow the terminal app on this Mac, then restart LiveDesk."})]}),j&&s.jsxs("span",{className:`wall-update-status ${j==="updated"?"updated":""}`,role:"status","aria-live":"polite",children:[j==="updating"?s.jsx("span",{className:"wall-update-spinner","aria-hidden":"true"}):s.jsx(In,{size:20,"aria-hidden":"true"}),s.jsx("strong",{children:j==="updating"?"Updating...":"Updated"})]}),c&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`tile-health-pill state-${$.state}`,children:$.label}),s.jsx("span",{className:"tile-metrics","aria-label":`${ma(n)} status`,children:F.map(P=>s.jsxs("span",{className:`tile-metric state-${P.state}`,children:[s.jsx("b",{children:P.label}),s.jsx("em",{children:P.value}),P.ratio!==void 0&&s.jsx("i",{style:{width:`${Math.round(P.ratio*100)}%`}})]},P.id))})]}),L&&s.jsxs("span",{className:"monitor-cycle","aria-label":`${ma(n)} display ${q+1} of ${m}`,onPointerDown:P=>P.stopPropagation(),onClick:P=>P.stopPropagation(),onDoubleClick:P=>P.stopPropagation(),children:[s.jsx("button",{className:"monitor-cycle-button previous",onClick:P=>{P.preventDefault(),P.stopPropagation(),w(-1),P.currentTarget.blur()},title:"Previous display",type:"button",children:s.jsx(Xy,{size:18})}),s.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",q+1,"/",m]}),s.jsx("button",{className:"monitor-cycle-button next",onClick:P=>{P.preventDefault(),P.stopPropagation(),w(1),P.currentTarget.blur()},title:"Next display",type:"button",children:s.jsx(Xh,{size:18})})]}),r&&s.jsx("span",{className:"device-selection-check","aria-hidden":"true",children:s.jsx(Hr,{size:23,strokeWidth:3.5})})]})})}function bT({visible:n}){return u.useEffect(()=>{if(!n||!fh)return;if(!document.getElementById(wy)){const r=document.createElement("script");r.id=wy,r.async=!0,r.crossOrigin="anonymous",r.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent($h)}`,document.head.appendChild(r)}const a=window.setTimeout(()=>{try{window.adsbygoogle=window.adsbygoogle||[],window.adsbygoogle.push({})}catch{}},120);return()=>window.clearTimeout(a)},[n]),n?s.jsxs("aside",{className:`free-ad-banner ${fh?"adsense-ready":"house-ad"}`,"aria-label":"Advertisement",children:[s.jsx("span",{className:"ad-label",children:"Advertisement"}),fh?s.jsx("ins",{className:"adsbygoogle livedesk-ad-unit",style:{display:"block"},"data-ad-client":$h,"data-ad-slot":db,"data-ad-format":"auto","data-full-width-responsive":"true"}):s.jsxs("div",{className:"house-ad-copy",children:[s.jsx("strong",{children:"Sponsored placement"}),s.jsx("span",{children:"Local AI gear, mini PCs, GPUs, NAS, and developer tools."})]})]}):null}function ST(){const n=_M(),{session:a,loading:r}=Kj(),{target:l,error:c,refresh:d}=Xj(a),m=u.useMemo(()=>{if(!l?.active)return null;const x=l.expires_at?Date.parse(l.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(x)&&x<=Date.now()?null:l},[l]),p=u.useMemo(()=>vx(m),[m]),v=u.useMemo(()=>p.length>0?[...new Set([...p,yn])]:[yn],[p]),[g,w]=u.useState(WM),y=u.useMemo(()=>v.some(x=>!!Xc(x)),[v]),b=!y||g,{status:j,devices:C,error:A,refresh:T,hubBaseUrl:k}=Qj(v,b),{entitlement:E,licensed:R,loading:$,error:F,refresh:q}=Zj(a),[L,_]=u.useState([]),[ie,V]=u.useState(""),[ne,Q]=u.useState(""),[J,le]=u.useState(""),[Y,O]=u.useState(""),[Z,X]=u.useState(""),[D,K]=u.useState("idle"),[ce,W]=u.useState(!1),[P,me]=u.useState(null),[ge,xe]=u.useState(""),Ce=u.useRef("");Ce.current=Y;const[Le,ze]=u.useState(!1),[ue,Ye]=u.useState(!1),We=u.useRef(""),oe=u.useRef(new Map),Ae=u.useRef(0),[je,Ee]=u.useState(""),[Re,Fe]=u.useState(""),[pe,ke]=u.useState(!1),[de,we]=u.useState(null);u.useEffect(()=>{je==="auth"&&a?.access_token&&Ee("")},[je,a?.access_token]);const[Ge,tt]=u.useState(""),[wn,Qe]=u.useState(null),ht=u.useRef(null),St=u.useRef(0),Tn=u.useCallback((x,N,I)=>{const U=String(x||"").trim();if(tt(U),ht.current!==null&&(window.clearTimeout(ht.current),ht.current=null),!U){Qe(null);return}const z=++St.current;if(Qe({id:z,message:U,tone:N}),!I)return;const ve=window.setTimeout(()=>{Qe(he=>he?.id===z?null:he),ht.current===ve&&(ht.current=null)},5e3);ht.current=ve},[]),Oe=u.useCallback((x,N="info")=>{Tn(x,N,!0)},[Tn]),Ft=u.useCallback(x=>{Tn(x,"progress",!1)},[Tn]);u.useEffect(()=>()=>{ht.current!==null&&window.clearTimeout(ht.current)},[]);const[Gt,pt]=u.useState(()=>typeof window<"u"&&window.location.pathname.startsWith("/support")?"support":"wall");u.useEffect(()=>{const x=()=>{pt(window.location.pathname.startsWith("/support")?"support":N=>N==="support"?"wall":N)};return window.addEventListener("popstate",x),()=>window.removeEventListener("popstate",x)},[]);const[it,nn]=u.useState("large"),[Mt,De]=u.useState(yT),[En,Xi]=u.useState(!1),[fn,Pn]=u.useState(!1),[pa,Ja]=u.useState(!1),[Rn,es]=u.useState(YM),[Ie,fi]=u.useState(tT),[ft,ts]=u.useState(aT),[Vt,Bs]=u.useState(JM),[B,$e]=u.useState(null),[mt,an]=u.useState([]),[mn,Fs]=u.useState(Ie.fps),[ia,te]=u.useState(""),[Ne,He]=u.useState(0),[at,Kt]=u.useState(0),[Tt,Xe]=u.useState(()=>new Set),rt=u.useRef(new Map),Qt=u.useRef(new Map),$t=u.useRef(new Map),Dt=u.useRef(new Map),Pt=u.useRef(new Map),Ut=u.useRef(new Set),_t=u.useRef(new Map),hn=u.useRef(""),ns=u.useRef(""),on=u.useRef(null),Xt=u.useRef(null),xs=u.useRef(new Map),ys=u.useRef(null),mi=u.useRef(0),Ho=u.useRef(new Map),[Zi,Bl]=u.useState({}),Oa=u.useRef(new Map),[Kn,ou]=u.useState({}),[cu,Qn]=u.useState(!1),Fl=u.useRef(null),ra=u.useRef(null),ga=u.useRef(0),bn=u.useRef(""),hi=u.useRef(new Map),Ji=u.useRef(new Map),er=u.useRef(performance.now()),as=u.useRef(new Map),pi=u.useRef(new Map),gi=u.useRef(new Map),Ps=u.useRef(new Map),Vr=u.useRef(0),Yr=u.useRef(0),Wr=u.useRef(0),tr=u.useRef(0),$o=u.useRef(0),uu=u.useRef(new Map),Ba=u.useRef(new Map),[Hn,ss]=u.useState(null),[Uo,Hs]=u.useState(!1),[Kr,du]=u.useState([]),[$s,fu]=u.useState("all"),[is,Fa]=u.useState([]),[mu,Pl]=u.useState(!1),[vi,qo]=u.useState(!0),Qr=u.useRef(null),Go=u.useRef(null),Hl=u.useRef(null),$l=u.useRef(null),hu=u.useRef(!1),Dn=u.useRef(!1),ws=u.useRef(!1),Us=u.useRef(0),va=u.useRef(0),Ul=Gt==="settings",ql=Gt==="pricing",Gl=Gt==="doc",nr=Gt==="support",qs=Gt==="share-files",Vl=Gt==="agents",pu=!Ul&&!ql&&!Gl&&!nr&&!qs&&!Vl,et=Gt==="control",ut=Ie.frameMode==="mode4-h264-atlas",Xn=Z||ft.frameMode,ar=Xn!=="mode3-h264-hw"?Math.min(30,ft.fps):ft.fps,Gs=Xn!=="mode3-h264-hw"?{maxWidth:Math.min(1920,ft.maxWidth),maxHeight:Math.min(1080,ft.maxHeight)}:{maxWidth:ft.maxWidth,maxHeight:ft.maxHeight};u.useEffect(()=>{if(j?.started){if(!a?.access_token){Ue("/api/remote/license",{method:"DELETE"},k).catch(()=>{});return}Ue("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`}},k).catch(x=>{console.warn("[LiveDesk] Hub license sync failed",x)})}},[E?.updated_at,k,a?.access_token,j?.started]),u.useEffect(()=>{!a?.access_token||!j?.started||j.runtimeRole!=="hub"||!j.deviceId||(async()=>{try{const{data:x,error:N}=await ct.rpc("register_livedesk_device",{p_device_id:j.deviceId,p_device_name:j.deviceName||j.deviceId,p_role:"hub",p_assigned_hub_id:null,p_platform:navigator.platform||navigator.userAgent,p_os_version:navigator.userAgent,p_app_version:j.managerVersion||j.managerPackage||""}),I=Array.isArray(x)?x[0]:x;(N||I?.ok===!1)&&console.warn("[LiveDesk] Hub device role registration failed",N||I?.reason||"unknown-error")}catch(x){console.warn("[LiveDesk] Hub device role registration failed",x)}})()},[a?.access_token,j?.deviceId,j?.deviceName,j?.managerPackage,j?.managerVersion,j?.runtimeRole,j?.started]),u.useEffect(()=>{!a?.access_token||!a.refresh_token||!j?.started||j.runtimeRole!=="hub"||ws.current||(ws.current=!0,Ue("/api/auth/session",{method:"POST",body:JSON.stringify({accessToken:a.access_token,refreshToken:a.refresh_token,expiresAt:a.expires_at,user:{id:a.user.id,email:a.user.email}})},k||yn).then(x=>{x.hostTarget?.ok===!1&&console.warn("[LiveDesk] Hub host target publish is waiting for a valid Hub role:",x.hostTarget.error||"unknown-error"),T()}).catch(x=>{console.warn("[LiveDesk] Hub session sync failed:",x)}).finally(()=>{ws.current=!1}))},[k,T,a?.access_token,a?.expires_at,a?.refresh_token,a?.user?.email,a?.user?.id,j?.runtimeRole,j?.started]);const Je=u.useMemo(()=>C.filter(x=>x.connected),[C]),gu=$s==="all"?Je.length:is.filter(x=>Je.some(N=>N.deviceId===x)).length,jf=u.useMemo(()=>Je.reduce((x,N)=>Math.max(x,Oy(N.slotNumber)),0),[Je]),Xr=Math.max(wM,Je.length,jf),Zr=u.useMemo(()=>{const x=Array(Xr).fill(null),N=[];for(const I of Je){const U=Oy(I.slotNumber);U>0&&U<=Xr&&!x[U-1]?x[U-1]=I:N.push(I)}for(const I of N){const U=x.findIndex(z=>!z);U<0?x.push(I):x[U]=I}return x},[Je]),Vo=u.useMemo(()=>Je.map(x=>x.deviceId),[Je]),sr=u.useMemo(()=>new Set(L),[L]),Pa=u.useMemo(()=>Je.filter(x=>sr.has(x.deviceId)),[Je,sr]),Vs=u.useMemo(()=>C.find(x=>x.deviceId===ie)||Pa[0]||null,[C,ie,Pa]),$n=u.useMemo(()=>C.find(x=>x.deviceId===ne)||null,[ne,C]),Ys=$n?Da(Vt[$n.deviceId],fa($n)):0,Me=et?$n:Vs,Yo=u.useMemo(()=>new Set(is),[is]),Cf=u.useMemo(()=>$s==="all"?Je.map(x=>x.deviceId):Je.filter(x=>Yo.has(x.deviceId)).map(x=>x.deviceId),[Je,Yo,$s]),rs=u.useMemo(()=>Me?yb(Me):null,[Me]),kf=Me?eu(Me,"control"):!1,Wo=Ki(Me?.platform)&&(Me?.capabilities?.controlPermission===!1||Me?.capabilities?.accessibilityPermission===!1),Jr=Me?eu(Me,"audio")||eu(Me,"remoteAudio"):!1,vu=Array.isArray(Me?.capabilities?.agentTools)?Me.capabilities.agentTools.map(String):[],Yl=vu.includes("system.power"),xu=vu.includes("command.run"),qt=R?E?.plan==="pro"?"pro":"ltd":"free",Wl=Al[qt],Ws=Wl.limit,xi=u.useMemo(()=>{if(!Number.isFinite(Ws))return new Set(Je.map(N=>N.deviceId));const x=Me?[Me,...Je.filter(N=>N.deviceId!==Me.deviceId)]:Je;return new Set(x.slice(0,Ws).map(N=>N.deviceId))},[Ws,Je,Me]),yu=!Me||xi.has(Me.deviceId),wu=qt==="free",Yt=yu,yi=qt==="ltd"?`Plus includes up to ${Vc} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${Gc} workstations. Upgrade to Plus for ${Vc} devices and no ads.`,bu=qt==="free",wi=Yt&&!!Me,bs=Yt&&!!Me&&kf,Su=Yt&&!!Me&&Jr;u.useEffect(()=>{ke(!1)},[Gt,Me?.deviceId]);const Kl=u.useMemo(()=>Zr.filter(x=>!!x?.connected).slice(0,iT(it)).map(x=>x.deviceId),[Zr,it]),el=u.useMemo(()=>ut?Vo:Ie.visibleOnlyLive?mt.length>0?mt:Kl:Vo,[Kl,ut,mt,Ie.visibleOnlyLive,Vo]),xa=u.useMemo(()=>xh(el.filter(x=>xi.has(x))),[xi,el]),ya=u.useMemo(()=>xa.filter(x=>x!==ia),[xa,ia]),Ks=u.useMemo(()=>new Map(Je.map(x=>[x.deviceId,x.platform])),[Je]),ls=x1(ut,xa.length),Un=u.useMemo(()=>ut?ya.filter(x=>Hc({mode4Enabled:ut,directMode4WallEnabled:ls,isMac:Ki(Ks.get(x))})==="atlas"):[],[ls,ut,Ks,ya]),Zn=u.useMemo(()=>ya.filter(x=>Hc({mode4Enabled:ut,directMode4WallEnabled:ls,isMac:Ki(Ks.get(x))})==="direct"),[ls,ut,Ks,ya]);u.useEffect(()=>{const x=new Set(xa);Xe(N=>{let I=!1;const U=new Set;for(const z of N)x.has(z)?U.add(z):I=!0;return I?U:N})},[xa]);const ju=u.useMemo(()=>{const x=z=>Je.find(ve=>ve.deviceId===z)||null,N=z=>Da(Vt[z],x(z)?fa(x(z)):0),I=(z,ve=N(z))=>z===J&&(D==="connecting"||D==="active"||D==="warm")?Dt.current.get(z)||Qt.current.get(z)||null:ut?xs.current.get(z)||rt.current.get(z)||null:rt.current.get(z)||null,U=(z,ve=N(z))=>{const he=x(z);return`${he?ma(he):z} · Monitor ${ve+1}`};return{resolveCurrentTarget(){if(et&&$n){const Pe=Ys;return{type:"control",deviceIds:[$n.deviceId],monitorIndex:Pe,label:`${ma($n)} · Monitor ${Pe+1}`,sourceCanvas:I($n.deviceId,Pe),signature:`control:${$n.deviceId}:${Pe}:${ft.frameMode}`}}const z=Pa.map(Pe=>Pe.deviceId).filter(Pe=>ya.includes(Pe)),ve=Vs&&ya.includes(Vs.deviceId)?Vs.deviceId:"",he=z.length>0?z:ve?[ve]:ya,_e=z.length===0&&!ve;if(he.length===0)return null;if(he.length===1){const Pe=he[0],lt=N(Pe);return{type:_e?"wall":z.length>1?"selection":"device",deviceIds:he,monitorIndex:lt,label:_e?"Wall":U(Pe,lt),sourceCanvas:_e?null:I(Pe,lt),signature:`${_e?"wall":"device"}:${Pe}:${lt}:${ut?"atlas":"direct"}`}}return{type:z.length>1?"selection":"wall",deviceIds:he,label:z.length>1?`${he.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${z.length>1?"selection":"wall"}:${he.join(",")}:${it}`}},getDeviceCanvas:I,composeWall(z,ve={}){return oM(z.map(he=>{const _e=N(he);return{deviceId:he,label:U(he,_e),canvas:I(he,_e)}}),ve)}}},[Je,$n,J,D,ft.frameMode,rt,ut,Vt,Ys,Pa,et,ya,Vs,it]),Ql=yM({hubUrl:k,sourceRegistry:ju,onToast:Oe}),Qs=u.useMemo(()=>Yt&&J&&xi.has(J)&&(D==="connecting"||D==="active"||D==="warm")?[J]:[],[J,D,Yt,xi]),Cu=u.useMemo(()=>xh([...xa,...Qs]),[Qs,xa]),_n=u.useMemo(()=>rT(Ie,it),[Ie,it]),bi=y1({mode4Enabled:ut,directMode4WallEnabled:ls,adaptiveFps:mn,directDeviceCount:Zn.length}),Ss=u.useCallback((x,N,I)=>{if(x.width<=0||x.height<=0)return!1;const U=I?Math.min(1,I.maxWidth/x.width,I.maxHeight/x.height):1,z=Math.max(1,Math.round(x.width*U)),ve=Math.max(1,Math.round(x.height*U));(N.width!==z||N.height!==ve)&&(N.width=z,N.height=ve);const he=N.getContext("2d",{alpha:!1});return he?(he.imageSmoothingEnabled=!0,he.imageSmoothingQuality="high",he.drawImage(x,0,0,x.width,x.height,0,0,N.width,N.height),!0):!1},[]),ir=u.useCallback(x=>{x&&Xe(N=>{if(N.has(x))return N;const I=new Set(N);return I.add(x),I})},[]),Xl=u.useCallback(x=>{x&&Xe(N=>{if(!N.has(x))return N;const I=new Set(N);return I.delete(x),I})},[]),Zl=u.useCallback((x,N)=>{if(!N||N.width<=0||N.height<=0)return!1;const I=document.createElement("canvas");return I.width=N.width,I.height=N.height,Ss(N,I)?($t.current.set(x,I),ir(x),!0):!1},[ir,Ss]),js=u.useCallback((x,N=!1)=>{if(!Ut.current.has(x))return!1;const I=performance.now(),U=_t.current.get(x)||0,z=Math.max(1,Math.min(ci.controlWallReuseMaxFps,ar)),ve=ar>z?Math.max(0,1e3/z-2):0;if(!N&&I-U<ve)return!1;const he=Dt.current.get(x)||Qt.current.get(x),_e=rt.current.get(x)||xs.current.get(x);return!he||!_e||!Ss(he,_e,_n)?!1:(_t.current.set(x,I),ir(x),!0)},[ar,_n,ir,Ss]);u.useEffect(()=>{hn.current=ia},[ia]);const Jn=u.useCallback((x,N)=>{const I=rt.current.get(x);if(I&&I!==N&&(Zl(x,I),Pc(I)),N){rt.current.set(x,N),$t.current.delete(x),js(x,!0);return}rt.current.delete(x),$t.current.has(x)||Xl(x)},[Xl,js,Zl]),tl=u.useCallback((x,N)=>{const I=Qt.current.get(x);if(I&&I!==N&&Pc(I),N){Qt.current.set(x,N);const U=Dt.current.get(x)||$t.current.get(x)||rt.current.get(x)||xs.current.get(x);U&&Ss(U,N)&&x===ne&&Qn(!0);return}Qt.current.delete(x)},[ne,Ss]),nl=u.useCallback((x,N,I)=>{const U=performance.now(),z=_s(x,I.deviceId);let ve=I;if(x==="control"&&I.visualChanged){const _e=s1(I.deviceId),Pe=uu.current.get(I.deviceId)||0,lt=_e?U-_e.sentAt:Number.POSITIVE_INFINITY;_e&&_e.inputSeq>Pe&<<=by&&(ve={...I,inputFeedbackSeq:_e.inputSeq,inputFeedbackMs:Math.max(0,lt),inputFeedbackAt:U},uu.current.set(I.deviceId,_e.inputSeq))}Ji.current.set(z,U);const he=Ho.current.get(z)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:U,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};x==="control"&&ve.inputFeedbackMs===void 0&&he.lastInfo?.inputFeedbackMs!==void 0&&he.lastInfo.inputFeedbackAt!==void 0&&U-he.lastInfo.inputFeedbackAt<=by&&(ve={...ve,inputFeedbackSeq:he.lastInfo.inputFeedbackSeq,inputFeedbackMs:he.lastInfo.inputFeedbackMs,inputFeedbackAt:he.lastInfo.inputFeedbackAt}),he.totalFrames+=1,he.sampleFrames+=1,Ay(he,U,ve.frameSeq),ve.visualChanged&&(he.totalChangedFrames+=1,he.sampleChangedFrames+=1),he.lastInfo=ve,Ho.current.set(z,he)},[]),al=u.useCallback((x,N)=>{nl("wall",x,N),x.kind==="live"&&ir(x.deviceId);const I=ce&&J===x.deviceId;hn.current!==x.deviceId&&!I&&(Ut.current.delete(x.deviceId),_t.current.delete(x.deviceId))},[J,ce,ir,nl]),Ko=u.useCallback((x,N)=>{nl("control",x,N),xe(ve=>ve&&"");const I=Dt.current.get(x.deviceId),U=Qt.current.get(x.deviceId);I&&I.width>0&&I.height>0&&(U&&Ss(I,U),Pt.current.set(x.deviceId,{...x,payload:new Uint8Array(0),byteLength:0}),$t.current.delete(x.deviceId),Ut.current.add(x.deviceId),x.deviceId===J&&(W(!0),K(ve=>ve==="connecting"?"active":ve)),js(x.deviceId));const z=Fl.current;!z||!DM(z,x)||Qn(!0)},[J,Ss,js,nl]);u.useEffect(()=>{const x=window.setInterval(()=>{const N=performance.now(),I={};for(const[U,z]of Ho.current.entries()){const ve=Math.max(1,N-z.sampleStartedAt);I[U]={totalFrames:z.totalFrames,totalChangedFrames:z.totalChangedFrames,framesPerSecond:z.sampleFrames*1e3/ve,changedFramesPerSecond:z.sampleChangedFrames*1e3/ve,averageIntervalMs:z.intervalCount>0?z.intervalSumMs/z.intervalCount:0,minIntervalMs:Number.isFinite(z.minIntervalMs)?z.minIntervalMs:0,maxIntervalMs:z.maxIntervalMs,p95IntervalMs:Zd(z.intervalSamplesMs,.95),intervalCount:z.intervalCount,seqGapCount:z.seqGapCount,maxSeqGap:z.maxSeqGap,decoderInputFps:Math.max(0,(Number(z.lastInfo?.decoderInputCount||0)-z.sampleDecoderInputBase)*1e3/ve),decoderOutputFps:Math.max(0,(Number(z.lastInfo?.decoderOutputCount||0)-z.sampleDecoderOutputBase)*1e3/ve),sampleMs:ve,lastInfo:z.lastInfo},z.sampleDecoderInputBase=Number(z.lastInfo?.decoderInputCount||0),z.sampleDecoderOutputBase=Number(z.lastInfo?.decoderOutputCount||0),z.sampleChangedFrames=0,ky(z,N)}Bl(I)},1e3);return()=>window.clearInterval(x)},[]);const Si=u.useCallback((x,N)=>{const I=performance.now(),U=_s(x,N.deviceId);hi.current.set(U,I),Ba.current.delete(U),x==="control"&&pi.current.delete(U);const z=Oa.current.get(U)||{totalFrames:0,sampleFrames:0,sampleStartedAt:I,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(z.totalFrames+=1,z.sampleFrames+=1,z.sampleBytes+=Math.max(0,Number(N.byteLength||0)),String(N.frameMode||N.mode||N.codec||N.mimeType||"").toLowerCase().includes("h264")){z.sampleH264Frames+=1,Number(N.byteLength||0)<=TM&&(z.sampleTinyFrames+=1);const Pe=String(N.contentHash||"");Pe&&z.lastContentHash===Pe&&(z.sampleRepeatedFrames+=1),z.lastContentHash=Pe}const _e=Number(N.agentSendGapMs||0);_e>0&&_e<1e3&&vp(z.sourceSendIntervalsMs,_e),z.lastFrame=N,Ay(z,I,N.frameSeq),Oa.current.set(U,z)},[]);u.useEffect(()=>{const x=window.setInterval(()=>{const N=performance.now(),I={};for(const[U,z]of Oa.current.entries()){const ve=Math.max(1,N-z.sampleStartedAt);I[U]={totalFrames:z.totalFrames,framesPerSecond:z.sampleFrames*1e3/ve,averageIntervalMs:z.intervalCount>0?z.intervalSumMs/z.intervalCount:0,minIntervalMs:Number.isFinite(z.minIntervalMs)?z.minIntervalMs:0,maxIntervalMs:z.maxIntervalMs,p95IntervalMs:Zd(z.intervalSamplesMs,.95),intervalCount:z.intervalCount,seqGapCount:z.seqGapCount,maxSeqGap:z.maxSeqGap,averageFrameBytes:z.sampleFrames>0?z.sampleBytes/z.sampleFrames:0,tinyFrameRatio:z.sampleH264Frames>0?z.sampleTinyFrames/z.sampleH264Frames:0,repeatedFrameRatio:z.sampleH264Frames>0?z.sampleRepeatedFrames/z.sampleH264Frames:0,sourceSendAverageMs:z.sourceSendIntervalsMs.length>0?z.sourceSendIntervalsMs.reduce((he,_e)=>he+_e,0)/z.sourceSendIntervalsMs.length:0,sourceSendP95Ms:Zd(z.sourceSendIntervalsMs,.95),sourceSendSampleCount:z.sourceSendIntervalsMs.length,sampleMs:ve,lastFrame:z.lastFrame},z.sampleBytes=0,z.sampleH264Frames=0,z.sampleTinyFrames=0,z.sampleRepeatedFrames=0,z.sourceSendIntervalsMs.length=0,ky(z,N)}ou(I)},1e3);return()=>window.clearInterval(x)},[]);const Jl=u.useCallback(x=>{Si("wall",x);const N=rt.current.get(x.deviceId);if(!N)return;const I=w1(ut,Ie.h264DecodeAcceleration);Jm(N,x,()=>rt.current.get(x.deviceId)!==N,al,I.acceleration,I.latencyMode).catch(()=>{})},[al,ut,Si,Ie.h264DecodeAcceleration]),ku=u.useCallback(x=>{Si("control",x);let N=Dt.current.get(x.deviceId);N||(N=document.createElement("canvas"),N.setAttribute("aria-hidden","true"),Dt.current.set(x.deviceId,N));const I=N,U=Ce.current;Jm(I,x,()=>Dt.current.get(x.deviceId)!==I,Ko,ft.h264DecodeAcceleration,"interactive").catch(z=>{Ce.current!==U||Dt.current.get(x.deviceId)!==I||J!==x.deviceId||xe(z instanceof Error?z.message:String(z||"Control H.264 decode failed"))})},[J,ft.h264DecodeAcceleration,Ko,Si]),rr=u.useCallback(x=>{const N=Xt.current;N&&N!==x&&Pc(N),Xt.current=x,Vr.current=0,Yr.current=0,Wr.current=0,tr.current=0,$o.current=0,mi.current=0},[]),Xs=u.useCallback(()=>{const x=Xt.current,N=ys.current;if(!(!x||!N||x.width<=0||x.height<=0||mi.current!==N.layoutVersion))for(const I of N.tiles){const U=xs.current.get(I.deviceId);if(!U||I.width<=0||I.height<=0)continue;const z=Math.max(1,Math.round(I.width)),ve=Math.max(1,Math.round(I.height)),he=EM,_e=RM;(U.width!==he||U.height!==_e)&&(U.width=he,U.height=_e);const Pe=U.getContext("2d",{alpha:!1});if(Pe){Pe.imageSmoothingEnabled=!0,Pe.imageSmoothingQuality="high";try{Pe.drawImage(x,Math.round(I.x),Math.round(I.y),z,ve,0,0,he,_e)}catch{}}}},[]),sl=u.useCallback((x,N)=>{if(N){xs.current.set(x,N),$t.current.delete(x),window.requestAnimationFrame(Xs),window.requestAnimationFrame(()=>js(x,!0));return}const I=xs.current.get(x);Zl(x,I),xs.current.delete(x),$t.current.has(x)||Xl(x)},[Xl,Xs,js,Zl]),eo=u.useCallback((x,N)=>{Wr.current=performance.now(),mi.current=Number(x.layoutVersion||0),Xs();const I=ys.current?.tiles||[],U=I.length>0?Math.round(x.byteLength/I.length):x.byteLength;for(const z of I){const ve={...x,deviceId:z.deviceId,width:z.width,height:z.height,sourceWidth:z.width,sourceHeight:z.height,byteLength:U};al(ve,{...N,deviceId:z.deviceId,width:z.width,height:z.height,byteLength:U}),hn.current===z.deviceId&&js(z.deviceId,!0)}},[al,Xs,js]),Au=u.useCallback(x=>{const N=performance.now();Vr.current<=0&&(Vr.current=N),Yr.current=N;const I=Xt.current;if(!I)return;const U=ys.current?.tiles||[],z=U.length>0?Math.round(x.byteLength/U.length):x.byteLength;for(const ve of U)Si("wall",{...x,deviceId:ve.deviceId,width:ve.width,height:ve.height,sourceWidth:ve.width,sourceHeight:ve.height,byteLength:z});Jm(I,x,()=>Xt.current!==I,eo).catch(()=>{})},[eo,Si]),ji=u.useMemo(()=>({fps:bi,maxWidth:_n.maxWidth,maxHeight:_n.maxHeight,quality:Ie.quality,mode:ut?"mode3-h264-hw":Ie.frameMode,frameMode:ut?"mode3-h264-hw":Ie.frameMode,streamPurpose:"wall",monitorSelections:Vt,onFrame:Jl}),[bi,Jl,_n,ut,Vt,Ie]),Ci=u.useCallback(x=>{if(x.deviceId!==J||x.streamPurpose!=="control"||x.monitorIndex!==Ys)return;const N=Je.find(I=>I.deviceId===x.deviceId);!N?.sessionId||N.sessionId!==x.sessionId||(me(x),K(I=>I==="connecting"?"active":I))},[Je,J,Ys]);u.useEffect(()=>{me(null)},[J,Y,Xn,Ys]);const Qo=u.useMemo(()=>({fps:ar,maxWidth:Gs.maxWidth,maxHeight:Gs.maxHeight,quality:ft.quality,mode:Xn,frameMode:Xn,streamPurpose:"control",forceRestart:Y!=="",forceRestartToken:Y,restartReason:Y?"control-session-start":"",monitorSelections:Vt,onFrame:ku,onStreamReady:Ci}),[Y,ft.quality,ku,ar,Xn,Gs.maxHeight,Gs.maxWidth,Ci,Vt]),{frames:Xo,state:Ha,error:Zo,stats:Cs,restartLive:il}=Ex(Zn,Ie.autoStartLive&&Zn.length>0,k,ji),{frame:lr,layout:ki,state:Jo,stats:Nu,refreshInputs:ec}=i1(Un,ut&&Ie.autoStartLive&&Un.length>0,k,{fps:ci.atlasOutputFps,width:1920,height:1080,tileWidth:_n.maxWidth,tileHeight:_n.maxHeight,captureDeviceIds:Un,monitorSelections:Vt,onFrame:Au});u.useEffect(()=>{ys.current=ki,ki&&window.requestAnimationFrame(Xs)},[ki,Xs]),u.useEffect(()=>{if(!ut||Jo!=="open"){Vr.current=0,Yr.current=0,Wr.current=0;return}const x=window.setInterval(()=>{const N=Xt.current,I=performance.now();if(!N||document.visibilityState!=="visible"||I-er.current<mh)return;const U=Yr.current,z=Vr.current;if(U<=0||z<=0||I-U>500)return;const ve=Wr.current||z,he=I-ve;if(he>=kM&&I-$o.current>=NM){Xm(N)&&($o.current=I,tr.current=I);return}he>=CM&&I-tr.current>=AM&&$j(N)&&(tr.current=I)},250);return()=>window.clearInterval(x)},[Jo,ut]);const{frames:rl,state:la,error:Zs,stats:wa,restartLive:ks,reconnectLive:to}=Ex(Qs,Qs.length>0,k,Qo),Ai=u.useMemo(()=>{const x=new Map(Xo);if(ut&&lr&&Un.length>0){const N=new Map((ki?.tiles||[]).map(U=>[U.deviceId,U])),I=Math.max(1,N.size);for(const U of Un){const z=N.get(U);z&&x.set(U,{...lr,deviceId:U,width:z.width,height:z.height,sourceWidth:z.width,sourceHeight:z.height,byteLength:Math.round(lr.byteLength/I)})}}for(const[N,I]of rl.entries())x.set(N,I);for(const N of el){if(!Ut.current.has(N)||x.has(N))continue;const I=Pt.current.get(N);I&&x.set(N,I)}return x},[lr,ki,rl,Un,ut,Xo,el,at]),or=et&&Qs.length>0?la:Un.length>0?Jo:Ha,ll=et&&Qs.length>0?wa:Un.length>0?Nu:Cs;u.useCallback((x,N="browser-stale")=>{const I=il(x,N),U=ks(x,N);return I||U},[ks,il]),u.useEffect(()=>{ut&&Un.length>0&&!et&&ec()},[Un.length,ut,ec,et]);const os=u.useCallback((x,N,I)=>{const U=N==="control"?Dt.current.get(x)||null:rt.current.get(x)||null;if(!U||!Xm(U))return!1;const z=performance.now();return Ps.current.set(_s(N,x),z),!0},[]),ol=u.useCallback(x=>{if(Xn!=="mode3-h264-hw"||!J||Z)return!1;const N=Je.find(_e=>_e.deviceId===J)||$n,I=String(N?.platform||"").toLowerCase();if(!["win32","windows","win32nt"].includes(I))return!1;const U="mode5-lzo-delta",z=_s("control",J),ve=performance.now();gi.current.set(z,ve),hi.current.delete(z),Ji.current.delete(z),as.current.delete(z),pi.current.delete(z),Ba.current.delete(z),Xm(Dt.current.get(J)||null),to([J],"control-decode-fallback"),X(U),O(`control-${U}-fallback-${J}-${Date.now()}`),W(!1),Qn(!1);const he=x==="no first frame"||x==="control-first-frame-timeout";return xe(_e=>_e||(he?`Control frame transport timeout; retrying Control with Mode 5 (${x})`:`H.264 decode failed; retrying Control with Mode 5 (${x})`)),K("connecting"),!0},[Je,$n,J,Z,Xn,to]);u.useEffect(()=>{const x=et?$n:null;if(x){Fl.current={deviceId:x.deviceId,monitorIndex:Ys,frameMode:Xn,startedAtEpochMs:Date.now()},Qn(J===x.deviceId&&ce||Tt.has(x.deviceId));return}Fl.current=null,Qn(!1)},[$n?.sessionId,ne,J,ce,Xn,Ys,et,Tt]);const Js=u.useCallback(async x=>{const N=C.find(he=>he.deviceId===x),I=Hc({mode4Enabled:ut,directMode4WallEnabled:ls,isMac:Ki(N?.platform)})==="atlas",U=Da(Vt[x],N?fa(N):1),z=I?{fps:ci.scalableAtlasInputFps,maxWidth:_n.maxWidth,maxHeight:_n.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:U}:{fps:ut&&!I?bi:mn,maxWidth:_n.maxWidth,maxHeight:_n.maxHeight,quality:Ie.quality,mode:ut?"mode3-h264-hw":Ie.frameMode,frameMode:ut?"mode3-h264-hw":Ie.frameMode,streamPurpose:"wall",monitorIndex:U},ve=await Ue(`/api/remote/devices/${encodeURIComponent(x)}/live/start`,{method:"POST",body:JSON.stringify(z)},k);if(ve?.ok===!1)throw new Error(ve.error||"wall-stream-start-failed");return ve},[mn,C,ls,bi,_n.maxHeight,_n.maxWidth,k,ut,Vt,Ie.frameMode,Ie.quality]),As=u.useCallback(async x=>{const N=C.find(z=>z.deviceId===x),I=Hc({mode4Enabled:ut,directMode4WallEnabled:ls,isMac:Ki(N?.platform)})==="atlas",U=await Ue(`/api/remote/devices/${encodeURIComponent(x)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:I?"atlas":"wall",reason:"control-active"})},k);if(U?.ok===!1)throw new Error(U.error||"wall-stream-stop-failed");return U},[C,ls,k,ut]),cr=u.useCallback(async(x,N="control-session-stop")=>{const I=await Ue(`/api/remote/devices/${encodeURIComponent(x)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:N})},k);if(I?.ok===!1)throw new Error(I.error||"control-stream-stop-failed");return I},[k]),Sn=u.useCallback(x=>{const N=Dt.current.get(x);N&&(Pc(N),Dt.current.delete(x));const I=Qt.current.get(x);I&&Pc(I),Pt.current.delete(x),Ut.current.delete(x),_t.current.delete(x)},[]);u.useEffect(()=>{const x=ne&&Je.find(z=>z.deviceId===ne)||null;if(!et||!Yt||!x){bn.current&&(++ga.current,bn.current="");return}if(J===x.deviceId&&(D==="active"||D==="warm"||D==="connecting")){K(z=>z==="warm"?"active":z);return}if(bn.current===x.deviceId)return;const N=++ga.current,I=J;bn.current=x.deviceId,(async()=>{if(I){if(K("stopping"),await cr(I,"control-session-switch").catch(()=>{}),N!==ga.current)return;const he=hn.current;if(he&&he!==x.deviceId)try{await Js(he)}catch(_e){Oe(_e instanceof Error?_e.message:String(_e))}finally{hn.current===he&&(hn.current="",te(""))}if(N!==ga.current)return;Sn(I)}if(N!==ga.current)return;if(Fy(x)){try{await As(x.deviceId)}catch(he){N===ga.current&&(bn.current="",K("error"),Oe(he instanceof Error?he.message:String(he)));return}if(N!==ga.current){await Js(x.deviceId).catch(()=>{});return}hn.current=x.deviceId,te(x.deviceId),Ut.current.add(x.deviceId)}const z=_s("control",x.deviceId),ve=`control-session-${N}-${x.deviceId}`;gi.current.set(z,performance.now()),hi.current.delete(z),Ji.current.delete(z),Ba.current.delete(z),pi.current.delete(z),X(""),xe(""),O(ve),le(x.deviceId),W(!1),K("connecting"),ga.current===N&&bn.current===x.deviceId&&(bn.current="")})()},[Je,ne,J,D,Yt,Sn,Oe,et,Js,cr,As]),u.useEffect(()=>{if(!J||Je.some(I=>I.deviceId===J))return;const x=J,N=++ga.current;K("stopping"),cr(x,"control-device-disconnected").catch(()=>{}).finally(()=>{N===ga.current&&(Sn(x),W(!1),O(""),X(""),xe(""),le(I=>I===x?"":I),K("idle"))})},[Je,J,Sn,cr]);const no=Fy(Je.find(x=>x.deviceId===J));u.useEffect(()=>{if(ra.current!==null&&(window.clearTimeout(ra.current),ra.current=null),!J||D==="idle"||D==="stopping"||D==="error"||et||Gt==="wall"){J&&!et&&Gt==="wall"&&K(I=>I==="warm"||I==="active"?"active":I);return}K(I=>I==="idle"||I==="stopping"?I:"warm");const x=J,N=++ga.current;return ra.current=window.setTimeout(()=>{ra.current=null,K("stopping"),cr(x,"control-session-warm-timeout").catch(()=>{}).finally(()=>{N===ga.current&&(Sn(x),W(!1),O(""),X(""),xe(""),le(I=>I===x?"":I),K("idle"))})},MM),()=>{ra.current!==null&&(window.clearTimeout(ra.current),ra.current=null)}},[Gt,J,D,Sn,et,cr]),u.useEffect(()=>()=>{ra.current!==null&&window.clearTimeout(ra.current)},[]),u.useEffect(()=>{const N=J&&(no&&(D==="connecting"||D==="active"||D==="warm"||D==="stopping")||ce&&(D==="active"||D==="warm"))?J:"";if(ns.current=N,on.current)return;const I=async()=>{for(;;){const z=ns.current,ve=hn.current;if(ve===z)return;if(ve){try{await Js(ve)}catch(he){Oe(he instanceof Error?he.message:String(he))}finally{hn.current===ve&&(hn.current="",te(""))}continue}if(!z)return;try{await As(z)}catch(he){ns.current=hn.current,Oe(he instanceof Error?he.message:String(he));return}hn.current=z,te(z),Ut.current.add(z)}};let U;U=I().finally(()=>{on.current===U&&(on.current=null),hn.current!==ns.current&&He(z=>z+1)}),on.current=U},[J,ce,D,no,ut,Oe,Js,As,Ne]);const qn=J&&Je.find(x=>x.deviceId===J)||null,cl=!!(et&&Le&&D==="active"&&qn?.sessionId&&P?.deviceId===qn.deviceId&&P.sessionId===qn.sessionId&&P.streamPurpose==="control"&&P.commandId&&P.captureGeneration>0&&P.monitorIndex===Ys),{state:Ni,sendInput:ei,stats:ba,error:tc}=r1(bs&&cl,k),Mi=u.useCallback((x,N)=>!cl||!qn||!P||x!==qn.deviceId?!1:ei(x,{...N,controlSessionId:qn.sessionId,controlCommandId:P.commandId,captureGeneration:P.captureGeneration}),[cl,qn,P,ei]),ur=cl&&Ni==="open",{state:Sa,lastFrame:Ti,stats:cn,error:ul}=p1(Me?.deviceId||"",Su&&ue,k),Ei=u.useRef(new Map);u.useEffect(()=>{const x=[["hub",A],["registry",c],["license",F],["wall-stream",Zo],["control-stream",Zs],["control-decode",ge],["remote-input",tc],["remote-audio",ul]];for(const[N,I]of x){const U=String(I||"").trim();if(!U){Ei.current.delete(N);continue}Ei.current.get(N)!==U&&(Ei.current.set(N,U),Oe(U))}},[ul,ge,Zs,A,tc,F,c,Oe,Zo]),u.useEffect(()=>{if(!et||!Le||!bs||!ur||!Me)return;const x=(U,z)=>{const ve=U.target,he=ve?.tagName?.toLowerCase();ve?.isContentEditable||he==="input"||he==="textarea"||he==="select"||(U.preventDefault(),U.stopPropagation(),Mi(Me.deviceId,{type:z,monitorIndex:Da(Vt[Me.deviceId],fa(Me)),key:U.key,code:U.code,keyCode:U.keyCode||U.which||0,location:U.location,text:U.key.length===1?U.key:"",repeat:z==="keydown"?U.repeat:!1,shiftKey:U.shiftKey,ctrlKey:U.ctrlKey,altKey:U.altKey,metaKey:U.metaKey}))},N=U=>x(U,"keydown"),I=U=>x(U,"keyup");return window.addEventListener("keydown",N),window.addEventListener("keyup",I),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",I)}},[bs,ur,Le,Vt,Me,Mi,et]),u.useEffect(()=>{const x=()=>{document.visibilityState==="visible"&&(er.current=performance.now())};return document.addEventListener("visibilitychange",x),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("pageshow",x)}},[]),u.useEffect(()=>{if(!J||D!=="connecting"&&D!=="active"&&D!=="warm"||la!=="open")return;const x=J,N=_s("control",x),I=window.setInterval(()=>{const U=performance.now();if(document.visibilityState!=="visible"||U-er.current<mh)return;const z=hi.current.get(N)||0,ve=Ji.current.get(N)||0,he=as.current.get(N)||0,_e=gi.current.get(N)||U;gi.current.has(N)||gi.current.set(N,_e);const Pe=z<=0,lt=Pe?U-_e>OM:U-z>Ry,Jt=z>0&&(ve<=0||U-ve>Ry);if(!lt&&Jt){const Sr=Ps.current.get(N)||0;U-Sr>=Dy&&os(x,"control","decoder-paint-stale");return}if(!lt)return;const Nn=pi.current.get(N)||0;if(Nn>0){if(U-Nn<FM)return;pi.current.delete(N)}const ka=Ba.current.get(N)||0;if(ka>=PM){if(ol(Pe?"no first frame":"stale stream"))return;W(!1),Qn(!1),K("error");return}if(U-he<_y(BM,ka))return;ks([x],Pe?"control-first-frame-timeout":"control-receive-stale")&&(as.current.set(N,U),pi.current.set(N,U),gi.current.set(N,U),Ba.current.set(N,ka+1))},650);return()=>window.clearInterval(I)},[la,J,D,ol,os,ks]),u.useEffect(()=>{!ge||Xn!=="mode3-h264-hw"||ol(ge)||(W(!1),Qn(!1),K("error"))},[ge,Xn,ol]),u.useEffect(()=>{!et||!J||!Zs||K(x=>x==="error"?x:"error")},[Zs,J,et]),u.useEffect(()=>{if(Ha!=="open"||!Ie.autoStartLive||Zn.length===0)return;const x=window.setInterval(()=>{const N=performance.now();if(document.visibilityState!=="visible"||N-er.current<mh)return;const I=1e3/Math.max(1,bi||Ie.fps||1),U=Math.max(HM,Math.ceil(I*4)),z=[];for(const ve of Zn){if(z.length>=qM)break;const he=_s("wall",ve),_e=hi.current.get(he)||0;if(_e<=0)continue;const Pe=as.current.get(he)||0,lt=Ji.current.get(he)||0,Jt=N-_e>U,Nn=lt<=0||N-lt>U;if(!Jt&&Nn){const fo=Ps.current.get(he)||0;N-fo>=Dy&&os(ve,"wall","decoder-paint-stale");continue}if(!Jt)continue;const ka=Ba.current.get(he)||0;N-Pe>=_y($M,ka)&&z.push(ve)}if(z.length>0&&il(z,"wall-frame-stale"))for(const ve of z){const he=_s("wall",ve);as.current.set(he,N),Ba.current.set(he,(Ba.current.get(he)||0)+1)}},UM);return()=>window.clearInterval(x)},[bi,Zn,os,il,Ie.autoStartLive,Ie.fps,Ha]),u.useEffect(()=>{Fs(Ie.fps),Us.current=Date.now(),va.current=0},[Ie.fps,Ie.frameMode,Ie.adaptiveLoadShedding]),u.useEffect(()=>{Lj({h264DecodeAcceleration:Ie.h264DecodeAcceleration})},[Ie.h264DecodeAcceleration]),u.useEffect(()=>{if(!Yt||et||!Ie.visibleOnlyLive){an([]);return}const x=Qr.current;if(!x||typeof IntersectionObserver>"u"){an(Kl);return}const N=Array.from(x.querySelectorAll("[data-live-device-id]"));if(N.length===0){an([]);return}const I=new Map,U=()=>{const ve=xh(N.map(he=>String(he.dataset.liveDeviceId||"")).filter(he=>(I.get(he)||0)>0));an(he=>vh(he,ve)?he:ve)},z=new IntersectionObserver(ve=>{for(const he of ve){const _e=String(he.target.dataset.liveDeviceId||"");_e&&I.set(_e,he.isIntersecting?he.intersectionRatio||.01:0)}U()},{root:null,rootMargin:sa.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return N.forEach(ve=>z.observe(ve)),U(),()=>z.disconnect()},[Kl,Yt,et,Zr,Ie.visibleOnlyLive,it]),u.useEffect(()=>{if(!Ie.adaptiveLoadShedding||!Ie.autoStartLive||Zn.length===0)return;const x=Ie.fps;if(Zn.length<=sa.preserveConfiguredFpsDeviceCount){mn!==x&&(Fs(x),Us.current=Date.now(),va.current=0);return}if(Ha!=="open"||Cs.sampleMs<500)return;const N=Date.now(),I=Zn.length*mn,U=Cs.framesPerSecond,z=Cs.bytesPerSecond,ve=Math.max(0,...Zn.map(Jt=>Kn[_s("wall",Jt)]?.maxIntervalMs||0)),he=Math.max(0,...Zn.map(Jt=>Zi[_s("wall",Jt)]?.maxIntervalMs||0)),_e=I>8&&U>0&&U<I*.72;if(U>sa.maxWallFramesPerSecond||z>sa.maxWallBytesPerSecond||ve>sa.maxFrameGapMs||he>sa.maxFrameGapMs||_e){va.current=0;const Jt=sa.minFps;if(N-Us.current>=sa.downshiftCooldownMs&&mn>Jt){const Nn=Math.max(Jt,lT(mn,Jt));Nn<mn&&(Fs(Nn),Us.current=N)}return}const lt=U<sa.maxWallFramesPerSecond*sa.lowLoadFrameRatio&&z<sa.maxWallBytesPerSecond*sa.lowLoadByteRatio;if(!lt||mn>=x){lt||(va.current=0);return}if(!va.current){va.current=N;return}if(N-va.current>=sa.recoveryCooldownMs){const Jt=Math.min(x,oT(mn,x));Jt>mn&&(Fs(Jt),Us.current=N,va.current=0)}},[mn,Zn.length,Zn,Zi,Kn,Ha,Cs.bytesPerSecond,Cs.framesPerSecond,Cs.lastUpdatedAt,Cs.sampleMs,Ie.adaptiveLoadShedding,Ie.autoStartLive,Ie.frameMode,Ie.fps]),u.useEffect(()=>{const x=new URLSearchParams(window.location.search).get("checkout");if(x==="success"){Oe("Checkout returned. Waiting for Dodo confirmation."),q();const N=window.setInterval(()=>{q()},4e3),I=window.setTimeout(()=>{window.clearInterval(N)},45e3);return()=>{window.clearInterval(N),window.clearTimeout(I)}}x==="cancelled"&&Oe("Checkout cancelled.")},[q]),u.useEffect(()=>{!Yt&&Le&&ze(!1),!Yt&&ue&&Ye(!1)},[ue,Le,Yt]),u.useEffect(()=>{const x=Me?.deviceId||"",N=We.current;if(We.current=x,!N||N===x)return;const I=++Ae.current,U=x?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";x&&ue&&oe.current.set(x,U);let z=!0;return(async()=>{try{const he=oe.current.get(N);if(oe.current.delete(N),await Ue(`/api/remote/devices/${encodeURIComponent(N)}/audio/stop`,{method:"POST",body:JSON.stringify(he?{streamId:he}:{})},k),!z||I!==Ae.current||!ue||!x||!Yt||!Jr)return;const _e=await Ue(`/api/remote/devices/${encodeURIComponent(x)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:U,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},k);if(_e.ok===!1)throw new Error(_e.error||"Remote audio start failed.")}catch(he){z&&(oe.current.delete(x),Ye(!1),Oe(he instanceof Error?he.message:String(he)))}})(),()=>{z=!1}},[ue,Yt,k,Jr,Me?.deviceId]),u.useEffect(()=>{const x=Je.map(U=>U.deviceId),N=new Set(x),I=new Map(Je.map(U=>[U.deviceId,U]));_(U=>{const z=U.filter(ve=>N.has(ve));return vh(U,z)?U:z}),V(U=>U&&N.has(U)?U:""),Q(U=>U&&N.has(U)?U:""),Bs(U=>{let z=!1;const ve={};for(const[he,_e]of Object.entries(U)){const Pe=I.get(he);if(!Pe){ve[he]=_e;continue}const lt=Da(_e,Pe?fa(Pe):1);ve[he]=lt,lt!==_e&&(z=!0)}return z?ve:U}),Fa(U=>{const z=U.filter(ve=>N.has(ve));return vh(U,z)?U:z})},[Je,Xr]),u.useEffect(()=>{du([]),qo(!1)},[js]),u.useEffect(()=>{!qs||$s!=="selected"||is.length>0||Pa.length===0||Fa(Pa.map(x=>x.deviceId))},[Pa,is.length,$s,qs]),u.useEffect(()=>{try{localStorage.setItem(rb,Rn)}catch{}},[Rn]),u.useEffect(()=>{nT(Ie)},[Ie]),u.useEffect(()=>{sT(ft)},[ft]),u.useEffect(()=>{eT(Vt)},[Vt]);const ea=u.useCallback(async()=>{const x=new Set(v);x.add(yn);try{const ve=await Ue("/api/remote/status",void 0,yn);vx({endpoint:ve.agentEndpoint,endpoint_candidates:[...ve.agentEndpointCandidates||[],...ve.hostTargetEndpointCandidates||[]]}).forEach(he=>x.add(he))}catch{}const N=[...x].sort((ve,he)=>{const _e=Pe=>{const lt=Xc(Pe);return lt==="local"?0:lt==="loopback"?1:2};return _e(ve)-_e(he)||ve.localeCompare(he)});let I=!1,U="",z=!1;try{for(const ve of N){const he=Xc(ve);try{if(await Ue("/api/health",void 0,ve),he==="local")return w(!0),No(!0),ve;he==="loopback"&&(I=!0,U=ve)}catch{he==="local"&&(z=!0)}}return I?(z&&Oe("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),No(!0),U||yn):(w(!1),No(!1),"")}catch{return w(!1),No(!1),""}},[v]),Ln=async()=>{if(Ee("auth"),Pn(!1),await ea(),window.liveDesk?.auth?.signInWithGoogle){const I=await window.liveDesk.auth.signInWithGoogle();I?.ok===!1&&(Oe(I.error||"LiveDesk could not open the system browser for Google sign-in."),Ee(""));return}const{data:x,error:N}=await ct.auth.signInWithOAuth({provider:"google",options:{redirectTo:`${window.location.origin}/callback`}});N&&(Oe(N.message),Ee(""))},ti=async()=>{Ee("auth"),Pn(!1),await ct.auth.signOut(),(await window.liveDesk?.auth?.persistSession?.(null))?.runtimeCleared===!1?Oe("Signed out locally. The LiveDesk runtime could not be reached to clear its session."):window.liveDesk?.auth?.persistSession||await Ue("/api/auth/session",{method:"DELETE"},yn).catch(()=>{}),Ee("")};u.useEffect(()=>{if(!fn)return;const x=I=>{I.target instanceof Element&&(I.target.closest(".account-popover, .rail-account")||Pn(!1))},N=I=>{I.key==="Escape"&&Pn(!1)};return window.addEventListener("pointerdown",x),window.addEventListener("keydown",N),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",N)}},[fn]);const $a=u.useCallback(async(x={})=>{const N=x.silent===!0,I=x.takeover===!0,U=x.requestLocalAccess===!0;if(!a?.user){N||Oe("Sign in before publishing this host.","error");return}if(!Dn.current){Dn.current=!0,N||(Ee("host"),Ft("Sync Server · 1/4 · Checking the local Hub…"));try{const ve=(U?await ea():"")||k||yn;if(!(j||await Ue("/api/remote/status",void 0,ve)).started)throw new Error("Start LiveDesk on this computer before syncing the server.");N||Ft("Sync Server · 2/4 · Sending the signed-in session to the Hub…");const _e=await Ue("/api/auth/session",{method:"POST",body:JSON.stringify({accessToken:a.access_token,refreshToken:a.refresh_token,expiresAt:a.expires_at,user:{id:a.user.id,email:a.user.email}})},ve);if(!_e.ok||!_e.authenticated)throw new Error(_e.error||"hub-session-sync-failed");N||Ft("Sync Server · 3/4 · Claiming the Hub role and publishing its endpoint…");const Pe=await Ue("/api/hub/sync",{method:"POST",body:JSON.stringify({takeover:I})},ve);if(!Pe.ok)throw new Error(Pe.error||"host-target-failed");if(!N){Ft("Sync Server · 4/4 · Verifying the endpoint and lease renewal…");const lt=await Ue("/api/hub/status",void 0,ve);if(!lt.hostTargetActive)throw new Error(lt.hostTargetLease?.lastError||"host-target-not-active-after-sync");const Jt=lt.hostTargetEndpoint||lt.agentEndpoint||"endpoint ready",Nn=Number(lt.connectedDeviceCount||0),ka=Nn>0?`${Nn} client${Nn===1?"":"s"} connected.`:"No clients connected yet; reconnect the laptop Client.";Oe(`Sync Server ready · ${Jt} · lease auto-renewal active. ${ka}`,"success"),(U||y)&&(w(!0),No(!0)),T()}d()}catch(z){if(!N){const ve=z instanceof Error?z.message:String(z);ve.includes("local network access")&&(w(!1),No(!1)),Oe(`Sync Server failed · ${ve}`,"error")}}finally{Dn.current=!1,N||Ee("")}}},[k,y,T,d,ea,a,Oe,Ft,j]),cs=u.useCallback(async()=>{if(!(!j?.update?.canApply||je==="update")){Ee("update");try{const x=await Ue("/api/update/apply",{method:"POST",body:JSON.stringify({})},k||yn);if(!x.ok)throw new Error(x.error||"LiveDesk update could not be started.");const N=[...new Set((x.targets||[]).map(I=>String(I.deviceId||"").trim()).filter(Boolean))];N.length>0&&$e({operationId:String(x.operationId||`wall-update-${Date.now()}`),targetIds:N,stage:x.state==="clients-updated"?"updated":"updating",requiresHubRestart:!!(x.managerUpdateAvailable||x.clientPackageUpdateAvailable),initialHostInstanceId:String(j.hostInstanceId||"")}),Oe(x.state==="hub-restart-requested"?hh:Cy),T()}catch(x){Oe(x instanceof Error?x.message:String(x))}finally{Ee("")}}},[je,k,T,j]);u.useEffect(()=>{const x=B,N=j?.update;if(!x||x.stage==="updated"||!N)return;if(N.state==="failed"){$e(z=>z?.operationId===x.operationId?null:z);return}if(N.operationId===x.operationId){!x.requiresHubRestart&&N.state==="clients-updated"&&$e(z=>z?.operationId===x.operationId?{...z,stage:"updated"}:z);return}if(!x.requiresHubRestart)return;const I=j.started===!0&&(!x.initialHostInstanceId||j.hostInstanceId&&j.hostInstanceId!==x.initialHostInstanceId),U=N.state==="idle"&&N.updateAvailable===!1;I&&U&&$e(z=>z?.operationId===x.operationId?{...z,stage:"updated"}:z)},[j,B]),u.useEffect(()=>{if(!B||B.stage!=="updated")return;const x=B.operationId,N=window.setTimeout(()=>{$e(I=>I?.operationId===x?null:I)},8e3);return()=>window.clearTimeout(N)},[B]),u.useEffect(()=>{if(Ge!==Cy&&Ge!==hh)return;const x=j?.update,N=String(x?.state||"");if(N==="failed"){Oe(x?.error||"LiveDesk update failed.");return}(N==="clients-updated"||N==="idle"&&x?.updateAvailable===!1||!j&&A&&Ge===hh)&&Oe("")},[A,Ge,j,j?.update?.error,j?.update?.state,j?.update?.updateAvailable]);const Ns=u.useCallback(async()=>{if(!je){Ee("pin");try{const N=await Ue("/api/remote/pairing-pin",{method:"POST"},k||yn);if(!N.ok)throw new Error(N.error||"pin-rotation-failed");await T(),Oe("New PIN published.")}catch(x){Oe(x instanceof Error?x.message:String(x))}finally{Ee("")}}},[je,k,T]),ao=u.useCallback(x=>{x&&(V(x),_(N=>N.includes(x)?N:[...N,x]))},[]),so=u.useCallback(x=>{if(!x)return;const N=sr.has(x);V(I=>N&&I===x?"":x),_(I=>N?I.filter(U=>U!==x):I.includes(x)?I:[...I,x])},[sr]),Ri=u.useCallback(()=>{_([]),V("")},[Ss]),nc=u.useCallback(()=>{_(Je.map(x=>x.deviceId)),V("")},[Je]),pn=u.useCallback((x,N)=>{const I=Je.find(z=>z.deviceId===x);if(!I)return;const U=fa(I);U<=1||(Bs(z=>{const he=(Da(z[x],U)+N+U)%U;return{...z,[x]:he}}),et&&(Qn(!1),Q(x)))},[Je,et]);u.useEffect(()=>{const x=N=>{if(et&&Le&&bs)return;const I=N.target,U=I?.tagName?.toLowerCase();I?.isContentEditable||U==="input"||U==="textarea"||U==="select"||((N.ctrlKey||N.metaKey)&&N.key.toLowerCase()==="a"&&(N.preventDefault(),nc()),N.key==="Escape"&&Ri())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[bs,Ri,Le,nc,et]);const Lt=async()=>{if(!Me||Re)return;const x=Me;if(!xi.has(x.deviceId)){Oe(yi);return}Fe("view-screen"),ke(!1),ze(!1),Qn(!1),Q(x.deviceId),pt("control");try{Oe(`Opening ${ma(x)} screen.`,"success")}finally{Fe("")}},gt=(x,N)=>{const I=Je.find(z=>z.deviceId===x),U=Da(N,I?fa(I):1);Bs(z=>({...z,[x]:U})),et?(Qn(!1),Q(x)):ao(x)},Ua=async x=>{if(Qn(!1),Q(x),pt("control"),!xi.has(x)){ze(!1),Oe(yi);return}const N=Je.find(U=>U.deviceId===x);if(Ki(N?.platform)&&(N?.capabilities?.controlPermission===!1||N?.capabilities?.accessibilityPermission===!1)){ze(!1),Oe("Mac remote control needs Accessibility permission. Allow it for the terminal app that starts LiveDesk, then restart the Mac client.","error");return}ze(!0),Oe(`Opening remote control${N?` for ${ma(N)}`:""}.`,"success")},ja=async()=>{if(!Me){Oe("Select a workstation before playing audio.");return}if(!Yt){Oe(yi);return}if(!Jr){Oe("Selected workstation does not report remote audio support yet.");return}if(Re)return;const x=!ue,N=x?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:oe.current.get(Me.deviceId);x&&N?oe.current.set(Me.deviceId,N):x||oe.current.delete(Me.deviceId),Fe("audio"),Ye(x);try{await Ue(`/api/remote/devices/${encodeURIComponent(Me.deviceId)}/audio/${x?"start":"stop"}`,{method:"POST",body:JSON.stringify({...N?{streamId:N}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},k),Oe(`${x?"Audio started":"Audio stopped"} for ${ma(Me)}.`,"success")}catch(I){x&&oe.current.delete(Me.deviceId),Ye(!1),Oe(I instanceof Error?I.message:String(I),"error")}finally{Fe("")}},ac=x=>{const N=x instanceof Error?x.message:String(x);return/remote-actions-disabled|allowAgent-blocked-by-settings/i.test(N)?"Remote actions are off. Turn on Settings > Agent > Enable AI Agent first.":/power-actions-disabled/i.test(N)?"Power actions are off. Turn on Settings > Agent > Allow power actions first.":/agent-tool-capability-unavailable|unsupported-agent-operation/i.test(N)?"This workstation needs a newer LiveDesk Client for power actions.":/device-not-connected|404 device-not-found/i.test(N)?"The workstation disconnected before the action could be sent.":N},qa=async x=>{if(!Me||Re)return;const N=Me,U={lock:"Lock",sleep:"Sleep",restart:"Restart",shutdown:"Shut down"}[x];if(!(x!=="lock"&&!window.confirm(`${U} ${ma(N)}? Unsaved work on that computer may be lost.`))){ke(!1),Fe(x),Oe(`Sending ${U.toLowerCase()} request to ${ma(N)}...`);try{const z=await Ue(`/api/remote/devices/${encodeURIComponent(N.deviceId)}/quick-actions`,{method:"POST",body:JSON.stringify({action:x})},k);if(!z.ok)throw new Error(z.error||"The remote action could not be sent.");Oe(`${U} request sent to ${ma(N)}.`,"success"),T()}catch(z){Oe(ac(z),"error")}finally{Fe("")}}},Mu=()=>{Me&&(ke(!1),we({id:Date.now(),deviceId:Me.deviceId,instruction:"Run command "}),ze(!1),pt("agents"),Oe(`Command runner opened for ${ma(Me)}.`))},sc=async(x,N,I="files")=>{const U=x.filter(_e=>_e.file.size>=0);if(U.length===0)return{files:0,bytes:0};if(!Yt)throw new Error(yi);if(N.length===0)throw new Error("Select at least one connected workstation.");const z=crypto.randomUUID(),ve=U.reduce((_e,Pe)=>_e+Pe.file.size,0);let he=0;ss({id:z,status:"reading",progress:1,message:`Preparing ${U.length} ${I}`});try{for(let _e=0;_e<U.length;_e+=1){const Pe=U[_e],lt=Pe.file,Jt=Math.max(1,Math.ceil(lt.size/dh));for(let Nn=0;Nn<Jt;Nn+=1){const ka=Nn*dh,fo=Math.min(lt.size,ka+dh),Sr=lt.size===0?new ArrayBuffer(0):await lt.slice(ka,fo).arrayBuffer(),hc=Nn===Jt-1;ss({id:z,status:"sending",progress:Math.max(2,Math.min(98,Math.round(he/Math.max(1,ve)*96))),message:`${_e+1}/${U.length} ${Pe.relativePath}`});const jr=await Ue("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:z,deviceIds:N,remoteDirectory:Rn.trim(),name:lt.name,relativePath:Pe.relativePath,size:lt.size,type:lt.type,lastModified:lt.lastModified,offset:ka,totalBytes:lt.size,final:hc,dataBase64:cT(Sr)})},k);if(!jr.ok||jr.queued!==N.length)throw new Error(jr.error||`file-chunk-not-queued-${jr.queued}/${N.length}`);he+=Sr.byteLength,await new Promise(Gn=>window.setTimeout(Gn,0))}}return ss({id:z,status:"queued",progress:100,message:`Sent ${U.length} file${U.length===1?"":"s"} to ${N.length} workstation${N.length===1?"":"s"}`}),window.setTimeout(()=>{ss(_e=>_e?.id===z&&_e.status==="queued"?null:_e)},4500),{files:U.length,bytes:ve}}catch(_e){throw ss({id:z,status:"failed",progress:100,message:_e instanceof Error?_e.message:String(_e)}),_e}},Di=async x=>{const N=Pa.length>0?Pa.map(I=>I.deviceId):Me?[Me.deviceId]:[];try{await sc(zy(x),N)}catch(I){Oe(I instanceof Error?I.message:String(I))}},ni=async x=>{try{await sc(zy(x),Cf)}catch(N){Oe(N instanceof Error?N.message:String(N))}};u.useEffect(()=>{hu.current=!1},[]);const ic=x=>{x.preventDefault(),x.stopPropagation(),Hs(!1),Di(x.dataTransfer.files)},ai=async(x="ltd")=>{if(!a){Oe("Sign in with Google before checkout.");return}if(R&&x===qt){Oe("LiveDesk license is already active.");return}if(R&&qt==="pro"){Oe("LiveDesk Pro is already active.");return}Ee("checkout");try{const{data:N,error:I}=await ct.functions.invoke("dodo-checkout",{body:{plan:x}});if(I)throw I;if(!N?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(N.checkout_url)}catch(N){Oe(N instanceof Error?N.message:String(N)),Ee("")}},us=GM(),ds=VM(),Ms=Je.length,fs=Cu.filter(x=>Ai.has(x)).length,Ga=or==="open"&&ll.sampleMs>0?`${ll.framesPerSecond.toFixed(1)} fps`:or,Te=Me?et?rl.get(Me.deviceId):Ai.get(Me.deviceId):void 0,dr=Me?Da(Vt[Me.deviceId],fa(Me)):0,_i=Me?QM(Me):[],io=typeof Te?.monitorIndex=="number"?Da(Te.monitorIndex,Math.max(1,Te.monitorCount||1)):dr,gn=(Te&&io===dr?vb(Te):null)||(Me?gb(Me,dr):null),ro=gn?`${gn.width}x${gn.height}`:"-",dl=Me?_s(et?"control":"wall",Me.deviceId):"",An=dl?Kn[dl]:void 0,oa=dl?Zi[dl]:void 0,vt=oa?.lastInfo,un=An&&An.sampleMs>0?`${An.framesPerSecond.toFixed(1)} fps`:"waiting",rc=An?`#${An.totalFrames} / ${un}`:"waiting",fl=oa&&oa.sampleMs>0?`${oa.framesPerSecond.toFixed(1)} fps`:"waiting",ml=oa&&oa.sampleMs>0?`${oa.changedFramesPerSecond.toFixed(1)} fps`:"waiting",lc=vt?`#${vt.frameSeq} ${vt.decoderLabel} q${vt.queueSize} r${vt.renderQueueSize} d${vt.droppedForLatency} f${vt.decoderFlushCount} t${vt.decoderTimestampFallbacks} io${vt.decoderInputCount}/${vt.decoderOutputCount} ${vt.visualChanged?"changed":"same"}`:"waiting",mr=vt?`${Math.round(vt.queuedForMs)}ms total / ${Math.round(vt.decodedForMs)}ms decode / ${Math.round(vt.scheduledForMs)}ms pace / ${vt.drawMs.toFixed(1)}ms draw`:"-",hr=vt?.targetPaintIntervalMs?`${vt.targetPaintIntervalMs.toFixed(1)}ms / ${(1e3/vt.targetPaintIntervalMs).toFixed(1)} fps`:"-",Af=oa?`${oa.decoderInputFps.toFixed(1)} in / ${oa.decoderOutputFps.toFixed(1)} out fps`:"waiting",Tu=vt?.canvasPresentation||"-",Nf=vt?`${vt.interactiveBufferWaitCount} waits / ${Math.round(vt.interactiveBufferWaitMs)}ms / ${vt.interactiveQueueDrainCount} drains`:"waiting",Eu=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",Li=An?Te?.frameMode==="mode5-lzo-delta"?`${Yc(An.averageFrameBytes)} avg / visual ${Te.deltaVisualTileCount||0} + refresh ${Te.deltaRefreshTileCount||0} / ${Te.deltaTotalTiles||0}`:`${Yc(An.averageFrameBytes)} avg / tiny ${Math.round(An.tinyFrameRatio*100)}% / repeat ${Math.round(An.repeatedFrameRatio*100)}%`:"waiting",oc=An&&An.sourceSendSampleCount>0?`${An.sourceSendAverageMs.toFixed(1)}ms avg / p95 ${An.sourceSendP95Ms.toFixed(1)}ms`:"waiting",lo=Ny(An),Ru=Ny(oa),pr=An&&oa?`rx ${My(An)} / paint ${My(oa)}`:"waiting",hl=Te?Te.frameMode||Te.mode||Te.codec||Te.mimeType:et?ft.frameMode:Ie.frameMode,gr=et?ft.frameMode:Ie.frameMode,oo=hl!==gr?`${gr} -> ${hl}`:gr,Du=Te?`${Te.width}x${Te.height} ${Yc(Te.byteLength)}`:et?`${Gs.maxWidth}x${Gs.maxHeight}`:`${Ie.maxWidth}x${Ie.maxHeight}`,_u=Te?`${Te.isKeyFrame?"key":String(Te.chunkType||"delta")}`:"-",zi=Te&&Te.monitorCount?`${(Te.monitorIndex??0)+1}/${Te.monitorCount}`:"-",Ii=Te?[`src ${Math.round(Te.sourceGapMs||0)}ms`,`gap ${Math.round(Te.agentSendGapMs||0)}ms`,`tx ${Math.round(Te.agentSendDurationMs||0)}ms`,`pace ${Math.round(Te.agentPaceMs||0)}ms`,`queue ${Math.round(Te.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Te.agentFrameAgeMs||0)}ms`,Te.browserReceivedEpochMs&&Te.receivedAt?`hub ${Math.max(0,Math.round(Te.browserReceivedEpochMs-Date.parse(Te.receivedAt)))}ms`:"",Te.browserReceivedEpochMs&&Te.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Te.browserReceivedEpochMs-Te.hubPacketEpochMs))}ms`:"",Te.droppedByAgent?`drop ${Te.droppedByAgent}`:"",Te.hubIngressDropped?`ingress-drop ${Te.hubIngressDropped}`:"",Te.hubClientDropped?`ws-drop ${Te.hubClientDropped}`:"",Te.captureStageMs?`capture ${Math.round(Te.captureStageMs)}ms`:"",Te.requestedFps?`req ${Math.round(Te.requestedFps)}fps`:"",Te.effectiveFps?`eff ${Math.round(Te.effectiveFps)}fps`:"",Te.captureAverageMs?`avg ${Math.round(Te.captureAverageMs)}ms`:"",Te.captureP95Ms?`p95 ${Math.round(Te.captureP95Ms)}ms`:"",Te.slowFrameCount?`slow ${Math.round(Te.slowFrameCount)}`:"",Te.captureHelperRestarts?`helper ${Math.round(Te.captureHelperRestarts)}`:"",Te.convertMs?`rgb565 ${Math.round(Te.convertMs)}ms`:"",Te.compressMs?`lzo ${Math.round(Te.compressMs)}ms`:"",Te.captureSourceSerial?`cap #${Te.captureSourceSerial}`:"",Te.captureSourceSkipped?`cap skip ${Te.captureSourceSkipped}`:"",Te.frameMode==="mode5-lzo-delta"?`tiles ${Te.deltaVisualTileCount||0}+${Te.deltaRefreshTileCount||0}/${Te.deltaTotalTiles||0}@${Te.deltaTileSize||0}`:"",Te.platformProfile||Te.hardwareEncoder||"-",Te.atlasComposeMs?`atlas ${Te.atlasComposeMs.toFixed(1)}ms`:"",Te.atlasPoolStarved?`pool ${Te.atlasPoolStarved}`:"",Te.atlasTileCount?`tiles ${Te.atlasReadyTiles||0}/${Te.atlasTileCount}`:"",Te.atlasInputRevision?`input #${Te.atlasInputRevision}`:"",Te.atlasSourceMaxAgeMs!==void 0?`input-age ${Math.round(Te.atlasSourceMaxAgeMs)}ms`:"",vt?.inputFeedbackMs!==void 0&&vt.inputFeedbackAt!==void 0&&performance.now()-vt.inputFeedbackAt<=Sy?`feedback ${Math.round(vt.inputFeedbackMs)}ms`:"",Te.contentHash?`enc ${Te.contentHash.slice(0,6)}`:"",vt?.visualHash?`pix ${vt.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "):"-",Lu=Ni==="open"?[`${ba.sentPerSecond.toFixed(1)} hz`,ba.lastInputSeq>0?`rtt ${Math.round(ba.lastRoundTripMs)}ms`:"",ba.lastInputSeq>0?`apply ${ba.lastAgentApplyMs.toFixed(1)}ms`:"",ba.droppedPerSecond>0?`drop ${ba.droppedPerSecond.toFixed(1)}/s`:"",ba.bufferedAmount>0?`buf ${Yc(ba.bufferedAmount)}`:"",ba.lastInputType||"ready"].filter(Boolean).join(" / "):Ni,zu=vt?.inputFeedbackMs!==void 0&&vt.inputFeedbackAt!==void 0&&performance.now()-vt.inputFeedbackAt<=Sy?`${Math.round(vt.inputFeedbackMs)}ms / input #${vt.inputFeedbackSeq||0}`:"waiting for changed frame",vr=ue?[Sa,`context ${cn.audioContextState}`,`queue ${Math.round(cn.queuedMs)}ms`,`last ${Math.round(cn.lastPacketAgeMs)}ms`,`accepted ${Math.round(cn.lastAcceptedAgeMs)}ms`,`process ${Math.round(cn.localProcessingAgeMs)}ms`,`remote ${Math.round(cn.browserAgeMs)}/${Math.round(cn.captureAgeMs)}ms`,`heartbeat ${Math.round(cn.captureStatusAgeMs)}ms`,`capture ${cn.captureAlive&&cn.helperAlive?"alive":"down"}`,`drop ${cn.drops}`,`resync ${cn.resyncs}`,`restart ${cn.automaticRestarts}`,cn.pendingDecodes>0?`decode ${cn.pendingDecodes}`:"",Ti?`#${Ti.frameSeq}`:"waiting"].filter(Boolean).join(" / "):"off",pl=Te?`#${Te.frameSeq} ${kh(Te.receivedAt||Te.capturedAt)}`:"waiting",Ts=Math.max(0,ll.bytesPerSecond*8/1e6),xr=lr?.atlasReadyTiles??fs,yr=lr?.atlasTileCount??fs,Iu=xr===yr?`${yr} tiles`:`${xr}/${yr} tiles`,si=Un.length>0,Ou=et?`1 stream / ${Ga} / ${Ts.toFixed(Ts>=10?0:1)}Mbps`:si?`1 stream / ${Iu} / ${Ga} / ${Ts.toFixed(Ts>=10?0:1)}Mbps`:`${fs} screens / ${Ga} / ${Ts.toFixed(Ts>=10?0:1)}Mbps`,Es=A?"offline":j?.started?"online":"starting",wr=Pa.length,co=et?Me?ma(Me):"No workstation":wr===0?"No workstation":wr>1?`${wr} selected`:Me?ma(Me):"No workstation",Zt=Io[Mt]||Io.en,Va=Zt.sync||Io.en.sync,br=r||$?"checking":R?qt==="pro"?"Pro LTD active":`Plus LTD ${Je.length}/${Vc}`:wu?`Free ${Je.length}/${Gc}`:`Upgrade ${Je.length}/${Gc}`,cc=qt==="pro"?"Pro active":je==="checkout"?"Opening":qt==="ltd"?"Pro $199":"Plus $79",gl=R?qt==="pro"?"Pro active":"Upgrade to Pro LTD":a?je==="checkout"?"Opening checkout":qt==="ltd"?"Buy Pro LTD":"Buy Plus LTD":je==="auth"?"Opening Google":"Sign in to buy",vl=qt==="pro"||je==="checkout"||je==="auth"||r||$,uc=a?.user?.user_metadata,xl=Iy(uc,"avatar_url","picture"),ms=Iy(uc,"full_name","name")||a?.user?.email||"Google",yl=ms.slice(0,1).toUpperCase(),Fu=j?.started?"Local app ready":"Start LiveDesk",dc=l?.active?"Published":a?"Not published":"Sign in required",fc=/^\d{6}$/.test(j?.pairingPin||"")?j?.pairingPin:"------",ca=ef.find(x=>x.width===Ie.maxWidth&&x.height===Ie.maxHeight)?.id||`${Ie.maxWidth}x${Ie.maxHeight}`,Ca=Ie.atlasTileSizeMode==="auto"?"auto":gh.find(x=>x.width===Ie.atlasTileWidth&&x.height===Ie.atlasTileHeight)?.id||"320x180",ii=ph.find(x=>x.width===ft.maxWidth&&x.height===ft.maxHeight)?.id||`${ft.maxWidth}x${ft.maxHeight}`,mc=Jd.find(x=>x.id===Ie.frameMode)||Jd[0],ua=x=>{fi(N=>{const I=x.frameMode?qh(x.frameMode):N.frameMode,U=x.frameMode!==void 0&&I!==N.frameMode;return{...N,...x,frameMode:I,fps:Vh(x.fps??(U?mb(I):N.fps),I)}})},ri=x=>{const N=ef.find(I=>I.id===x);N&&ua({maxWidth:N.width,maxHeight:N.height})},da=x=>{if(x==="auto"){ua({atlasTileSizeMode:"auto"});return}const N=gh.find(I=>I.id===x);!N?.width||!N?.height||ua({atlasTileSizeMode:"fixed",atlasTileWidth:N.width,atlasTileHeight:N.height})},zt=x=>{x.frameMode!==void 0&&(X(""),xe("")),ts(N=>{const I=x.frameMode?Gh(x.frameMode):N.frameMode,U=x.frameMode!==void 0&&I!==N.frameMode,z=x.fps??(U?30:N.fps),ve=x.maxWidth??N.maxWidth,he=x.maxHeight??N.maxHeight;return{...N,...x,frameMode:I,fps:gs(z,20,I==="mode3-h264-hw"?60:30,I==="mode3-h264-hw"?60:30),maxWidth:I==="mode3-h264-hw"?ve:Math.min(1920,ve),maxHeight:I==="mode3-h264-hw"?he:Math.min(1080,he)}})},uo=x=>{const N=ph.find(I=>I.id===x);N&&zt({maxWidth:N.width,maxHeight:N.height})},Ya=x=>{if(typeof window<"u"&&(x==="support"?window.history.pushState({},"","/support"):Gt==="support"&&window.history.pushState({},"","/")),x==="control"){const N=$n||Vs;if(N&&(Qn(!1),Q(N.deviceId)),pt(x),!Yt){ze(!1),Oe(yi);return}ze(!0);return}x==="agents"&&we(null),x==="wall"&&Kt(N=>N+1),pt(x),ze(!1)},st=je==="update"||["dispatching","waiting-for-clients","hub-restart-requested"].includes(j?.update?.state||""),At=u.useCallback(x=>{if(B?.targetIds.includes(x))return B.stage},[B]);return s.jsxs("main",{className:"app-shell",children:[s.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk tools",children:[s.jsx("div",{className:"rail-brand",title:"LiveDesk",children:s.jsx(nw,{size:25})}),s.jsx("nav",{className:"rail-tools",children:pT.map(x=>{const N=x.icon;return s.jsxs(u.Fragment,{children:[s.jsxs("button",{className:`rail-tool ${x.id==="sync-server"?"sync-server":""} ${Gt===x.id?"active":""} accent-${x.accent}`,onClick:()=>x.id==="sync-server"?void $a({takeover:!0,requestLocalAccess:!0}):Ya(x.id),title:x.label,type:"button",disabled:x.id==="sync-server"&&je==="host","aria-busy":x.id==="sync-server"&&je==="host",children:[x.id==="sync-server"&&je==="host"?s.jsx("span",{className:"sync-server-spinner","aria-hidden":"true"}):s.jsx(N,{size:19}),s.jsx("span",{children:x.id==="sync-server"&&je==="host"?"Syncing…":x.label})]}),x.id==="sync-server"&&j?.update?.updateAvailable&&j.update.canApply&&!st?s.jsxs("button",{className:"rail-update-button",onClick:()=>{cs()},title:`Update LiveDesk to ${j.update.latestVersion||"latest"}`,type:"button",children:[s.jsx(Yh,{size:16}),s.jsx("span",{children:"Update"})]}):null]},x.id)})}),s.jsxs("div",{className:"rail-footer",children:[gT.map(x=>{const N=x.icon;return s.jsxs("button",{className:`rail-tool compact ${Gt===x.id?"active":""} accent-${x.accent}`,onClick:()=>Ya(x.id),title:x.label,type:"button",children:[s.jsx(N,{size:18}),s.jsx("span",{children:x.label})]},x.id)}),s.jsxs("button",{className:`rail-tool compact local-settings ${Ul?"active":""}`,onClick:()=>{pt("settings"),typeof window<"u"&&window.history.pushState({},"","/"),Pn(!1),ze(!1),Xi(!1)},title:"Settings",type:"button",children:[s.jsx(Hy,{size:18}),s.jsx("span",{children:"Settings"})]}),s.jsxs("button",{className:`rail-account ${a?"signed-in":""}`,onClick:()=>{Pn(x=>!x)},disabled:r||je==="auth","aria-expanded":fn,title:a?`Account: ${a.user?.email||ms}`:"Sign in with Google",type:"button",children:[a?xl?s.jsx("img",{src:xl,alt:ms,referrerPolicy:"no-referrer"}):s.jsx("span",{className:"avatar-fallback",children:yl}):s.jsx(_l,{size:18}),s.jsx("span",{children:a?"Account":"Google"})]}),fn&&s.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[s.jsxs("div",{className:"account-popover-head",children:[s.jsx("div",{className:"account-popover-avatar",children:a&&xl?s.jsx("img",{src:xl,alt:ms,referrerPolicy:"no-referrer"}):a?s.jsx("span",{children:yl}):s.jsx(_l,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:a?ms:"Account"}),s.jsx("p",{children:a?.user?.email||"Not signed in"})]})]}),s.jsxs("dl",{className:"account-popover-facts",children:[s.jsx("dt",{children:"User"}),s.jsx("dd",{children:a?.user?.email||"Not signed in"}),s.jsx("dt",{children:"Network"}),s.jsx("dd",{children:Fu}),s.jsx("dt",{children:"Access"}),s.jsx("dd",{children:dc}),s.jsx("dt",{children:"Plan"}),s.jsx("dd",{children:br}),s.jsx("dt",{children:"Ads"}),s.jsx("dd",{children:qt==="free"?"Standard banner":"Removed"})]}),a?s.jsxs("button",{className:"account-popover-action",onClick:ti,disabled:je==="auth",type:"button",children:[s.jsx($y,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:Ln,disabled:je==="auth",type:"button",children:[s.jsx(_l,{size:16}),"Sign in with Google"]})]})]})]}),s.jsxs("section",{className:`desk-stage ${pu&&!En?"dock-open":""} ${et?"control-stage":""} ${Vl?"agents-stage":""}`,children:[s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(ln,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Control wall for local machines"})]})]}),qs&&!et&&s.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[s.jsxs("div",{children:[s.jsx(Rl,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Source"}),s.jsx("strong",{children:"LiveDesk Hub"})]})]}),s.jsx(Qh,{size:15}),s.jsx(i0,{size:16}),s.jsxs("div",{children:[s.jsx("span",{className:"file-share-top-route-laptops",children:"▣ ▣ ▣"}),s.jsxs("span",{children:[s.jsx("small",{children:"Destination"}),s.jsxs("strong",{children:[gu," workstation",gu===1?"":"s"]}),s.jsx("em",{children:Rn.trim()||"Desktop/LiveDeskFiles"})]})]})]}),pu&&!et&&s.jsxs("div",{className:"top-actions",children:[s.jsx(xy,{controller:Ql,onError:Oe}),s.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),s.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:hT.map(x=>s.jsx("button",{className:it===x.id?"active":"",onClick:()=>nn(x.id),type:"button",children:x.label},x.id))})]}),et&&s.jsx("div",{className:"top-actions",children:s.jsx(xy,{controller:Ql,onError:Oe})})]}),Gl?s.jsxs("section",{className:"doc-page",lang:Mt,dir:Mt==="ar"?"rtl":"ltr",children:[s.jsxs("section",{className:"doc-hero",children:[s.jsxs("div",{className:"doc-hero-copy",children:[s.jsxs("span",{className:"pricing-eyebrow",children:[s.jsx(tf,{size:16}),Zt.eyebrow]}),s.jsx("h2",{children:Zt.title}),s.jsx("p",{children:Zt.intro})]}),s.jsxs("label",{className:"doc-language-picker",children:[s.jsxs("span",{children:[s.jsx(r0,{size:17}),Zt.languageLabel]}),s.jsx("select",{value:Mt,onChange:x=>De(x.target.value),children:xT.map(x=>s.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),s.jsx("section",{className:"doc-grid",children:Zt.sections.map((x,N)=>{const U=[nf,qc,Wd,Bt,Ro][N]||tf;return s.jsxs("article",{className:"doc-card",children:[s.jsx("div",{className:"doc-card-icon",children:s.jsx(U,{size:19})}),s.jsxs("div",{children:[s.jsx("h3",{children:x.title}),s.jsx("p",{children:x.body}),s.jsx("ul",{children:x.points.map(z=>s.jsx("li",{children:z},z))})]})]},x.title)})}),Va&&s.jsxs("section",{className:"doc-sync",children:[s.jsxs("div",{className:"doc-sync-head",children:[s.jsx(Wd,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:Va.title}),s.jsx("p",{children:Va.body})]})]}),s.jsx("ul",{children:Va.points.map(x=>s.jsx("li",{children:x},x))})]}),s.jsxs("section",{className:"doc-firewall",children:[s.jsxs("div",{className:"doc-firewall-head",children:[s.jsx(Bt,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:Zt.firewall.title}),s.jsx("p",{children:Zt.firewall.body})]})]}),s.jsx("ul",{children:Zt.firewall.points.map(x=>s.jsx("li",{children:x},x))})]}),s.jsxs("section",{className:"doc-command-panel",children:[s.jsxs("div",{className:"doc-command-head",children:[s.jsx(qc,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:Zt.commands.title}),s.jsx("p",{children:Zt.commands.body})]})]}),s.jsxs("div",{className:"doc-command-list",children:[Zt.commands.manager&&s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:Zt.commands.manager}),s.jsx("code",{children:ds}),s.jsx("button",{className:"icon-button",onClick:()=>Tl(ds),title:"Copy command",type:"button",children:s.jsx(jl,{size:16})})]}),s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:Zt.commands.primary}),s.jsx("code",{children:us}),s.jsx("button",{className:"icon-button",onClick:()=>Tl(us),title:"Copy command",type:"button",children:s.jsx(jl,{size:16})})]}),s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:Zt.commands.slot}),s.jsx("code",{children:`${us} 3`}),s.jsx("button",{className:"icon-button",onClick:()=>Tl(`${us} 3`),title:"Copy command",type:"button",children:s.jsx(jl,{size:16})})]})]})]})]}):Vl?s.jsx(tM,{hubUrl:k,devices:C,launchRequest:de}):qs?s.jsx(iN,{hubUrl:k,devices:Je,localFeatureAccess:Yt,upgradeNotice:yi,remoteDirectory:Rn,onRemoteDirectoryChange:es,targetMode:$s,selectedTargetIds:is,onTargetModeChange:fu,onTargetToggle:x=>Fa(N=>N.includes(x)?N.filter(I=>I!==x):[...N,x]),filePickerRef:Hl,folderPickerRef:$l,onBrowserFileImport:x=>{ni(x)},onBrowserFolderImport:x=>{ni(x)},onNotice:Oe,onTransferChange:x=>{if(!x){ss(null);return}const N=x.state==="failed"||x.state==="partially-failed"||x.state==="cancelled"?"failed":x.state==="completed"?"queued":x.state==="sending"?"sending":"reading";ss({id:x.id,status:N,progress:x.progress,message:x.message}),["completed","partially-failed","failed","cancelled"].includes(x.state)&&window.setTimeout(()=>ss(I=>I?.id===x.id?null:I),4500)}}):nr?s.jsx(Jy,{session:a,currentProductKey:"livedesk",appVersion:"",onSignIn:Ln}):Ul?s.jsx(S1,{hubUrl:k,runtimeRole:j?.runtimeRole||"hub",runtimeDeviceId:j?.deviceId||"",sessionAccessToken:a?.access_token||"",pin:s.jsxs(j1,{children:[s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card settings-pairing-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Pair a workstation"}),s.jsx("h3",{children:"Connect another local PC"})]}),s.jsx(tn,{size:20})]}),s.jsxs("div",{className:"settings-pin-display",children:[s.jsx("span",{children:"Hub PIN"}),s.jsx("strong",{children:fc}),s.jsxs("button",{className:"text-button ghost compact",onClick:Ns,disabled:!j?.started||je==="pin",type:"button",children:[s.jsx(Ls,{size:15}),je==="pin"?"Creating":"New PIN"]})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Hub status"}),s.jsx("h3",{children:Es})]}),s.jsx("span",{className:`settings-status-dot state-${Es}`})]}),s.jsxs("dl",{className:"settings-facts",children:[s.jsx("dt",{children:"Address"}),s.jsx("dd",{children:k||"-"}),s.jsx("dt",{children:"Connected workstations"}),s.jsxs("dd",{children:[Ms,"/",Xr]}),s.jsx("dt",{children:"Sync access"}),s.jsx("dd",{children:j?.started?"Local app ready":"Start Hub first"}),s.jsx("dt",{children:"Plan"}),s.jsx("dd",{children:br})]}),s.jsxs("div",{className:"settings-action-row",children:[s.jsxs("button",{className:"text-button primary",onClick:()=>$a({takeover:!0,requestLocalAccess:!0}),disabled:!a||je==="host",type:"button",children:[je==="host"?s.jsx("span",{className:"sync-server-spinner","aria-hidden":"true"}):s.jsx(Wd,{size:16}),je==="host"?"Syncing…":"Sync access"]}),s.jsxs("button",{className:"text-button buy",onClick:()=>ai(qt==="ltd"?"pro":"ltd"),disabled:je==="checkout"||qt==="pro",type:"button",children:[s.jsx(Eo,{size:16}),cc]})]})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"File transfer"}),s.jsx("h3",{children:"Client destination folder"})]}),s.jsx(Do,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Remote folder"}),s.jsx("input",{value:Rn,onChange:x=>es(x.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),s.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:s.jsx(C1,{children:s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Wall stream"}),s.jsx("h3",{children:"Frame delivery"})]}),s.jsx(tu,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Frame mode"}),s.jsx("select",{value:Ie.frameMode,onChange:x=>ua({frameMode:qh(x.target.value)}),children:Jd.map(x=>s.jsxs("option",{value:x.id,children:[x.label," - ",x.detail]},x.id))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"H.264 decode"}),s.jsx("select",{value:Ie.h264DecodeAcceleration,onChange:x=>ua({h264DecodeAcceleration:mf(x.target.value)}),children:Uh.map(x=>s.jsx("option",{value:x.id,children:x.label},x.id))})]}),s.jsxs("div",{className:"settings-field-grid",children:[s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"FPS"}),s.jsx("select",{value:Ie.fps,onChange:x=>ua({fps:Vh(x.target.value,Ie.frameMode)}),children:xp.filter(x=>x<=hb(Ie.frameMode)).map(x=>s.jsx("option",{value:x,children:x},x))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:ut?"Atlas tile":"Resolution"}),s.jsx("select",{value:ut?Ca:ca,onChange:x=>ut?da(x.target.value):ri(x.target.value),children:(ut?gh:ef).map(x=>s.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Quality"}),s.jsx("select",{value:Ie.quality,onChange:x=>ua({quality:gs(x.target.value,20,95,ha.quality)}),children:Ty.map(x=>s.jsx("option",{value:x,children:x},x))})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Wall behavior"}),s.jsx("h3",{children:"Visibility and load"})]}),s.jsx(ln,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:Ie.autoStartLive,onChange:x=>ua({autoStartLive:x.target.checked})}),s.jsx("span",{children:"Auto live on connected screens"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:Ie.visibleOnlyLive,onChange:x=>ua({visibleOnlyLive:x.target.checked})}),s.jsx("span",{children:"Stream visible tiles first"})]}),!ut&&s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:Ie.adaptiveSizeByWall,onChange:x=>ua({adaptiveSizeByWall:x.target.checked})}),s.jsx("span",{children:"Fit stream size to Wall"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:Ie.adaptiveLoadShedding,onChange:x=>ua({adaptiveLoadShedding:x.target.checked})}),s.jsx("span",{children:"Reduce FPS under load"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:Ie.showScreenStatus,onChange:x=>ua({showScreenStatus:x.target.checked})}),s.jsx("span",{children:"Screen status overlay"})]}),s.jsxs("div",{className:"settings-summary",children:[s.jsx("span",{children:mc.label}),s.jsxs("strong",{children:[_n.maxWidth,"x",_n.maxHeight," / ",mn,"fps"]})]}),s.jsxs("button",{className:"settings-reset",onClick:()=>fi(ha),type:"button",children:[s.jsx(Kc,{size:15})," Reset Wall settings"]})]})]})}),control:s.jsx(k1,{children:s.jsxs("div",{className:"settings-section-grid",children:[s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Control stream"}),s.jsx("h3",{children:"Low-latency delivery"})]}),s.jsx(Yd,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Frame mode"}),s.jsx("select",{value:ft.frameMode,onChange:x=>zt({frameMode:Gh(x.target.value)}),children:zM.map(x=>s.jsx("option",{value:x.id,children:x.label},x.id))})]}),ft.frameMode==="mode3-h264-hw"&&s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"H.264 decode"}),s.jsx("select",{value:ft.h264DecodeAcceleration,onChange:x=>zt({h264DecodeAcceleration:mf(x.target.value)}),children:Uh.map(x=>s.jsx("option",{value:x.id,children:x.label},x.id))})]}),s.jsxs("div",{className:"settings-field-grid",children:[s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"FPS"}),s.jsx("select",{value:ft.fps,onChange:x=>zt({fps:gs(x.target.value,20,60,_a.fps)}),children:IM.filter(x=>ft.frameMode==="mode3-h264-hw"||x<=30).map(x=>s.jsx("option",{value:x,children:x},x))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Resolution"}),s.jsx("select",{value:ii,onChange:x=>uo(x.target.value),children:ph.filter(x=>ft.frameMode==="mode3-h264-hw"||x.width<=1920).map(x=>s.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),ft.frameMode==="mode3-h264-hw"&&s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Quality"}),s.jsx("select",{value:ft.quality,onChange:x=>zt({quality:gs(x.target.value,20,95,_a.quality)}),children:Ty.map(x=>s.jsx("option",{value:x,children:x},x))})]})]}),s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Control behavior"}),s.jsx("h3",{children:"Session display"})]}),s.jsx(tn,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:ft.showScreenStatus,onChange:x=>zt({showScreenStatus:x.target.checked})}),s.jsx("span",{children:"Screen status overlay"})]}),s.jsxs("div",{className:"settings-summary control",children:[s.jsx("span",{children:ft.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":"Mode 3 H.264"}),s.jsxs("strong",{children:[Gs.maxWidth,"x",Gs.maxHeight," / ",ar,"fps"]})]}),s.jsxs("button",{className:"settings-reset",onClick:()=>ts(_a),type:"button",children:[s.jsx(Kc,{size:15})," Reset Control settings"]})]})]})}),agent:s.jsx(A1,{hubUrl:k}),captureGallery:s.jsx(lM,{hubUrl:k,onToast:Oe}),advancedExtras:s.jsxs("section",{className:"settings-section-card",children:[s.jsxs("div",{className:"settings-section-heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Connection commands"}),s.jsx("h3",{children:"Developer setup"})]}),s.jsx(jl,{size:20})]}),s.jsxs("div",{className:"settings-command-list",children:[s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Client"}),s.jsx("code",{children:us}),s.jsx("button",{className:"icon-button",onClick:()=>Tl(us),title:"Copy client command",type:"button",children:s.jsx(jl,{size:16})})]}),s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Slot example"}),s.jsx("code",{children:`${us} 3`}),s.jsx("button",{className:"icon-button",onClick:()=>Tl(`${us} 3`),title:"Copy slot command",type:"button",children:s.jsx(jl,{size:16})})]}),s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Hub"}),s.jsx("code",{children:ds}),s.jsx("button",{className:"icon-button",onClick:()=>Tl(ds),title:"Copy Hub command",type:"button",children:s.jsx(jl,{size:16})})]})]})]})}):ql?s.jsxs("section",{className:"pricing-page",children:[s.jsxs("header",{className:"pricing-header",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"pricing-eyebrow",children:[s.jsx(jh,{size:15})," LiveDesk plans"]}),s.jsx("h2",{children:"Choose the plan that fits your wall"}),s.jsx("p",{children:"Start free with a local screen wall. Upgrade when you need ad-free monitoring, more workstations, or commercial controls."})]}),s.jsx("button",{className:"pricing-close",onClick:()=>Ya("wall"),title:"Close pricing",type:"button",children:s.jsx(zs,{size:18})})]}),s.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[s.jsx("span",{children:"Current plan"}),s.jsx("strong",{children:Wl.name}),s.jsxs("small",{children:[Je.length,"/",LM(Ws)," connected devices"]})]}),s.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[s.jsxs("article",{className:`pricing-plan-card ${qt==="free"?"current":""}`,children:[s.jsxs("div",{className:"pricing-plan-topline",children:[s.jsx("span",{className:"pricing-plan-badge free",children:"Free"}),s.jsx("strong",{children:"$0"})]}),s.jsx("p",{className:"pricing-plan-audience",children:Al.free.audience}),s.jsx("h3",{children:"Monitor your local wall"}),s.jsx("p",{children:Al.free.note}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx(In,{size:16})," Up to ",Gc," devices"]}),s.jsxs("li",{children:[s.jsx(In,{size:16})," Live view and local control"]}),s.jsxs("li",{children:[s.jsx(In,{size:16})," Standard ad-supported banner"]})]}),s.jsx("span",{className:"pricing-current-label",children:qt==="free"?"Current plan":"Included for everyone"})]}),s.jsxs("article",{className:`pricing-plan-card featured ${qt==="ltd"?"current":""}`,children:[s.jsxs("div",{className:"pricing-plan-topline",children:[s.jsxs("span",{className:"pricing-plan-badge plus",children:[s.jsx(l0,{size:14})," Plus"]}),s.jsx("strong",{children:"$5"})]}),s.jsx("p",{className:"pricing-plan-audience",children:Al.ltd.audience}),s.jsx("h3",{children:"Ad-free monitoring"}),s.jsx("p",{children:"More room for personal AI workstations without the standard banner."}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx(In,{size:16})," Up to ",Vc," devices"]}),s.jsxs("li",{children:[s.jsx(In,{size:16})," No standard ad banner"]}),s.jsxs("li",{children:[s.jsx(In,{size:16})," ",Al.ltd.ltd]})]}),s.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>ai("ltd"):Ln,disabled:qt!=="free"||je==="checkout"||je==="auth"||r||$,type:"button",children:[s.jsx(Eo,{size:16}),qt==="free"?a?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),s.jsxs("article",{className:`pricing-plan-card pro ${qt==="pro"?"current":""}`,children:[s.jsxs("div",{className:"pricing-plan-topline",children:[s.jsxs("span",{className:"pricing-plan-badge pro",children:[s.jsx(Bt,{size:14})," Pro"]}),s.jsx("strong",{children:"$15"})]}),s.jsx("p",{className:"pricing-plan-audience",children:Al.pro.audience}),s.jsx("h3",{children:"For serious operations"}),s.jsx("p",{children:"Commercial-ready monitoring for larger AI labs, studios, and teams."}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx(In,{size:16})," 30+ workstation walls"]}),s.jsxs("li",{children:[s.jsx(In,{size:16})," Commercial use included"]}),s.jsxs("li",{children:[s.jsx(In,{size:16})," ",Al.pro.ltd]})]}),s.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>ai("pro"):Ln,disabled:qt==="pro"||je==="checkout"||je==="auth"||r||$,type:"button",children:[s.jsx(Eo,{size:16}),qt==="pro"?"Pro active":a?"Choose Pro":"Sign in for Pro"]})]})]}),s.jsxs("section",{className:"pricing-includes",children:[s.jsxs("div",{children:[s.jsx(tn,{size:17}),s.jsx("span",{children:"Screen wall"}),s.jsx("strong",{children:"120+ slots"})]}),s.jsxs("div",{children:[s.jsx(Yd,{size:17}),s.jsx("span",{children:"Focused control"}),s.jsx("strong",{children:"Local-first"})]}),s.jsxs("div",{children:[s.jsx(ax,{size:17}),s.jsx("span",{children:"Remote audio"}),s.jsx("strong",{children:"Available"})]}),s.jsxs("div",{children:[s.jsx(Do,{size:17}),s.jsx("span",{children:"File transfer"}),s.jsx("strong",{children:"Included"})]})]}),s.jsxs("p",{className:"pricing-note",children:[s.jsx(In,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),s.jsxs("button",{className:"pricing-primary-cta",onClick:a?()=>ai(qt==="ltd"?"pro":"ltd"):Ln,disabled:vl,type:"button",children:[s.jsx(Eo,{size:18}),gl]})]}):s.jsx(s.Fragment,{children:s.jsxs("section",{className:`monitor-layout ${En?"dock-collapsed":""}`,children:[s.jsxs("section",{ref:Qr,className:`screen-wall-panel ${Uo?"drop-active":""}`,onClick:x=>{x.currentTarget===x.target&&Ri()},onDragEnter:x=>{x.preventDefault(),Hs(!0)},onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy"},onDragLeave:x=>{x.currentTarget===x.target&&Hs(!1)},onDrop:ic,children:[Un.length>0&&s.jsx("canvas",{ref:rr,className:"atlas-source-canvas",width:ki?.width||1920,height:ki?.height||1080,"aria-hidden":"true"}),et?s.jsx("section",{className:"control-focus",children:s.jsxs("div",{className:"control-wall",children:[Me&&_i.length>1&&s.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:_i.map(x=>s.jsxs("button",{className:x.index===dr?"active":"",onClick:()=>gt(Me.deviceId,x.index),title:XM(x),type:"button",children:[s.jsx("span",{children:x.name||`Display ${x.index+1}`}),x.width>0&&x.height>0&&s.jsxs("small",{children:[x.width,"x",x.height]})]},x.index))}),Me?s.jsx(Sh,{device:Me,frame:Te,selected:!1,controlEnabled:bs&&Le&&ur,showStatus:ft.showScreenStatus,monitorIndex:Da(Vt[Me.deviceId],fa(Me)),monitorCount:fa(Me),onSelect:()=>{},onFocusDevice:()=>Q(Me.deviceId),onOpenControl:()=>Ua(Me.deviceId),onCycleMonitor:x=>pn(Me.deviceId,x),onCanvasReady:tl,sendInput:Mi,presentationReady:cu},Me.deviceId):s.jsxs("div",{className:"control-empty",children:[s.jsx(tn,{size:30}),s.jsx("strong",{children:"No workstation"}),s.jsx("span",{children:"Open a workstation from the Wall."})]}),Me&&Wo&&s.jsxs("div",{className:"control-connection-overlay",role:"alert",children:[s.jsx(Bt,{size:22,"aria-hidden":"true"}),s.jsx("strong",{children:"Accessibility permission required"}),s.jsx("small",{children:"On the Mac, allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client."})]}),Me&&!Wo&&!cu&&s.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[D!=="error"&&s.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),s.jsx("strong",{children:D==="error"?"Connection failed":"Connecting"}),s.jsx("small",{children:D==="error"?"See the notification for details. Reopen Control to retry.":Zs||ge?"Control stream is recovering. See the notification for details.":or==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):ut?s.jsx("div",{className:`screen-wall atlas-slot-wall size-${it}`,onClick:x=>{x.currentTarget===x.target&&Ri()},children:Zr.map((x,N)=>x?s.jsx(Sh,{device:x,frame:Ai.get(x.deviceId),selected:sr.has(x.deviceId),controlEnabled:!1,showStatus:Ie.showScreenStatus,monitorIndex:Da(Vt[x.deviceId],fa(x)),monitorCount:fa(x),onSelect:()=>so(x.deviceId),onFocusDevice:()=>ao(x.deviceId),onOpenControl:()=>Ua(x.deviceId),onCycleMonitor:I=>pn(x.deviceId,I),onCanvasReady:Hc({mode4Enabled:ut,directMode4WallEnabled:ls,isMac:Ki(x.platform)})==="direct"?Jn:sl,sendInput:Mi,updateIndicator:At(x.deviceId),presentationReady:Ie.autoStartLive&&xa.includes(x.deviceId)?Tt.has(x.deviceId):void 0,showPresentationSpinner:Ie.autoStartLive&&xa.includes(x.deviceId)},x.deviceId):s.jsx(By,{index:N},`slot-${N}`))}):s.jsx("div",{className:`screen-wall size-${it}`,onClick:x=>{x.currentTarget===x.target&&Ri()},children:Zr.map((x,N)=>x?s.jsx(Sh,{device:x,frame:Ai.get(x.deviceId),selected:sr.has(x.deviceId),controlEnabled:bs&&Le&&ur&&Me?.deviceId===x.deviceId,showStatus:Ie.showScreenStatus,monitorIndex:Da(Vt[x.deviceId],fa(x)),monitorCount:fa(x),onSelect:()=>so(x.deviceId),onFocusDevice:()=>ao(x.deviceId),onOpenControl:()=>Ua(x.deviceId),onCycleMonitor:I=>pn(x.deviceId,I),onCanvasReady:Jn,sendInput:Mi,updateIndicator:At(x.deviceId),presentationReady:Ie.autoStartLive&&xa.includes(x.deviceId)?Tt.has(x.deviceId):void 0,showPresentationSpinner:Ie.autoStartLive&&xa.includes(x.deviceId)},x.deviceId):s.jsx(By,{index:N},`slot-${N}`))}),s.jsx(bT,{visible:bu&&!et})]}),!Ul&&s.jsxs("aside",{className:`right-dock actions-mode ${En?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[s.jsx("button",{className:"dock-toggle",onClick:()=>Xi(x=>!x),"aria-label":En?"Show control panel":"Hide control panel",title:En?"Show control panel":"Hide control panel",type:"button",children:En?s.jsx(Xy,{size:18}):s.jsx(Xh,{size:18})}),!En&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"action-dock",children:[s.jsxs("div",{className:"action-context",children:[s.jsx("span",{children:et?"Control target":wr>0?"Selection":"No selection"}),s.jsx("strong",{children:co})]}),s.jsx("input",{ref:Go,className:"hidden-file-input",type:"file",multiple:!0,onChange:x=>{x.currentTarget.files&&Di(x.currentTarget.files),x.currentTarget.value=""}}),s.jsxs("div",{className:"action-grid",children:[s.jsxs("button",{className:"action-tile primary",onClick:()=>{Lt()},disabled:!wi||!!Re,type:"button",title:"Open this workstation's screen",children:[Re==="view-screen"?s.jsx($r,{className:"spin",size:21}):s.jsx(sx,{size:21}),s.jsx("span",{children:Re==="view-screen"?"Opening...":"View Screen"})]}),s.jsxs("button",{className:`action-tile ${Le?"active":""}`,onClick:()=>{if(Me){if(et&&Le){ze(!1),Oe("Remote control paused. Screen viewing stays on.");return}Ua(Me.deviceId)}},disabled:!bs||!!Re,title:Wo?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":bs?ur?"Keyboard and mouse control is ready":"Waiting for the current Control capture session":"Remote control is not available on this workstation",type:"button",children:[s.jsx(Yd,{size:21}),s.jsx("span",{children:Le&&Ni==="connecting"?"Connecting...":"Remote Control"})]}),s.jsxs("button",{className:`action-tile ${ue?"active":""}`,onClick:()=>{ja()},disabled:!Su||!!Re,type:"button",title:Jr?ue?"Stop hearing this workstation":"Hear this workstation":"Audio is not available on this workstation",children:[Re==="audio"?s.jsx($r,{className:"spin",size:21}):s.jsx(ax,{size:21}),s.jsx("span",{children:Re==="audio"?"Updating...":ue?"Mute Audio":"Hear Audio"})]}),s.jsxs("button",{className:"action-tile",onClick:()=>{Oe(`Choose files to send to ${co}.`),Go.current?.click()},disabled:!!Re||!Yt||(et?!Me:Pa.length===0),type:"button",title:"Choose files and send them to the selected workstation",children:[s.jsx(Do,{size:21}),s.jsx("span",{children:"Send Files"})]}),s.jsxs("button",{className:"action-tile",onClick:()=>{qa("restart")},disabled:!Me||!Yt||!Yl||!!Re,type:"button",title:Yl?"Restart the selected workstation":"Restart requires a current LiveDesk Client",children:[Re==="restart"?s.jsx($r,{className:"spin",size:21}):s.jsx(Kc,{size:21}),s.jsx("span",{children:Re==="restart"?"Sending...":"Restart"})]}),s.jsxs("button",{className:`action-tile ${pe?"active":""}`,onClick:()=>ke(x=>!x),disabled:!Me||!Yt||!Yl||!!Re,type:"button",title:Yl?"Lock, sleep, or shut down this workstation":"Power options require a current LiveDesk Client","aria-expanded":pe,children:[s.jsx(ix,{size:21}),s.jsx("span",{children:"Power Options"})]}),s.jsxs("button",{className:"action-tile",onClick:Mu,disabled:!Me||!Yt||!xu||!!Re,type:"button",title:xu?"Open the command runner for this workstation":"Command runner requires a current LiveDesk Client",children:[s.jsx(qc,{size:21}),s.jsx("span",{children:"Run Command"})]})]}),pe&&Me&&s.jsxs("div",{className:"power-action-menu",role:"group","aria-label":`Power options for ${ma(Me)}`,children:[s.jsxs("button",{type:"button",onClick:()=>{qa("lock")},children:[s.jsx(Ls,{size:16}),"Lock"]}),s.jsxs("button",{type:"button",onClick:()=>{qa("sleep")},children:[s.jsx(o0,{size:16}),"Sleep"]}),s.jsxs("button",{type:"button",className:"danger",onClick:()=>{qa("shutdown")},children:[s.jsx(ix,{size:16}),"Shut Down"]})]})]}),Me&&rs&&s.jsxs("section",{className:"side-panel selected-panel",children:[s.jsxs("div",{className:"machine-detail-head",children:[s.jsxs("div",{className:"panel-title",children:[s.jsx(tn,{size:17}),s.jsx("h2",{children:"Machine detail"})]}),s.jsx("span",{className:`machine-health state-${rs.state}`,children:rs.label})]}),s.jsxs("div",{className:"machine-title",children:[s.jsx("strong",{children:ma(Me)}),s.jsx("span",{children:rs.role})]}),s.jsx("div",{className:"machine-metric-grid",children:rs.metrics.map(x=>s.jsxs("article",{className:`machine-metric state-${x.state}`,children:[s.jsx("span",{children:x.label}),s.jsx("strong",{children:x.value}),s.jsx("small",{children:x.detail}),x.ratio!==void 0&&s.jsx("i",{children:s.jsx("b",{style:{width:`${Math.round(x.ratio*100)}%`}})})]},x.id))}),s.jsxs("section",{className:"machine-section",children:[s.jsxs("div",{className:"machine-section-title",children:[s.jsx(ln,{size:15}),s.jsx("span",{children:"Stream"})]}),s.jsxs("dl",{className:"facts compact",children:[s.jsx("dt",{children:"Frames"}),s.jsx("dd",{children:rc}),s.jsx("dt",{children:et?"Control RX":si?"Atlas RX":"Wall RX"}),s.jsx("dd",{children:Ou}),s.jsx("dt",{children:"Painted"}),s.jsx("dd",{children:fl}),s.jsx("dt",{children:et?"Encoded changes":"Visual samples"}),s.jsx("dd",{children:ml}),s.jsx("dt",{children:"Decoder"}),s.jsx("dd",{children:lc}),s.jsx("dt",{children:"Decoder IO"}),s.jsx("dd",{children:Af}),s.jsx("dt",{children:"Canvas"}),s.jsx("dd",{children:Tu}),s.jsx("dt",{children:"Control buffer"}),s.jsx("dd",{children:Nf}),s.jsx("dt",{children:"Browser RAF"}),s.jsx("dd",{children:Eu}),s.jsx("dt",{children:"Latency"}),s.jsx("dd",{children:mr}),s.jsx("dt",{children:"Cadence"}),s.jsx("dd",{children:hr}),s.jsx("dt",{children:"Source send"}),s.jsx("dd",{children:oc}),s.jsx("dt",{children:"Packet mix"}),s.jsx("dd",{children:Li}),s.jsx("dt",{children:"Receive gap"}),s.jsx("dd",{children:lo}),s.jsx("dt",{children:"Paint gap"}),s.jsx("dd",{children:Ru}),s.jsx("dt",{children:"Seq gap"}),s.jsx("dd",{children:pr}),s.jsx("dt",{children:"Selected"}),s.jsx("dd",{children:pl}),s.jsx("dt",{children:"Requested"}),s.jsx("dd",{children:oo}),s.jsx("dt",{children:"Mode"}),s.jsx("dd",{children:hl}),s.jsx("dt",{children:"Chunk"}),s.jsx("dd",{children:_u}),s.jsx("dt",{children:"Size"}),s.jsx("dd",{children:Du}),s.jsx("dt",{children:"Native"}),s.jsx("dd",{children:ro}),s.jsx("dt",{children:"Monitor"}),s.jsx("dd",{children:zi}),s.jsx("dt",{children:"Source"}),s.jsx("dd",{children:Ii}),s.jsx("dt",{children:"Input"}),s.jsx("dd",{children:Lu}),s.jsx("dt",{children:"Audio"}),s.jsx("dd",{children:vr}),et&&s.jsxs(s.Fragment,{children:[s.jsx("dt",{children:"Visual feedback"}),s.jsx("dd",{children:zu})]})]})]}),s.jsxs("section",{className:"machine-section",children:[s.jsxs("div",{className:"machine-section-title",children:[s.jsx(qc,{size:15}),s.jsx("span",{children:"Local services"})]}),s.jsx("div",{className:"tool-probe-list",children:rs.tools.map(x=>s.jsxs("span",{className:`tool-probe state-${x.status}`,children:[s.jsx("b",{children:x.label}),s.jsx("em",{children:x.detail})]},x.id))})]}),s.jsxs("section",{className:"machine-section",children:[s.jsxs("div",{className:"machine-section-title",children:[s.jsx(Bo,{size:15}),s.jsx("span",{children:"Workload"})]}),s.jsxs("div",{className:"workload-card",children:[s.jsx("strong",{children:rs.taskLabel}),s.jsx("span",{children:rs.taskStatus}),rs.taskSummary&&s.jsx("p",{children:rs.taskSummary})]})]}),s.jsxs("div",{className:"machine-section",children:[s.jsxs("div",{className:"machine-section-title",children:[s.jsx(nf,{size:15}),s.jsx("span",{children:"System"})]}),s.jsxs("dl",{className:"facts compact",children:[s.jsx("dt",{children:"Platform"}),s.jsxs("dd",{children:[Me.platform||"-"," ",Me.arch||""]}),s.jsx("dt",{children:"Release"}),s.jsx("dd",{children:La(Me.status,"release")||"-"}),s.jsx("dt",{children:"Uptime"}),s.jsx("dd",{children:xb(sn(Me.status,"uptimeSec"))}),s.jsx("dt",{children:"Last seen"}),s.jsx("dd",{children:kh(Me.lastSeenAt||Me.connectedAt)}),s.jsx("dt",{children:"Agent"}),s.jsx("dd",{children:Me.agentVersion||"-"}),s.jsx("dt",{children:"Address"}),s.jsx("dd",{children:Me.remoteAddress||"-"})]})]}),s.jsxs("button",{className:"text-button full",onClick:()=>{Lt()},disabled:!wi||!!Re,type:"button",children:[s.jsx(sx,{size:16}),"View screen"]})]})]})]})]})})]}),Hn&&s.jsxs("aside",{className:`transfer-bar state-${Hn.status}`,"aria-live":"polite",children:[s.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:Hn.status==="queued"?s.jsx(In,{size:18}):Hn.status==="failed"?s.jsx(zs,{size:18}):s.jsx(Yy,{size:18})}),s.jsxs("div",{className:"transfer-bar-copy",children:[s.jsx("p",{children:Hn.message}),s.jsx("div",{className:"transfer-bar-track",children:s.jsx("span",{style:{width:`${Math.max(0,Math.min(100,Hn.progress))}%`}})})]}),s.jsxs("strong",{children:[Math.max(0,Math.min(100,Hn.progress)),"%"]})]}),wn&&s.jsxs("aside",{className:`livedesk-toast tone-${wn.tone}`,role:wn.tone==="error"?"alert":"status","aria-live":wn.tone==="error"?"assertive":"polite","aria-busy":wn.tone==="progress",children:[wn.tone==="progress"&&s.jsx("span",{className:"livedesk-toast-spinner","aria-hidden":"true"}),s.jsx("span",{children:wn.message}),s.jsx("button",{className:"livedesk-toast-close",onClick:()=>Oe(""),type:"button","aria-label":"Dismiss notification",title:"Dismiss notification",children:s.jsx(zs,{size:15})})]})]})}function jT(){if(typeof window>"u")return[];const n=window.location.origin;return window.location.port==="5179"?[n]:["http://127.0.0.1:5179"]}function CT(){const[a,r]=u.useState(null);return u.useEffect(()=>{let l=!1,c=!1;const d=async()=>{for(const v of jT())try{const g=await fetch(`${v}/api/runtime`,{cache:"no-store"});if(!g.ok)continue;const y=(await g.json()).role==="hub"?"hub":"client";c=!0,l||r(y);return}catch{}};d();const m=window.setInterval(()=>{d()},1e3),p=window.setTimeout(()=>{!l&&!c&&r("client")},2500);return()=>{l=!0,window.clearInterval(m),window.clearTimeout(p)}},[null]),a?a==="client"?s.jsx(dj,{}):s.jsx(ST,{}):s.jsxs("main",{className:"runtime-role-boot","aria-busy":"true","aria-label":"Starting LiveDesk",children:[s.jsx("span",{className:"runtime-role-boot-mark","aria-hidden":"true"}),s.jsx("strong",{children:"Starting LiveDesk"}),s.jsx("p",{children:"Loading this computer's assigned role..."})]})}g0.createRoot(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(CT,{})}));
|