livedesk 0.1.402 → 0.1.404
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{r as LS,a as u,M as Dc,S as Bt,R as Ro,B as _S,P as Hm,X as Ya,b as Bc,C as Ii,F as ey,L as Ts,A as $x,c as zS,d as ty,E as ny,T as IS,D as Vh,e as Fn,f as OS,g as HS,h as BS,i as FS,j as Tl,k as an,l as Hd,m as ko,n as Ux,o as El,p as qx,q as pn,s as Gx,t as Vx,u as PS,v as $S,H as Nl,W as Rl,w as US,x as qS,y as Ao,K as No,z as Wx,G as Yx,I as Bd,J as GS,N as Fc,O as Es,Q as jo,U as VS,V as WS,Y as YS,Z as Wh,_ as Lc,$ as Yh,a0 as KS,a1 as Kh,a2 as Kx,a3 as QS,a4 as Js,a5 as ay,a6 as Qh,a7 as Zd,a8 as Pc,a9 as Ed,aa as XS,ab as Qx,ac as ZS,ad as Xx,ae as JS,af as e0,ag as Sh,ah as t0,ai as n0,aj as a0,ak as s0,al as i0,am as r0,an as l0,ao as sy,ap as o0,aq as c0,ar as Rd,as as Dd,at as u0,au as d0,av as Bm,aw as xl,ax as f0,ay as iy,az as Zx,aA as m0,aB as h0}from"./icons-HeE5A4Vk.js";import{r as Jx}from"./react-DW3yB5LY.js";import{c as p0}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 Fm={exports:{}},Sc={};var ry;function g0(){if(ry)return Sc;ry=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 Sc.Fragment=a,Sc.jsx=r,Sc.jsxs=r,Sc}var ly;function v0(){return ly||(ly=1,Fm.exports=g0()),Fm.exports}var s=v0(),Pm={exports:{}},Cc={},$m={exports:{}},Um={};var oy;function y0(){return oy||(oy=1,(function(n){function a(I,Q){var q=I.length;I.push(Q);e:for(;0<q;){var V=q-1>>>1,ce=I[V];if(0<c(ce,Q))I[V]=Q,I[q]=ce,q=V;else break e}}function r(I){return I.length===0?null:I[0]}function l(I){if(I.length===0)return null;var Q=I[0],q=I.pop();if(q!==Q){I[0]=q;e:for(var V=0,ce=I.length,be=ce>>>1;V<be;){var X=2*(V+1)-1,$=I[X],ue=X+1,he=I[ue];if(0>c($,q))ue<ce&&0>c(he,$)?(I[V]=he,I[ue]=q,V=ue):(I[V]=$,I[X]=q,V=X);else if(ue<ce&&0>c(he,q))I[V]=he,I[ue]=q,V=ue;else break e}}return Q}function c(I,Q){var q=I.sortIndex-Q.sortIndex;return q!==0?q:I.id-Q.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 g=[],v=[],w=1,x=null,b=3,C=!1,j=!1,A=!1,N=!1,k=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function U(I){for(var Q=r(v);Q!==null;){if(Q.callback===null)l(v);else if(Q.startTime<=I)l(v),Q.sortIndex=Q.expirationTime,a(g,Q);else break;Q=r(v)}}function O(I){if(A=!1,U(I),!j)if(r(g)!==null)j=!0,Y||(Y=!0,B());else{var Q=r(v);Q!==null&&K(O,Q.startTime-I)}}var Y=!1,_=-1,D=5,ne=-1;function G(){return N?!0:!(n.unstable_now()-ne<D)}function te(){if(N=!1,Y){var I=n.unstable_now();ne=I;var Q=!0;try{e:{j=!1,A&&(A=!1,T(_),_=-1),C=!0;var q=b;try{t:{for(U(I),x=r(g);x!==null&&!(x.expirationTime>I&&G());){var V=x.callback;if(typeof V=="function"){x.callback=null,b=x.priorityLevel;var ce=V(x.expirationTime<=I);if(I=n.unstable_now(),typeof ce=="function"){x.callback=ce,U(I),Q=!0;break t}x===r(g)&&l(g),U(I)}else l(g);x=r(g)}if(x!==null)Q=!0;else{var be=r(v);be!==null&&K(O,be.startTime-I),Q=!1}}break e}finally{x=null,b=q,C=!1}Q=void 0}}finally{Q?B():Y=!1}}}var B;if(typeof R=="function")B=function(){R(te)};else if(typeof MessageChannel<"u"){var xe=new MessageChannel,se=xe.port2;xe.port1.onmessage=te,B=function(){se.postMessage(null)}}else B=function(){k(te,0)};function K(I,Q){_=k(function(){I(n.unstable_now())},Q)}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(I){I.callback=null},n.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<I?Math.floor(1e3/I):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(I){switch(b){case 1:case 2:case 3:var Q=3;break;default:Q=b}var q=b;b=Q;try{return I()}finally{b=q}},n.unstable_requestPaint=function(){N=!0},n.unstable_runWithPriority=function(I,Q){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var q=b;b=I;try{return Q()}finally{b=q}},n.unstable_scheduleCallback=function(I,Q,q){var V=n.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?V+q:V):q=V,I){case 1:var ce=-1;break;case 2:ce=250;break;case 5:ce=1073741823;break;case 4:ce=1e4;break;default:ce=5e3}return ce=q+ce,I={id:w++,callback:Q,priorityLevel:I,startTime:q,expirationTime:ce,sortIndex:-1},q>V?(I.sortIndex=q,a(v,I),r(g)===null&&I===r(v)&&(A?(T(_),_=-1):A=!0,K(O,q-V))):(I.sortIndex=ce,a(g,I),j||C||(j=!0,Y||(Y=!0,B()))),I},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(I){var Q=b;return function(){var q=b;b=Q;try{return I.apply(this,arguments)}finally{b=q}}}})(Um)),Um}var cy;function x0(){return cy||(cy=1,$m.exports=y0()),$m.exports}var uy;function b0(){if(uy)return Cc;uy=1;var n=x0(),a=LS(),r=Jx();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 g(e){if(d(e)!==e)throw Error(l(188))}function v(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 g(f),e;if(h===o)return g(f),t;h=h.sibling}throw Error(l(188))}if(i.return!==o.return)i=f,o=h;else{for(var S=!1,E=f.child;E;){if(E===i){S=!0,i=f,o=h;break}if(E===o){S=!0,o=f,i=h;break}E=E.sibling}if(!S){for(E=h.child;E;){if(E===i){S=!0,i=h,o=f;break}if(E===o){S=!0,o=h,i=f;break}E=E.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 x=Object.assign,b=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),R=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),G=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function B(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var xe=Symbol.for("react.client.reference");function se(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===xe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case A:return"Fragment";case k:return"Profiler";case N:return"StrictMode";case O:return"Suspense";case Y:return"SuspenseList";case ne:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case R:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case U:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:se(e.type)||"Memo";case D:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var K=Array.isArray,I=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q={pending:!1,data:null,method:null,action:null},V=[],ce=-1;function be(e){return{current:e}}function X(e){0>ce||(e.current=V[ce],V[ce]=null,ce--)}function $(e,t){ce++,V[ce]=e.current,e.current=t}var ue=be(null),he=be(null),ve=be(null),Se=be(null);function _e(e,t){switch($(ve,t),$(he,e),$(ue,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Cv(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Cv(t),e=jv(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}X(ue),$(ue,e)}function re(){X(ue),X(he),X(ve)}function Z(e){e.memoizedState!==null&&$(Se,e);var t=ue.current,i=jv(t,e.type);t!==i&&($(he,e),$(ue,i))}function ze(e){he.current===e&&(X(ue),X(he)),Se.current===e&&(X(Se),yc._currentValue=q)}var De,ae;function fe(e){if(De===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);De=t&&t[1]||"",ae=-1<i.stack.indexOf(`
|
|
1
|
+
import{r as _S,a as u,M as Lc,S as Bt,R as Do,B as zS,P as Bm,X as Ya,b as Fc,C as Ii,F as ty,L as Ts,A as Ux,c as IS,d as ny,E as ay,T as OS,D as Wh,e as Fn,f as HS,g as BS,h as FS,i as PS,j as El,k as an,l as Bd,m as Ao,n as qx,o as Rl,p as Gx,q as pn,s as Vx,t as Wx,u as $S,v as US,H as Ml,W as Dl,w as qS,x as GS,y as No,K as Mo,z as Yx,G as Kx,I as Fd,J as VS,N as Pc,O as Es,Q as ko,U as WS,V as YS,Y as KS,Z as Yh,_ as _c,$ as Kh,a0 as QS,a1 as Qh,a2 as Qx,a3 as XS,a4 as Js,a5 as sy,a6 as Xh,a7 as Jd,a8 as $c,a9 as Rd,aa as ZS,ab as Xx,ac as JS,ad as Zx,ae as e0,af as t0,ag as Ch,ah as n0,ai as a0,aj as s0,ak as i0,al as r0,am as l0,an as o0,ao as iy,ap as c0,aq as u0,ar as Dd,as as Ld,at as d0,au as f0,av as Fm,aw as bl,ax as m0,ay as ry,az as Jx,aA as h0,aB as p0}from"./icons-HeE5A4Vk.js";import{r as eb}from"./react-DW3yB5LY.js";import{c as g0}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 Pm={exports:{}},Cc={};var ly;function v0(){if(ly)return Cc;ly=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 Cc.Fragment=a,Cc.jsx=r,Cc.jsxs=r,Cc}var oy;function y0(){return oy||(oy=1,Pm.exports=v0()),Pm.exports}var s=y0(),$m={exports:{}},jc={},Um={exports:{}},qm={};var cy;function x0(){return cy||(cy=1,(function(n){function a(I,Q){var q=I.length;I.push(Q);e:for(;0<q;){var V=q-1>>>1,ce=I[V];if(0<c(ce,Q))I[V]=Q,I[q]=ce,q=V;else break e}}function r(I){return I.length===0?null:I[0]}function l(I){if(I.length===0)return null;var Q=I[0],q=I.pop();if(q!==Q){I[0]=q;e:for(var V=0,ce=I.length,be=ce>>>1;V<be;){var X=2*(V+1)-1,$=I[X],ue=X+1,he=I[ue];if(0>c($,q))ue<ce&&0>c(he,$)?(I[V]=he,I[ue]=q,V=ue):(I[V]=$,I[X]=q,V=X);else if(ue<ce&&0>c(he,q))I[V]=he,I[ue]=q,V=ue;else break e}}return Q}function c(I,Q){var q=I.sortIndex-Q.sortIndex;return q!==0?q:I.id-Q.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 g=[],v=[],w=1,x=null,b=3,C=!1,j=!1,A=!1,N=!1,k=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function U(I){for(var Q=r(v);Q!==null;){if(Q.callback===null)l(v);else if(Q.startTime<=I)l(v),Q.sortIndex=Q.expirationTime,a(g,Q);else break;Q=r(v)}}function O(I){if(A=!1,U(I),!j)if(r(g)!==null)j=!0,Y||(Y=!0,B());else{var Q=r(v);Q!==null&&K(O,Q.startTime-I)}}var Y=!1,_=-1,D=5,ne=-1;function G(){return N?!0:!(n.unstable_now()-ne<D)}function te(){if(N=!1,Y){var I=n.unstable_now();ne=I;var Q=!0;try{e:{j=!1,A&&(A=!1,T(_),_=-1),C=!0;var q=b;try{t:{for(U(I),x=r(g);x!==null&&!(x.expirationTime>I&&G());){var V=x.callback;if(typeof V=="function"){x.callback=null,b=x.priorityLevel;var ce=V(x.expirationTime<=I);if(I=n.unstable_now(),typeof ce=="function"){x.callback=ce,U(I),Q=!0;break t}x===r(g)&&l(g),U(I)}else l(g);x=r(g)}if(x!==null)Q=!0;else{var be=r(v);be!==null&&K(O,be.startTime-I),Q=!1}}break e}finally{x=null,b=q,C=!1}Q=void 0}}finally{Q?B():Y=!1}}}var B;if(typeof R=="function")B=function(){R(te)};else if(typeof MessageChannel<"u"){var xe=new MessageChannel,se=xe.port2;xe.port1.onmessage=te,B=function(){se.postMessage(null)}}else B=function(){k(te,0)};function K(I,Q){_=k(function(){I(n.unstable_now())},Q)}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(I){I.callback=null},n.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<I?Math.floor(1e3/I):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(I){switch(b){case 1:case 2:case 3:var Q=3;break;default:Q=b}var q=b;b=Q;try{return I()}finally{b=q}},n.unstable_requestPaint=function(){N=!0},n.unstable_runWithPriority=function(I,Q){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var q=b;b=I;try{return Q()}finally{b=q}},n.unstable_scheduleCallback=function(I,Q,q){var V=n.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?V+q:V):q=V,I){case 1:var ce=-1;break;case 2:ce=250;break;case 5:ce=1073741823;break;case 4:ce=1e4;break;default:ce=5e3}return ce=q+ce,I={id:w++,callback:Q,priorityLevel:I,startTime:q,expirationTime:ce,sortIndex:-1},q>V?(I.sortIndex=q,a(v,I),r(g)===null&&I===r(v)&&(A?(T(_),_=-1):A=!0,K(O,q-V))):(I.sortIndex=ce,a(g,I),j||C||(j=!0,Y||(Y=!0,B()))),I},n.unstable_shouldYield=G,n.unstable_wrapCallback=function(I){var Q=b;return function(){var q=b;b=Q;try{return I.apply(this,arguments)}finally{b=q}}}})(qm)),qm}var uy;function b0(){return uy||(uy=1,Um.exports=x0()),Um.exports}var dy;function w0(){if(dy)return jc;dy=1;var n=b0(),a=_S(),r=eb();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 g(e){if(d(e)!==e)throw Error(l(188))}function v(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 g(f),e;if(h===o)return g(f),t;h=h.sibling}throw Error(l(188))}if(i.return!==o.return)i=f,o=h;else{for(var S=!1,E=f.child;E;){if(E===i){S=!0,i=f,o=h;break}if(E===o){S=!0,o=f,i=h;break}E=E.sibling}if(!S){for(E=h.child;E;){if(E===i){S=!0,i=h,o=f;break}if(E===o){S=!0,o=h,i=f;break}E=E.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 x=Object.assign,b=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),R=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),Y=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),ne=Symbol.for("react.activity"),G=Symbol.for("react.memo_cache_sentinel"),te=Symbol.iterator;function B(e){return e===null||typeof e!="object"?null:(e=te&&e[te]||e["@@iterator"],typeof e=="function"?e:null)}var xe=Symbol.for("react.client.reference");function se(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===xe?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case A:return"Fragment";case k:return"Profiler";case N:return"StrictMode";case O:return"Suspense";case Y:return"SuspenseList";case ne:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case R:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case U:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case _:return t=e.displayName||null,t!==null?t:se(e.type)||"Memo";case D:t=e._payload,e=e._init;try{return se(e(t))}catch{}}return null}var K=Array.isArray,I=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,q={pending:!1,data:null,method:null,action:null},V=[],ce=-1;function be(e){return{current:e}}function X(e){0>ce||(e.current=V[ce],V[ce]=null,ce--)}function $(e,t){ce++,V[ce]=e.current,e.current=t}var ue=be(null),he=be(null),ve=be(null),Se=be(null);function _e(e,t){switch($(ve,t),$(he,e),$(ue,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?jv(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=jv(t),e=kv(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}X(ue),$(ue,e)}function re(){X(ue),X(he),X(ve)}function Z(e){e.memoizedState!==null&&$(Se,e);var t=ue.current,i=kv(t,e.type);t!==i&&($(he,e),$(ue,i))}function ze(e){he.current===e&&(X(ue),X(he)),Se.current===e&&(X(Se),xc._currentValue=q)}var Le,ae;function fe(e){if(Le===void 0)try{throw Error()}catch(i){var t=i.stack.trim().match(/\n( *(at )?)/);Le=t&&t[1]||"",ae=-1<i.stack.indexOf(`
|
|
2
2
|
at`)?" (<anonymous>)":-1<i.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
-
`+
|
|
3
|
+
`+Le+e+ae}var Ae=!1;function Te(e,t){if(!e||Ae)return"";Ae=!0;var i=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var Ce=function(){throw Error()};if(Object.defineProperty(Ce.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ce,[])}catch(me){var oe=me}Reflect.construct(e,[],Ce)}else{try{Ce.call()}catch(me){oe=me}e.call(Ce.prototype)}}else{try{throw Error()}catch(me){oe=me}(Ce=e())&&typeof Ce.catch=="function"&&Ce.catch(function(){})}}catch(me){if(me&&oe&&typeof me.stack=="string")return[me.stack,oe.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],E=h[1];if(S&&E){var P=S.split(`
|
|
4
4
|
`),le=E.split(`
|
|
5
5
|
`);for(f=o=0;o<P.length&&!P[o].includes("DetermineComponentFrameRoot");)o++;for(;f<le.length&&!le[f].includes("DetermineComponentFrameRoot");)f++;if(o===P.length||f===le.length)for(o=P.length-1,f=le.length-1;1<=o&&0<=f&&P[o]!==le[f];)f--;for(;1<=o&&0<=f;o--,f--)if(P[o]!==le[f]){if(o!==1||f!==1)do if(o--,f--,0>f||P[o]!==le[f]){var ye=`
|
|
6
6
|
`+P[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{Ae=!1,Error.prepareStackTrace=i}return(i=e?e.displayName||e.name:"")?fe(i):""}function Be(e,t){switch(e.tag){case 26:case 27:case 5:return fe(e.type);case 16:return fe("Lazy");case 13:return e.child!==t&&t!==null?fe("Suspense Fallback"):fe("Suspense");case 19:return fe("SuspenseList");case 0:case 15:return Te(e.type,!1);case 11:return Te(e.type.render,!1);case 1:return Te(e.type,!0);case 31:return fe("Activity");default:return""}}function Ve(e){try{var t="",i=null;do t+=Be(e,i),i=e,e=e.return;while(e);return t}catch(o){return`
|
|
7
7
|
Error generating stack: `+o.message+`
|
|
8
|
-
`+o.stack}}var Je=Object.prototype.hasOwnProperty,Et=n.unstable_scheduleCallback,je=n.unstable_cancelCallback,We=n.unstable_shouldYield,it=n.unstable_requestPaint,ot=n.unstable_now,gn=n.unstable_getCurrentPriorityLevel,Kt=n.unstable_ImmediatePriority,Ie=n.unstable_UserBlockingPriority,ct=n.unstable_NormalPriority,_t=n.unstable_LowPriority,Ft=n.unstable_IdlePriority,ge=n.log,Oe=n.unstable_setDisableYieldValue,Fe=null,ke=null;function at(e){if(typeof ge=="function"&&Oe(e),ke&&typeof ke.setStrictMode=="function")try{ke.setStrictMode(Fe,e)}catch{}}var gt=Math.clz32?Math.clz32:Ls,Ee=Math.log,jn=Math.LN2;function Ls(e){return e>>>=0,e===0?32:31-(Ee(e)/jn|0)|0}var nt=256,zt=262144,zn=4194304;function He(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 va(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 E=o&134217727;return E!==0?(o=E&~h,o!==0?f=He(o):(S&=E,S!==0?f=He(S):i||(i=E&~e,i!==0&&(f=He(i))))):(E=o&~h,E!==0?f=He(E):S!==0?f=He(S):i||(i=o&~e,i!==0&&(f=He(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 dt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Hi(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 Qt(){var e=zn;return zn<<=1,(zn&62914560)===0&&(zn=4194304),e}function ps(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function bt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qn(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 E=e.entanglements,P=e.expirationTimes,le=e.hiddenUpdates;for(i=S&~i;0<i;){var ye=31-gt(i),Ce=1<<ye;E[ye]=0,P[ye]=-1;var oe=le[ye];if(oe!==null)for(le[ye]=null,ye=0;ye<oe.length;ye++){var me=oe[ye];me!==null&&(me.lane&=-536870913)}i&=~Ce}o!==0&&_s(e,o,0),h!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=h&~(S&~t))}function _s(e,t,i){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-gt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|i&261930}function H(e,t){var i=e.entangledLanes|=t;for(e=e.entanglements;i;){var o=31-gt(i),f=1<<o;f&t|e[o]&t&&(e[o]|=t),i&=~f}}function Pe(e,t){var i=t&-t;return i=(i&42)!==0?1:vt(i),(i&(e.suspendedLanes|t))!==0?0:i}function vt(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 sn(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Qa(){var e=Q.p;return e!==0?e:(e=window.event,e===void 0?32:Wv(e.type))}function Hr(e,t){var i=Q.p;try{return Q.p=e,t()}finally{Q.p=i}}var Xa=Math.random().toString(36).slice(2),ee="__reactFiber$"+Xa,Ne="__reactProps$"+Xa,qe="__reactContainer$"+Xa,rt="__reactEvents$"+Xa,Nt="__reactListeners$"+Xa,Mt="__reactHandles$"+Xa,Qe="__reactResources$"+Xa,ut="__reactMarker$"+Xa;function kn(e){delete e[ee],delete e[Ne],delete e[rt],delete e[Nt],delete e[Mt]}function Wt(e){var t=e[ee];if(t)return t;for(var i=e.parentNode;i;){if(t=i[qe]||i[ee]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Rv(e);e!==null;){if(i=e[ee])return i;e=Rv(e)}return t}e=i,i=e.parentNode}return null}function An(e){if(e=e[ee]||e[qe]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function St(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function rn(e){var t=e[Qe];return t||(t=e[Qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Pt(e){e[ut]=!0}var ya=new Set,ca={};function cn(e,t){vn(e,t),vn(e+"Capture",t)}function vn(e,t){for(ca[e]=t,e=0;e<t.length;e++)ya.add(t[e])}var Br=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]*$"),zs={},Fr={};function _o(e){return Je.call(Fr,e)?!0:Je.call(zs,e)?!1:Br.test(e)?Fr[e]=!0:(zs[e]=!0,!1)}function Bi(e,t,i){if(_o(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 zl(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 Za(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 Zt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Il(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ja(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 Xn(e){if(!e._valueTracker){var t=Il(e)?"checked":"value";e._valueTracker=Ja(e,t,""+e[t])}}function Is(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),o="";return e&&(o=Il(e)?e.checked?"true":"false":e.value),e=o,e!==i?(t.setValue(e),!0):!1}function Os(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 Pr=/[\n"\\]/g;function Gn(e){return e.replace(Pr,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function ai(e,t,i,o,f,h,S,E){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=""+Zt(t)):e.value!==""+Zt(t)&&(e.value=""+Zt(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?Hs(e,S,Zt(t)):i!=null?Hs(e,S,Zt(i)):o!=null&&e.removeAttribute("value"),f==null&&h!=null&&(e.defaultChecked=!!h),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+Zt(E):e.removeAttribute("name")}function si(e,t,i,o,f,h,S,E){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)){Xn(e);return}i=i!=null?""+Zt(i):"",t=t!=null?""+Zt(t):i,E||t===e.value||(e.value=t),e.defaultValue=t}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=E?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),Xn(e)}function Hs(e,t,i){t==="number"&&Os(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function Bs(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=""+Zt(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 Fi(e,t,i){if(t!=null&&(t=""+Zt(t),t!==e.value&&(e.value=t),i==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=i!=null?""+Zt(i):""}function $r(e,t,i,o){if(t==null){if(o!=null){if(i!=null)throw Error(l(92));if(K(o)){if(1<o.length)throw Error(l(93));o=o[0]}i=o}i==null&&(i=""),t=i}i=Zt(t),e.defaultValue=i,o=e.textContent,o===i&&o!==""&&o!==null&&(e.value=o),Xn(e)}function gs(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}var Ol=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 Hl(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||Ol.has(t)?t==="float"?e.cssFloat=i:e[t]=(""+i).trim():e[t]=i+"px"}function zo(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&&Hl(e,f,o)}else for(var h in t)t.hasOwnProperty(h)&&Hl(e,h,t[h])}function es(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 ii=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"]]),Fs=/^[\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 Bl(e){return Fs.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function _a(){}var Yc=null;function Io(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var za=null,Pi=null;function ri(e){var t=An(e);if(t&&(e=t.stateNode)){var i=e[Ne]||null;e:switch(e=t.stateNode,t.type){case"input":if(ai(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="'+Gn(""+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));ai(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&&Is(o)}break e;case"textarea":Fi(e,i.value,i.defaultValue);break e;case"select":t=i.value,t!=null&&Bs(e,!!i.multiple,t,!1)}}}var Ur=!1;function of(e,t,i){if(Ur)return e(t,i);Ur=!0;try{var o=e(t);return o}finally{if(Ur=!1,(za!==null||Pi!==null)&&(Bu(),za&&(t=za,e=Pi,Pi=za=null,ri(t),e)))for(t=0;t<e.length;t++)ri(e[t])}}function Fl(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 Ps=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Oo=!1;if(Ps)try{var $i={};Object.defineProperty($i,"passive",{get:function(){Oo=!0}}),window.addEventListener("test",$i,$i),window.removeEventListener("test",$i,$i)}catch{Oo=!1}var vs=null,Ho=null,Pl=null;function Kc(){if(Pl)return Pl;var e,t=Ho,i=t.length,o,f="value"in vs?vs.value:vs.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 Pl=f.slice(e,1<o?1-o:void 0)}function Ui(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 qi(){return!0}function Gi(){return!1}function ln(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 E in e)e.hasOwnProperty(E)&&(i=e[E],this[E]=i?i(h):h[E]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?qi:Gi,this.isPropagationStopped=Gi,this}return x(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=qi)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=qi)},persist:function(){},isPersistent:qi}),t}var ts={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qr=ln(ts),Vi=x({},ts,{view:0,detail:0}),Qc=ln(Vi),li,Gr,Wi,st=x({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Le,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!==Wi&&(Wi&&e.type==="mousemove"?(li=e.screenX-Wi.screenX,Gr=e.screenY-Wi.screenY):Gr=li=0,Wi=e),li)},movementY:function(e){return"movementY"in e?e.movementY:Gr}}),ft=ln(st),xa=x({},st,{dataTransfer:0}),Yi=ln(xa),$s=x({},Vi,{relatedTarget:0}),et=ln($s),Xc=x({},ts,{animationName:0,elapsedTime:0,pseudoElement:0}),cf=ln(Xc),$l=x({},ts,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Vr=ln($l),Bo=x({},ts,{data:0}),oi=ln(Bo),ba={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ki={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"},Vn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Us(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Vn[e])?!!t[e]:!1}function Le(){return Us}var Zc=x({},Vi,{key:function(e){if(e.key){var t=ba[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ki[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Le,charCode:function(e){return e.type==="keypress"?Ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),uf=ln(Zc),df=x({},st,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ul=ln(df),Wr=x({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Le}),Jc=ln(Wr),eu=x({},ts,{propertyName:0,elapsedTime:0,pseudoElement:0}),tu=ln(eu),Yt=x({},st,{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}),nu=ln(Yt),ql=x({},ts,{newState:0,oldState:0}),Qi=ln(ql),ff=[9,13,27,32],Fo=Ps&&"CompositionEvent"in window,It=null;Ps&&"documentMode"in document&&(It=document.documentMode);var Yr=Ps&&"TextEvent"in window&&!It,au=Ps&&(!Fo||It&&8<It&&11>=It),ns=" ",Po=!1;function Kr(e,t){switch(e){case"keyup":return ff.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qr(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var In=!1;function qs(e,t){switch(e){case"compositionend":return Qr(t);case"keypress":return t.which!==32?null:(Po=!0,ns);case"textInput":return e=t.data,e===ns&&Po?null:e;default:return null}}function Gl(e,t){if(In)return e==="compositionend"||!Fo&&Kr(e,t)?(e=Kc(),Pl=Ho=vs=null,In=!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 au&&t.locale!=="ko"?null:t.data;default:return null}}var as={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 ua(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!as[e.type]:t==="textarea"}function Zn(e,t,i,o){za?Pi?Pi.push(o):Pi=[o]:za=o,t=Vu(t,"onChange"),0<t.length&&(i=new qr("onChange","change",null,i,o),e.push({event:i,listeners:t}))}var Xr=null,Xi=null;function Zi(e){vv(e,0)}function Vl(e){var t=St(e);if(Is(t))return e}function On(e,t){if(e==="change")return t}var ci=!1;if(Ps){var Ia;if(Ps){var Gs="oninput"in document;if(!Gs){var Zr=document.createElement("div");Zr.setAttribute("oninput","return;"),Gs=typeof Zr.oninput=="function"}Ia=Gs}else Ia=!1;ci=Ia&&(!document.documentMode||9<document.documentMode)}function Jr(){Xr&&(Xr.detachEvent("onpropertychange",ss),Xi=Xr=null)}function ss(e){if(e.propertyName==="value"&&Vl(Xi)){var t=[];Zn(t,Xi,e,Io(e)),of(Zi,t)}}function su(e,t,i){e==="focusin"?(Jr(),Xr=t,Xi=i,Xr.attachEvent("onpropertychange",ss)):e==="focusout"&&Jr()}function mf(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Vl(Xi)}function Wl(e,t){if(e==="click")return Vl(t)}function Yl(e,t){if(e==="input"||e==="change")return Vl(t)}function iu(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Nn=typeof Object.is=="function"?Object.is:iu;function Ji(e,t){if(Nn(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(!Je.call(t,f)||!Nn(e[f],t[f]))return!1}return!0}function $o(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ru(e,t){var i=$o(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=$o(i)}}function ui(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ui(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function lu(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Os(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=Os(e.document)}return t}function Kl(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 hf=Ps&&"documentMode"in document&&11>=document.documentMode,er=null,Ql=null,el=null,Xl=!1;function tr(e,t,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Xl||er==null||er!==Os(o)||(o=er,"selectionStart"in o&&Kl(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}),el&&Ji(el,o)||(el=o,o=Vu(Ql,"onSelect"),0<o.length&&(t=new qr("onSelect","select",null,t,i),e.push({event:t,listeners:o}),t.target=er)))}function Vs(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var da={animationend:Vs("Animation","AnimationEnd"),animationiteration:Vs("Animation","AnimationIteration"),animationstart:Vs("Animation","AnimationStart"),transitionrun:Vs("Transition","TransitionRun"),transitionstart:Vs("Transition","TransitionStart"),transitioncancel:Vs("Transition","TransitionCancel"),transitionend:Vs("Transition","TransitionEnd")},nr={},di={};Ps&&(di=document.createElement("div").style,"AnimationEvent"in window||(delete da.animationend.animation,delete da.animationiteration.animation,delete da.animationstart.animation),"TransitionEvent"in window||delete da.transitionend.transition);function fa(e){if(nr[e])return nr[e];if(!da[e])return e;var t=da[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in di)return nr[e]=t[i];return e}var Zl=fa("animationend"),ou=fa("animationiteration"),Uo=fa("animationstart"),qo=fa("transitionrun"),Go=fa("transitionstart"),tl=fa("transitioncancel"),cu=fa("transitionend"),nl=new Map,Jl="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(" ");Jl.push("scrollEnd");function Jn(e,t){nl.set(e,t),cn(t,[e])}var ar=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)},ea=[],ys=0,sr=0;function Ws(){for(var e=ys,t=sr=ys=0;t<e;){var i=ea[t];ea[t++]=null;var o=ea[t];ea[t++]=null;var f=ea[t];ea[t++]=null;var h=ea[t];if(ea[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&&Vo(i,f,h)}}function fi(e,t,i,o){ea[ys++]=e,ea[ys++]=t,ea[ys++]=i,ea[ys++]=o,sr|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Ys(e,t,i,o){return fi(e,t,i,o),is(e)}function wa(e,t){return fi(e,null,null,t),is(e)}function Vo(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-gt(i),e=h.hiddenUpdates,o=e[f],o===null?e[f]=[t]:o.push(t),t.lane=i|536870912),h):null}function is(e){if(50<dc)throw dc=0,om=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var xs={};function Wo(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 ta(e,t,i,o){return new Wo(e,t,i,o)}function Sa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function rs(e,t){var i=e.alternate;return i===null?(i=ta(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 ir(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 Ks(e,t,i,o,f,h){var S=0;if(o=e,typeof e=="function")Sa(e)&&(S=1);else if(typeof e=="string")S=wS(e,i,ue.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case ne:return e=ta(31,i,t,f),e.elementType=ne,e.lanes=h,e;case A:return mi(i.children,f,h,t);case N:S=8,f|=24;break;case k:return e=ta(12,i,t,f|2),e.elementType=k,e.lanes=h,e;case O:return e=ta(13,i,t,f),e.elementType=O,e.lanes=h,e;case Y:return e=ta(19,i,t,f),e.elementType=Y,e.lanes=h,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:S=10;break e;case T:S=9;break e;case U:S=11;break e;case _:S=14;break e;case D:S=16,o=null;break e}S=29,i=Error(l(130,e===null?"null":typeof e,"")),o=null}return t=ta(S,i,t,f),t.elementType=e,t.type=o,t.lanes=h,t}function mi(e,t,i,o){return e=ta(7,e,o,t),e.lanes=i,e}function eo(e,t,i){return e=ta(6,e,null,t),e.lanes=i,e}function Hn(e){var t=ta(18,null,null,0);return t.stateNode=e,t}function to(e,t,i){return t=ta(4,e.children!==null?e.children:[],e.key,t),t.lanes=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var al=new WeakMap;function na(e,t){if(typeof e=="object"&&e!==null){var i=al.get(e);return i!==void 0?i:(t={value:e,source:t,stack:Ve(t)},al.set(e,t),t)}return{value:e,source:t,stack:Ve(t)}}var ls=[],rr=0,sl=null,il=0,Ca=[],aa=0,bs=null,sa=1,Oa="";function Ha(e,t){ls[rr++]=il,ls[rr++]=sl,sl=e,il=t}function uu(e,t,i){Ca[aa++]=sa,Ca[aa++]=Oa,Ca[aa++]=bs,bs=e;var o=sa;e=Oa;var f=32-gt(o)-1;o&=~(1<<f),i+=1;var h=32-gt(t)+f;if(30<h){var S=f-f%5;h=(o&(1<<S)-1).toString(32),o>>=S,f-=S,sa=1<<32-gt(t)+f|i<<f|o,Oa=h+e}else sa=1<<h|i<<f|o,Oa=e}function lr(e){e.return!==null&&(Ha(e,1),uu(e,1,0))}function Yo(e){for(;e===sl;)sl=ls[--rr],ls[rr]=null,il=ls[--rr],ls[rr]=null;for(;e===bs;)bs=Ca[--aa],Ca[aa]=null,Oa=Ca[--aa],Ca[aa]=null,sa=Ca[--aa],Ca[aa]=null}function du(e,t){Ca[aa++]=sa,Ca[aa++]=Oa,Ca[aa++]=bs,sa=t.id,Oa=t.overflow,bs=e}var un=null,Gt=null,wt=!1,ws=null,ma=!1,Ko=Error(l(519));function Ba(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Me(na(t,e)),Ko}function Ss(e){var t=e.stateNode,i=e.type,o=e.memoizedProps;switch(t[ee]=e,t[Ne]=o,i){case"dialog":jt("cancel",t),jt("close",t);break;case"iframe":case"object":case"embed":jt("load",t);break;case"video":case"audio":for(i=0;i<mc.length;i++)jt(mc[i],t);break;case"source":jt("error",t);break;case"img":case"image":case"link":jt("error",t),jt("load",t);break;case"details":jt("toggle",t);break;case"input":jt("invalid",t),si(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":jt("invalid",t);break;case"textarea":jt("invalid",t),$r(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||wv(t.textContent,i)?(o.popover!=null&&(jt("beforetoggle",t),jt("toggle",t)),o.onScroll!=null&&jt("scroll",t),o.onScrollEnd!=null&&jt("scrollend",t),o.onClick!=null&&(t.onclick=_a),t=!0):t=!1,t||Ba(e,!0)}function rl(e){for(un=e.return;un;)switch(un.tag){case 5:case 31:case 13:ma=!1;return;case 27:case 3:ma=!0;return;default:un=un.return}}function or(e){if(e!==un)return!1;if(!wt)return rl(e),wt=!0,!1;var t=e.tag,i;if((i=t!==3&&t!==27)&&((i=t===5)&&(i=e.type,i=!(i!=="form"&&i!=="button")||Cm(e.type,e.memoizedProps)),i=!i),i&&Gt&&Ba(e),rl(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Gt=Ev(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Gt=Ev(e)}else t===27?(t=Gt,kr(e.type)?(e=Mm,Mm=null,Gt=e):Gt=t):Gt=un?us(e.stateNode.nextSibling):null;return!0}function Cs(){Gt=un=null,wt=!1}function ll(){var e=ws;return e!==null&&(Na===null?Na=e:Na.push.apply(Na,e),ws=null),e}function Me(e){ws===null?ws=[e]:ws.push(e)}var cr=be(null),Qs=null,js=null;function hi(e,t,i){$(cr,t._currentValue),t._currentValue=i}function Fa(e){e._currentValue=cr.current,X(cr)}function ur(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 yn(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 E=h;h=f;for(var P=0;P<t.length;P++)if(E.context===t[P]){h.lanes|=i,E=h.alternate,E!==null&&(E.lanes|=i),ur(h.return,i,e),o||(S=null);break e}h=E.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),ur(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 Mn(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 E=f.type;Nn(f.pendingProps.value,S.value)||(e!==null?e.push(E):e=[E])}}else if(f===Se.current){if(S=f.alternate,S===null)throw Error(l(387));S.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(yc):e=[yc])}f=f.return}e!==null&&yn(t,e,i,o),t.flags|=262144}function xt(e){for(e=e.firstContext;e!==null;){if(!Nn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function pi(e){Qs=e,js=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Jt(e){return no(Qs,e)}function ol(e,t){return Qs===null&&pi(e),no(e,t)}function no(e,t){var i=t._currentValue;if(t={context:t,memoizedValue:i,next:null},js===null){if(e===null)throw Error(l(308));js=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else js=js.next=t;return i}var pf=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()})}},gf=n.unstable_scheduleCallback,fu=n.unstable_NormalPriority,en={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Qo(){return{controller:new pf,data:new Map,refCount:0}}function cl(e){e.refCount--,e.refCount===0&&gf(fu,function(){e.controller.abort()})}var xn=null,dr=0,gi=0,fr=null;function yp(e,t){if(xn===null){var i=xn=[];dr=0,gi=hm(),fr={status:"pending",value:void 0,then:function(o){i.push(o)}}}return dr++,t.then(mu,mu),t}function mu(){if(--dr===0&&xn!==null){fr!==null&&(fr.status="fulfilled");var e=xn;xn=null,gi=0,fr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function vf(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 Xo=I.S;I.S=function(e,t){Gg=ot(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&yp(e,t),Xo!==null&&Xo(e,t)};var os=be(null);function vi(){var e=os.current;return e!==null?e:Vt.pooledCache}function ul(e,t){t===null?$(os,os.current):$(os,t.pool)}function hu(){var e=vi();return e===null?null:{parent:en._currentValue,pool:e}}var mr=Error(l(460)),Zo=Error(l(474)),ao=Error(l(542)),so={then:function(){}};function pu(e){return e=e.status,e==="fulfilled"||e==="rejected"}function gu(e,t,i){switch(i=e[i],i===void 0?e.push(t):i!==t&&(t.then(_a,_a),t=i),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,xi(e),e;default:if(typeof t.status=="string")t.then(_a,_a);else{if(e=Vt,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,xi(e),e}throw yi=t,mr}}function Tn(e){try{var t=e._init;return t(e._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(yi=i,mr):i}}var yi=null;function vu(){if(yi===null)throw Error(l(459));var e=yi;return yi=null,e}function xi(e){if(e===mr||e===ao)throw Error(l(483))}var hr=null,bi=0;function ks(e){var t=bi;return bi+=1,hr===null&&(hr=[]),gu(hr,e,t)}function dl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function fl(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 y(e){function t(J,W){if(e){var ie=J.deletions;ie===null?(J.deletions=[W],J.flags|=16):ie.push(W)}}function i(J,W){if(!e)return null;for(;W!==null;)t(J,W),W=W.sibling;return null}function o(J){for(var W=new Map;J!==null;)J.key!==null?W.set(J.key,J):W.set(J.index,J),J=J.sibling;return W}function f(J,W){return J=rs(J,W),J.index=0,J.sibling=null,J}function h(J,W,ie){return J.index=ie,e?(ie=J.alternate,ie!==null?(ie=ie.index,ie<W?(J.flags|=67108866,W):ie):(J.flags|=67108866,W)):(J.flags|=1048576,W)}function S(J){return e&&J.alternate===null&&(J.flags|=67108866),J}function E(J,W,ie,we){return W===null||W.tag!==6?(W=eo(ie,J.mode,we),W.return=J,W):(W=f(W,ie),W.return=J,W)}function P(J,W,ie,we){var Ze=ie.type;return Ze===A?ye(J,W,ie.props.children,we,ie.key):W!==null&&(W.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===D&&Tn(Ze)===W.type)?(W=f(W,ie.props),dl(W,ie),W.return=J,W):(W=Ks(ie.type,ie.key,ie.props,null,J.mode,we),dl(W,ie),W.return=J,W)}function le(J,W,ie,we){return W===null||W.tag!==4||W.stateNode.containerInfo!==ie.containerInfo||W.stateNode.implementation!==ie.implementation?(W=to(ie,J.mode,we),W.return=J,W):(W=f(W,ie.children||[]),W.return=J,W)}function ye(J,W,ie,we,Ze){return W===null||W.tag!==7?(W=mi(ie,J.mode,we,Ze),W.return=J,W):(W=f(W,ie),W.return=J,W)}function Ce(J,W,ie){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=eo(""+W,J.mode,ie),W.return=J,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case C:return ie=Ks(W.type,W.key,W.props,null,J.mode,ie),dl(ie,W),ie.return=J,ie;case j:return W=to(W,J.mode,ie),W.return=J,W;case D:return W=Tn(W),Ce(J,W,ie)}if(K(W)||B(W))return W=mi(W,J.mode,ie,null),W.return=J,W;if(typeof W.then=="function")return Ce(J,ks(W),ie);if(W.$$typeof===R)return Ce(J,ol(J,W),ie);fl(J,W)}return null}function oe(J,W,ie,we){var Ze=W!==null?W.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return Ze!==null?null:E(J,W,""+ie,we);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case C:return ie.key===Ze?P(J,W,ie,we):null;case j:return ie.key===Ze?le(J,W,ie,we):null;case D:return ie=Tn(ie),oe(J,W,ie,we)}if(K(ie)||B(ie))return Ze!==null?null:ye(J,W,ie,we,null);if(typeof ie.then=="function")return oe(J,W,ks(ie),we);if(ie.$$typeof===R)return oe(J,W,ol(J,ie),we);fl(J,ie)}return null}function me(J,W,ie,we,Ze){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return J=J.get(ie)||null,E(W,J,""+we,Ze);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case C:return J=J.get(we.key===null?ie:we.key)||null,P(W,J,we,Ze);case j:return J=J.get(we.key===null?ie:we.key)||null,le(W,J,we,Ze);case D:return we=Tn(we),me(J,W,ie,we,Ze)}if(K(we)||B(we))return J=J.get(ie)||null,ye(W,J,we,Ze,null);if(typeof we.then=="function")return me(J,W,ie,ks(we),Ze);if(we.$$typeof===R)return me(J,W,ie,ol(W,we),Ze);fl(W,we)}return null}function Ye(J,W,ie,we){for(var Ze=null,Rt=null,Ke=W,yt=W=0,At=null;Ke!==null&&yt<ie.length;yt++){Ke.index>yt?(At=Ke,Ke=null):At=Ke.sibling;var Dt=oe(J,Ke,ie[yt],we);if(Dt===null){Ke===null&&(Ke=At);break}e&&Ke&&Dt.alternate===null&&t(J,Ke),W=h(Dt,W,yt),Rt===null?Ze=Dt:Rt.sibling=Dt,Rt=Dt,Ke=At}if(yt===ie.length)return i(J,Ke),wt&&Ha(J,yt),Ze;if(Ke===null){for(;yt<ie.length;yt++)Ke=Ce(J,ie[yt],we),Ke!==null&&(W=h(Ke,W,yt),Rt===null?Ze=Ke:Rt.sibling=Ke,Rt=Ke);return wt&&Ha(J,yt),Ze}for(Ke=o(Ke);yt<ie.length;yt++)At=me(Ke,J,yt,ie[yt],we),At!==null&&(e&&At.alternate!==null&&Ke.delete(At.key===null?yt:At.key),W=h(At,W,yt),Rt===null?Ze=At:Rt.sibling=At,Rt=At);return e&&Ke.forEach(function(Er){return t(J,Er)}),wt&&Ha(J,yt),Ze}function tt(J,W,ie,we){if(ie==null)throw Error(l(151));for(var Ze=null,Rt=null,Ke=W,yt=W=0,At=null,Dt=ie.next();Ke!==null&&!Dt.done;yt++,Dt=ie.next()){Ke.index>yt?(At=Ke,Ke=null):At=Ke.sibling;var Er=oe(J,Ke,Dt.value,we);if(Er===null){Ke===null&&(Ke=At);break}e&&Ke&&Er.alternate===null&&t(J,Ke),W=h(Er,W,yt),Rt===null?Ze=Er:Rt.sibling=Er,Rt=Er,Ke=At}if(Dt.done)return i(J,Ke),wt&&Ha(J,yt),Ze;if(Ke===null){for(;!Dt.done;yt++,Dt=ie.next())Dt=Ce(J,Dt.value,we),Dt!==null&&(W=h(Dt,W,yt),Rt===null?Ze=Dt:Rt.sibling=Dt,Rt=Dt);return wt&&Ha(J,yt),Ze}for(Ke=o(Ke);!Dt.done;yt++,Dt=ie.next())Dt=me(Ke,J,yt,Dt.value,we),Dt!==null&&(e&&Dt.alternate!==null&&Ke.delete(Dt.key===null?yt:Dt.key),W=h(Dt,W,yt),Rt===null?Ze=Dt:Rt.sibling=Dt,Rt=Dt);return e&&Ke.forEach(function(DS){return t(J,DS)}),wt&&Ha(J,yt),Ze}function qt(J,W,ie,we){if(typeof ie=="object"&&ie!==null&&ie.type===A&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case C:e:{for(var Ze=ie.key;W!==null;){if(W.key===Ze){if(Ze=ie.type,Ze===A){if(W.tag===7){i(J,W.sibling),we=f(W,ie.props.children),we.return=J,J=we;break e}}else if(W.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===D&&Tn(Ze)===W.type){i(J,W.sibling),we=f(W,ie.props),dl(we,ie),we.return=J,J=we;break e}i(J,W);break}else t(J,W);W=W.sibling}ie.type===A?(we=mi(ie.props.children,J.mode,we,ie.key),we.return=J,J=we):(we=Ks(ie.type,ie.key,ie.props,null,J.mode,we),dl(we,ie),we.return=J,J=we)}return S(J);case j:e:{for(Ze=ie.key;W!==null;){if(W.key===Ze)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){i(J,W.sibling),we=f(W,ie.children||[]),we.return=J,J=we;break e}else{i(J,W);break}else t(J,W);W=W.sibling}we=to(ie,J.mode,we),we.return=J,J=we}return S(J);case D:return ie=Tn(ie),qt(J,W,ie,we)}if(K(ie))return Ye(J,W,ie,we);if(B(ie)){if(Ze=B(ie),typeof Ze!="function")throw Error(l(150));return ie=Ze.call(ie),tt(J,W,ie,we)}if(typeof ie.then=="function")return qt(J,W,ks(ie),we);if(ie.$$typeof===R)return qt(J,W,ol(J,ie),we);fl(J,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(i(J,W.sibling),we=f(W,ie),we.return=J,J=we):(i(J,W),we=eo(ie,J.mode,we),we.return=J,J=we),S(J)):i(J,W)}return function(J,W,ie,we){try{bi=0;var Ze=qt(J,W,ie,we);return hr=null,Ze}catch(Ke){if(Ke===mr||Ke===ao)throw Ke;var Rt=ta(29,Ke,null,J.mode);return Rt.lanes=we,Rt.return=J,Rt}}}var M=y(!0),L=y(!1),F=!1;function z(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function pe(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 de(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Re(e,t,i){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(Lt&2)!==0){var f=o.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),o.pending=t,t=is(e),Vo(e,null,i),t}return fi(e,o,t,i),is(e)}function $e(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,H(e,i)}}function Xe(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 tn=!1;function dn(){if(tn){var e=fr;if(e!==null)throw e}}function Wn(e,t,i,o){tn=!1;var f=e.updateQueue;F=!1;var h=f.firstBaseUpdate,S=f.lastBaseUpdate,E=f.shared.pending;if(E!==null){f.shared.pending=null;var P=E,le=P.next;P.next=null,S===null?h=le:S.next=le,S=P;var ye=e.alternate;ye!==null&&(ye=ye.updateQueue,E=ye.lastBaseUpdate,E!==S&&(E===null?ye.firstBaseUpdate=le:E.next=le,ye.lastBaseUpdate=P))}if(h!==null){var Ce=f.baseState;S=0,ye=le=P=null,E=h;do{var oe=E.lane&-536870913,me=oe!==E.lane;if(me?(kt&oe)===oe:(o&oe)===oe){oe!==0&&oe===gi&&(tn=!0),ye!==null&&(ye=ye.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ye=e,tt=E;oe=t;var qt=i;switch(tt.tag){case 1:if(Ye=tt.payload,typeof Ye=="function"){Ce=Ye.call(qt,Ce,oe);break e}Ce=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=tt.payload,oe=typeof Ye=="function"?Ye.call(qt,Ce,oe):Ye,oe==null)break e;Ce=x({},Ce,oe);break e;case 2:F=!0}}oe=E.callback,oe!==null&&(e.flags|=64,me&&(e.flags|=8192),me=f.callbacks,me===null?f.callbacks=[oe]:me.push(oe))}else me={lane:oe,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ye===null?(le=ye=me,P=Ce):ye=ye.next=me,S|=oe;if(E=E.next,E===null){if(E=f.shared.pending,E===null)break;me=E,E=me.next,me.next=null,f.lastBaseUpdate=me,f.shared.pending=null}}while(!0);ye===null&&(P=Ce),f.baseState=P,f.firstBaseUpdate=le,f.lastBaseUpdate=ye,h===null&&(f.shared.lanes=0),br|=S,e.lanes=S,e.memoizedState=Ce}}function ml(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function hl(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;e<i.length;e++)ml(i[e],t)}var pr=be(null),wi=be(0);function yu(e,t){e=Ei,$(wi,e),$(pr,t),Ei=e|t.baseLanes}function yf(){$(wi,Ei),$(pr,pr.current)}function xf(){Ei=wi.current,X(pr),X(wi)}var Pa=be(null),cs=null;function gr(e){var t=e.alternate;$(bn,bn.current&1),$(Pa,e),cs===null&&(t===null||pr.current!==null||t.memoizedState!==null)&&(cs=e)}function bf(e){$(bn,bn.current),$(Pa,e),cs===null&&(cs=e)}function xp(e){e.tag===22?($(bn,bn.current),$(Pa,e),cs===null&&(cs=e)):vr()}function vr(){$(bn,bn.current),$(Pa,Pa.current)}function $a(e){X(Pa),cs===e&&(cs=null),X(bn)}var bn=be(0);function xu(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Am(i)||Nm(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 Si=0,mt=null,$t=null,En=null,bu=!1,io=!1,pl=!1,wu=0,Jo=0,ro=null,Sw=0;function fn(){throw Error(l(321))}function wf(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!Nn(e[i],t[i]))return!1;return!0}function Sf(e,t,i,o,f,h){return Si=h,mt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?ng:Of,pl=!1,h=i(o,f),pl=!1,io&&(h=wp(t,i,o,f)),bp(e),h}function bp(e){I.H=nc;var t=$t!==null&&$t.next!==null;if(Si=0,En=$t=mt=null,bu=!1,Jo=0,ro=null,t)throw Error(l(300));e===null||Rn||(e=e.dependencies,e!==null&&xt(e)&&(Rn=!0))}function wp(e,t,i,o){mt=e;var f=0;do{if(io&&(ro=null),Jo=0,io=!1,25<=f)throw Error(l(301));if(f+=1,En=$t=null,e.updateQueue!=null){var h=e.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}I.H=ag,h=t(i,o)}while(io);return h}function Cw(){var e=I.H,t=e.useState()[0];return t=typeof t.then=="function"?ec(t):t,e=e.useState()[0],($t!==null?$t.memoizedState:null)!==e&&(mt.flags|=1024),t}function Cf(){var e=wu!==0;return wu=0,e}function jf(e,t,i){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i}function kf(e){if(bu){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}bu=!1}Si=0,En=$t=mt=null,io=!1,Jo=wu=0,ro=null}function ha(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return En===null?mt.memoizedState=En=e:En=En.next=e,En}function wn(){if($t===null){var e=mt.alternate;e=e!==null?e.memoizedState:null}else e=$t.next;var t=En===null?mt.memoizedState:En.next;if(t!==null)En=t,$t=e;else{if(e===null)throw mt.alternate===null?Error(l(467)):Error(l(310));$t=e,e={memoizedState:$t.memoizedState,baseState:$t.baseState,baseQueue:$t.baseQueue,queue:$t.queue,next:null},En===null?mt.memoizedState=En=e:En=En.next=e}return En}function Su(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ec(e){var t=Jo;return Jo+=1,ro===null&&(ro=[]),e=gu(ro,e,t),t=mt,(En===null?t.memoizedState:En.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?ng:Of),e}function Cu(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ec(e);if(e.$$typeof===R)return Jt(e)}throw Error(l(438,String(e)))}function Af(e){var t=null,i=mt.updateQueue;if(i!==null&&(t=i.memoCache),t==null){var o=mt.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=Su(),mt.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]=G;return t.index++,i}function Ci(e,t){return typeof t=="function"?t(e):t}function ju(e){var t=wn();return Nf(t,$t,e)}function Nf(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 E=S=null,P=null,le=t,ye=!1;do{var Ce=le.lane&-536870913;if(Ce!==le.lane?(kt&Ce)===Ce:(Si&Ce)===Ce){var oe=le.revertLane;if(oe===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),Ce===gi&&(ye=!0);else if((Si&oe)===oe){le=le.next,oe===gi&&(ye=!0);continue}else Ce={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},P===null?(E=P=Ce,S=h):P=P.next=Ce,mt.lanes|=oe,br|=oe;Ce=le.action,pl&&i(h,Ce),h=le.hasEagerState?le.eagerState:i(h,Ce)}else oe={lane:Ce,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},P===null?(E=P=oe,S=h):P=P.next=oe,mt.lanes|=Ce,br|=Ce;le=le.next}while(le!==null&&le!==t);if(P===null?S=h:P.next=E,!Nn(h,e.memoizedState)&&(Rn=!0,ye&&(i=fr,i!==null)))throw i;e.memoizedState=h,e.baseState=S,e.baseQueue=P,o.lastRenderedState=h}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Mf(e){var t=wn(),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);Nn(h,t.memoizedState)||(Rn=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),i.lastRenderedState=h}return[h,o]}function Sp(e,t,i){var o=mt,f=wn(),h=wt;if(h){if(i===void 0)throw Error(l(407));i=i()}else i=t();var S=!Nn(($t||f).memoizedState,i);if(S&&(f.memoizedState=i,Rn=!0),f=f.queue,Rf(kp.bind(null,o,f,e),[e]),f.getSnapshot!==t||S||En!==null&&En.memoizedState.tag&1){if(o.flags|=2048,lo(9,{destroy:void 0},jp.bind(null,o,f,i,t),null),Vt===null)throw Error(l(349));h||(Si&127)!==0||Cp(o,t,i)}return i}function Cp(e,t,i){e.flags|=16384,e={getSnapshot:t,value:i},t=mt.updateQueue,t===null?(t=Su(),mt.updateQueue=t,t.stores=[e]):(i=t.stores,i===null?t.stores=[e]:i.push(e))}function jp(e,t,i,o){t.value=i,t.getSnapshot=o,Ap(t)&&Np(e)}function kp(e,t,i){return i(function(){Ap(t)&&Np(e)})}function Ap(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!Nn(e,i)}catch{return!0}}function Np(e){var t=wa(e,2);t!==null&&Ma(t,e,2)}function Tf(e){var t=ha();if(typeof e=="function"){var i=e;if(e=i(),pl){at(!0);try{i()}finally{at(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:e},t}function Mp(e,t,i,o){return e.baseState=i,Nf(e,$t,typeof o=="function"?o:Ci)}function jw(e,t,i,o,f){if(Nu(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)}};I.T!==null?i(!0):h.isTransition=!1,o(h),i=t.pending,i===null?(h.next=t.pending=h,Tp(t,h)):(h.next=i.next,t.pending=i.next=h)}}function Tp(e,t){var i=t.action,o=t.payload,f=e.state;if(t.isTransition){var h=I.T,S={};I.T=S;try{var E=i(f,o),P=I.S;P!==null&&P(S,E),Ep(e,t,E)}catch(le){Ef(e,t,le)}finally{h!==null&&S.types!==null&&(h.types=S.types),I.T=h}}else try{h=i(f,o),Ep(e,t,h)}catch(le){Ef(e,t,le)}}function Ep(e,t,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(o){Rp(e,t,o)},function(o){return Ef(e,t,o)}):Rp(e,t,i)}function Rp(e,t,i){t.status="fulfilled",t.value=i,Dp(t),e.state=i,t=e.pending,t!==null&&(i=t.next,i===t?e.pending=null:(i=i.next,t.next=i,Tp(e,i)))}function Ef(e,t,i){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=i,Dp(t),t=t.next;while(t!==o)}e.action=null}function Dp(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Lp(e,t){return t}function _p(e,t){if(wt){var i=Vt.formState;if(i!==null){e:{var o=mt;if(wt){if(Gt){t:{for(var f=Gt,h=ma;f.nodeType!==8;){if(!h){f=null;break t}if(f=us(f.nextSibling),f===null){f=null;break t}}h=f.data,f=h==="F!"||h==="F"?f:null}if(f){Gt=us(f.nextSibling),o=f.data==="F!";break e}}Ba(o)}o=!1}o&&(t=i[0])}}return i=ha(),i.memoizedState=i.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lp,lastRenderedState:t},i.queue=o,i=Jp.bind(null,mt,o),o.dispatch=i,o=Tf(!1),h=If.bind(null,mt,!1,o.queue),o=ha(),f={state:t,dispatch:null,action:e,pending:null},o.queue=f,i=jw.bind(null,mt,f,h,i),f.dispatch=i,o.memoizedState=e,[t,i,!1]}function zp(e){var t=wn();return Ip(t,$t,e)}function Ip(e,t,i){if(t=Nf(e,t,Lp)[0],e=ju(Ci)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=ec(t)}catch(S){throw S===mr?ao:S}else o=t;t=wn();var f=t.queue,h=f.dispatch;return i!==t.memoizedState&&(mt.flags|=2048,lo(9,{destroy:void 0},kw.bind(null,f,i),null)),[o,h,e]}function kw(e,t){e.action=t}function Op(e){var t=wn(),i=$t;if(i!==null)return Ip(t,i,e);wn(),t=t.memoizedState,i=wn();var o=i.queue.dispatch;return i.memoizedState=e,[t,o,!1]}function lo(e,t,i,o){return e={tag:e,create:i,deps:o,inst:t,next:null},t=mt.updateQueue,t===null&&(t=Su(),mt.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 Hp(){return wn().memoizedState}function ku(e,t,i,o){var f=ha();mt.flags|=e,f.memoizedState=lo(1|t,{destroy:void 0},i,o===void 0?null:o)}function Au(e,t,i,o){var f=wn();o=o===void 0?null:o;var h=f.memoizedState.inst;$t!==null&&o!==null&&wf(o,$t.memoizedState.deps)?f.memoizedState=lo(t,h,i,o):(mt.flags|=e,f.memoizedState=lo(1|t,h,i,o))}function Bp(e,t){ku(8390656,8,e,t)}function Rf(e,t){Au(2048,8,e,t)}function Aw(e){mt.flags|=4;var t=mt.updateQueue;if(t===null)t=Su(),mt.updateQueue=t,t.events=[e];else{var i=t.events;i===null?t.events=[e]:i.push(e)}}function Fp(e){var t=wn().memoizedState;return Aw({ref:t,nextImpl:e}),function(){if((Lt&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function Pp(e,t){return Au(4,2,e,t)}function $p(e,t){return Au(4,4,e,t)}function Up(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 qp(e,t,i){i=i!=null?i.concat([e]):null,Au(4,4,Up.bind(null,t,e),i)}function Df(){}function Gp(e,t){var i=wn();t=t===void 0?null:t;var o=i.memoizedState;return t!==null&&wf(t,o[1])?o[0]:(i.memoizedState=[e,t],e)}function Vp(e,t){var i=wn();t=t===void 0?null:t;var o=i.memoizedState;if(t!==null&&wf(t,o[1]))return o[0];if(o=e(),pl){at(!0);try{e()}finally{at(!1)}}return i.memoizedState=[o,t],o}function Lf(e,t,i){return i===void 0||(Si&1073741824)!==0&&(kt&261930)===0?e.memoizedState=t:(e.memoizedState=i,e=Wg(),mt.lanes|=e,br|=e,i)}function Wp(e,t,i,o){return Nn(i,t)?i:pr.current!==null?(e=Lf(e,i,o),Nn(e,t)||(Rn=!0),e):(Si&42)===0||(Si&1073741824)!==0&&(kt&261930)===0?(Rn=!0,e.memoizedState=i):(e=Wg(),mt.lanes|=e,br|=e,t)}function Yp(e,t,i,o,f){var h=Q.p;Q.p=h!==0&&8>h?h:8;var S=I.T,E={};I.T=E,If(e,!1,t,i);try{var P=f(),le=I.S;if(le!==null&&le(E,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var ye=vf(P,o);tc(e,t,ye,Ga(e))}else tc(e,t,o,Ga(e))}catch(Ce){tc(e,t,{then:function(){},status:"rejected",reason:Ce},Ga())}finally{Q.p=h,S!==null&&E.types!==null&&(S.types=E.types),I.T=S}}function Nw(){}function _f(e,t,i,o){if(e.tag!==5)throw Error(l(476));var f=Kp(e).queue;Yp(e,f,t,q,i===null?Nw:function(){return Qp(e),i(o)})}function Kp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:q},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Qp(e){var t=Kp(e);t.next===null&&(t=e.alternate.memoizedState),tc(e,t.next.queue,{},Ga())}function zf(){return Jt(yc)}function Xp(){return wn().memoizedState}function Zp(){return wn().memoizedState}function Mw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=Ga();e=de(i);var o=Re(t,e,i);o!==null&&(Ma(o,t,i),$e(o,t,i)),t={cache:Qo()},e.payload=t;return}t=t.return}}function Tw(e,t,i){var o=Ga();i={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Nu(e)?eg(t,i):(i=Ys(e,t,i,o),i!==null&&(Ma(i,e,o),tg(i,t,o)))}function Jp(e,t,i){var o=Ga();tc(e,t,i,o)}function tc(e,t,i,o){var f={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Nu(e))eg(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,E=h(S,i);if(f.hasEagerState=!0,f.eagerState=E,Nn(E,S))return fi(e,t,f,0),Vt===null&&Ws(),!1}catch{}if(i=Ys(e,t,f,o),i!==null)return Ma(i,e,o),tg(i,t,o),!0}return!1}function If(e,t,i,o){if(o={lane:2,revertLane:hm(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Nu(e)){if(t)throw Error(l(479))}else t=Ys(e,i,o,2),t!==null&&Ma(t,e,2)}function Nu(e){var t=e.alternate;return e===mt||t!==null&&t===mt}function eg(e,t){io=bu=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function tg(e,t,i){if((i&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,i|=o,t.lanes=i,H(e,i)}}var nc={readContext:Jt,use:Cu,useCallback:fn,useContext:fn,useEffect:fn,useImperativeHandle:fn,useLayoutEffect:fn,useInsertionEffect:fn,useMemo:fn,useReducer:fn,useRef:fn,useState:fn,useDebugValue:fn,useDeferredValue:fn,useTransition:fn,useSyncExternalStore:fn,useId:fn,useHostTransitionStatus:fn,useFormState:fn,useActionState:fn,useOptimistic:fn,useMemoCache:fn,useCacheRefresh:fn};nc.useEffectEvent=fn;var ng={readContext:Jt,use:Cu,useCallback:function(e,t){return ha().memoizedState=[e,t===void 0?null:t],e},useContext:Jt,useEffect:Bp,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,ku(4194308,4,Up.bind(null,t,e),i)},useLayoutEffect:function(e,t){return ku(4194308,4,e,t)},useInsertionEffect:function(e,t){ku(4,2,e,t)},useMemo:function(e,t){var i=ha();t=t===void 0?null:t;var o=e();if(pl){at(!0);try{e()}finally{at(!1)}}return i.memoizedState=[o,t],o},useReducer:function(e,t,i){var o=ha();if(i!==void 0){var f=i(t);if(pl){at(!0);try{i(t)}finally{at(!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=Tw.bind(null,mt,e),[o.memoizedState,e]},useRef:function(e){var t=ha();return e={current:e},t.memoizedState=e},useState:function(e){e=Tf(e);var t=e.queue,i=Jp.bind(null,mt,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:Df,useDeferredValue:function(e,t){var i=ha();return Lf(i,e,t)},useTransition:function(){var e=Tf(!1);return e=Yp.bind(null,mt,e.queue,!0,!1),ha().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var o=mt,f=ha();if(wt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=t(),Vt===null)throw Error(l(349));(kt&127)!==0||Cp(o,t,i)}f.memoizedState=i;var h={value:i,getSnapshot:t};return f.queue=h,Bp(kp.bind(null,o,h,e),[e]),o.flags|=2048,lo(9,{destroy:void 0},jp.bind(null,o,h,i,t),null),i},useId:function(){var e=ha(),t=Vt.identifierPrefix;if(wt){var i=Oa,o=sa;i=(o&~(1<<32-gt(o)-1)).toString(32)+i,t="_"+t+"R_"+i,i=wu++,0<i&&(t+="H"+i.toString(32)),t+="_"}else i=Sw++,t="_"+t+"r_"+i.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:zf,useFormState:_p,useActionState:_p,useOptimistic:function(e){var t=ha();t.memoizedState=t.baseState=e;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=i,t=If.bind(null,mt,!0,i),i.dispatch=t,[e,t]},useMemoCache:Af,useCacheRefresh:function(){return ha().memoizedState=Mw.bind(null,mt)},useEffectEvent:function(e){var t=ha(),i={impl:e};return t.memoizedState=i,function(){if((Lt&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},Of={readContext:Jt,use:Cu,useCallback:Gp,useContext:Jt,useEffect:Rf,useImperativeHandle:qp,useInsertionEffect:Pp,useLayoutEffect:$p,useMemo:Vp,useReducer:ju,useRef:Hp,useState:function(){return ju(Ci)},useDebugValue:Df,useDeferredValue:function(e,t){var i=wn();return Wp(i,$t.memoizedState,e,t)},useTransition:function(){var e=ju(Ci)[0],t=wn().memoizedState;return[typeof e=="boolean"?e:ec(e),t]},useSyncExternalStore:Sp,useId:Xp,useHostTransitionStatus:zf,useFormState:zp,useActionState:zp,useOptimistic:function(e,t){var i=wn();return Mp(i,$t,e,t)},useMemoCache:Af,useCacheRefresh:Zp};Of.useEffectEvent=Fp;var ag={readContext:Jt,use:Cu,useCallback:Gp,useContext:Jt,useEffect:Rf,useImperativeHandle:qp,useInsertionEffect:Pp,useLayoutEffect:$p,useMemo:Vp,useReducer:Mf,useRef:Hp,useState:function(){return Mf(Ci)},useDebugValue:Df,useDeferredValue:function(e,t){var i=wn();return $t===null?Lf(i,e,t):Wp(i,$t.memoizedState,e,t)},useTransition:function(){var e=Mf(Ci)[0],t=wn().memoizedState;return[typeof e=="boolean"?e:ec(e),t]},useSyncExternalStore:Sp,useId:Xp,useHostTransitionStatus:zf,useFormState:Op,useActionState:Op,useOptimistic:function(e,t){var i=wn();return $t!==null?Mp(i,$t,e,t):(i.baseState=e,[e,i.queue.dispatch])},useMemoCache:Af,useCacheRefresh:Zp};ag.useEffectEvent=Fp;function Hf(e,t,i,o){t=e.memoizedState,i=i(o,t),i=i==null?t:x({},t,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Bf={enqueueSetState:function(e,t,i){e=e._reactInternals;var o=Ga(),f=de(o);f.payload=t,i!=null&&(f.callback=i),t=Re(e,f,o),t!==null&&(Ma(t,e,o),$e(t,e,o))},enqueueReplaceState:function(e,t,i){e=e._reactInternals;var o=Ga(),f=de(o);f.tag=1,f.payload=t,i!=null&&(f.callback=i),t=Re(e,f,o),t!==null&&(Ma(t,e,o),$e(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var i=Ga(),o=de(i);o.tag=2,t!=null&&(o.callback=t),t=Re(e,o,i),t!==null&&(Ma(t,e,i),$e(t,e,i))}};function sg(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?!Ji(i,o)||!Ji(f,h):!0}function ig(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&&Bf.enqueueReplaceState(t,t.state,null)}function gl(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=x({},i));for(var f in e)i[f]===void 0&&(i[f]=e[f])}return i}function rg(e){ar(e)}function lg(e){console.error(e)}function og(e){ar(e)}function Mu(e,t){try{var i=e.onUncaughtError;i(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function cg(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 Ff(e,t,i){return i=de(i),i.tag=3,i.payload={element:null},i.callback=function(){Mu(e,t)},i}function ug(e){return e=de(e),e.tag=3,e}function dg(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(){cg(t,i,o)}}var S=i.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){cg(t,i,o),typeof f!="function"&&(wr===null?wr=new Set([this]):wr.add(this));var E=o.stack;this.componentDidCatch(o.value,{componentStack:E!==null?E:""})})}function Ew(e,t,i,o,f){if(i.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=i.alternate,t!==null&&Mn(t,i,f,!0),i=Pa.current,i!==null){switch(i.tag){case 31:case 13:return cs===null?Fu():i.alternate===null&&mn===0&&(mn=3),i.flags&=-257,i.flags|=65536,i.lanes=f,o===so?i.flags|=16384:(t=i.updateQueue,t===null?i.updateQueue=new Set([o]):t.add(o),dm(e,o,f)),!1;case 22:return i.flags|=65536,o===so?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)),dm(e,o,f)),!1}throw Error(l(435,i.tag))}return dm(e,o,f),Fu(),!1}if(wt)return t=Pa.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=f,o!==Ko&&(e=Error(l(422),{cause:o}),Me(na(e,i)))):(o!==Ko&&(t=Error(l(423),{cause:o}),Me(na(t,i))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=na(o,i),f=Ff(e.stateNode,o,f),Xe(e,f),mn!==4&&(mn=2)),!1;var h=Error(l(520),{cause:o});if(h=na(h,i),uc===null?uc=[h]:uc.push(h),mn!==4&&(mn=2),t===null)return!0;o=na(o,i),i=t;do{switch(i.tag){case 3:return i.flags|=65536,e=f&-f,i.lanes|=e,e=Ff(i.stateNode,o,e),Xe(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"&&(wr===null||!wr.has(h))))return i.flags|=65536,f&=-f,i.lanes|=f,f=ug(f),dg(f,e,i,o),Xe(i,f),!1}i=i.return}while(i!==null);return!1}var Pf=Error(l(461)),Rn=!1;function Yn(e,t,i,o){t.child=e===null?L(t,null,i,o):M(t,e.child,i,o)}function fg(e,t,i,o,f){i=i.render;var h=t.ref;if("ref"in o){var S={};for(var E in o)E!=="ref"&&(S[E]=o[E])}else S=o;return pi(t),o=Sf(e,t,i,S,h,f),E=Cf(),e!==null&&!Rn?(jf(e,t,f),ji(e,t,f)):(wt&&E&&lr(t),t.flags|=1,Yn(e,t,o,f),t.child)}function mg(e,t,i,o,f){if(e===null){var h=i.type;return typeof h=="function"&&!Sa(h)&&h.defaultProps===void 0&&i.compare===null?(t.tag=15,t.type=h,hg(e,t,h,o,f)):(e=Ks(i.type,null,o,t,t.mode,f),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,!Kf(e,f)){var S=h.memoizedProps;if(i=i.compare,i=i!==null?i:Ji,i(S,o)&&e.ref===t.ref)return ji(e,t,f)}return t.flags|=1,e=rs(h,o),e.ref=t.ref,e.return=t,t.child=e}function hg(e,t,i,o,f){if(e!==null){var h=e.memoizedProps;if(Ji(h,o)&&e.ref===t.ref)if(Rn=!1,t.pendingProps=o=h,Kf(e,f))(e.flags&131072)!==0&&(Rn=!0);else return t.lanes=e.lanes,ji(e,t,f)}return $f(e,t,i,o,f)}function pg(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 gg(e,t,h,i,o)}if((i&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ul(t,h!==null?h.cachePool:null),h!==null?yu(t,h):yf(),xp(t);else return o=t.lanes=536870912,gg(e,t,h!==null?h.baseLanes|i:i,i,o)}else h!==null?(ul(t,h.cachePool),yu(t,h),vr(),t.memoizedState=null):(e!==null&&ul(t,null),yf(),vr());return Yn(e,t,f,i),t.child}function ac(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function gg(e,t,i,o,f){var h=vi();return h=h===null?null:{parent:en._currentValue,pool:h},t.memoizedState={baseLanes:i,cachePool:h},e!==null&&ul(t,null),yf(),xp(t),e!==null&&Mn(e,t,o,!0),t.childLanes=f,null}function Tu(e,t){return t=Ru({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function vg(e,t,i){return M(t,e.child,null,i),e=Tu(t,t.pendingProps),e.flags|=2,$a(t),t.memoizedState=null,e}function Rw(e,t,i){var o=t.pendingProps,f=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(wt){if(o.mode==="hidden")return e=Tu(t,o),t.lanes=536870912,ac(null,e);if(bf(t),(e=Gt)?(e=Tv(e,ma),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:bs!==null?{id:sa,overflow:Oa}:null,retryLane:536870912,hydrationErrors:null},i=Hn(e),i.return=t,t.child=i,un=t,Gt=null)):e=null,e===null)throw Ba(t);return t.lanes=536870912,null}return Tu(t,o)}var h=e.memoizedState;if(h!==null){var S=h.dehydrated;if(bf(t),f)if(t.flags&256)t.flags&=-257,t=vg(e,t,i);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(Rn||Mn(e,t,i,!1),f=(i&e.childLanes)!==0,Rn||f){if(o=Vt,o!==null&&(S=Pe(o,i),S!==0&&S!==h.retryLane))throw h.retryLane=S,wa(e,S),Ma(o,e,S),Pf;Fu(),t=vg(e,t,i)}else e=h.treeContext,Gt=us(S.nextSibling),un=t,wt=!0,ws=null,ma=!1,e!==null&&du(t,e),t=Tu(t,o),t.flags|=4096;return t}return e=rs(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Eu(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 $f(e,t,i,o,f){return pi(t),i=Sf(e,t,i,o,void 0,f),o=Cf(),e!==null&&!Rn?(jf(e,t,f),ji(e,t,f)):(wt&&o&&lr(t),t.flags|=1,Yn(e,t,i,f),t.child)}function yg(e,t,i,o,f,h){return pi(t),t.updateQueue=null,i=wp(t,o,i,f),bp(e),o=Cf(),e!==null&&!Rn?(jf(e,t,h),ji(e,t,h)):(wt&&o&&lr(t),t.flags|=1,Yn(e,t,i,h),t.child)}function xg(e,t,i,o,f){if(pi(t),t.stateNode===null){var h=xs,S=i.contextType;typeof S=="object"&&S!==null&&(h=Jt(S)),h=new i(o,h),t.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Bf,t.stateNode=h,h._reactInternals=t,h=t.stateNode,h.props=o,h.state=t.memoizedState,h.refs={},z(t),S=i.contextType,h.context=typeof S=="object"&&S!==null?Jt(S):xs,h.state=t.memoizedState,S=i.getDerivedStateFromProps,typeof S=="function"&&(Hf(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&&Bf.enqueueReplaceState(h,h.state,null),Wn(t,o,h,f),dn(),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){h=t.stateNode;var E=t.memoizedProps,P=gl(i,E);h.props=P;var le=h.context,ye=i.contextType;S=xs,typeof ye=="object"&&ye!==null&&(S=Jt(ye));var Ce=i.getDerivedStateFromProps;ye=typeof Ce=="function"||typeof h.getSnapshotBeforeUpdate=="function",E=t.pendingProps!==E,ye||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(E||le!==S)&&ig(t,h,o,S),F=!1;var oe=t.memoizedState;h.state=oe,Wn(t,o,h,f),dn(),le=t.memoizedState,E||oe!==le||F?(typeof Ce=="function"&&(Hf(t,i,Ce,o),le=t.memoizedState),(P=F||sg(t,i,P,o,oe,le,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=le),h.props=o,h.state=le,h.context=S,o=P):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{h=t.stateNode,pe(e,t),S=t.memoizedProps,ye=gl(i,S),h.props=ye,Ce=t.pendingProps,oe=h.context,le=i.contextType,P=xs,typeof le=="object"&&le!==null&&(P=Jt(le)),E=i.getDerivedStateFromProps,(le=typeof E=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(S!==Ce||oe!==P)&&ig(t,h,o,P),F=!1,oe=t.memoizedState,h.state=oe,Wn(t,o,h,f),dn();var me=t.memoizedState;S!==Ce||oe!==me||F||e!==null&&e.dependencies!==null&&xt(e.dependencies)?(typeof E=="function"&&(Hf(t,i,E,o),me=t.memoizedState),(ye=F||sg(t,i,ye,o,oe,me,P)||e!==null&&e.dependencies!==null&&xt(e.dependencies))?(le||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,me,P),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,me,P)),typeof h.componentDidUpdate=="function"&&(t.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=me),h.props=o,h.state=me,h.context=P,o=ye):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=1024),o=!1)}return h=o,Eu(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=M(t,e.child,null,f),t.child=M(t,null,i,f)):Yn(e,t,i,f),t.memoizedState=h.state,e=t.child):e=ji(e,t,f),e}function bg(e,t,i,o){return Cs(),t.flags|=256,Yn(e,t,i,o),t.child}var Uf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qf(e){return{baseLanes:e,cachePool:hu()}}function Gf(e,t,i){return e=e!==null?e.childLanes&~i:0,t&&(e|=qa),e}function wg(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:(bn.current&2)!==0),S&&(f=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(wt){if(f?gr(t):vr(),(e=Gt)?(e=Tv(e,ma),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:bs!==null?{id:sa,overflow:Oa}:null,retryLane:536870912,hydrationErrors:null},i=Hn(e),i.return=t,t.child=i,un=t,Gt=null)):e=null,e===null)throw Ba(t);return Nm(e)?t.lanes=32:t.lanes=536870912,null}var E=o.children;return o=o.fallback,f?(vr(),f=t.mode,E=Ru({mode:"hidden",children:E},f),o=mi(o,f,i,null),E.return=t,o.return=t,E.sibling=o,t.child=E,o=t.child,o.memoizedState=qf(i),o.childLanes=Gf(e,S,i),t.memoizedState=Uf,ac(null,o)):(gr(t),Vf(t,E))}var P=e.memoizedState;if(P!==null&&(E=P.dehydrated,E!==null)){if(h)t.flags&256?(gr(t),t.flags&=-257,t=Wf(e,t,i)):t.memoizedState!==null?(vr(),t.child=e.child,t.flags|=128,t=null):(vr(),E=o.fallback,f=t.mode,o=Ru({mode:"visible",children:o.children},f),E=mi(E,f,i,null),E.flags|=2,o.return=t,E.return=t,o.sibling=E,t.child=o,M(t,e.child,null,i),o=t.child,o.memoizedState=qf(i),o.childLanes=Gf(e,S,i),t.memoizedState=Uf,t=ac(null,o));else if(gr(t),Nm(E)){if(S=E.nextSibling&&E.nextSibling.dataset,S)var le=S.dgst;S=le,o=Error(l(419)),o.stack="",o.digest=S,Me({value:o,source:null,stack:null}),t=Wf(e,t,i)}else if(Rn||Mn(e,t,i,!1),S=(i&e.childLanes)!==0,Rn||S){if(S=Vt,S!==null&&(o=Pe(S,i),o!==0&&o!==P.retryLane))throw P.retryLane=o,wa(e,o),Ma(S,e,o),Pf;Am(E)||Fu(),t=Wf(e,t,i)}else Am(E)?(t.flags|=192,t.child=e.child,t=null):(e=P.treeContext,Gt=us(E.nextSibling),un=t,wt=!0,ws=null,ma=!1,e!==null&&du(t,e),t=Vf(t,o.children),t.flags|=4096);return t}return f?(vr(),E=o.fallback,f=t.mode,P=e.child,le=P.sibling,o=rs(P,{mode:"hidden",children:o.children}),o.subtreeFlags=P.subtreeFlags&65011712,le!==null?E=rs(le,E):(E=mi(E,f,i,null),E.flags|=2),E.return=t,o.return=t,o.sibling=E,t.child=o,ac(null,o),o=t.child,E=e.child.memoizedState,E===null?E=qf(i):(f=E.cachePool,f!==null?(P=en._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=hu(),E={baseLanes:E.baseLanes|i,cachePool:f}),o.memoizedState=E,o.childLanes=Gf(e,S,i),t.memoizedState=Uf,ac(e.child,o)):(gr(t),i=e.child,e=i.sibling,i=rs(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 Vf(e,t){return t=Ru({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Ru(e,t){return e=ta(22,e,null,t),e.lanes=0,e}function Wf(e,t,i){return M(t,e.child,null,i),e=Vf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Sg(e,t,i){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),ur(e.return,t,i)}function Yf(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 Cg(e,t,i){var o=t.pendingProps,f=o.revealOrder,h=o.tail;o=o.children;var S=bn.current,E=(S&2)!==0;if(E?(S=S&1|2,t.flags|=128):S&=1,$(bn,S),Yn(e,t,o,i),o=wt?il:0,!E&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Sg(e,i,t);else if(e.tag===19)Sg(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&&xu(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=t.child,t.child=null):(f=i.sibling,i.sibling=null),Yf(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&&xu(e)===null){t.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}Yf(t,!0,i,null,h,o);break;case"together":Yf(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function ji(e,t,i){if(e!==null&&(t.dependencies=e.dependencies),br|=t.lanes,(i&t.childLanes)===0)if(e!==null){if(Mn(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=rs(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=rs(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}function Kf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&xt(e)))}function Dw(e,t,i){switch(t.tag){case 3:_e(t,t.stateNode.containerInfo),hi(t,en,e.memoizedState.cache),Cs();break;case 27:case 5:Z(t);break;case 4:_e(t,t.stateNode.containerInfo);break;case 10:hi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,bf(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(gr(t),t.flags|=128,null):(i&t.child.childLanes)!==0?wg(e,t,i):(gr(t),e=ji(e,t,i),e!==null?e.sibling:null);gr(t);break;case 19:var f=(e.flags&128)!==0;if(o=(i&t.childLanes)!==0,o||(Mn(e,t,i,!1),o=(i&t.childLanes)!==0),f){if(o)return Cg(e,t,i);t.flags|=128}if(f=t.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),$(bn,bn.current),o)break;return null;case 22:return t.lanes=0,pg(e,t,i,t.pendingProps);case 24:hi(t,en,e.memoizedState.cache)}return ji(e,t,i)}function jg(e,t,i){if(e!==null)if(e.memoizedProps!==t.pendingProps)Rn=!0;else{if(!Kf(e,i)&&(t.flags&128)===0)return Rn=!1,Dw(e,t,i);Rn=(e.flags&131072)!==0}else Rn=!1,wt&&(t.flags&1048576)!==0&&uu(t,il,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Tn(t.elementType),t.type=e,typeof e=="function")Sa(e)?(o=gl(e,o),t.tag=1,t=xg(null,t,e,o,i)):(t.tag=0,t=$f(null,t,e,o,i));else{if(e!=null){var f=e.$$typeof;if(f===U){t.tag=11,t=fg(null,t,e,o,i);break e}else if(f===_){t.tag=14,t=mg(null,t,e,o,i);break e}}throw t=se(e)||e,Error(l(306,t,""))}}return t;case 0:return $f(e,t,t.type,t.pendingProps,i);case 1:return o=t.type,f=gl(o,t.pendingProps),xg(e,t,o,f,i);case 3:e:{if(_e(t,t.stateNode.containerInfo),e===null)throw Error(l(387));o=t.pendingProps;var h=t.memoizedState;f=h.element,pe(e,t),Wn(t,o,null,i);var S=t.memoizedState;if(o=S.cache,hi(t,en,o),o!==h.cache&&yn(t,[en],i,!0),dn(),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=bg(e,t,o,i);break e}else if(o!==f){f=na(Error(l(424)),t),Me(f),t=bg(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,Gt=us(e.firstChild),un=t,wt=!0,ws=null,ma=!0,i=L(t,null,o,i),t.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Cs(),o===f){t=ji(e,t,i);break e}Yn(e,t,o,i)}t=t.child}return t;case 26:return Eu(e,t),e===null?(i=zv(t.type,null,t.pendingProps,null))?t.memoizedState=i:wt||(i=t.type,e=t.pendingProps,o=Wu(ve.current).createElement(i),o[ee]=t,o[Ne]=e,Kn(o,i,e),Pt(o),t.stateNode=o):t.memoizedState=zv(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Z(t),e===null&&wt&&(o=t.stateNode=Dv(t.type,t.pendingProps,ve.current),un=t,ma=!0,f=Gt,kr(t.type)?(Mm=f,Gt=us(o.firstChild)):Gt=f),Yn(e,t,t.pendingProps.children,i),Eu(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&wt&&((f=o=Gt)&&(o=oS(o,t.type,t.pendingProps,ma),o!==null?(t.stateNode=o,un=t,Gt=us(o.firstChild),ma=!1,f=!0):f=!1),f||Ba(t)),Z(t),f=t.type,h=t.pendingProps,S=e!==null?e.memoizedProps:null,o=h.children,Cm(f,h)?o=null:S!==null&&Cm(f,S)&&(t.flags|=32),t.memoizedState!==null&&(f=Sf(e,t,Cw,null,null,i),yc._currentValue=f),Eu(e,t),Yn(e,t,o,i),t.child;case 6:return e===null&&wt&&((e=i=Gt)&&(i=cS(i,t.pendingProps,ma),i!==null?(t.stateNode=i,un=t,Gt=null,e=!0):e=!1),e||Ba(t)),null;case 13:return wg(e,t,i);case 4:return _e(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=M(t,null,o,i):Yn(e,t,o,i),t.child;case 11:return fg(e,t,t.type,t.pendingProps,i);case 7:return Yn(e,t,t.pendingProps,i),t.child;case 8:return Yn(e,t,t.pendingProps.children,i),t.child;case 12:return Yn(e,t,t.pendingProps.children,i),t.child;case 10:return o=t.pendingProps,hi(t,t.type,o.value),Yn(e,t,o.children,i),t.child;case 9:return f=t.type._context,o=t.pendingProps.children,pi(t),f=Jt(f),o=o(f),t.flags|=1,Yn(e,t,o,i),t.child;case 14:return mg(e,t,t.type,t.pendingProps,i);case 15:return hg(e,t,t.type,t.pendingProps,i);case 19:return Cg(e,t,i);case 31:return Rw(e,t,i);case 22:return pg(e,t,i,t.pendingProps);case 24:return pi(t),o=Jt(en),e===null?(f=vi(),f===null&&(f=Vt,h=Qo(),f.pooledCache=h,h.refCount++,h!==null&&(f.pooledCacheLanes|=i),f=h),t.memoizedState={parent:o,cache:f},z(t),hi(t,en,f)):((e.lanes&i)!==0&&(pe(e,t),Wn(t,null,null,i),dn()),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),hi(t,en,o)):(o=h.cache,hi(t,en,o),o!==f.cache&&yn(t,[en],i,!0))),Yn(e,t,t.pendingProps.children,i),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function ki(e){e.flags|=4}function Qf(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(Xg())e.flags|=8192;else throw yi=so,Zo}else e.flags&=-16777217}function kg(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Fv(t))if(Xg())e.flags|=8192;else throw yi=so,Zo}function Du(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Qt():536870912,e.lanes|=t,fo|=t)}function sc(e,t){if(!wt)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 Xt(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 Lw(e,t,i){var o=t.pendingProps;switch(Yo(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xt(t),null;case 1:return Xt(t),null;case 3:return i=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),Fa(en),re(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(or(t)?ki(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,ll())),Xt(t),null;case 26:var f=t.type,h=t.memoizedState;return e===null?(ki(t),h!==null?(Xt(t),kg(t,h)):(Xt(t),Qf(t,f,null,o,i))):h?h!==e.memoizedState?(ki(t),Xt(t),kg(t,h)):(Xt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&ki(t),Xt(t),Qf(t,f,e,o,i)),null;case 27:if(ze(t),i=ve.current,f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ki(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Xt(t),null}e=ue.current,or(t)?Ss(t):(e=Dv(f,o,i),t.stateNode=e,ki(t))}return Xt(t),null;case 5:if(ze(t),f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ki(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Xt(t),null}if(h=ue.current,or(t))Ss(t);else{var S=Wu(ve.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[ee]=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(Kn(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&&ki(t)}}return Xt(t),Qf(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&ki(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(l(166));if(e=ve.current,or(t)){if(e=t.stateNode,i=t.memoizedProps,o=null,f=un,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[ee]=t,e=!!(e.nodeValue===i||o!==null&&o.suppressHydrationWarning===!0||wv(e.nodeValue,i)),e||Ba(t,!0)}else e=Wu(e).createTextNode(o),e[ee]=t,t.stateNode=e}return Xt(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(o=or(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[ee]=t}else Cs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Xt(t),e=!1}else i=ll(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Xt(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=or(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[ee]=t}else Cs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Xt(t),f=!1}else f=ll(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?($a(t),t):($a(t),null)}return $a(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),Du(t,t.updateQueue),Xt(t),null);case 4:return re(),e===null&&ym(t.stateNode.containerInfo),Xt(t),null;case 10:return Fa(t.type),Xt(t),null;case 19:if(X(bn),o=t.memoizedState,o===null)return Xt(t),null;if(f=(t.flags&128)!==0,h=o.rendering,h===null)if(f)sc(o,!1);else{if(mn!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(h=xu(e),h!==null){for(t.flags|=128,sc(o,!1),e=h.updateQueue,t.updateQueue=e,Du(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)ir(i,e),i=i.sibling;return $(bn,bn.current&1|2),wt&&Ha(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&ot()>Ou&&(t.flags|=128,f=!0,sc(o,!1),t.lanes=4194304)}else{if(!f)if(e=xu(h),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,Du(t,e),sc(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!wt)return Xt(t),null}else 2*ot()-o.renderingStartTime>Ou&&i!==536870912&&(t.flags|=128,f=!0,sc(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=ot(),e.sibling=null,i=bn.current,$(bn,f?i&1|2:i&1),wt&&Ha(t,o.treeForkCount),e):(Xt(t),null);case 22:case 23:return $a(t),xf(),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&&(Xt(t),t.subtreeFlags&6&&(t.flags|=8192)):Xt(t),i=t.updateQueue,i!==null&&Du(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&&X(os),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Fa(en),Xt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function _w(e,t){switch(Yo(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fa(en),re(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ze(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(l(340));Cs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));Cs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return X(bn),null;case 4:return re(),null;case 10:return Fa(t.type),null;case 22:case 23:return $a(t),xf(),e!==null&&X(os),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Fa(en),null;case 25:return null;default:return null}}function Ag(e,t){switch(Yo(t),t.tag){case 3:Fa(en),re();break;case 26:case 27:case 5:ze(t);break;case 4:re();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:X(bn);break;case 10:Fa(t.type);break;case 22:case 23:$a(t),xf(),e!==null&&X(os);break;case 24:Fa(en)}}function ic(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(E){Ht(t,t.return,E)}}function yr(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,E=S.destroy;if(E!==void 0){S.destroy=void 0,f=t;var P=i,le=E;try{le()}catch(ye){Ht(f,P,ye)}}}o=o.next}while(o!==h)}}catch(ye){Ht(t,t.return,ye)}}function Ng(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{hl(t,i)}catch(o){Ht(e,e.return,o)}}}function Mg(e,t,i){i.props=gl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(o){Ht(e,t,o)}}function rc(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){Ht(e,t,f)}}function Xs(e,t){var i=e.ref,o=e.refCleanup;if(i!==null)if(typeof o=="function")try{o()}catch(f){Ht(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){Ht(e,t,f)}else i.current=null}function Tg(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){Ht(e,e.return,f)}}function Xf(e,t,i){try{var o=e.stateNode;nS(o,e.type,i,t),o[Ne]=t}catch(f){Ht(e,e.return,f)}}function Eg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&kr(e.type)||e.tag===4}function Zf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Eg(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&kr(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 Jf(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=_a));else if(o!==4&&(o===27&&kr(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(Jf(e,t,i),e=e.sibling;e!==null;)Jf(e,t,i),e=e.sibling}function Lu(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&&kr(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(Lu(e,t,i),e=e.sibling;e!==null;)Lu(e,t,i),e=e.sibling}function Rg(e){var t=e.stateNode,i=e.memoizedProps;try{for(var o=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);Kn(t,o,i),t[ee]=e,t[Ne]=i}catch(h){Ht(e,e.return,h)}}var Ai=!1,Dn=!1,em=!1,Dg=typeof WeakSet=="function"?WeakSet:Set,Bn=null;function zw(e,t){if(e=e.containerInfo,wm=ed,e=lu(e),Kl(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,E=-1,P=-1,le=0,ye=0,Ce=e,oe=null;t:for(;;){for(var me;Ce!==i||f!==0&&Ce.nodeType!==3||(E=S+f),Ce!==h||o!==0&&Ce.nodeType!==3||(P=S+o),Ce.nodeType===3&&(S+=Ce.nodeValue.length),(me=Ce.firstChild)!==null;)oe=Ce,Ce=me;for(;;){if(Ce===e)break t;if(oe===i&&++le===f&&(E=S),oe===h&&++ye===o&&(P=S),(me=Ce.nextSibling)!==null)break;Ce=oe,oe=Ce.parentNode}Ce=me}i=E===-1||P===-1?null:{start:E,end:P}}else i=null}i=i||{start:0,end:0}}else i=null;for(Sm={focusedElem:e,selectionRange:i},ed=!1,Bn=t;Bn!==null;)if(t=Bn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Bn=e;else for(;Bn!==null;){switch(t=Bn,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 Ye=gl(i.type,f);e=o.getSnapshotBeforeUpdate(Ye,h),o.__reactInternalSnapshotBeforeUpdate=e}catch(tt){Ht(i,i.return,tt)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,i=e.nodeType,i===9)km(e);else if(i===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":km(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,Bn=e;break}Bn=t.return}}function Lg(e,t,i){var o=i.flags;switch(i.tag){case 0:case 11:case 15:Mi(e,i),o&4&&ic(5,i);break;case 1:if(Mi(e,i),o&4)if(e=i.stateNode,t===null)try{e.componentDidMount()}catch(S){Ht(i,i.return,S)}else{var f=gl(i.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(f,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){Ht(i,i.return,S)}}o&64&&Ng(i),o&512&&rc(i,i.return);break;case 3:if(Mi(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{hl(e,t)}catch(S){Ht(i,i.return,S)}}break;case 27:t===null&&o&4&&Rg(i);case 26:case 5:Mi(e,i),t===null&&o&4&&Tg(i),o&512&&rc(i,i.return);break;case 12:Mi(e,i);break;case 31:Mi(e,i),o&4&&Ig(e,i);break;case 13:Mi(e,i),o&4&&Og(e,i),o&64&&(e=i.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(i=qw.bind(null,i),uS(e,i))));break;case 22:if(o=i.memoizedState!==null||Ai,!o){t=t!==null&&t.memoizedState!==null||Dn,f=Ai;var h=Dn;Ai=o,(Dn=t)&&!h?Ti(e,i,(i.subtreeFlags&8772)!==0):Mi(e,i),Ai=f,Dn=h}break;case 30:break;default:Mi(e,i)}}function _g(e){var t=e.alternate;t!==null&&(e.alternate=null,_g(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&kn(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 nn=null,ja=!1;function Ni(e,t,i){for(i=i.child;i!==null;)zg(e,t,i),i=i.sibling}function zg(e,t,i){if(ke&&typeof ke.onCommitFiberUnmount=="function")try{ke.onCommitFiberUnmount(Fe,i)}catch{}switch(i.tag){case 26:Dn||Xs(i,t),Ni(e,t,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Dn||Xs(i,t);var o=nn,f=ja;kr(i.type)&&(nn=i.stateNode,ja=!1),Ni(e,t,i),pc(i.stateNode),nn=o,ja=f;break;case 5:Dn||Xs(i,t);case 6:if(o=nn,f=ja,nn=null,Ni(e,t,i),nn=o,ja=f,nn!==null)if(ja)try{(nn.nodeType===9?nn.body:nn.nodeName==="HTML"?nn.ownerDocument.body:nn).removeChild(i.stateNode)}catch(h){Ht(i,t,h)}else try{nn.removeChild(i.stateNode)}catch(h){Ht(i,t,h)}break;case 18:nn!==null&&(ja?(e=nn,Nv(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,i.stateNode),bo(e)):Nv(nn,i.stateNode));break;case 4:o=nn,f=ja,nn=i.stateNode.containerInfo,ja=!0,Ni(e,t,i),nn=o,ja=f;break;case 0:case 11:case 14:case 15:yr(2,i,t),Dn||yr(4,i,t),Ni(e,t,i);break;case 1:Dn||(Xs(i,t),o=i.stateNode,typeof o.componentWillUnmount=="function"&&Mg(i,t,o)),Ni(e,t,i);break;case 21:Ni(e,t,i);break;case 22:Dn=(o=Dn)||i.memoizedState!==null,Ni(e,t,i),Dn=o;break;default:Ni(e,t,i)}}function Ig(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{bo(e)}catch(i){Ht(t,t.return,i)}}}function Og(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{bo(e)}catch(i){Ht(t,t.return,i)}}function Iw(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Dg),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Dg),t;default:throw Error(l(435,e.tag))}}function _u(e,t){var i=Iw(e);t.forEach(function(o){if(!i.has(o)){i.add(o);var f=Gw.bind(null,e,o);o.then(f,f)}})}function ka(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,E=S;e:for(;E!==null;){switch(E.tag){case 27:if(kr(E.type)){nn=E.stateNode,ja=!1;break e}break;case 5:nn=E.stateNode,ja=!1;break e;case 3:case 4:nn=E.stateNode.containerInfo,ja=!0;break e}E=E.return}if(nn===null)throw Error(l(160));zg(h,S,f),nn=null,ja=!1,h=f.alternate,h!==null&&(h.return=null),f.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Hg(t,e),t=t.sibling}var As=null;function Hg(e,t){var i=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ka(t,e),Aa(e),o&4&&(yr(3,e,e.return),ic(3,e),yr(5,e,e.return));break;case 1:ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(i,i.return)),o&64&&Ai&&(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=As;if(ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(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[ut]||h[ee]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=f.createElement(o),f.head.insertBefore(h,f.querySelector("head > title"))),Kn(h,o,i),h[ee]=e,Pt(h),o=h;break e;case"link":var S=Hv("link","href",f).get(o+(i.href||""));if(S){for(var E=0;E<S.length;E++)if(h=S[E],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(E,1);break t}}h=f.createElement(o),Kn(h,o,i),f.head.appendChild(h);break;case"meta":if(S=Hv("meta","content",f).get(o+(i.content||""))){for(E=0;E<S.length;E++)if(h=S[E],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(E,1);break t}}h=f.createElement(o),Kn(h,o,i),f.head.appendChild(h);break;default:throw Error(l(468,o))}h[ee]=e,Pt(h),o=h}e.stateNode=o}else Bv(f,e.type,e.stateNode);else e.stateNode=Ov(f,o,e.memoizedProps);else h!==o?(h===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):h.count--,o===null?Bv(f,e.type,e.stateNode):Ov(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Xf(e,e.memoizedProps,i.memoizedProps)}break;case 27:ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(i,i.return)),i!==null&&o&4&&Xf(e,e.memoizedProps,i.memoizedProps);break;case 5:if(ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(i,i.return)),e.flags&32){f=e.stateNode;try{gs(f,"")}catch(Ye){Ht(e,e.return,Ye)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,Xf(e,f,i!==null?i.memoizedProps:f)),o&1024&&(em=!0);break;case 6:if(ka(t,e),Aa(e),o&4){if(e.stateNode===null)throw Error(l(162));o=e.memoizedProps,i=e.stateNode;try{i.nodeValue=o}catch(Ye){Ht(e,e.return,Ye)}}break;case 3:if(Qu=null,f=As,As=Yu(t.containerInfo),ka(t,e),As=f,Aa(e),o&4&&i!==null&&i.memoizedState.isDehydrated)try{bo(t.containerInfo)}catch(Ye){Ht(e,e.return,Ye)}em&&(em=!1,Bg(e));break;case 4:o=As,As=Yu(e.stateNode.containerInfo),ka(t,e),Aa(e),As=o;break;case 12:ka(t,e),Aa(e);break;case 31:ka(t,e),Aa(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,_u(e,o)));break;case 13:ka(t,e),Aa(e),e.child.flags&8192&&e.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(Iu=ot()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,_u(e,o)));break;case 22:f=e.memoizedState!==null;var P=i!==null&&i.memoizedState!==null,le=Ai,ye=Dn;if(Ai=le||f,Dn=ye||P,ka(t,e),Dn=ye,Ai=le,Aa(e),o&8192)e:for(t=e.stateNode,t._visibility=f?t._visibility&-2:t._visibility|1,f&&(i===null||P||Ai||Dn||vl(e)),i=null,t=e;;){if(t.tag===5||t.tag===26){if(i===null){P=i=t;try{if(h=P.stateNode,f)S=h.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{E=P.stateNode;var Ce=P.memoizedProps.style,oe=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;E.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch(Ye){Ht(P,P.return,Ye)}}}else if(t.tag===6){if(i===null){P=t;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(Ye){Ht(P,P.return,Ye)}}}else if(t.tag===18){if(i===null){P=t;try{var me=P.stateNode;f?Mv(me,!0):Mv(P.stateNode,!1)}catch(Ye){Ht(P,P.return,Ye)}}}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,_u(e,i))));break;case 19:ka(t,e),Aa(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,_u(e,o)));break;case 30:break;case 21:break;default:ka(t,e),Aa(e)}}function Aa(e){var t=e.flags;if(t&2){try{for(var i,o=e.return;o!==null;){if(Eg(o)){i=o;break}o=o.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var f=i.stateNode,h=Zf(e);Lu(e,h,f);break;case 5:var S=i.stateNode;i.flags&32&&(gs(S,""),i.flags&=-33);var E=Zf(e);Lu(e,E,S);break;case 3:case 4:var P=i.stateNode.containerInfo,le=Zf(e);Jf(e,le,P);break;default:throw Error(l(161))}}catch(ye){Ht(e,e.return,ye)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Bg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Bg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Mi(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Lg(e,t.alternate,t),t=t.sibling}function vl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:yr(4,t,t.return),vl(t);break;case 1:Xs(t,t.return);var i=t.stateNode;typeof i.componentWillUnmount=="function"&&Mg(t,t.return,i),vl(t);break;case 27:pc(t.stateNode);case 26:case 5:Xs(t,t.return),vl(t);break;case 22:t.memoizedState===null&&vl(t);break;case 30:vl(t);break;default:vl(t)}e=e.sibling}}function Ti(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:Ti(f,h,i),ic(4,h);break;case 1:if(Ti(f,h,i),o=h,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(le){Ht(o,o.return,le)}if(o=h,f=o.updateQueue,f!==null){var E=o.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)ml(P[f],E)}catch(le){Ht(o,o.return,le)}}i&&S&64&&Ng(h),rc(h,h.return);break;case 27:Rg(h);case 26:case 5:Ti(f,h,i),i&&o===null&&S&4&&Tg(h),rc(h,h.return);break;case 12:Ti(f,h,i);break;case 31:Ti(f,h,i),i&&S&4&&Ig(f,h);break;case 13:Ti(f,h,i),i&&S&4&&Og(f,h);break;case 22:h.memoizedState===null&&Ti(f,h,i),rc(h,h.return);break;case 30:break;default:Ti(f,h,i)}t=t.sibling}}function tm(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&&cl(i))}function nm(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&cl(e))}function Ns(e,t,i,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Fg(e,t,i,o),t=t.sibling}function Fg(e,t,i,o){var f=t.flags;switch(t.tag){case 0:case 11:case 15:Ns(e,t,i,o),f&2048&&ic(9,t);break;case 1:Ns(e,t,i,o);break;case 3:Ns(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&&cl(e)));break;case 12:if(f&2048){Ns(e,t,i,o),e=t.stateNode;try{var h=t.memoizedProps,S=h.id,E=h.onPostCommit;typeof E=="function"&&E(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){Ht(t,t.return,P)}}else Ns(e,t,i,o);break;case 31:Ns(e,t,i,o);break;case 13:Ns(e,t,i,o);break;case 23:break;case 22:h=t.stateNode,S=t.alternate,t.memoizedState!==null?h._visibility&2?Ns(e,t,i,o):lc(e,t):h._visibility&2?Ns(e,t,i,o):(h._visibility|=2,oo(e,t,i,o,(t.subtreeFlags&10256)!==0||!1)),f&2048&&tm(S,t);break;case 24:Ns(e,t,i,o),f&2048&&nm(t.alternate,t);break;default:Ns(e,t,i,o)}}function oo(e,t,i,o,f){for(f=f&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var h=e,S=t,E=i,P=o,le=S.flags;switch(S.tag){case 0:case 11:case 15:oo(h,S,E,P,f),ic(8,S);break;case 23:break;case 22:var ye=S.stateNode;S.memoizedState!==null?ye._visibility&2?oo(h,S,E,P,f):lc(h,S):(ye._visibility|=2,oo(h,S,E,P,f)),f&&le&2048&&tm(S.alternate,S);break;case 24:oo(h,S,E,P,f),f&&le&2048&&nm(S.alternate,S);break;default:oo(h,S,E,P,f)}t=t.sibling}}function lc(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:lc(i,o),f&2048&&tm(o.alternate,o);break;case 24:lc(i,o),f&2048&&nm(o.alternate,o);break;default:lc(i,o)}t=t.sibling}}var oc=8192;function co(e,t,i){if(e.subtreeFlags&oc)for(e=e.child;e!==null;)Pg(e,t,i),e=e.sibling}function Pg(e,t,i){switch(e.tag){case 26:co(e,t,i),e.flags&oc&&e.memoizedState!==null&&SS(i,As,e.memoizedState,e.memoizedProps);break;case 5:co(e,t,i);break;case 3:case 4:var o=As;As=Yu(e.stateNode.containerInfo),co(e,t,i),As=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=oc,oc=16777216,co(e,t,i),oc=o):co(e,t,i));break;default:co(e,t,i)}}function $g(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];Bn=o,qg(o,e)}$g(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ug(e),e=e.sibling}function Ug(e){switch(e.tag){case 0:case 11:case 15:cc(e),e.flags&2048&&yr(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,zu(e)):cc(e);break;default:cc(e)}}function zu(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];Bn=o,qg(o,e)}$g(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:yr(8,t,t.return),zu(t);break;case 22:i=t.stateNode,i._visibility&2&&(i._visibility&=-3,zu(t));break;default:zu(t)}e=e.sibling}}function qg(e,t){for(;Bn!==null;){var i=Bn;switch(i.tag){case 0:case 11:case 15:yr(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:cl(i.memoizedState.cache)}if(o=i.child,o!==null)o.return=i,Bn=o;else e:for(i=e;Bn!==null;){o=Bn;var f=o.sibling,h=o.return;if(_g(o),o===i){Bn=null;break e}if(f!==null){f.return=h,Bn=f;break e}Bn=h}}}var Ow={getCacheForType:function(e){var t=Jt(en),i=t.data.get(e);return i===void 0&&(i=e(),t.data.set(e,i)),i},cacheSignal:function(){return Jt(en).controller.signal}},Hw=typeof WeakMap=="function"?WeakMap:Map,Lt=0,Vt=null,Ct=null,kt=0,Ot=0,Ua=null,xr=!1,uo=!1,am=!1,Ei=0,mn=0,br=0,yl=0,sm=0,qa=0,fo=0,uc=null,Na=null,im=!1,Iu=0,Gg=0,Ou=1/0,Hu=null,wr=null,_n=0,Sr=null,mo=null,Ri=0,rm=0,lm=null,Vg=null,dc=0,om=null;function Ga(){return(Lt&2)!==0&&kt!==0?kt&-kt:I.T!==null?hm():Qa()}function Wg(){if(qa===0)if((kt&536870912)===0||wt){var e=zt;zt<<=1,(zt&3932160)===0&&(zt=262144),qa=e}else qa=536870912;return e=Pa.current,e!==null&&(e.flags|=32),qa}function Ma(e,t,i){(e===Vt&&(Ot===2||Ot===9)||e.cancelPendingCommit!==null)&&(ho(e,0),Cr(e,kt,qa,!1)),bt(e,i),((Lt&2)===0||e!==Vt)&&(e===Vt&&((Lt&2)===0&&(yl|=i),mn===4&&Cr(e,kt,qa,!1)),Zs(e))}function Yg(e,t,i){if((Lt&6)!==0)throw Error(l(327));var o=!i&&(t&127)===0&&(t&e.expiredLanes)===0||dt(e,t),f=o?Pw(e,t):um(e,t,!0),h=o;do{if(f===0){uo&&!o&&Cr(e,t,0,!1);break}else{if(i=e.current.alternate,h&&!Bw(i)){f=um(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 E=e;f=uc;var P=E.current.memoizedState.isDehydrated;if(P&&(ho(E,S).flags|=256),S=um(E,S,!1),S!==2){if(am&&!P){E.errorRecoveryDisabledLanes|=h,yl|=h,f=4;break e}h=Na,Na=f,h!==null&&(Na===null?Na=h:Na.push.apply(Na,h))}f=S}if(h=!1,f!==2)continue}}if(f===1){ho(e,0),Cr(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:Cr(o,t,qa,!xr);break e;case 2:Na=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(f=Iu+300-ot(),10<f)){if(Cr(o,t,qa,!xr),va(o,0,!0)!==0)break e;Ri=t,o.timeoutHandle=kv(Kg.bind(null,o,i,Na,Hu,im,t,qa,yl,fo,xr,h,"Throttled",-0,0),f);break e}Kg(o,i,Na,Hu,im,t,qa,yl,fo,xr,h,null,-0,0)}}break}while(!0);Zs(e)}function Kg(e,t,i,o,f,h,S,E,P,le,ye,Ce,oe,me){if(e.timeoutHandle=-1,Ce=t.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:_a},Pg(t,h,Ce);var Ye=(h&62914560)===h?Iu-ot():(h&4194048)===h?Gg-ot():0;if(Ye=CS(Ce,Ye),Ye!==null){Ri=h,e.cancelPendingCommit=Ye(av.bind(null,e,t,h,i,o,f,S,E,P,ye,Ce,null,oe,me)),Cr(e,h,S,!le);return}}av(e,t,h,i,o,f,S,E,P)}function Bw(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(!Nn(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 Cr(e,t,i,o){t&=~sm,t&=~yl,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var f=t;0<f;){var h=31-gt(f),S=1<<h;o[h]=-1,f&=~S}i!==0&&_s(e,i,t)}function Bu(){return(Lt&6)===0?(fc(0),!1):!0}function cm(){if(Ct!==null){if(Ot===0)var e=Ct.return;else e=Ct,js=Qs=null,kf(e),hr=null,bi=0,e=Ct;for(;e!==null;)Ag(e.alternate,e),e=e.return;Ct=null}}function ho(e,t){var i=e.timeoutHandle;i!==-1&&(e.timeoutHandle=-1,iS(i)),i=e.cancelPendingCommit,i!==null&&(e.cancelPendingCommit=null,i()),Ri=0,cm(),Vt=e,Ct=i=rs(e.current,null),kt=t,Ot=0,Ua=null,xr=!1,uo=dt(e,t),am=!1,fo=qa=sm=yl=br=mn=0,Na=uc=null,im=!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-gt(o),h=1<<f;t|=e[f],o&=~h}return Ei=t,Ws(),i}function Qg(e,t){mt=null,I.H=nc,t===mr||t===ao?(t=vu(),Ot=3):t===Zo?(t=vu(),Ot=4):Ot=t===Pf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ua=t,Ct===null&&(mn=1,Mu(e,na(t,e.current)))}function Xg(){var e=Pa.current;return e===null?!0:(kt&4194048)===kt?cs===null:(kt&62914560)===kt||(kt&536870912)!==0?e===cs:!1}function Zg(){var e=I.H;return I.H=nc,e===null?nc:e}function Jg(){var e=I.A;return I.A=Ow,e}function Fu(){mn=4,xr||(kt&4194048)!==kt&&Pa.current!==null||(uo=!0),(br&134217727)===0&&(yl&134217727)===0||Vt===null||Cr(Vt,kt,qa,!1)}function um(e,t,i){var o=Lt;Lt|=2;var f=Zg(),h=Jg();(Vt!==e||kt!==t)&&(Hu=null,ho(e,t)),t=!1;var S=mn;e:do try{if(Ot!==0&&Ct!==null){var E=Ct,P=Ua;switch(Ot){case 8:cm(),S=6;break e;case 3:case 2:case 9:case 6:Pa.current===null&&(t=!0);var le=Ot;if(Ot=0,Ua=null,po(e,E,P,le),i&&uo){S=0;break e}break;default:le=Ot,Ot=0,Ua=null,po(e,E,P,le)}}Fw(),S=mn;break}catch(ye){Qg(e,ye)}while(!0);return t&&e.shellSuspendCounter++,js=Qs=null,Lt=o,I.H=f,I.A=h,Ct===null&&(Vt=null,kt=0,Ws()),S}function Fw(){for(;Ct!==null;)ev(Ct)}function Pw(e,t){var i=Lt;Lt|=2;var o=Zg(),f=Jg();Vt!==e||kt!==t?(Hu=null,Ou=ot()+500,ho(e,t)):uo=dt(e,t);e:do try{if(Ot!==0&&Ct!==null){t=Ct;var h=Ua;t:switch(Ot){case 1:Ot=0,Ua=null,po(e,t,h,1);break;case 2:case 9:if(pu(h)){Ot=0,Ua=null,tv(t);break}t=function(){Ot!==2&&Ot!==9||Vt!==e||(Ot=7),Zs(e)},h.then(t,t);break e;case 3:Ot=7;break e;case 4:Ot=5;break e;case 7:pu(h)?(Ot=0,Ua=null,tv(t)):(Ot=0,Ua=null,po(e,t,h,7));break;case 5:var S=null;switch(Ct.tag){case 26:S=Ct.memoizedState;case 5:case 27:var E=Ct;if(S?Fv(S):E.stateNode.complete){Ot=0,Ua=null;var P=E.sibling;if(P!==null)Ct=P;else{var le=E.return;le!==null?(Ct=le,Pu(le)):Ct=null}break t}}Ot=0,Ua=null,po(e,t,h,5);break;case 6:Ot=0,Ua=null,po(e,t,h,6);break;case 8:cm(),mn=6;break e;default:throw Error(l(462))}}$w();break}catch(ye){Qg(e,ye)}while(!0);return js=Qs=null,I.H=o,I.A=f,Lt=i,Ct!==null?0:(Vt=null,kt=0,Ws(),mn)}function $w(){for(;Ct!==null&&!We();)ev(Ct)}function ev(e){var t=jg(e.alternate,e,Ei);e.memoizedProps=e.pendingProps,t===null?Pu(e):Ct=t}function tv(e){var t=e,i=t.alternate;switch(t.tag){case 15:case 0:t=yg(i,t,t.pendingProps,t.type,void 0,kt);break;case 11:t=yg(i,t,t.pendingProps,t.type.render,t.ref,kt);break;case 5:kf(t);default:Ag(i,t),t=Ct=ir(t,Ei),t=jg(i,t,Ei)}e.memoizedProps=e.pendingProps,t===null?Pu(e):Ct=t}function po(e,t,i,o){js=Qs=null,kf(t),hr=null,bi=0;var f=t.return;try{if(Ew(e,f,t,i,kt)){mn=1,Mu(e,na(i,e.current)),Ct=null;return}}catch(h){if(f!==null)throw Ct=f,h;mn=1,Mu(e,na(i,e.current)),Ct=null;return}t.flags&32768?(wt||o===1?e=!0:uo||(kt&536870912)!==0?e=!1:(xr=e=!0,(o===2||o===9||o===3||o===6)&&(o=Pa.current,o!==null&&o.tag===13&&(o.flags|=16384))),nv(t,e)):Pu(t)}function Pu(e){var t=e;do{if((t.flags&32768)!==0){nv(t,xr);return}e=t.return;var i=Lw(t.alternate,t,Ei);if(i!==null){Ct=i;return}if(t=t.sibling,t!==null){Ct=t;return}Ct=t=e}while(t!==null);mn===0&&(mn=5)}function nv(e,t){do{var i=_w(e.alternate,e);if(i!==null){i.flags&=32767,Ct=i;return}if(i=e.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!t&&(e=e.sibling,e!==null)){Ct=e;return}Ct=e=i}while(e!==null);mn=6,Ct=null}function av(e,t,i,o,f,h,S,E,P){e.cancelPendingCommit=null;do $u();while(_n!==0);if((Lt&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(h=t.lanes|t.childLanes,h|=sr,qn(e,i,h,S,E,P),e===Vt&&(Ct=Vt=null,kt=0),mo=t,Sr=e,Ri=i,rm=h,lm=f,Vg=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Vw(ct,function(){return ov(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=I.T,I.T=null,f=Q.p,Q.p=2,S=Lt,Lt|=4;try{zw(e,t,i)}finally{Lt=S,Q.p=f,I.T=o}}_n=1,sv(),iv(),rv()}}function sv(){if(_n===1){_n=0;var e=Sr,t=mo,i=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||i){i=I.T,I.T=null;var o=Q.p;Q.p=2;var f=Lt;Lt|=4;try{Hg(t,e);var h=Sm,S=lu(e.containerInfo),E=h.focusedElem,P=h.selectionRange;if(S!==E&&E&&E.ownerDocument&&ui(E.ownerDocument.documentElement,E)){if(P!==null&&Kl(E)){var le=P.start,ye=P.end;if(ye===void 0&&(ye=le),"selectionStart"in E)E.selectionStart=le,E.selectionEnd=Math.min(ye,E.value.length);else{var Ce=E.ownerDocument||document,oe=Ce&&Ce.defaultView||window;if(oe.getSelection){var me=oe.getSelection(),Ye=E.textContent.length,tt=Math.min(P.start,Ye),qt=P.end===void 0?tt:Math.min(P.end,Ye);!me.extend&&tt>qt&&(S=qt,qt=tt,tt=S);var J=ru(E,tt),W=ru(E,qt);if(J&&W&&(me.rangeCount!==1||me.anchorNode!==J.node||me.anchorOffset!==J.offset||me.focusNode!==W.node||me.focusOffset!==W.offset)){var ie=Ce.createRange();ie.setStart(J.node,J.offset),me.removeAllRanges(),tt>qt?(me.addRange(ie),me.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),me.addRange(ie))}}}}for(Ce=[],me=E;me=me.parentNode;)me.nodeType===1&&Ce.push({element:me,left:me.scrollLeft,top:me.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<Ce.length;E++){var we=Ce[E];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}ed=!!wm,Sm=wm=null}finally{Lt=f,Q.p=o,I.T=i}}e.current=t,_n=2}}function iv(){if(_n===2){_n=0;var e=Sr,t=mo,i=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||i){i=I.T,I.T=null;var o=Q.p;Q.p=2;var f=Lt;Lt|=4;try{Lg(e,t.alternate,t)}finally{Lt=f,Q.p=o,I.T=i}}_n=3}}function rv(){if(_n===4||_n===3){_n=0,it();var e=Sr,t=mo,i=Ri,o=Vg;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?_n=5:(_n=0,mo=Sr=null,lv(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(wr=null),sn(i),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot=="function")try{ke.onCommitFiberRoot(Fe,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=I.T,f=Q.p,Q.p=2,I.T=null;try{for(var h=e.onRecoverableError,S=0;S<o.length;S++){var E=o[S];h(E.value,{componentStack:E.stack})}}finally{I.T=t,Q.p=f}}(Ri&3)!==0&&$u(),Zs(e),f=e.pendingLanes,(i&261930)!==0&&(f&42)!==0?e===om?dc++:(dc=0,om=e):dc=0,fc(0)}}function lv(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,cl(t)))}function $u(){return sv(),iv(),rv(),ov()}function ov(){if(_n!==5)return!1;var e=Sr,t=rm;rm=0;var i=sn(Ri),o=I.T,f=Q.p;try{Q.p=32>i?32:i,I.T=null,i=lm,lm=null;var h=Sr,S=Ri;if(_n=0,mo=Sr=null,Ri=0,(Lt&6)!==0)throw Error(l(331));var E=Lt;if(Lt|=4,Ug(h.current),Fg(h,h.current,S,i),Lt=E,fc(0,!1),ke&&typeof ke.onPostCommitFiberRoot=="function")try{ke.onPostCommitFiberRoot(Fe,h)}catch{}return!0}finally{Q.p=f,I.T=o,lv(e,t)}}function cv(e,t,i){t=na(i,t),t=Ff(e.stateNode,t,2),e=Re(e,t,2),e!==null&&(bt(e,2),Zs(e))}function Ht(e,t,i){if(e.tag===3)cv(e,e,i);else for(;t!==null;){if(t.tag===3){cv(t,e,i);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(wr===null||!wr.has(o))){e=na(i,e),i=ug(2),o=Re(t,i,2),o!==null&&(dg(i,o,t,e),bt(o,2),Zs(o));break}}t=t.return}}function dm(e,t,i){var o=e.pingCache;if(o===null){o=e.pingCache=new Hw;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)||(am=!0,f.add(i),e=Uw.bind(null,e,t,i),t.then(e,e))}function Uw(e,t,i){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Vt===e&&(kt&i)===i&&(mn===4||mn===3&&(kt&62914560)===kt&&300>ot()-Iu?(Lt&2)===0&&ho(e,0):sm|=i,fo===kt&&(fo=0)),Zs(e)}function uv(e,t){t===0&&(t=Qt()),e=wa(e,t),e!==null&&(bt(e,t),Zs(e))}function qw(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),uv(e,i)}function Gw(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),uv(e,i)}function Vw(e,t){return Et(e,t)}var Uu=null,go=null,fm=!1,qu=!1,mm=!1,jr=0;function Zs(e){e!==go&&e.next===null&&(go===null?Uu=go=e:go=go.next=e),qu=!0,fm||(fm=!0,Yw())}function fc(e,t){if(!mm&&qu){mm=!0;do for(var i=!1,o=Uu;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var h=0;else{var S=o.suspendedLanes,E=o.pingedLanes;h=(1<<31-gt(42|e)+1)-1,h&=f&~(S&~E),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(i=!0,hv(o,h))}else h=kt,h=va(o,o===Vt?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||dt(o,h)||(i=!0,hv(o,h));o=o.next}while(i);mm=!1}}function Ww(){dv()}function dv(){qu=fm=!1;var e=0;jr!==0&&sS()&&(e=jr);for(var t=ot(),i=null,o=Uu;o!==null;){var f=o.next,h=fv(o,t);h===0?(o.next=null,i===null?Uu=f:i.next=f,f===null&&(go=i)):(i=o,(e!==0||(h&3)!==0)&&(qu=!0)),o=f}_n!==0&&_n!==5||fc(e),jr!==0&&(jr=0)}function fv(e,t){for(var i=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,h=e.pendingLanes&-62914561;0<h;){var S=31-gt(h),E=1<<S,P=f[S];P===-1?((E&i)===0||(E&o)!==0)&&(f[S]=Hi(E,t)):P<=t&&(e.expiredLanes|=E),h&=~E}if(t=Vt,i=kt,i=va(e,e===t?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,i===0||e===t&&(Ot===2||Ot===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&je(o),e.callbackNode=null,e.callbackPriority=0;if((i&3)===0||dt(e,i)){if(t=i&-i,t===e.callbackPriority)return t;switch(o!==null&&je(o),sn(i)){case 2:case 8:i=Ie;break;case 32:i=ct;break;case 268435456:i=Ft;break;default:i=ct}return o=mv.bind(null,e),i=Et(i,o),e.callbackPriority=t,e.callbackNode=i,t}return o!==null&&o!==null&&je(o),e.callbackPriority=2,e.callbackNode=null,2}function mv(e,t){if(_n!==0&&_n!==5)return e.callbackNode=null,e.callbackPriority=0,null;var i=e.callbackNode;if($u()&&e.callbackNode!==i)return null;var o=kt;return o=va(e,e===Vt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Yg(e,o,t),fv(e,ot()),e.callbackNode!=null&&e.callbackNode===i?mv.bind(null,e):null)}function hv(e,t){if($u())return null;Yg(e,t,!0)}function Yw(){rS(function(){(Lt&6)!==0?Et(Kt,Ww):dv()})}function hm(){if(jr===0){var e=gi;e===0&&(e=nt,nt<<=1,(nt&261888)===0&&(nt=256)),jr=e}return jr}function pv(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Bl(""+e)}function gv(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 Kw(e,t,i,o,f){if(t==="submit"&&i&&i.stateNode===f){var h=pv((f[Ne]||null).action),S=o.submitter;S&&(t=(t=S[Ne]||null)?pv(t.formAction):S.getAttribute("formAction"),t!==null&&(h=t,S=null));var E=new qr("action","action",null,o,f);e.push({event:E,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(jr!==0){var P=S?gv(f,S):new FormData(f);_f(i,{pending:!0,data:P,method:f.method,action:h},null,P)}}else typeof h=="function"&&(E.preventDefault(),P=S?gv(f,S):new FormData(f),_f(i,{pending:!0,data:P,method:f.method,action:h},h,P))},currentTarget:f}]})}}for(var pm=0;pm<Jl.length;pm++){var gm=Jl[pm],Qw=gm.toLowerCase(),Xw=gm[0].toUpperCase()+gm.slice(1);Jn(Qw,"on"+Xw)}Jn(Zl,"onAnimationEnd"),Jn(ou,"onAnimationIteration"),Jn(Uo,"onAnimationStart"),Jn("dblclick","onDoubleClick"),Jn("focusin","onFocus"),Jn("focusout","onBlur"),Jn(qo,"onTransitionRun"),Jn(Go,"onTransitionStart"),Jn(tl,"onTransitionCancel"),Jn(cu,"onTransitionEnd"),vn("onMouseEnter",["mouseout","mouseover"]),vn("onMouseLeave",["mouseout","mouseover"]),vn("onPointerEnter",["pointerout","pointerover"]),vn("onPointerLeave",["pointerout","pointerover"]),cn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),cn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),cn("onBeforeInput",["compositionend","keypress","textInput","paste"]),cn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),cn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),cn("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(" "),Zw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(mc));function vv(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 E=o[S],P=E.instance,le=E.currentTarget;if(E=E.listener,P!==h&&f.isPropagationStopped())break e;h=E,f.currentTarget=le;try{h(f)}catch(ye){ar(ye)}f.currentTarget=null,h=P}else for(S=0;S<o.length;S++){if(E=o[S],P=E.instance,le=E.currentTarget,E=E.listener,P!==h&&f.isPropagationStopped())break e;h=E,f.currentTarget=le;try{h(f)}catch(ye){ar(ye)}f.currentTarget=null,h=P}}}}function jt(e,t){var i=t[rt];i===void 0&&(i=t[rt]=new Set);var o=e+"__bubble";i.has(o)||(yv(t,e,2,!1),i.add(o))}function vm(e,t,i){var o=0;t&&(o|=4),yv(i,e,o,t)}var Gu="_reactListening"+Math.random().toString(36).slice(2);function ym(e){if(!e[Gu]){e[Gu]=!0,ya.forEach(function(i){i!=="selectionchange"&&(Zw.has(i)||vm(i,!1,e),vm(i,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Gu]||(t[Gu]=!0,vm("selectionchange",!1,t))}}function yv(e,t,i,o){switch(Wv(t)){case 2:var f=AS;break;case 8:f=NS;break;default:f=Lm}i=f.bind(null,t,i,e),f=void 0,!Oo||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 xm(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 E=o.stateNode.containerInfo;if(E===f)break;if(S===4)for(S=o.return;S!==null;){var P=S.tag;if((P===3||P===4)&&S.stateNode.containerInfo===f)return;S=S.return}for(;E!==null;){if(S=Wt(E),S===null)return;if(P=S.tag,P===5||P===6||P===26||P===27){o=h=S;continue e}E=E.parentNode}}o=o.return}of(function(){var le=h,ye=Io(i),Ce=[];e:{var oe=nl.get(e);if(oe!==void 0){var me=qr,Ye=e;switch(e){case"keypress":if(Ui(i)===0)break e;case"keydown":case"keyup":me=uf;break;case"focusin":Ye="focus",me=et;break;case"focusout":Ye="blur",me=et;break;case"beforeblur":case"afterblur":me=et;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":me=ft;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=Yi;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=Jc;break;case Zl:case ou:case Uo:me=cf;break;case cu:me=tu;break;case"scroll":case"scrollend":me=Qc;break;case"wheel":me=nu;break;case"copy":case"cut":case"paste":me=Vr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=Ul;break;case"toggle":case"beforetoggle":me=Qi}var tt=(t&4)!==0,qt=!tt&&(e==="scroll"||e==="scrollend"),J=tt?oe!==null?oe+"Capture":null:oe;tt=[];for(var W=le,ie;W!==null;){var we=W;if(ie=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||ie===null||J===null||(we=Fl(W,J),we!=null&&tt.push(hc(W,we,ie))),qt)break;W=W.return}0<tt.length&&(oe=new me(oe,Ye,null,i,ye),Ce.push({event:oe,listeners:tt}))}}if((t&7)===0){e:{if(oe=e==="mouseover"||e==="pointerover",me=e==="mouseout"||e==="pointerout",oe&&i!==Yc&&(Ye=i.relatedTarget||i.fromElement)&&(Wt(Ye)||Ye[qe]))break e;if((me||oe)&&(oe=ye.window===ye?ye:(oe=ye.ownerDocument)?oe.defaultView||oe.parentWindow:window,me?(Ye=i.relatedTarget||i.toElement,me=le,Ye=Ye?Wt(Ye):null,Ye!==null&&(qt=d(Ye),tt=Ye.tag,Ye!==qt||tt!==5&&tt!==27&&tt!==6)&&(Ye=null)):(me=null,Ye=le),me!==Ye)){if(tt=ft,we="onMouseLeave",J="onMouseEnter",W="mouse",(e==="pointerout"||e==="pointerover")&&(tt=Ul,we="onPointerLeave",J="onPointerEnter",W="pointer"),qt=me==null?oe:St(me),ie=Ye==null?oe:St(Ye),oe=new tt(we,W+"leave",me,i,ye),oe.target=qt,oe.relatedTarget=ie,we=null,Wt(ye)===le&&(tt=new tt(J,W+"enter",Ye,i,ye),tt.target=ie,tt.relatedTarget=qt,we=tt),qt=we,me&&Ye)t:{for(tt=Jw,J=me,W=Ye,ie=0,we=J;we;we=tt(we))ie++;we=0;for(var Ze=W;Ze;Ze=tt(Ze))we++;for(;0<ie-we;)J=tt(J),ie--;for(;0<we-ie;)W=tt(W),we--;for(;ie--;){if(J===W||W!==null&&J===W.alternate){tt=J;break t}J=tt(J),W=tt(W)}tt=null}else tt=null;me!==null&&xv(Ce,oe,me,tt,!1),Ye!==null&&qt!==null&&xv(Ce,qt,Ye,tt,!0)}}e:{if(oe=le?St(le):window,me=oe.nodeName&&oe.nodeName.toLowerCase(),me==="select"||me==="input"&&oe.type==="file")var Rt=On;else if(ua(oe))if(ci)Rt=Yl;else{Rt=mf;var Ke=su}else me=oe.nodeName,!me||me.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?le&&es(le.elementType)&&(Rt=On):Rt=Wl;if(Rt&&(Rt=Rt(e,le))){Zn(Ce,Rt,i,ye);break e}Ke&&Ke(e,oe,le),e==="focusout"&&le&&oe.type==="number"&&le.memoizedProps.value!=null&&Hs(oe,"number",oe.value)}switch(Ke=le?St(le):window,e){case"focusin":(ua(Ke)||Ke.contentEditable==="true")&&(er=Ke,Ql=le,el=null);break;case"focusout":el=Ql=er=null;break;case"mousedown":Xl=!0;break;case"contextmenu":case"mouseup":case"dragend":Xl=!1,tr(Ce,i,ye);break;case"selectionchange":if(hf)break;case"keydown":case"keyup":tr(Ce,i,ye)}var yt;if(Fo)e:{switch(e){case"compositionstart":var At="onCompositionStart";break e;case"compositionend":At="onCompositionEnd";break e;case"compositionupdate":At="onCompositionUpdate";break e}At=void 0}else In?Kr(e,i)&&(At="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(At="onCompositionStart");At&&(au&&i.locale!=="ko"&&(In||At!=="onCompositionStart"?At==="onCompositionEnd"&&In&&(yt=Kc()):(vs=ye,Ho="value"in vs?vs.value:vs.textContent,In=!0)),Ke=Vu(le,At),0<Ke.length&&(At=new oi(At,e,null,i,ye),Ce.push({event:At,listeners:Ke}),yt?At.data=yt:(yt=Qr(i),yt!==null&&(At.data=yt)))),(yt=Yr?qs(e,i):Gl(e,i))&&(At=Vu(le,"onBeforeInput"),0<At.length&&(Ke=new oi("onBeforeInput","beforeinput",null,i,ye),Ce.push({event:Ke,listeners:At}),Ke.data=yt)),Kw(Ce,e,le,i,ye)}vv(Ce,t)})}function hc(e,t,i){return{instance:e,listener:t,currentTarget:i}}function Vu(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=Fl(e,i),f!=null&&o.unshift(hc(e,f,h)),f=Fl(e,t),f!=null&&o.push(hc(e,f,h))),e.tag===3)return o;e=e.return}return[]}function Jw(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function xv(e,t,i,o,f){for(var h=t._reactName,S=[];i!==null&&i!==o;){var E=i,P=E.alternate,le=E.stateNode;if(E=E.tag,P!==null&&P===o)break;E!==5&&E!==26&&E!==27||le===null||(P=le,f?(le=Fl(i,h),le!=null&&S.unshift(hc(i,le,P))):f||(le=Fl(i,h),le!=null&&S.push(hc(i,le,P)))),i=i.return}S.length!==0&&e.push({event:t,listeners:S})}var eS=/\r\n?/g,tS=/\u0000|\uFFFD/g;function bv(e){return(typeof e=="string"?e:""+e).replace(eS,`
|
|
9
|
-
`).replace(tS,"")}function wv(e,t){return t=bv(t),bv(e)===t}function Ut(e,t,i,o,f,h){switch(i){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||gs(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&gs(e,""+o);break;case"className":zl(e,"class",o);break;case"tabIndex":zl(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":zl(e,i,o);break;case"style":zo(e,o,h);break;case"data":if(t!=="object"){zl(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=Bl(""+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"&&Ut(e,t,"name",f.name,f,null),Ut(e,t,"formEncType",f.formEncType,f,null),Ut(e,t,"formMethod",f.formMethod,f,null),Ut(e,t,"formTarget",f.formTarget,f,null)):(Ut(e,t,"encType",f.encType,f,null),Ut(e,t,"method",f.method,f,null),Ut(e,t,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(i);break}o=Bl(""+o),e.setAttribute(i,o);break;case"onClick":o!=null&&(e.onclick=_a);break;case"onScroll":o!=null&&jt("scroll",e);break;case"onScrollEnd":o!=null&&jt("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=Bl(""+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":jt("beforetoggle",e),jt("toggle",e),Bi(e,"popover",o);break;case"xlinkActuate":Za(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Za(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Za(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Za(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Za(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Za(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Za(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Za(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Za(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Bi(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=ii.get(i)||i,Bi(e,i,o))}}function bm(e,t,i,o,f,h){switch(i){case"style":zo(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"?gs(e,o):(typeof o=="number"||typeof o=="bigint")&&gs(e,""+o);break;case"onScroll":o!=null&&jt("scroll",e);break;case"onScrollEnd":o!=null&&jt("scrollend",e);break;case"onClick":o!=null&&(e.onclick=_a);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ca.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,""):Bi(e,i,o)}}}function Kn(e,t,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":jt("error",e),jt("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:Ut(e,t,h,S,i,null)}}f&&Ut(e,t,"srcSet",i.srcSet,i,null),o&&Ut(e,t,"src",i.src,i,null);return;case"input":jt("invalid",e);var E=h=S=f=null,P=null,le=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":P=ye;break;case"defaultChecked":le=ye;break;case"value":h=ye;break;case"defaultValue":E=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(l(137,t));break;default:Ut(e,t,o,ye,i,null)}}si(e,h,E,P,le,S,f,!1);return;case"select":jt("invalid",e),o=S=h=null;for(f in i)if(i.hasOwnProperty(f)&&(E=i[f],E!=null))switch(f){case"value":h=E;break;case"defaultValue":S=E;break;case"multiple":o=E;default:Ut(e,t,f,E,i,null)}t=h,i=S,e.multiple=!!o,t!=null?Bs(e,!!o,t,!1):i!=null&&Bs(e,!!o,i,!0);return;case"textarea":jt("invalid",e),h=f=o=null;for(S in i)if(i.hasOwnProperty(S)&&(E=i[S],E!=null))switch(S){case"value":o=E;break;case"defaultValue":f=E;break;case"children":h=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(l(91));break;default:Ut(e,t,S,E,i,null)}$r(e,o,f,h);return;case"option":for(P in i)i.hasOwnProperty(P)&&(o=i[P],o!=null)&&(P==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":Ut(e,t,P,o,i,null));return;case"dialog":jt("beforetoggle",e),jt("toggle",e),jt("cancel",e),jt("close",e);break;case"iframe":case"object":jt("load",e);break;case"video":case"audio":for(o=0;o<mc.length;o++)jt(mc[o],e);break;case"image":jt("error",e),jt("load",e);break;case"details":jt("toggle",e);break;case"embed":case"source":case"link":jt("error",e),jt("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(le in i)if(i.hasOwnProperty(le)&&(o=i[le],o!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Ut(e,t,le,o,i,null)}return;default:if(es(t)){for(ye in i)i.hasOwnProperty(ye)&&(o=i[ye],o!==void 0&&bm(e,t,ye,o,i,void 0));return}}for(E in i)i.hasOwnProperty(E)&&(o=i[E],o!=null&&Ut(e,t,E,o,i,null))}function nS(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,E=null,P=null,le=null,ye=null;for(me in i){var Ce=i[me];if(i.hasOwnProperty(me)&&Ce!=null)switch(me){case"checked":break;case"value":break;case"defaultValue":P=Ce;default:o.hasOwnProperty(me)||Ut(e,t,me,null,o,Ce)}}for(var oe in o){var me=o[oe];if(Ce=i[oe],o.hasOwnProperty(oe)&&(me!=null||Ce!=null))switch(oe){case"type":h=me;break;case"name":f=me;break;case"checked":le=me;break;case"defaultChecked":ye=me;break;case"value":S=me;break;case"defaultValue":E=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(l(137,t));break;default:me!==Ce&&Ut(e,t,oe,me,o,Ce)}}ai(e,S,E,P,le,ye,h,f);return;case"select":me=S=E=oe=null;for(h in i)if(P=i[h],i.hasOwnProperty(h)&&P!=null)switch(h){case"value":break;case"multiple":me=P;default:o.hasOwnProperty(h)||Ut(e,t,h,null,o,P)}for(f in o)if(h=o[f],P=i[f],o.hasOwnProperty(f)&&(h!=null||P!=null))switch(f){case"value":oe=h;break;case"defaultValue":E=h;break;case"multiple":S=h;default:h!==P&&Ut(e,t,f,h,o,P)}t=E,i=S,o=me,oe!=null?Bs(e,!!i,oe,!1):!!o!=!!i&&(t!=null?Bs(e,!!i,t,!0):Bs(e,!!i,i?[]:"",!1));return;case"textarea":me=oe=null;for(E in i)if(f=i[E],i.hasOwnProperty(E)&&f!=null&&!o.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:Ut(e,t,E,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":oe=f;break;case"defaultValue":me=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(l(91));break;default:f!==h&&Ut(e,t,S,f,o,h)}Fi(e,oe,me);return;case"option":for(var Ye in i)oe=i[Ye],i.hasOwnProperty(Ye)&&oe!=null&&!o.hasOwnProperty(Ye)&&(Ye==="selected"?e.selected=!1:Ut(e,t,Ye,null,o,oe));for(P in o)oe=o[P],me=i[P],o.hasOwnProperty(P)&&oe!==me&&(oe!=null||me!=null)&&(P==="selected"?e.selected=oe&&typeof oe!="function"&&typeof oe!="symbol":Ut(e,t,P,oe,o,me));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var tt in i)oe=i[tt],i.hasOwnProperty(tt)&&oe!=null&&!o.hasOwnProperty(tt)&&Ut(e,t,tt,null,o,oe);for(le in o)if(oe=o[le],me=i[le],o.hasOwnProperty(le)&&oe!==me&&(oe!=null||me!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(l(137,t));break;default:Ut(e,t,le,oe,o,me)}return;default:if(es(t)){for(var qt in i)oe=i[qt],i.hasOwnProperty(qt)&&oe!==void 0&&!o.hasOwnProperty(qt)&&bm(e,t,qt,void 0,o,oe);for(ye in o)oe=o[ye],me=i[ye],!o.hasOwnProperty(ye)||oe===me||oe===void 0&&me===void 0||bm(e,t,ye,oe,o,me);return}}for(var J in i)oe=i[J],i.hasOwnProperty(J)&&oe!=null&&!o.hasOwnProperty(J)&&Ut(e,t,J,null,o,oe);for(Ce in o)oe=o[Ce],me=i[Ce],!o.hasOwnProperty(Ce)||oe===me||oe==null&&me==null||Ut(e,t,Ce,oe,o,me)}function Sv(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function aS(){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,E=f.duration;if(h&&E&&Sv(S)){for(S=0,E=f.responseEnd,o+=1;o<i.length;o++){var P=i[o],le=P.startTime;if(le>E)break;var ye=P.transferSize,Ce=P.initiatorType;ye&&Sv(Ce)&&(P=P.responseEnd,S+=ye*(P<E?1:(E-le)/(P-le)))}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 wm=null,Sm=null;function Wu(e){return e.nodeType===9?e:e.ownerDocument}function Cv(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 jv(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 Cm(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 jm=null;function sS(){var e=window.event;return e&&e.type==="popstate"?e===jm?!1:(jm=e,!0):(jm=null,!1)}var kv=typeof setTimeout=="function"?setTimeout:void 0,iS=typeof clearTimeout=="function"?clearTimeout:void 0,Av=typeof Promise=="function"?Promise:void 0,rS=typeof queueMicrotask=="function"?queueMicrotask:typeof Av<"u"?function(e){return Av.resolve(null).then(e).catch(lS)}:kv;function lS(e){setTimeout(function(){throw e})}function kr(e){return e==="head"}function Nv(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),bo(t);return}o--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")o++;else if(i==="html")pc(e.ownerDocument.documentElement);else if(i==="head"){i=e.ownerDocument.head,pc(i);for(var h=i.firstChild;h;){var S=h.nextSibling,E=h.nodeName;h[ut]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&h.rel.toLowerCase()==="stylesheet"||i.removeChild(h),h=S}}else i==="body"&&pc(e.ownerDocument.body);i=f}while(i);bo(t)}function Mv(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 km(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":km(i),kn(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}e.removeChild(i)}}function oS(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[ut])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=us(e.nextSibling),e===null)break}return null}function cS(e,t,i){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!i||(e=us(e.nextSibling),e===null))return null;return e}function Tv(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=us(e.nextSibling),e===null))return null;return e}function Am(e){return e.data==="$?"||e.data==="$~"}function Nm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function uS(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 us(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 Mm=null;function Ev(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"||i==="/&"){if(t===0)return us(e.nextSibling);t--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||t++}e=e.nextSibling}return null}function Rv(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 Dv(e,t,i){switch(t=Wu(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 pc(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);kn(e)}var ds=new Map,Lv=new Set;function Yu(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Di=Q.d;Q.d={f:dS,r:fS,D:mS,C:hS,L:pS,m:gS,X:yS,S:vS,M:xS};function dS(){var e=Di.f(),t=Bu();return e||t}function fS(e){var t=An(e);t!==null&&t.tag===5&&t.type==="form"?Qp(t):Di.r(e)}var vo=typeof document>"u"?null:document;function _v(e,t,i){var o=vo;if(o&&typeof t=="string"&&t){var f=Gn(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),Lv.has(f)||(Lv.add(f),e={rel:e,crossOrigin:i,href:t},o.querySelector(f)===null&&(t=o.createElement("link"),Kn(t,"link",e),Pt(t),o.head.appendChild(t)))}}function mS(e){Di.D(e),_v("dns-prefetch",e,null)}function hS(e,t){Di.C(e,t),_v("preconnect",e,t)}function pS(e,t,i){Di.L(e,t,i);var o=vo;if(o&&e&&t){var f='link[rel="preload"][as="'+Gn(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+Gn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+Gn(i.imageSizes)+'"]')):f+='[href="'+Gn(e)+'"]';var h=f;switch(t){case"style":h=yo(e);break;case"script":h=xo(e)}ds.has(h)||(e=x({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),ds.set(h,e),o.querySelector(f)!==null||t==="style"&&o.querySelector(gc(h))||t==="script"&&o.querySelector(vc(h))||(t=o.createElement("link"),Kn(t,"link",e),Pt(t),o.head.appendChild(t)))}}function gS(e,t){Di.m(e,t);var i=vo;if(i&&e){var o=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+Gn(o)+'"][href="'+Gn(e)+'"]',h=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=xo(e)}if(!ds.has(h)&&(e=x({rel:"modulepreload",href:e},t),ds.set(h,e),i.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(vc(h)))return}o=i.createElement("link"),Kn(o,"link",e),Pt(o),i.head.appendChild(o)}}}function vS(e,t,i){Di.S(e,t,i);var o=vo;if(o&&e){var f=rn(o).hoistableStyles,h=yo(e);t=t||"default";var S=f.get(h);if(!S){var E={loading:0,preload:null};if(S=o.querySelector(gc(h)))E.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":t},i),(i=ds.get(h))&&Tm(e,i);var P=S=o.createElement("link");Pt(P),Kn(P,"link",e),P._p=new Promise(function(le,ye){P.onload=le,P.onerror=ye}),P.addEventListener("load",function(){E.loading|=1}),P.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Ku(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:E},f.set(h,S)}}}function yS(e,t){Di.X(e,t);var i=vo;if(i&&e){var o=rn(i).hoistableScripts,f=xo(e),h=o.get(f);h||(h=i.querySelector(vc(f)),h||(e=x({src:e,async:!0},t),(t=ds.get(f))&&Em(e,t),h=i.createElement("script"),Pt(h),Kn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function xS(e,t){Di.M(e,t);var i=vo;if(i&&e){var o=rn(i).hoistableScripts,f=xo(e),h=o.get(f);h||(h=i.querySelector(vc(f)),h||(e=x({src:e,async:!0,type:"module"},t),(t=ds.get(f))&&Em(e,t),h=i.createElement("script"),Pt(h),Kn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function zv(e,t,i,o){var f=(f=ve.current)?Yu(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=yo(i.href),i=rn(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=yo(i.href);var h=rn(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(gc(e)))&&!h._p&&(S.instance=h,S.state.loading=5),ds.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},ds.set(e,i),h||bS(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=xo(i),i=rn(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 yo(e){return'href="'+Gn(e)+'"'}function gc(e){return'link[rel="stylesheet"]['+e+"]"}function Iv(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function bS(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}),Kn(t,"link",i),Pt(t),e.head.appendChild(t))}function xo(e){return'[src="'+Gn(e)+'"]'}function vc(e){return"script[async]"+e}function Ov(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Gn(i.href)+'"]');if(o)return t.instance=o,Pt(o),o;var f=x({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Pt(o),Kn(o,"style",f),Ku(o,i.precedence,e),t.instance=o;case"stylesheet":f=yo(i.href);var h=e.querySelector(gc(f));if(h)return t.state.loading|=4,t.instance=h,Pt(h),h;o=Iv(i),(f=ds.get(f))&&Tm(o,f),h=(e.ownerDocument||e).createElement("link"),Pt(h);var S=h;return S._p=new Promise(function(E,P){S.onload=E,S.onerror=P}),Kn(h,"link",o),t.state.loading|=4,Ku(h,i.precedence,e),t.instance=h;case"script":return h=xo(i.src),(f=e.querySelector(vc(h)))?(t.instance=f,Pt(f),f):(o=i,(f=ds.get(h))&&(o=x({},i),Em(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),Pt(f),Kn(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,Ku(o,i.precedence,e));return t.instance}function Ku(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 E=o[S];if(E.dataset.precedence===t)h=E;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 Tm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Em(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Qu=null;function Hv(e,t,i){if(Qu===null){var o=new Map,f=Qu=new Map;f.set(i,o)}else f=Qu,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[ut]||h[ee]||e==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var S=h.getAttribute(t)||"";S=e+S;var E=o.get(S);E?E.push(h):o.set(S,[h])}}return o}function Bv(e,t,i){e=e.ownerDocument||e,e.head.insertBefore(i,t==="title"?e.querySelector("head > title"):null)}function wS(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 Fv(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function SS(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=yo(o.href),h=t.querySelector(gc(f));if(h){t=h._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Xu.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=h,Pt(h);return}h=t.ownerDocument||t,o=Iv(o),(f=ds.get(f))&&Tm(o,f),h=h.createElement("link"),Pt(h);var S=h;S._p=new Promise(function(E,P){S.onload=E,S.onerror=P}),Kn(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=Xu.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var Rm=0;function CS(e,t){return e.stylesheets&&e.count===0&&Ju(e,e.stylesheets),0<e.count||0<e.imgCount?function(i){var o=setTimeout(function(){if(e.stylesheets&&Ju(e,e.stylesheets),e.unsuspend){var h=e.unsuspend;e.unsuspend=null,h()}},6e4+t);0<e.imgBytes&&Rm===0&&(Rm=62500*aS());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ju(e,e.stylesheets),e.unsuspend)){var h=e.unsuspend;e.unsuspend=null,h()}},(e.imgBytes>Rm?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function Xu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ju(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Zu=null;function Ju(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Zu=new Map,t.forEach(jS,e),Zu=null,Xu.call(e))}function jS(e,t){if(!(t.state.loading&4)){var i=Zu.get(e);if(i)var o=i.get(null);else{i=new Map,Zu.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=Xu.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 yc={$$typeof:R,Provider:null,Consumer:null,_currentValue:q,_currentValue2:q,_threadCount:0};function kS(e,t,i,o,f,h,S,E,P){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=ps(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ps(0),this.hiddenUpdates=ps(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=h,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function Pv(e,t,i,o,f,h,S,E,P,le,ye,Ce){return e=new kS(e,t,i,S,P,le,ye,Ce,E),t=1,h===!0&&(t|=24),h=ta(3,null,null,t),e.current=h,h.stateNode=e,t=Qo(),t.refCount++,e.pooledCache=t,t.refCount++,h.memoizedState={element:o,isDehydrated:i,cache:t},z(h),e}function $v(e){return e?(e=xs,e):xs}function Uv(e,t,i,o,f,h){f=$v(f),o.context===null?o.context=f:o.pendingContext=f,o=de(t),o.payload={element:i},h=h===void 0?null:h,h!==null&&(o.callback=h),i=Re(e,o,t),i!==null&&(Ma(i,e,t),$e(i,e,t))}function qv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var i=e.retryLane;e.retryLane=i!==0&&i<t?i:t}}function Dm(e,t){qv(e,t),(e=e.alternate)&&qv(e,t)}function Gv(e){if(e.tag===13||e.tag===31){var t=wa(e,67108864);t!==null&&Ma(t,e,67108864),Dm(e,67108864)}}function Vv(e){if(e.tag===13||e.tag===31){var t=Ga();t=vt(t);var i=wa(e,t);i!==null&&Ma(i,e,t),Dm(e,t)}}var ed=!0;function AS(e,t,i,o){var f=I.T;I.T=null;var h=Q.p;try{Q.p=2,Lm(e,t,i,o)}finally{Q.p=h,I.T=f}}function NS(e,t,i,o){var f=I.T;I.T=null;var h=Q.p;try{Q.p=8,Lm(e,t,i,o)}finally{Q.p=h,I.T=f}}function Lm(e,t,i,o){if(ed){var f=_m(o);if(f===null)xm(e,t,o,td,i),Yv(e,o);else if(TS(f,e,t,i,o))o.stopPropagation();else if(Yv(e,o),t&4&&-1<MS.indexOf(e)){for(;f!==null;){var h=An(f);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var S=He(h.pendingLanes);if(S!==0){var E=h;for(E.pendingLanes|=2,E.entangledLanes|=2;S;){var P=1<<31-gt(S);E.entanglements[1]|=P,S&=~P}Zs(h),(Lt&6)===0&&(Ou=ot()+500,fc(0))}}break;case 31:case 13:E=wa(h,2),E!==null&&Ma(E,h,2),Bu(),Dm(h,2)}if(h=_m(o),h===null&&xm(e,t,o,td,i),h===f)break;f=h}f!==null&&o.stopPropagation()}else xm(e,t,o,null,i)}}function _m(e){return e=Io(e),zm(e)}var td=null;function zm(e){if(td=null,e=Wt(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 td=e,null}function Wv(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(gn()){case Kt:return 2;case Ie:return 8;case ct:case _t:return 32;case Ft:return 268435456;default:return 32}default:return 32}}var Im=!1,Ar=null,Nr=null,Mr=null,xc=new Map,bc=new Map,Tr=[],MS="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 Yv(e,t){switch(e){case"focusin":case"focusout":Ar=null;break;case"dragenter":case"dragleave":Nr=null;break;case"mouseover":case"mouseout":Mr=null;break;case"pointerover":case"pointerout":xc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":bc.delete(t.pointerId)}}function wc(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=An(t),t!==null&&Gv(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,f!==null&&t.indexOf(f)===-1&&t.push(f),e)}function TS(e,t,i,o,f){switch(t){case"focusin":return Ar=wc(Ar,e,t,i,o,f),!0;case"dragenter":return Nr=wc(Nr,e,t,i,o,f),!0;case"mouseover":return Mr=wc(Mr,e,t,i,o,f),!0;case"pointerover":var h=f.pointerId;return xc.set(h,wc(xc.get(h)||null,e,t,i,o,f)),!0;case"gotpointercapture":return h=f.pointerId,bc.set(h,wc(bc.get(h)||null,e,t,i,o,f)),!0}return!1}function Kv(e){var t=Wt(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,Hr(e.priority,function(){Vv(i)});return}}else if(t===31){if(t=p(i),t!==null){e.blockedOn=t,Hr(e.priority,function(){Vv(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 nd(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var i=_m(e.nativeEvent);if(i===null){i=e.nativeEvent;var o=new i.constructor(i.type,i);Yc=o,i.target.dispatchEvent(o),Yc=null}else return t=An(i),t!==null&&Gv(t),e.blockedOn=i,!1;t.shift()}return!0}function Qv(e,t,i){nd(e)&&i.delete(t)}function ES(){Im=!1,Ar!==null&&nd(Ar)&&(Ar=null),Nr!==null&&nd(Nr)&&(Nr=null),Mr!==null&&nd(Mr)&&(Mr=null),xc.forEach(Qv),bc.forEach(Qv)}function ad(e,t){e.blockedOn===t&&(e.blockedOn=null,Im||(Im=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,ES)))}var sd=null;function Xv(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(zm(o||i)===null)continue;break}var h=An(i);h!==null&&(e.splice(t,3),t-=3,_f(h,{pending:!0,data:f,method:i.method,action:o},o,f))}}))}function bo(e){function t(P){return ad(P,e)}Ar!==null&&ad(Ar,e),Nr!==null&&ad(Nr,e),Mr!==null&&ad(Mr,e),xc.forEach(t),bc.forEach(t);for(var i=0;i<Tr.length;i++){var o=Tr[i];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Tr.length&&(i=Tr[0],i.blockedOn===null);)Kv(i),i.blockedOn===null&&Tr.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||Xv(i);else if(S){var E=null;if(h&&h.hasAttribute("formAction")){if(f=h,S=h[Ne]||null)E=S.formAction;else if(zm(f)!==null)continue}else E=S.action;typeof E=="function"?i[o+1]=E:(i.splice(o,3),o-=3),Xv(i)}}}function Zv(){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 Om(e){this._internalRoot=e}id.prototype.render=Om.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var i=t.current,o=Ga();Uv(i,o,e,t,null,null)},id.prototype.unmount=Om.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Uv(e.current,2,null,e,null,null),Bu(),t[qe]=null}};function id(e){this._internalRoot=e}id.prototype.unstable_scheduleHydration=function(e){if(e){var t=Qa();e={blockedOn:null,target:e,priority:t};for(var i=0;i<Tr.length&&t!==0&&t<Tr[i].priority;i++);Tr.splice(i,0,e),i===0&&Kv(e)}};var Jv=a.version;if(Jv!=="19.2.7")throw Error(l(527,Jv,"19.2.7"));Q.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=v(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var RS={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var rd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!rd.isDisabled&&rd.supportsFiber)try{Fe=rd.inject(RS),ke=rd}catch{}}return Cc.createRoot=function(e,t){if(!c(e))throw Error(l(299));var i=!1,o="",f=rg,h=lg,S=og;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=Pv(e,1,!1,null,null,i,o,null,f,h,S,Zv),e[qe]=t.current,ym(e),new Om(t)},Cc.hydrateRoot=function(e,t,i){if(!c(e))throw Error(l(299));var o=!1,f="",h=rg,S=lg,E=og,P=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&&(E=i.onRecoverableError),i.formState!==void 0&&(P=i.formState)),t=Pv(e,1,!0,t,i??null,o,f,P,h,S,E,Zv),t.context=$v(null),i=t.current,o=Ga(),o=vt(o),f=de(o),f.callback=null,Re(i,f,o),i=o,t.current.lanes=i,bt(t,i),Zs(t),e[qe]=t.current,ym(e),new id(t)},Cc.version="19.2.7",Cc}var dy;function w0(){if(dy)return Pm.exports;dy=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(),Pm.exports=b0(),Pm.exports}var S0=w0();const C0="https://otbyfkjxrkngvjziawki.supabase.co",j0="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",k0={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},fy=typeof window<"u"&&!!window.liveDesk,pt=p0(C0,j0,{auth:{autoRefreshToken:!0,persistSession:!fy,storage:fy?k0:void 0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}}),A0=new Set(["browserLanguage","platform","online","viewport","timezone","screen"]),N0={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])=>A0.has(a)&&r!==void 0))}};function M0(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 T0(n=N0){return n.collect()}async function E0(n,a="livedesk"){const{data:r,error:l}=await pt.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:C}=await pt.rpc("register_product_access",{p_product_key:a,p_access_type:"free"});if(C)throw C}const[d,m,p]=await Promise.all([pt.from("products").select("id, product_key, name, description, sort_order").order("sort_order"),pt.from("product_admins").select("product_id, role").eq("user_id",n),pt.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 g=d.data||[],v=(m.data||[]).map(C=>String(C.product_id)),w=(p.data||[]).map(C=>String(C.product_id)),x=c==="owner",b=x?g.map(C=>C.id):[...new Set([...v,...w])];return{products:g,access:{userId:n,globalRole:c,accessibleProductIds:b,managedProductIds:x?g.map(C=>C.id):v,canViewAllProducts:x,canViewAllPrivatePosts:x,canManageAllProducts:x,canCreateAnnouncements:x||v.length>0}}}async function R0(n=""){const{data:a,error:r}=await pt.rpc("search_support_posts",{p_query:n.trim()||null,p_limit:250});if(r)throw r;return a||[]}async function D0(n){const{data:a,error:r}=await pt.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 pt.storage.from("support-attachments").createSignedUrl(c.storage_path,3600);return{...c,signed_url:d.data?.signedUrl||void 0}}))}async function L0(){const{data:n,error:a}=await pt.from("support_notifications").select("*").order("created_at",{ascending:!1}).limit(30);if(a)throw a;return n||[]}async function _0(n){const{error:a}=await pt.rpc("mark_support_notification_read",{p_notification_id:n});if(a)throw a}async function my(n){const{data:a,error:r}=await pt.from("support_comments").select("*").eq("post_id",n).order("created_at");if(r)throw r;return a||[]}async function z0(n){const{data:a,error:r}=await pt.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 I0(n){const{data:a,error:r}=await pt.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?T0():{}});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 O0=new Set(["image/png","image/jpeg","image/webp","text/plain","text/markdown","application/json","application/pdf"]);async function H0(n,a){if(!O0.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 pt.storage.from("support-attachments").upload(c,a,{contentType:a.type,upsert:!1});if(d.error)throw d.error;const{data:m,error:p}=await pt.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 pt.storage.from("support-attachments").remove([c]),p;const g=Array.isArray(m)?m[0]?.attachment_id:m?.attachment_id;if(!g)throw new Error("Attachment metadata was not created.");return String(g)}async function B0(n,a,r,l){const{error:c}=await pt.rpc("update_support_post",{p_post_id:n,p_title:a,p_body:r,p_visibility:l});if(c)throw c}async function F0(n,a){const{error:r}=await pt.rpc("add_support_comment",{p_post_id:n,p_body:a});if(r)throw r}async function P0(n){const{data:a,error:r}=await pt.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 $0(n,a){const{error:r}=await pt.rpc("change_support_post_status",{p_post_id:n,p_target_status:a});if(r)throw r}async function U0(n){const{error:a}=await pt.rpc("set_support_post_hidden",{p_post_id:n,p_hidden:!0});if(a)throw a}async function q0(n,a){const{error:r}=await pt.rpc("set_support_post_locked",{p_post_id:n,p_locked:a});if(r)throw r}async function G0(n,a){const{error:r}=await pt.rpc("set_support_post_pinned",{p_post_id:n,p_pinned:a});if(r)throw r}async function V0(n,a){const{error:r}=await pt.rpc("mark_support_duplicate",{p_post_id:n,p_duplicate_of_post_id:a});if(r)throw r}async function W0(n,a){const{error:r}=await pt.rpc("accept_support_answer",{p_post_id:n,p_comment_id:a});if(r)throw r}async function Y0(n,a=!0){const{error:r}=await pt.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"}],K0=[{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"]},X0={type:"all",product:"",status:"all",visibility:"all",sort:"recent",query:""};function qm(){if(typeof window>"u")return X0;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 Z0(n){return n==="all"?"":n==="question"?"questions":n==="issue"?"issues":n==="feature"?"features":"announcements"}function J0(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=Z0(r.type),d=l.toString();return`/support${c?`/${c}`:""}${d?`?${d}`:""}`}function ld(n){const a=new Date(n);return Number.isFinite(a.getTime())?a.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"}):n}function Gm(n){return n.replaceAll("-"," ").replace(/\b\w/g,a=>a.toUpperCase())}function hy(n){return n==="question"?OS:n==="issue"?HS:n==="feature"?BS:FS}function py(n){return Ch.find(a=>a.id===n)?.shortLabel||n}function Vm(n,a){return n.find(r=>r.id===a)?.name||"Product"}function Ta(n){const a=M0(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 eb({session:n,currentProductKey:a="livedesk",appVersion:r="",onSignIn:l}){const[c,d]=u.useState(()=>qm()),[m,p]=u.useState(null),[g,v]=u.useState([]),[w,x]=u.useState([]),[b,C]=u.useState(""),[j,A]=u.useState([]),[N,k]=u.useState([]),[T,R]=u.useState([]),[U,O]=u.useState(()=>new Set),[Y,_]=u.useState(!0),[D,ne]=u.useState(""),[G,te]=u.useState(""),[B,xe]=u.useState(!1),[se,K]=u.useState(!1),[I,Q]=u.useState(""),[q,V]=u.useState(()=>qm().query),[ce,be]=u.useState(!1),[X,$]=u.useState(!1),[ue,he]=u.useState(""),[ve,Se]=u.useState(""),[_e,re]=u.useState("free"),[Z,ze]=u.useState(""),[De,ae]=u.useState(""),[fe,Ae]=u.useState("admin"),[Te,Be]=u.useState(""),[Ve,Je]=u.useState(""),[Et,je]=u.useState(""),[We,it]=u.useState(""),[ot,gn]=u.useState(""),[Kt,Ie]=u.useState([]),[ct,_t]=u.useState({productId:"",postType:"question",title:"",body:"",visibility:"public",includeEnvironment:!0,files:[]}),Ft=u.useCallback(H=>{const Pe={...c,...H};d(Pe),typeof window<"u"&&window.history.pushState({},"",J0(c,H))},[c]);u.useEffect(()=>{const H=()=>d(qm());return window.addEventListener("popstate",H),()=>window.removeEventListener("popstate",H)},[]);const ge=u.useCallback(async()=>{const H=await R0(c.query);return x(H),n?.user.id&&O(await z0(n.user.id)),H},[c.query,n?.user.id]),Oe=u.useCallback(async()=>{if(!n?.user.id){p(null),v([]),x([]),C(""),R([]),_(!1);return}_(!0),te("");try{const H=await E0(n.user.id,a);p(H.access),v(H.products),await ge(),R(await L0())}catch(H){te(Ta(H))}finally{_(!1)}},[a,ge,n?.user.id]);u.useEffect(()=>{Oe()},[Oe]);const Fe=u.useMemo(()=>m?m.canViewAllProducts?g:g.filter(H=>m.accessibleProductIds.includes(H.id)):[],[m,g]),ke=u.useMemo(()=>{const H=Fe.find(Pe=>Pe.product_key===c.product);return m?.canViewAllProducts&&!c.product||c.product==="all"&&m?.canViewAllProducts?"all":H?H.product_key:Fe.some(Pe=>Pe.product_key===a)?a:Fe[0]?.product_key||""},[m?.canViewAllProducts,Fe,a,c.product]),at=ke==="all"?"":Fe.find(H=>H.product_key===ke)?.id||"",gt=u.useMemo(()=>{const H=new Map(g.map(vt=>[vt.id,vt.product_key]));return[...w.filter(vt=>c.type!=="all"&&vt.post_type!==c.type||ke!=="all"&&at&&vt.product_id!==at||c.status==="needs-response"&&!["open","needs-info"].includes(vt.status)||c.status!=="all"&&c.status!=="needs-response"&&vt.status!==c.status||c.visibility!=="all"&&vt.visibility!==c.visibility?!1:H.has(vt.product_id))].sort((vt,sn)=>c.sort==="votes"?sn.vote_count-vt.vote_count||sn.updated_at.localeCompare(vt.updated_at):c.sort==="newest"?sn.created_at.localeCompare(vt.created_at):Number(sn.is_pinned)-Number(vt.is_pinned)||sn.updated_at.localeCompare(vt.updated_at))},[w,g,c.sort,c.status,c.type,c.visibility,at,ke]),Ee=gt.find(H=>H.id===b)||gt[0]||null,jn=!!(Ee&&m&&(m.canViewAllProducts||m.managedProductIds.includes(Ee.product_id))),Ls=!!(Ee&&n?.user.id===Ee.author_id)||jn;u.useEffect(()=>{if(!Ee){C(""),A([]),K(!1);return}Ee.id!==b&&C(Ee.id)},[Ee,b]),u.useEffect(()=>{let H=!0;return b?(my(b).then(Pe=>{H&&A(Pe)}).catch(Pe=>{H&&te(Ta(Pe))}),D0(b).then(Pe=>{H&&k(Pe)}).catch(Pe=>{H&&te(Ta(Pe))}),()=>{H=!1}):(A([]),k([]),()=>{H=!1})},[b]),u.useEffect(()=>{!ct.productId&&Fe[0]&&_t(H=>({...H,productId:at||Fe[0].id}))},[Fe,ct.productId,at]),u.useEffect(()=>{V(c.query)},[c.query]),u.useEffect(()=>{!ve&&Fe[0]&&Se(Fe[0].id),!De&&Fe[0]&&ae(Fe[0].id)},[Fe,ve,De]);const nt=H=>{Ee&&x(Pe=>Pe.map(vt=>vt.id===Ee.id?{...vt,...H}:vt))},zt=async H=>{if(H.preventDefault(),!(!n||!ct.productId)){ne("create"),te("");try{const Pe=await I0({productId:ct.productId,postType:ct.postType,title:ct.title,body:ct.body,visibility:ct.postType==="announcement"?"public":ct.visibility,appVersion:r,includeEnvironment:ct.postType==="issue"&&ct.includeEnvironment});for(const sn of Kt)await H0(Pe,sn);const vt=await ge();xe(!1),Ie([]),_t(sn=>({...sn,title:"",body:"",files:[]})),C(Pe),vt.some(sn=>sn.id===Pe)||await Oe()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},zn=async H=>{if(H.preventDefault(),!!Ee){ne("edit"),te("");try{await B0(Ee.id,Ee.title,Ee.body,Ee.visibility),K(!1),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},He=async H=>{if(H.preventDefault(),!(!Ee||!I.trim())){ne("comment"),te("");try{await F0(Ee.id,I),Q(""),A(await my(Ee.id)),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},va=async()=>{if(!(!Ee||Ee.post_type!=="feature")){ne("vote"),te("");try{const H=await P0(Ee.id);O(Pe=>{const vt=new Set(Pe);return H.voted?vt.add(Ee.id):vt.delete(Ee.id),vt}),nt({vote_count:H.totalVotes})}catch(H){te(Ta(H))}finally{ne("")}}},dt=async H=>{if(Ee){ne("status"),te("");try{await $0(Ee.id,H),nt({status:H}),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},Hi=async()=>{if(!(!Ee||!window.confirm("Hide this Support post from the board?"))){ne("hide"),te("");try{await U0(Ee.id),C(""),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},Qt=async()=>{if(Ee){ne("lock"),te("");try{await q0(Ee.id,!Ee.is_locked),nt({is_locked:!Ee.is_locked}),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},ps=async()=>{if(Ee){ne("pin"),te("");try{await G0(Ee.id,!Ee.is_pinned),nt({is_pinned:!Ee.is_pinned}),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},bt=async H=>{if(Ee){ne(`accept-${H}`),te("");try{await W0(Ee.id,H),nt({accepted_comment_id:H,status:Ee.post_type==="question"?"answered":Ee.status}),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},qn=async()=>{if(!(!Ee||!We||We===Ee.id)){ne("duplicate"),te("");try{await V0(Ee.id,We),C(""),it(""),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},_s=async H=>{if(!H.read_at)try{await _0(H.id),R(Pe=>Pe.map(vt=>vt.id===H.id?{...vt,read_at:new Date().toISOString()}:vt))}catch(Pe){te(Ta(Pe))}H.post_id&&C(H.post_id),be(!1)};return n?Y&&!m?s.jsxs("section",{className:"support-page support-loading",children:[s.jsx(Ro,{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:()=>be(H=>!H),title:"Notifications",children:[s.jsx(_S,{size:16})," ",T.filter(H=>!H.read_at).length>0&&s.jsx("b",{children:T.filter(H=>!H.read_at).length})]}),ce&&s.jsxs("div",{className:"support-notification-popover",children:[s.jsx("strong",{children:"Notifications"}),T.length===0?s.jsx("span",{className:"support-muted",children:"No notifications yet."}):T.map(H=>s.jsxs("button",{type:"button",className:H.read_at?"":"unread",onClick:()=>{_s(H)},children:[s.jsx("b",{children:H.title}),s.jsx("span",{children:H.body}),s.jsx("small",{children:ld(H.created_at)})]},H.id))]})]}),m?.canViewAllProducts&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>$(H=>!H),children:[s.jsx(Bt,{size:16})," Admin"]}),s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{Oe()},disabled:Y,children:[s.jsx(Ro,{size:16,className:Y?"support-spin":""})," Refresh"]}),s.jsxs("button",{className:"support-primary-button",type:"button",onClick:()=>xe(!0),disabled:Fe.length===0,children:[s.jsx(Hm,{size:17})," New request"]})]})}),G&&s.jsxs("div",{className:"support-error",role:"alert",children:[s.jsx(Ya,{size:17})," ",s.jsx("span",{children:G}),s.jsx("button",{type:"button",onClick:()=>te(""),"aria-label":"Dismiss error",children:s.jsx(Ya,{size:15})})]}),B&&s.jsxs("form",{className:"support-composer",onSubmit:H=>{zt(H)},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:()=>xe(!1),"aria-label":"Close composer",children:s.jsx(Ya,{size:18})})]}),s.jsxs("div",{className:"support-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsx("select",{value:ct.productId,onChange:H=>_t(Pe=>({...Pe,productId:H.target.value})),children:Fe.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Type"}),s.jsx("select",{value:ct.postType,onChange:H=>_t(Pe=>({...Pe,postType:H.target.value})),children:Ch.filter(H=>H.id!=="announcement"||m?.canCreateAnnouncements).map(H=>s.jsx("option",{value:H.id,children:H.label},H.id))})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:"Title"}),s.jsx("input",{required:!0,minLength:3,maxLength:180,value:ct.title,onChange:H=>_t(Pe=>({...Pe,title:H.target.value})),placeholder:"A short, searchable summary"})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:ct.postType==="issue"?"What happened?":ct.postType==="feature"?"Describe the desired behavior":ct.postType==="announcement"?"Announcement":"Question"}),s.jsx("textarea",{required:!0,value:ct.body,onChange:H=>_t(Pe=>({...Pe,body:H.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:ct.visibility,disabled:ct.postType==="announcement",onChange:H=>_t(Pe=>({...Pe,visibility:H.target.value})),children:[s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]})]}),ct.postType==="issue"&&s.jsxs("label",{className:"support-checkbox",children:[s.jsx("input",{type:"checkbox",checked:ct.includeEnvironment,onChange:H=>_t(Pe=>({...Pe,includeEnvironment:H.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:H=>Ie(Array.from(H.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:Kt.length>0?`${Kt.length} attachment${Kt.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:D==="create",children:[s.jsx(Bc,{size:16})," ",D==="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:()=>Ft({type:"all"}),children:"All"}),Ch.map(H=>{const Pe=hy(H.id);return s.jsxs("button",{className:c.type===H.id?"active":"",type:"button",onClick:()=>Ft({type:H.id}),children:[s.jsx(Pe,{size:15})," ",H.label]},H.id)})]}),X&&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:H=>{},children:[s.jsx("strong",{children:"Grant product access"}),s.jsx("input",{type:"email",required:!0,placeholder:"User email",value:ue,onChange:H=>he(H.target.value)}),s.jsx("select",{value:ve,onChange:H=>Se(H.target.value),children:Fe.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))}),s.jsxs("select",{value:_e,onChange:H=>re(H.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:ot==="access",children:[s.jsx(Ii,{size:15})," Grant access"]})]}),s.jsxs("form",{onSubmit:H=>{},children:[s.jsx("strong",{children:"Assign product admin"}),s.jsx("input",{type:"email",required:!0,placeholder:"Admin email",value:Z,onChange:H=>ze(H.target.value)}),s.jsx("select",{value:De,onChange:H=>ae(H.target.value),children:Fe.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))}),s.jsxs("select",{value:fe,onChange:H=>Ae(H.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:ot==="product-admin",children:[s.jsx(Bt,{size:15})," Assign admin"]})]}),s.jsxs("form",{onSubmit:H=>{},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:Te,onChange:H=>Be(H.target.value)}),s.jsx("input",{required:!0,placeholder:"Product name",value:Ve,onChange:H=>Je(H.target.value)}),s.jsx("input",{placeholder:"Description",value:Et,onChange:H=>je(H.target.value)}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:ot==="product",children:[s.jsx(Hm,{size:15})," Add product"]})]})]})]}),s.jsxs("form",{className:"support-search-bar",onSubmit:H=>{H.preventDefault(),Ft({query:q.trim()})},children:[s.jsxs("label",{children:[s.jsx("span",{children:"Search Support"}),s.jsx("input",{value:q,onChange:H=>V(H.target.value),placeholder:"Search titles and request details"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",children:[s.jsx(ey,{size:15})," Search"]}),c.query&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{V(""),Ft({query:""})},"aria-label":"Clear search",children:s.jsx(Ya,{size:16})})]}),s.jsxs("div",{className:"support-filter-bar",children:[s.jsxs("div",{className:"support-filter-title",children:[s.jsx(ey,{size:16}),s.jsx("span",{children:"Filter"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsxs("select",{value:ke,onChange:H=>Ft({product:H.target.value}),disabled:!m?.canViewAllProducts&&Fe.length<=1,children:[s.jsx("option",{value:"all",children:"All products"}),Fe.map(H=>s.jsx("option",{value:H.product_key,children:H.name},H.id))]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Status"}),s.jsx("select",{value:c.status,onChange:H=>Ft({status:H.target.value}),children:K0.map(H=>s.jsx("option",{value:H.id,children:H.label},H.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Visibility"}),s.jsxs("select",{value:c.visibility,onChange:H=>Ft({visibility:H.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:H=>Ft({sort:H.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:()=>Ft({status:"needs-response"}),children:"Needs response"}),s.jsx("button",{type:"button",onClick:()=>Ft({visibility:"private"}),children:"Private requests"}),s.jsx("button",{type:"button",onClick:()=>Ft({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:[gt.length," request",gt.length===1?"":"s"]}),s.jsx("small",{children:ke==="all"?"All products":Vm(Fe,at)})]}),gt.length===0?s.jsxs("div",{className:"support-list-empty",children:[s.jsx(Dc,{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."}),Fe.length>0&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>xe(!0),children:[s.jsx(Hm,{size:16})," Create the first request"]})]}):gt.map(H=>{const Pe=hy(H.post_type);return s.jsxs("button",{type:"button",className:`support-post-row ${H.id===Ee?.id?"active":""}`,onClick:()=>{C(H.id),K(!1)},children:[s.jsx("span",{className:"support-post-row-icon",children:s.jsx(Pe,{size:17})}),s.jsxs("span",{className:"support-post-row-copy",children:[s.jsxs("span",{className:"support-post-row-meta",children:[s.jsx("b",{children:Vm(g,H.product_id)}),s.jsx("em",{children:py(H.post_type)}),H.visibility==="private"&&s.jsx(Ts,{size:13})]}),s.jsx("strong",{children:H.title}),s.jsxs("small",{children:[Gm(H.status)," · ",ld(H.updated_at)," · ",H.comment_count," comments"]})]}),H.post_type==="feature"&&s.jsxs("span",{className:"support-vote-count",children:[s.jsx($x,{size:14})," ",H.vote_count]})]},H.id)})]}),s.jsx("section",{className:"support-post-detail","aria-label":"Support post detail",children:Ee?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:Vm(g,Ee.product_id)}),s.jsx("span",{className:"support-type-badge",children:py(Ee.post_type)}),s.jsx("span",{className:`support-status-badge status-${Ee.status}`,children:Gm(Ee.status)}),Ee.visibility==="private"&&s.jsxs("span",{className:"support-private-badge",children:[s.jsx(Ts,{size:13})," Private"]})]}),s.jsxs("div",{className:"support-detail-actions",children:[Ls&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>K(H=>!H),title:"Edit post",children:s.jsx(zS,{size:16})}),jn&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{ps()},disabled:D==="pin",title:Ee.is_pinned?"Unpin post":"Pin post",children:s.jsx(ty,{size:16})}),s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{Qt()},disabled:D==="lock",title:Ee.is_locked?"Unlock post":"Lock post",children:s.jsx(Ts,{size:16})}),s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{Hi()},disabled:D==="hide",title:"Hide post",children:s.jsx(ny,{size:16})})]})]})]}),se?s.jsxs("form",{className:"support-edit-form",onSubmit:H=>{zn(H)},children:[s.jsx("input",{value:Ee.title,onChange:H=>nt({title:H.target.value}),minLength:3,maxLength:180,required:!0}),s.jsx("textarea",{value:Ee.body,onChange:H=>nt({body:H.target.value}),rows:9,required:!0}),s.jsxs("div",{className:"support-edit-actions",children:[s.jsxs("select",{value:Ee.visibility,onChange:H=>nt({visibility:H.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:D==="edit",children:[s.jsx(Ii,{size:16})," Save changes"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:Ee.title}),s.jsx("div",{className:"support-detail-body",children:Ee.body.split(`
|
|
10
|
-
`).map((H,Pe)=>s.jsx("p",{children:H||" "},`${Ee.id}-body-${Pe}`))})]}),s.jsxs("div",{className:"support-detail-meta",children:[s.jsxs("span",{children:["Opened ",ld(Ee.created_at)]}),Ee.app_version&&s.jsxs("span",{children:["Version ",Ee.app_version]}),Ee.platform&&s.jsx("span",{children:Ee.platform}),Ee.is_locked&&s.jsxs("span",{children:[s.jsx(Ts,{size:13})," Locked"]}),Ee.is_pinned&&s.jsxs("span",{children:[s.jsx(ty,{size:13})," Pinned"]})]}),s.jsxs("div",{className:"support-detail-controls",children:[Ee.post_type==="feature"&&s.jsxs("button",{className:`support-vote-button ${U.has(Ee.id)?"voted":""}`,type:"button",onClick:()=>{va()},disabled:D==="vote",children:[s.jsx(IS,{size:16})," ",U.has(Ee.id)?"Voted":"Vote"," ",s.jsx("b",{children:Ee.vote_count})]}),jn&&s.jsxs("label",{className:"support-status-control",children:[s.jsx("span",{children:"Change status"}),s.jsx("select",{value:Ee.status,onChange:H=>{dt(H.target.value)},disabled:D==="status",children:(Q0[Ee.post_type]||[]).map(H=>s.jsx("option",{value:H,children:Gm(H)},H))})]}),jn&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"support-status-control",value:We,onChange:H=>it(H.target.value),children:[s.jsx("option",{value:"",children:"Duplicate of..."}),gt.filter(H=>H.id!==Ee.id&&H.product_id===Ee.product_id).map(H=>s.jsx("option",{value:H.id,children:H.title.slice(0,55)},H.id))]}),s.jsx("button",{className:"support-secondary-button",type:"button",onClick:()=>{qn()},disabled:!We||D==="duplicate",children:"Merge duplicate"})]})]}),N.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:[N.length," file",N.length===1?"":"s"]})]})}),N.map(H=>s.jsxs("a",{href:H.signed_url,target:"_blank",rel:"noreferrer",children:[s.jsx(Vh,{size:14})," ",H.file_name,s.jsxs("small",{children:[Math.ceil(H.size_bytes/1024)," KB"]})]},H.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:[j.length," comment",j.length===1?"":"s"]})]}),Ee.is_locked&&s.jsxs("span",{className:"support-locked-label",children:[s.jsx(Ts,{size:14})," Locked"]})]}),j.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:j.map(H=>s.jsxs("article",{className:`support-comment ${H.is_staff_answer?"staff":""} ${Ee.accepted_comment_id===H.id?"accepted":""}`,children:[s.jsxs("div",{className:"support-comment-head",children:[s.jsx("strong",{children:H.is_staff_answer?"LiveDesk Support":H.author_id===n.user.id?"You":"Support user"}),H.is_staff_answer&&s.jsxs("span",{children:[s.jsx(Bt,{size:13})," Staff answer"]}),Ee.accepted_comment_id===H.id&&s.jsxs("span",{children:[s.jsx(Fn,{size:13})," Accepted"]}),s.jsx("time",{children:ld(H.created_at)})]}),s.jsx("p",{children:H.body}),s.jsxs("div",{className:"support-comment-actions",children:[(n.user.id===Ee.author_id||jn)&&Ee.post_type==="question"&&Ee.accepted_comment_id!==H.id&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{bt(H.id)},disabled:D===`accept-${H.id}`,children:[s.jsx(Ii,{size:14})," Accept answer"]}),jn&&s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{Y0(H.id)},title:"Hide comment",children:s.jsx(ny,{size:14})})]})]},H.id))}),!Ee.is_locked&&s.jsxs("form",{className:"support-comment-form",onSubmit:H=>{He(H)},children:[s.jsx("textarea",{value:I,onChange:H=>Q(H.target.value),placeholder:"Add a focused reply...",rows:3}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:D==="comment"||!I.trim(),children:[s.jsx(Bc,{size:15})," Reply"]})]})]})]}):s.jsxs("div",{className:"support-detail-empty",children:[s.jsx(Dc,{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(Dc,{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 od(n){return!!n&&typeof n=="object"}function tb(n){let a=n;return od(a)&&"data"in a&&(a=a.data),od(a)&&"session"in a&&(a=a.session),!od(a)||typeof a.access_token!="string"||!a.access_token||!od(a.user)||typeof a.user.id!="string"||!a.user.id?null:a}function gy(n){return n?.access_token?n.refresh_token?"":"refresh-token-required":"access-token-required"}const _c=5179,Cn=Or(`http://127.0.0.1:${_c}`);function eC(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 tC(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function nC(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function aC(n){const a=eC(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 sC(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function iC(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||nC(c)?null:{host:c,port:d}}catch{return null}}function Or(n){const a=String(n||"").trim()||`http://127.0.0.1:${_c}`,r=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const l=new URL(r);return l.port||(l.port=String(_c)),l.hash="",l.search="",l.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${_c}`}}function rC(n){const a=iC(n);return a?Or(`http://${sC(a.host)}:${_c}`):""}function vy(n){const r=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(l=>rC(String(l||""))).filter(Boolean);return[...new Set(r)]}function zc(n=Cn){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(tC(a.hostname))return"loopback";if(aC(a.hostname))return"local"}catch{return}}function Jd(n,a=Cn){const r=new URL(n,Or(a));return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}async function Ge(n,a,r=Cn){const l=Or(r),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=zc(l);d&&(c.targetAddressSpace=d);let m;try{m=await fetch(`${l}${n}`,c)}catch(g){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."):g}let p=null;try{p=await m.json()}catch{p=null}if(!m.ok){const g=p&&typeof p=="object"&&"error"in p?String(p.error||""):"";throw new Error(`${m.status} ${g||m.statusText}`)}return p}async function nb({baseUrl:n=Cn,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 g=await Ge("/api/runtime/status",void 0,n),v=String(g.role||"").toLowerCase(),w=String(g.state||"").toLowerCase(),x=Number(g.runtimePid||0),b=r>1?x>1&&x!==r:x>1;if(v===a&&l.map(C=>C.toLowerCase()).includes(w)&&b)return g}catch(g){m=g}await new Promise(g=>setTimeout(g,300))}const p=m instanceof Error?` ${m.message}`:"";throw new Error(`LiveDesk runtime did not become ${a} with a new process.${p}`)}function lC(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 ab(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 kl(n){await navigator.clipboard.writeText(n)}function sb({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 ib={hub:"Use this computer as the LiveDesk Hub. Hub is the unified control center for Client connections, Wall, Control, file sharing, and Agents; press it after network changes to refresh secure access.","switch-to-hub":"Switch this computer from Client to Hub. LiveDesk saves the new role, restarts the same desktop runtime, and opens the Wall; this computer stops sharing as a Client.",client:"Keep this computer in Client mode so its screens, files, audio, and remote controls remain available to the active Hub.",wall:"Show live thumbnails from every connected Client. Choose a display, change tile size, or move into Control without opening another connection.",control:"Open the selected Client at full resolution and send mouse and keyboard input through the existing Hub session.","share-files":"Browse files on the Hub, send files to selected Clients, and manage shared folders and transfer progress.",agents:"Run Hub-hosted Codex tasks on connected Clients within the selected permissions, timeouts, and audit controls."},jh={en:ib,ko:{hub:"이 컴퓨터를 LiveDesk Hub로 운영합니다. Hub는 Client 연결, Wall, Control, 파일 공유와 Agents를 한곳에서 관리하는 통합 제어 공간이며, 네트워크 변경 후 누르면 보안 접속 정보도 갱신됩니다.","switch-to-hub":"이 컴퓨터를 Client에서 Hub로 전환합니다. 새 역할을 저장한 뒤 같은 데스크톱 런타임을 재시작하고 Wall을 열며, 이 컴퓨터의 Client 화면 공유는 중지됩니다.",client:"이 컴퓨터를 Client 모드로 유지합니다. 화면, 파일, 오디오와 원격 제어 기능이 활성 Hub에서 계속 사용 가능하도록 연결합니다.",wall:"연결된 모든 Client의 실시간 화면을 한곳에 표시합니다. 모니터와 타일 크기를 선택하고 새 연결 없이 Control로 이동할 수 있습니다.",control:"선택한 Client 화면을 전체 해상도로 열고 기존 Hub 세션을 통해 마우스와 키보드 입력을 전송합니다.","share-files":"Hub의 파일을 탐색하고 선택한 Client로 전송하며 공유 폴더와 전송 진행 상태를 관리합니다.",agents:"Hub에서 실행되는 Codex 작업을 연결된 Client에 전달합니다. 선택한 권한, 제한 시간과 감사 기록 범위 안에서만 실행됩니다."},ja:{hub:"このコンピューターを LiveDesk Hub として運用します。Hub は Client 接続、Wall、Control、ファイル共有、Agents を一か所で管理する統合コントロールセンターで、ネットワーク変更後に押すと安全な接続情報も更新します。","switch-to-hub":"このコンピューターを Client から Hub に切り替えます。新しい役割を保存して同じデスクトップランタイムを再起動し、Wall を開きます。Client としての共有は停止します。",client:"このコンピューターを Client モードで維持し、画面、ファイル、音声、リモート操作をアクティブ Hub から利用できるようにします。",wall:"接続中のすべての Client のライブ画面を一覧表示します。ディスプレイやタイルサイズを選び、新しい接続なしで Control に移動できます。",control:"選択した Client をフル解像度で開き、既存の Hub セッションからマウスとキーボード入力を送信します。","share-files":"Hub のファイルを参照し、選択した Client への送信、共有フォルダー、転送状況を管理します。",agents:"Hub 上の Codex タスクを接続中の Client で実行します。選択した権限、タイムアウト、監査設定が適用されます。"},zh:{hub:"将此电脑作为 LiveDesk Hub 运行。Hub 是统一控制中心,可集中管理 Client 连接、Wall、Control、文件共享和 Agents;网络变化后按下此按钮还会刷新安全连接信息。","switch-to-hub":"将此电脑从 Client 切换为 Hub。LiveDesk 保存新角色、重启同一桌面运行时并打开 Wall;此电脑将停止作为 Client 共享。",client:"让此电脑保持 Client 模式,使活动 Hub 可以继续使用它的屏幕、文件、音频和远程控制。",wall:"集中显示所有已连接 Client 的实时缩略图。可以选择显示器、调整磁贴大小,并在不新建连接的情况下进入 Control。",control:"以完整分辨率打开所选 Client,并通过现有 Hub 会话发送鼠标和键盘输入。","share-files":"浏览 Hub 文件、向所选 Client 发送文件,并管理共享文件夹和传输进度。",agents:"在已连接 Client 上运行由 Hub 托管的 Codex 任务,并遵守所选权限、超时和审计控制。"},"zh-TW":{hub:"將此電腦作為 LiveDesk Hub 運作。Hub 是統一控制中心,可集中管理 Client 連線、Wall、Control、檔案分享與 Agents;網路變更後按下此按鈕也會更新安全連線資訊。","switch-to-hub":"將此電腦從 Client 切換為 Hub。LiveDesk 會儲存新角色、重新啟動同一桌面執行階段並開啟 Wall;此電腦將停止以 Client 身分共享。",client:"讓此電腦維持 Client 模式,使作用中 Hub 可繼續使用它的畫面、檔案、音訊與遠端控制。",wall:"集中顯示所有已連線 Client 的即時縮圖。可選擇顯示器、調整圖塊大小,並在不建立新連線的情況下進入 Control。",control:"以完整解析度開啟所選 Client,並透過現有 Hub 工作階段傳送滑鼠與鍵盤輸入。","share-files":"瀏覽 Hub 檔案、傳送檔案到所選 Client,並管理共享資料夾與傳輸進度。",agents:"在已連線 Client 上執行由 Hub 託管的 Codex 工作,並遵守所選權限、逾時與稽核控制。"},es:{hub:"Usa este equipo como LiveDesk Hub. Hub es el centro de control unificado para conexiones Client, Wall, Control, archivos y Agents; púlsalo tras cambios de red para actualizar el acceso seguro.","switch-to-hub":"Cambia este equipo de Client a Hub. LiveDesk guarda el nuevo rol, reinicia el mismo entorno de escritorio y abre Wall; el equipo deja de compartirse como Client.",client:"Mantiene este equipo en modo Client para que sus pantallas, archivos, audio y control remoto sigan disponibles desde el Hub activo.",wall:"Muestra miniaturas en vivo de todos los Clients conectados. Elige pantalla y tamaño, o entra en Control sin abrir otra conexión.",control:"Abre el Client seleccionado a resolución completa y envía ratón y teclado por la sesión Hub existente.","share-files":"Explora archivos del Hub, envíalos a los Clients seleccionados y administra carpetas compartidas y transferencias.",agents:"Ejecuta tareas Codex alojadas en el Hub sobre Clients conectados, respetando permisos, límites de tiempo y auditoría."},fr:{hub:"Utilise cet ordinateur comme LiveDesk Hub. Hub est le centre de contrôle unifié des connexions Client, de Wall, Control, des fichiers et des Agents ; appuyez après un changement réseau pour actualiser l’accès sécurisé.","switch-to-hub":"Bascule cet ordinateur de Client vers Hub. LiveDesk enregistre le nouveau rôle, redémarre le même environnement de bureau et ouvre Wall ; le partage Client s’arrête.",client:"Maintient cet ordinateur en mode Client afin que ses écrans, fichiers, sons et commandes à distance restent disponibles depuis le Hub actif.",wall:"Affiche les miniatures en direct de tous les Clients connectés. Choisissez l’écran et la taille, ou passez à Control sans nouvelle connexion.",control:"Ouvre le Client sélectionné en pleine résolution et transmet souris et clavier via la session Hub existante.","share-files":"Parcourez les fichiers du Hub, envoyez-les aux Clients sélectionnés et gérez dossiers partagés et transferts.",agents:"Exécute des tâches Codex hébergées par le Hub sur les Clients connectés, selon les permissions, délais et règles d’audit."},de:{hub:"Verwendet diesen Computer als LiveDesk Hub. Hub ist die gemeinsame Steuerzentrale für Client-Verbindungen, Wall, Control, Dateien und Agents; nach Netzwerkänderungen aktualisiert ein Klick den sicheren Zugriff.","switch-to-hub":"Wechselt diesen Computer von Client zu Hub. LiveDesk speichert die neue Rolle, startet dieselbe Desktop-Laufzeit neu und öffnet Wall; die Client-Freigabe endet.",client:"Hält diesen Computer im Client-Modus, damit Bildschirme, Dateien, Audio und Fernsteuerung am aktiven Hub verfügbar bleiben.",wall:"Zeigt Live-Vorschaubilder aller verbundenen Clients. Display und Kachelgröße wählen oder ohne neue Verbindung zu Control wechseln.",control:"Öffnet den gewählten Client in voller Auflösung und sendet Maus- und Tastatureingaben über die bestehende Hub-Sitzung.","share-files":"Dateien auf dem Hub durchsuchen, an gewählte Clients senden sowie Freigaben und Übertragungen verwalten.",agents:"Führt Hub-gehostete Codex-Aufgaben auf verbundenen Clients innerhalb der gewählten Berechtigungen, Zeitlimits und Auditregeln aus."},"pt-BR":{hub:"Usa este computador como LiveDesk Hub. Hub é o centro de controle unificado para conexões Client, Wall, Control, arquivos e Agents; após mudanças de rede, pressione para atualizar o acesso seguro.","switch-to-hub":"Muda este computador de Client para Hub. O LiveDesk salva a nova função, reinicia o mesmo runtime de desktop e abre o Wall; o compartilhamento como Client é encerrado.",client:"Mantém este computador no modo Client para que telas, arquivos, áudio e controle remoto continuem disponíveis no Hub ativo.",wall:"Mostra miniaturas ao vivo de todos os Clients conectados. Escolha a tela e o tamanho ou entre em Control sem criar outra conexão.",control:"Abre o Client selecionado em resolução total e envia mouse e teclado pela sessão Hub existente.","share-files":"Navegue pelos arquivos do Hub, envie para Clients selecionados e gerencie pastas compartilhadas e transferências.",agents:"Executa tarefas Codex hospedadas no Hub em Clients conectados, respeitando permissões, limites de tempo e auditoria."},it:{hub:"Usa questo computer come LiveDesk Hub. Hub è il centro di controllo unificato per connessioni Client, Wall, Control, file e Agents; dopo modifiche di rete, premilo per aggiornare l’accesso sicuro.","switch-to-hub":"Passa questo computer da Client a Hub. LiveDesk salva il nuovo ruolo, riavvia lo stesso runtime desktop e apre Wall; la condivisione come Client termina.",client:"Mantiene questo computer in modalità Client, rendendo schermi, file, audio e controllo remoto disponibili all’Hub attivo.",wall:"Mostra le anteprime live di tutti i Client connessi. Scegli display e dimensione oppure passa a Control senza una nuova connessione.",control:"Apre il Client selezionato a piena risoluzione e invia mouse e tastiera tramite la sessione Hub esistente.","share-files":"Esplora i file dell’Hub, inviali ai Client selezionati e gestisci cartelle condivise e trasferimenti.",agents:"Esegue attività Codex ospitate dall’Hub sui Client connessi rispettando permessi, timeout e controlli di audit."},id:{hub:"Gunakan komputer ini sebagai LiveDesk Hub. Hub adalah pusat kendali terpadu untuk koneksi Client, Wall, Control, file, dan Agents; tekan setelah perubahan jaringan untuk memperbarui akses aman.","switch-to-hub":"Alihkan komputer ini dari Client menjadi Hub. LiveDesk menyimpan peran baru, memulai ulang runtime desktop yang sama, lalu membuka Wall; berbagi sebagai Client berhenti.",client:"Pertahankan komputer ini dalam mode Client agar layar, file, audio, dan kendali jarak jauh tetap tersedia bagi Hub aktif.",wall:"Tampilkan thumbnail live semua Client yang terhubung. Pilih layar dan ukuran tile atau masuk ke Control tanpa koneksi baru.",control:"Buka Client terpilih pada resolusi penuh dan kirim input mouse serta keyboard melalui sesi Hub yang ada.","share-files":"Jelajahi file Hub, kirim ke Client terpilih, serta kelola folder bersama dan progres transfer.",agents:"Jalankan tugas Codex yang di-host Hub pada Client terhubung sesuai izin, batas waktu, dan kontrol audit."},vi:{hub:"Dùng máy tính này làm LiveDesk Hub. Hub là trung tâm điều khiển hợp nhất cho kết nối Client, Wall, Control, tệp và Agents; nhấn sau khi đổi mạng để làm mới quyền truy cập an toàn.","switch-to-hub":"Chuyển máy tính này từ Client sang Hub. LiveDesk lưu vai trò mới, khởi động lại cùng môi trường desktop và mở Wall; việc chia sẻ dưới dạng Client sẽ dừng.",client:"Giữ máy tính này ở chế độ Client để màn hình, tệp, âm thanh và điều khiển từ xa luôn sẵn sàng cho Hub đang hoạt động.",wall:"Hiển thị ảnh thu nhỏ trực tiếp của mọi Client đã kết nối. Chọn màn hình, cỡ ô hoặc vào Control mà không tạo kết nối mới.",control:"Mở Client đã chọn ở độ phân giải đầy đủ và gửi chuột, bàn phím qua phiên Hub hiện có.","share-files":"Duyệt tệp trên Hub, gửi tới Client đã chọn và quản lý thư mục chia sẻ cùng tiến trình truyền.",agents:"Chạy tác vụ Codex do Hub lưu trữ trên các Client đã kết nối trong phạm vi quyền, thời gian chờ và kiểm toán đã chọn."},th:{hub:"ใช้คอมพิวเตอร์เครื่องนี้เป็น LiveDesk Hub โดย Hub คือศูนย์ควบคุมรวมสำหรับการเชื่อมต่อ Client, Wall, Control, ไฟล์ และ Agents และกดหลังเปลี่ยนเครือข่ายเพื่อรีเฟรชการเข้าถึงที่ปลอดภัย","switch-to-hub":"เปลี่ยนคอมพิวเตอร์นี้จาก Client เป็น Hub โดย LiveDesk จะบันทึกบทบาทใหม่ รีสตาร์ต desktop runtime เดิม และเปิด Wall พร้อมหยุดแชร์ในฐานะ Client",client:"ให้คอมพิวเตอร์นี้อยู่ในโหมด Client เพื่อให้ Hub ที่ใช้งานเข้าถึงหน้าจอ ไฟล์ เสียง และการควบคุมระยะไกลได้ต่อเนื่อง",wall:"แสดงภาพสดแบบย่อของ Client ที่เชื่อมต่อทั้งหมด เลือกจอและขนาด tile หรือเข้า Control ได้โดยไม่เปิดการเชื่อมต่อใหม่",control:"เปิด Client ที่เลือกแบบความละเอียดเต็ม และส่งเมาส์กับคีย์บอร์ดผ่าน session ของ Hub ที่มีอยู่","share-files":"เรียกดูไฟล์บน Hub ส่งไปยัง Client ที่เลือก และจัดการโฟลเดอร์แชร์กับความคืบหน้าการโอน",agents:"เรียกใช้งาน Codex ที่โฮสต์บน Hub กับ Client ที่เชื่อมต่อ ภายใต้สิทธิ์ timeout และการตรวจสอบที่เลือก"},hi:{hub:"इस कंप्यूटर को LiveDesk Hub के रूप में उपयोग करें। Hub, Client कनेक्शन, Wall, Control, फ़ाइल और Agents का एकीकृत नियंत्रण केंद्र है; नेटवर्क बदलने के बाद सुरक्षित पहुँच ताज़ा करने के लिए इसे दबाएँ।","switch-to-hub":"इस कंप्यूटर को Client से Hub में बदलता है। LiveDesk नई भूमिका सहेजता है, उसी desktop runtime को restart करके Wall खोलता है और Client sharing रोक देता है।",client:"इस कंप्यूटर को Client मोड में रखता है ताकि इसकी स्क्रीन, फ़ाइलें, ऑडियो और remote control सक्रिय Hub पर उपलब्ध रहें।",wall:"सभी जुड़े Clients के live thumbnail दिखाता है। स्क्रीन और tile आकार चुनें या नया connection खोले बिना Control में जाएँ।",control:"चुने हुए Client को पूर्ण resolution में खोलता है और मौजूदा Hub session से mouse तथा keyboard input भेजता है।","share-files":"Hub की फ़ाइलें देखें, चुने हुए Clients को भेजें और shared folders तथा transfer progress प्रबंधित करें।",agents:"चुनी हुई permissions, timeout और audit controls के भीतर जुड़े Clients पर Hub-hosted Codex tasks चलाता है।"},ar:{hub:"استخدم هذا الكمبيوتر بوصفه LiveDesk Hub. يمثّل Hub مركز التحكم الموحّد لاتصالات Client وWall وControl والملفات وAgents؛ اضغط عليه بعد تغييرات الشبكة لتحديث الوصول الآمن.","switch-to-hub":"يحوّل هذا الكمبيوتر من Client إلى Hub. يحفظ LiveDesk الدور الجديد ويعيد تشغيل بيئة سطح المكتب نفسها ويفتح Wall، ويتوقف الجهاز عن المشاركة كـ Client.",client:"يبقي هذا الكمبيوتر في وضع Client لتظل شاشاته وملفاته وصوته والتحكم عن بعد متاحة من Hub النشط.",wall:"يعرض صورا حية مصغرة لكل Clients المتصلين. اختر الشاشة وحجم البلاطات أو انتقل إلى Control من دون اتصال جديد.",control:"يفتح Client المحدد بالدقة الكاملة ويرسل إدخال الماوس ولوحة المفاتيح عبر جلسة Hub الحالية.","share-files":"استعرض ملفات Hub وأرسلها إلى Clients المحددين وأدر المجلدات المشتركة وتقدم النقل.",agents:"يشغّل مهام Codex المستضافة على Hub في Clients المتصلين ضمن الصلاحيات والمهل وضوابط التدقيق المحددة."},tr:{hub:"Bu bilgisayarı LiveDesk Hub olarak kullanır. Hub; Client bağlantıları, Wall, Control, dosyalar ve Agents için birleşik kontrol merkezidir; ağ değişikliklerinden sonra güvenli erişimi yenilemek için basın.","switch-to-hub":"Bu bilgisayarı Client rolünden Hub rolüne geçirir. LiveDesk yeni rolü kaydeder, aynı masaüstü runtime’ını yeniden başlatıp Wall’u açar; Client paylaşımı durur.",client:"Bu bilgisayarı Client modunda tutar; ekran, dosya, ses ve uzaktan kontrol özellikleri etkin Hub tarafından kullanılabilir kalır.",wall:"Bağlı tüm Client ekranlarının canlı küçük görüntülerini gösterir. Ekran ve kutu boyutunu seçin veya yeni bağlantı açmadan Control’e geçin.",control:"Seçili Client’ı tam çözünürlükte açar ve mevcut Hub oturumu üzerinden fare ile klavye girdisi gönderir.","share-files":"Hub dosyalarını gezin, seçili Client’lara gönderin ve paylaşılan klasörlerle aktarım ilerlemesini yönetin.",agents:"Hub üzerinde barındırılan Codex görevlerini seçili izinler, zaman aşımları ve denetim kontrolleri içinde bağlı Client’larda çalıştırır."}};function Xh(n){const a=n?[n]:typeof navigator>"u"?["en"]:navigator.languages?.length?navigator.languages:[navigator.language];for(const r of a){const l=String(r||"").trim(),c=l.toLowerCase();if(!c)continue;if(c.startsWith("zh-tw")||c.startsWith("zh-hk"))return"zh-TW";if(c.startsWith("zh"))return"zh";if(c.startsWith("pt"))return"pt-BR";const d=c.split("-")[0];if(jh[l])return l;if(jh[d])return d}return"en"}function Fd(n,a){const r=Xh(a);return jh[r]?.[n]||ib[n]}function kh(n,a,r){return`${n}
|
|
11
|
-
${Fd(a,r)}`}const rb={eyebrow:"Change computer role",title:"Switch this computer to Hub?",description:"LiveDesk will stop sharing this computer as a Client, save the Hub role, restart the local runtime, and open Wall in this same window.",restartNotice:"Remote streams from this computer will end while LiveDesk restarts.",cancel:"Cancel",confirm:"Switch to Hub",closeLabel:"Close Hub switch confirmation"},oC={en:rb,ko:{eyebrow:"컴퓨터 역할 변경",title:"이 컴퓨터를 Hub로 전환하시겠습니까?",description:"이 컴퓨터의 Client 공유를 중지하고 Hub 역할을 저장한 뒤 로컬 런타임을 재시작하여 같은 창에서 Wall을 엽니다.",restartNotice:"LiveDesk가 재시작되는 동안 이 컴퓨터의 원격 스트림이 종료됩니다.",cancel:"취소",confirm:"Hub로 전환",closeLabel:"Hub 전환 확인 닫기"},ja:{eyebrow:"コンピューターの役割を変更",title:"このコンピューターを Hub に切り替えますか?",description:"このコンピューターの Client 共有を停止し、Hub の役割を保存してローカルランタイムを再起動し、同じウィンドウで Wall を開きます。",restartNotice:"LiveDesk の再起動中、このコンピューターのリモートストリームは終了します。",cancel:"キャンセル",confirm:"Hub に切り替える",closeLabel:"Hub 切り替え確認を閉じる"},zh:{eyebrow:"更改电脑角色",title:"将此电脑切换为 Hub?",description:"LiveDesk 将停止此电脑的 Client 共享,保存 Hub 角色,重启本地运行时,并在同一窗口中打开 Wall。",restartNotice:"LiveDesk 重启期间,此电脑的远程流将会结束。",cancel:"取消",confirm:"切换为 Hub",closeLabel:"关闭 Hub 切换确认"},"zh-TW":{eyebrow:"變更電腦角色",title:"要將此電腦切換為 Hub 嗎?",description:"LiveDesk 將停止此電腦的 Client 分享、儲存 Hub 角色、重新啟動本機執行階段,並在同一視窗中開啟 Wall。",restartNotice:"LiveDesk 重新啟動期間,此電腦的遠端串流將會結束。",cancel:"取消",confirm:"切換為 Hub",closeLabel:"關閉 Hub 切換確認"},es:{eyebrow:"Cambiar función del equipo",title:"¿Cambiar este equipo a Hub?",description:"LiveDesk dejará de compartir este equipo como Client, guardará la función Hub, reiniciará el entorno local y abrirá Wall en esta misma ventana.",restartNotice:"Los streams remotos de este equipo terminarán mientras LiveDesk se reinicia.",cancel:"Cancelar",confirm:"Cambiar a Hub",closeLabel:"Cerrar confirmación de cambio a Hub"},fr:{eyebrow:"Changer le rôle de l’ordinateur",title:"Basculer cet ordinateur vers Hub ?",description:"LiveDesk arrêtera le partage Client de cet ordinateur, enregistrera le rôle Hub, redémarrera le runtime local et ouvrira Wall dans cette même fenêtre.",restartNotice:"Les flux distants de cet ordinateur prendront fin pendant le redémarrage de LiveDesk.",cancel:"Annuler",confirm:"Basculer vers Hub",closeLabel:"Fermer la confirmation de bascule vers Hub"},de:{eyebrow:"Computerrolle ändern",title:"Diesen Computer auf Hub umstellen?",description:"LiveDesk beendet die Client-Freigabe dieses Computers, speichert die Hub-Rolle, startet die lokale Laufzeit neu und öffnet Wall im selben Fenster.",restartNotice:"Die Remote-Streams dieses Computers enden während des LiveDesk-Neustarts.",cancel:"Abbrechen",confirm:"Auf Hub umstellen",closeLabel:"Bestätigung für Hub-Wechsel schließen"},"pt-BR":{eyebrow:"Alterar função do computador",title:"Mudar este computador para Hub?",description:"O LiveDesk interromperá o compartilhamento deste computador como Client, salvará a função Hub, reiniciará o runtime local e abrirá o Wall nesta mesma janela.",restartNotice:"Os streams remotos deste computador serão encerrados enquanto o LiveDesk reinicia.",cancel:"Cancelar",confirm:"Mudar para Hub",closeLabel:"Fechar confirmação de mudança para Hub"},it:{eyebrow:"Cambia ruolo del computer",title:"Passare questo computer a Hub?",description:"LiveDesk interromperà la condivisione Client di questo computer, salverà il ruolo Hub, riavvierà il runtime locale e aprirà Wall nella stessa finestra.",restartNotice:"Gli stream remoti di questo computer termineranno durante il riavvio di LiveDesk.",cancel:"Annulla",confirm:"Passa a Hub",closeLabel:"Chiudi la conferma del passaggio a Hub"},id:{eyebrow:"Ubah peran komputer",title:"Alihkan komputer ini menjadi Hub?",description:"LiveDesk akan menghentikan berbagi komputer ini sebagai Client, menyimpan peran Hub, memulai ulang runtime lokal, lalu membuka Wall di jendela yang sama.",restartNotice:"Stream jarak jauh dari komputer ini akan berakhir saat LiveDesk dimulai ulang.",cancel:"Batal",confirm:"Alihkan ke Hub",closeLabel:"Tutup konfirmasi peralihan Hub"},vi:{eyebrow:"Đổi vai trò máy tính",title:"Chuyển máy tính này thành Hub?",description:"LiveDesk sẽ dừng chia sẻ máy tính này dưới dạng Client, lưu vai trò Hub, khởi động lại runtime cục bộ và mở Wall trong cùng cửa sổ.",restartNotice:"Các luồng từ xa của máy tính này sẽ kết thúc trong khi LiveDesk khởi động lại.",cancel:"Hủy",confirm:"Chuyển sang Hub",closeLabel:"Đóng xác nhận chuyển sang Hub"},th:{eyebrow:"เปลี่ยนบทบาทคอมพิวเตอร์",title:"เปลี่ยนคอมพิวเตอร์เครื่องนี้เป็น Hub หรือไม่",description:"LiveDesk จะหยุดแชร์คอมพิวเตอร์เครื่องนี้ในฐานะ Client บันทึกบทบาท Hub รีสตาร์ทรันไทม์ภายในเครื่อง และเปิด Wall ในหน้าต่างเดิม",restartNotice:"สตรีมระยะไกลจากคอมพิวเตอร์เครื่องนี้จะสิ้นสุดลงระหว่างที่ LiveDesk รีสตาร์ท",cancel:"ยกเลิก",confirm:"เปลี่ยนเป็น Hub",closeLabel:"ปิดการยืนยันการเปลี่ยนเป็น Hub"},hi:{eyebrow:"कंप्यूटर की भूमिका बदलें",title:"इस कंप्यूटर को Hub में बदलें?",description:"LiveDesk इस कंप्यूटर की Client साझेदारी बंद करेगा, Hub भूमिका सहेजेगा, स्थानीय रनटाइम पुनः आरंभ करेगा और इसी विंडो में Wall खोलेगा।",restartNotice:"LiveDesk के पुनः आरंभ होने के दौरान इस कंप्यूटर की रिमोट स्ट्रीम समाप्त हो जाएँगी।",cancel:"रद्द करें",confirm:"Hub में बदलें",closeLabel:"Hub परिवर्तन की पुष्टि बंद करें"},ar:{eyebrow:"تغيير دور الكمبيوتر",title:"هل تريد تحويل هذا الكمبيوتر إلى Hub؟",description:"سيوقف LiveDesk مشاركة هذا الكمبيوتر كـ Client، ويحفظ دور Hub، ويعيد تشغيل وقت التشغيل المحلي، ثم يفتح Wall في النافذة نفسها.",restartNotice:"ستنتهي التدفقات البعيدة من هذا الكمبيوتر أثناء إعادة تشغيل LiveDesk.",cancel:"إلغاء",confirm:"التحويل إلى Hub",closeLabel:"إغلاق تأكيد التحويل إلى Hub"},tr:{eyebrow:"Bilgisayar rolünü değiştir",title:"Bu bilgisayar Hub rolüne geçirilsin mi?",description:"LiveDesk bu bilgisayarın Client paylaşımını durdurur, Hub rolünü kaydeder, yerel çalışma zamanını yeniden başlatır ve Wall’u aynı pencerede açar.",restartNotice:"LiveDesk yeniden başlatılırken bu bilgisayarın uzak akışları sona erer.",cancel:"İptal",confirm:"Hub’a geçir",closeLabel:"Hub geçişi onayını kapat"}};function cC(n){const a=Xh(n);return oC[a]||rb}const uC=[{id:"docs",label:"Doc",icon:Hd},{id:"support",label:"Support",icon:Dc},{id:"pricing",label:"Pricing",icon:ko},{id:"settings",label:"Settings",icon:Ux}],yy=[0,1e3,2e3,5e3,1e4,2e4,3e4];function dC(){return typeof window>"u"?"":window.location.port==="5179"?window.location.origin:"http://127.0.0.1:5179"}async function jc(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 lb(n){return Number.isFinite(n)?Ah(Number(n)):"0%"}function Ml(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 xy(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 fC(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 mC(n,a){return!Number.isFinite(a)||Number(a)<=0?"Dedicated memory unavailable":Number.isFinite(n)?`${Ml(n)} / ${Ml(a)}`:`${Ml(a)} available`}function hC(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 cd({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:lb(c)}})})]})}function pC(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 gC(n){const a=n?.user.user_metadata||{},r=a.avatar_url||a.picture;return typeof r=="string"?r.trim():""}function vC({page:n,status:a}){const l={docs:{label:"DOC",title:"Using this computer",body:"This computer connects to its assigned Hub 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 Hub."})]}),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 yC({session:n,status:a,pin:r,error:l,roleChangeMessage:c,roleChangeBusy:d,onSignIn:m,onPinChange:p,onSubmitPin:g,onSwitchToHub:v}){const w=a?.connectionState==="connected",x=a?.system?.memoryTotalBytes?Number(a.system.memoryUsedBytes||0)/a.system.memoryTotalBytes*100:0,b=a?.system?.gpus||[],C=b.find(O=>Number.isFinite(O.usagePercent)||Number.isFinite(O.memoryTotalBytes))||b[0],j=Number.isFinite(C?.usagePercent)?Number(C?.usagePercent):null,A=Number.isFinite(C?.memoryTotalBytes)&&Number(C?.memoryTotalBytes)>0&&Number.isFinite(C?.memoryUsedBytes)?Number(C?.memoryUsedBytes)/Number(C?.memoryTotalBytes)*100:null,N=a?.system?.disks||[],k=a?.system?.network,T=k?.interfaces||[],R=[...new Set(T.map(O=>O.name).filter(Boolean))],U=T.map(O=>O.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(an,{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(Gx,{size:14})," Uptime ",hC(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(cd,{icon:Vx,label:"CPU",value:Ah(a?.system?.cpuUsagePercent),detail:a?.system?.cpuLogicalCores?`${a.system.cpuLogicalCores} logical cores · Current processor usage`:"Current processor usage",percent:a?.system?.cpuUsagePercent}),s.jsx(cd,{icon:PS,label:"Memory",value:Ah(x),detail:fC(a?.system?.memoryUsedBytes,a?.system?.memoryTotalBytes),percent:x}),s.jsx(cd,{icon:$S,label:"GPU",value:Wm(j),detail:C?.name||(a?.system?.hardwareCollecting?"Detecting graphics hardware…":"Graphics usage unavailable"),percent:j}),s.jsx(cd,{icon:Tl,label:"VRAM",value:Wm(A),detail:mC(C?.memoryUsedBytes,C?.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:N.length>0?`${N.length} ${N.length===1?"drive":"drives"}`:a?.system?.hardwareCollecting?"Detecting…":"Unavailable"})]}),s.jsxs("div",{className:"client-disk-list",children:[N.map(O=>s.jsxs("article",{className:"client-disk-row",children:[s.jsxs("div",{className:"client-disk-row-head",children:[s.jsxs("span",{children:[s.jsx(Nl,{size:16}),s.jsx("strong",{children:O.mount||"Disk"}),s.jsx("small",{children:O.name||"Local disk"})]}),s.jsx("strong",{children:Wm(O.usedPercent)})]}),s.jsxs("small",{children:[Ml(O.freeBytes)," free · ",Ml(O.totalBytes)," total"]}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:lb(O.usedPercent)}})})]},`${O.mount}-${O.name||""}`)),N.length===0&&s.jsxs("div",{className:"client-disk-empty",children:[s.jsx(Nl,{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(Rl,{size:18}),s.jsxs("span",{children:[s.jsx("strong",{children:R.join(", ")||"Network"}),s.jsx("small",{children:U.join(" / ")||"Checking active connection"})]})]}),s.jsxs("div",{className:"client-network-rate download",children:[s.jsx(US,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Receive"}),s.jsx("strong",{children:xy(k?.receiveBytesPerSecond)})]})]}),s.jsxs("div",{className:"client-network-rate upload",children:[s.jsx(qS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Send"}),s.jsx("strong",{children:xy(k?.sendBytesPerSecond)})]})]}),s.jsxs("small",{className:"client-network-total",children:["Total ",Ml(k?.receivedBytes)," received / ",Ml(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(an,{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(Ao,{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(pn,{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(El,{size:16})," Sign in with Google"]}):s.jsxs("p",{className:"client-unified-success",children:[s.jsx(Fn,{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(No,{size:16}),s.jsx("input",{value:r,onChange:O=>p(O.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:g,disabled:r.length!==6,children:"Connect"})]})]}),(l||a?.lastError)&&s.jsxs("p",{className:"client-unified-error",role:"alert",children:[s.jsx(Wx,{size:15})," ",l||a?.lastError]}),c&&s.jsx("p",{className:"client-unified-success",children:c}),s.jsxs("button",{className:"client-unified-secondary full client-hub-switch-trigger",type:"button",onClick:v,disabled:d||!a?.authenticated,children:[s.jsx(Tl,{size:16})," ",d?"Switching to Hub…":"Switch this computer to Hub"]})]})]})]})}function xC(){const[n,a]=u.useState(null),[r,l]=u.useState(null),[c,d]=u.useState(!1),[m,p]=u.useState(""),[g,v]=u.useState(""),[w,x]=u.useState(""),[b,C]=u.useState(!1),[j,A]=u.useState(!1),[N,k]=u.useState("computer"),[T,R]=u.useState(!1),U=u.useRef(null),O=u.useRef(null),Y=u.useRef(!1),_=u.useRef(!1),D=u.useRef(!1),ne=u.useRef(0),G=u.useMemo(dC,[]),te=u.useMemo(()=>pC(r),[r]),B=u.useMemo(()=>gC(r),[r]),xe=te.slice(0,1).toUpperCase()||"L",se=u.useCallback(async()=>{if(v(""),window.liveDesk?.auth?.signInWithGoogle){const re=await window.liveDesk.auth.signInWithGoogle();return re?.ok===!1?(v(re.error||"LiveDesk could not open the system browser for Google sign-in."),!1):!0}return window.location.assign(`${G}/auth/google`),!0},[G]),K=u.useCallback(async()=>{D.current||(D.current=!0,v("Your saved Google sign-in is incomplete. LiveDesk is reopening sign-in once to repair it."),await pt.auth.signOut({scope:"local"}).catch(()=>{}),l(null),await se()||(D.current=!1))},[se]),I=u.useCallback(async re=>{const Z=gy(re);if(Z)throw new Error(Z);if(Y.current)return!1;Y.current=!0;try{const ze=await window.liveDesk?.auth?.persistSession?.(re);if(ze?.ok===!1)throw new Error(ze.error||"LiveDesk could not validate the desktop session.");for(let De=0;De<2;De+=1){const ae=await jc(G,De>0),fe=await fetch(`${G}/api/auth/session`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":ae},signal:AbortSignal.timeout(1e4),body:JSON.stringify({accessToken:re.access_token,refreshToken:re.refresh_token,expiresAt:re.expires_at,user:{id:re.user.id,email:re.user.email}})}),Ae=await fe.json().catch(()=>({}));if(fe.status===403&&De===0){sessionStorage.removeItem("livedesk.client.csrf");continue}if(!fe.ok)throw new Error(Ae.error||`Client runtime returned HTTP ${fe.status}.`);return v(""),!0}throw new Error("Client runtime rejected the session transfer.")}finally{Y.current=!1}},[G]),Q=u.useCallback(async()=>{try{const re=await fetch(`${G}/api/client/status`,{cache:"no-store"}),Z=await re.json().catch(()=>({}));if(!re.ok)throw new Error(Z.error||`Client runtime returned HTTP ${re.status}.`);if(Z.csrfToken&&sessionStorage.setItem("livedesk.client.csrf",Z.csrfToken),String(Z.role||"").toLowerCase()==="hub")throw new Error("This computer is assigned to the Hub role.");a(Z)}catch(re){v(re instanceof Error?re.message:String(re))}},[G]);u.useEffect(()=>{Q();const re=window.setInterval(()=>{Q()},2e3);return()=>window.clearInterval(re)},[Q]);const q=u.useCallback(async()=>{const re=Date.now();if(!(!n?.authenticated||n.connectionState==="connected"||!["waiting","reconnecting"].includes(String(n.agent?.state||""))||re-ne.current<4e3)){ne.current=re;try{const Z=await fetch(`${G}/api/client/reconnect`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await jc(G)},body:JSON.stringify({onlyIfWaiting:!0,reason:"app-active"})});if(!Z.ok)throw new Error(`Client reconnect returned HTTP ${Z.status}.`);await Q()}catch(Z){v(Z instanceof Error?Z.message:String(Z))}}},[G,Q,n]);u.useEffect(()=>{const re=()=>{q()},Z=()=>{q()},ze=()=>{document.visibilityState==="visible"&&q()};return window.addEventListener("online",re),window.addEventListener("focus",Z),document.addEventListener("visibilitychange",ze),()=>{window.removeEventListener("online",re),window.removeEventListener("focus",Z),document.removeEventListener("visibilitychange",ze)}},[q]),u.useEffect(()=>{if(!c||!n||!r?.access_token||n.authenticated)return;if(gy(r)==="refresh-token-required"){K().catch(ae=>{D.current=!1,v(ae instanceof Error?ae.message:String(ae))});return}let re=!1,Z,ze=0;const De=async()=>{if(re)return;try{const fe=await I(r);if(await Q(),fe)return}catch(fe){v(fe instanceof Error?fe.message:String(fe))}if(re)return;const ae=yy[Math.min(ze,yy.length-1)];ze+=1,Z=window.setTimeout(()=>{De()},ae)};return De(),()=>{re=!0,Z!==void 0&&window.clearTimeout(Z)}},[c,Q,K,r,n,I]),u.useEffect(()=>{const re=new URLSearchParams(window.location.search),Z=re.get("auth_error");if(!Z)return;v(Z),re.delete("auth_error");const ze=re.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${ze?`?${ze}`:""}${window.location.hash}`)},[]),u.useEffect(()=>{let re=!0;if(!window.liveDesk?.auth)return l(null),d(!0),Q(),()=>{re=!1};const Z=window.liveDesk?.auth?.onComplete?.(De=>{De.ok&&De.session?pt.auth.setSession(De.session).catch(ae=>v(ae instanceof Error?ae.message:String(ae))):De.error&&v(De.error)});(async()=>{try{const De=window.liveDesk?.auth?.getSession?await window.liveDesk.auth.getSession():await pt.auth.getSession();if(!re)return;const ae=tb(De);l(ae),Q()}catch(De){re&&v(De instanceof Error?De.message:String(De))}finally{re&&d(!0)}})();const{data:ze}=pt.auth.onAuthStateChange((De,ae)=>{re&&(l(ae),d(!0),Q())});return()=>{re=!1,Z?.(),ze.subscription.unsubscribe()}},[Q]),u.useEffect(()=>{if(!c||!n||_.current||D.current||r||n.authenticated)return;const re=new URLSearchParams(window.location.search);if(!re.has("livedesk_launch"))return;_.current=!0,re.delete("livedesk_launch");const Z=re.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${Z?`?${Z}`:""}${window.location.hash}`),se().catch(ze=>v(ze instanceof Error?ze.message:String(ze)))},[c,r,se,n]);const V=async()=>{R(!1),window.liveDesk?.auth?.persistSession?(await pt.auth.signOut(),(await window.liveDesk.auth.persistSession(null))?.runtimeCleared===!1&&v("Signed out locally. The LiveDesk runtime could not be reached to clear its session.")):await fetch(`${G}/api/auth/session`,{method:"DELETE",headers:{"X-LiveDesk-CSRF":await jc(G)}}).catch(()=>{}),l(null),await Q()};u.useEffect(()=>{if(!T)return;const re=ze=>{ze.target instanceof Element&&ze.target.closest(".account-popover, .rail-account")||R(!1)},Z=ze=>{ze.key==="Escape"&&R(!1)};return window.addEventListener("pointerdown",re),window.addEventListener("keydown",Z),()=>{window.removeEventListener("pointerdown",re),window.removeEventListener("keydown",Z)}},[T]);const ce=u.useCallback((re=!0)=>{b||(A(!1),re&&window.requestAnimationFrame(()=>O.current?.focus()))},[b]),be=u.useCallback(()=>{b||!n?.authenticated||(O.current=document.activeElement instanceof HTMLElement?document.activeElement:null,x(""),A(!0))},[b,n?.authenticated]);u.useEffect(()=>{if(!j)return;const re=window.requestAnimationFrame(()=>U.current?.focus()),Z=De=>{De.target instanceof Element&&De.target.closest(".client-hub-switch-popover, .client-hub-switch-trigger")||ce(!1)},ze=De=>{De.key==="Escape"&&ce()};return window.addEventListener("pointerdown",Z),window.addEventListener("keydown",ze),()=>{window.cancelAnimationFrame(re),window.removeEventListener("pointerdown",Z),window.removeEventListener("keydown",ze)}},[ce,j]);const X=async()=>{v("");try{const re=await fetch(`${G}/api/client/pin`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await jc(G)},body:JSON.stringify({pin:m})}),Z=await re.json().catch(()=>({}));if(!re.ok||Z?.ok===!1)throw new Error(Z?.error||"PIN could not be accepted.");p(""),await Q()}catch(re){v(re instanceof Error?re.message:String(re))}},$=async()=>{A(!1),C(!0),x(""),v("");try{const re=await fetch(`${G}/api/runtime/switch-role`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await jc(G)},body:JSON.stringify({role:"hub"})}),Z=await re.json().catch(()=>({}));if(!re.ok||Z?.ok===!1)throw new Error(Z?.error||`Role change failed with HTTP ${re.status}.`);x("Hub role accepted. LiveDesk is restarting this computer with the Hub Wall.");const ze=Number(n?.runtimePid||0);await nb({baseUrl:G,targetRole:"hub",previousRuntimePid:ze,allowedStates:["running"]}),window.location.reload()}catch(re){v(re instanceof Error?re.message:String(re)),C(!1)}},ue=!!(n?.authenticated||r),he=u.useMemo(()=>Xh(),[]),ve=Fd("switch-to-hub",he),Se=Fd("client",he),_e=cC(he);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(sb,{size:25})}),s.jsx("nav",{className:"rail-tools","aria-label":"Client navigation",children:s.jsxs("div",{className:"client-main-tool-slot",children:[s.jsxs("button",{className:"rail-tool client-main-tool client-hub-tool client-hub-switch-trigger accent-blue",type:"button",onClick:be,disabled:b||!n?.authenticated,"aria-busy":b,"aria-expanded":j,"aria-haspopup":"dialog","aria-controls":j?"client-hub-switch-popover":void 0,"aria-label":`Hub. ${ve}`,"data-tooltip":j?void 0:kh("Hub","switch-to-hub",he),children:[s.jsx(Tl,{size:19}),s.jsx("span",{children:b?"Switching…":"Hub"})]}),s.jsxs("button",{className:`rail-tool client-main-tool accent-blue ${N==="computer"?"active":""}`,type:"button",onClick:()=>k("computer"),"aria-current":N==="computer"?"page":void 0,"aria-label":`Client. ${Se}`,"data-tooltip":kh("Client","client",he),children:[s.jsx(an,{size:19}),s.jsx("span",{children:"Client"})]})]})}),s.jsxs("div",{className:"rail-footer",children:[uC.map(re=>{const Z=re.icon;return s.jsxs("button",{className:`rail-tool compact ${N===re.id?"active":""}`,type:"button",onClick:()=>k(re.id),title:re.label,children:[s.jsx(Z,{size:18}),s.jsx("span",{children:re.label})]},re.id)}),s.jsxs("button",{className:`rail-account ${ue?"signed-in":""}`,type:"button",onClick:()=>R(re=>!re),"aria-expanded":T,"aria-haspopup":"dialog",title:ue?"Account":"Sign in",children:[r&&B?s.jsx("img",{src:B,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{className:"avatar-fallback",children:xe}):ue?s.jsx(Bt,{size:18}):s.jsx(El,{size:18}),s.jsx("span",{children:ue?"Account":"Sign in"})]})]})]}),j&&s.jsxs("section",{id:"client-hub-switch-popover",className:"client-hub-switch-popover",role:"dialog","aria-modal":"false","aria-labelledby":"client-hub-switch-title","aria-describedby":"client-hub-switch-description client-hub-switch-restart",children:[s.jsxs("header",{className:"client-hub-switch-head",children:[s.jsx("span",{className:"client-hub-switch-mark","aria-hidden":"true",children:s.jsx(Tl,{size:19})}),s.jsx("span",{className:"client-hub-switch-eyebrow",children:_e.eyebrow}),s.jsx("button",{className:"client-hub-switch-close",type:"button",onClick:()=>ce(),"aria-label":_e.closeLabel,children:s.jsx(Ya,{size:17})})]}),s.jsx("h2",{id:"client-hub-switch-title",children:_e.title}),s.jsx("p",{id:"client-hub-switch-description",children:_e.description}),s.jsxs("p",{id:"client-hub-switch-restart",className:"client-hub-switch-notice",children:[s.jsx(Bt,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:_e.restartNotice})]}),s.jsxs("div",{className:"client-hub-switch-actions",children:[s.jsx("button",{type:"button",onClick:()=>ce(),children:_e.cancel}),s.jsxs("button",{ref:U,className:"primary",type:"button",onClick:()=>{$()},disabled:b||!n?.authenticated,children:[s.jsx(Tl,{size:16}),_e.confirm]})]})]}),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&&B?s.jsx("img",{src:B,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{children:xe}):s.jsx(El,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:r?te:ue?"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":ue?"Active for this run":"Not saved"}),s.jsx("dt",{children:"Role"}),s.jsx("dd",{children:"Client"})]}),ue?s.jsxs("button",{className:"account-popover-action",onClick:()=>{V()},type:"button",children:[s.jsx(qx,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:()=>{R(!1),se()},type:"button",children:[s.jsx(El,{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(pn,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Client workspace"})]})]})}),N==="support"?s.jsx("section",{className:"client-unified-page",children:s.jsx(eb,{session:r,currentProductKey:"livedesk",appVersion:n?.appVersion||"",onSignIn:()=>{se()}})}):N!=="computer"?s.jsx("section",{className:"client-unified-page",children:s.jsx(vC,{page:N,status:n})}):s.jsx(yC,{session:r,status:n,pin:m,error:g,roleChangeMessage:w,roleChangeBusy:b,onSignIn:()=>{se()},onPinChange:re=>p(re.replace(/\D/g,"").slice(0,6)),onSubmitPin:()=>{X()},onSwitchToHub:be})]})]})}function Dr(n,a,r){if(r<0||a<0||a+r>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function Ym(n,a,r){let l=0;for(;Dr(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 ud(n,a,r,l){if(Dr(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 bC(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 ob(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,ud(n,l,r,m),c=4}else n[l.inputIndex]>=18&&(c=n[l.inputIndex]-17,l.inputIndex+=1,ud(n,l,r,c));for(;;){Dr(n,l.inputIndex,1);const m=n[l.inputIndex];l.inputIndex+=1;let p,g;if((m&192)!==0)Dr(n,l.inputIndex,1),g=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+=Ym(n,l,31)),Dr(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;l.inputIndex+=2,g=l.outputIndex-((v>>2)+1),p=v&3}else if((m&16)!==0){d=(m&7)+2,d===2&&(d+=Ym(n,l,7)),Dr(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;if(l.inputIndex+=2,g=l.outputIndex-(((m&8)<<11)+(v>>2)),p=v&3,g===l.outputIndex)break;g-=16384}else if(c===0){let v=m+3;v===3&&(v+=Ym(n,l,15)),ud(n,l,r,v),c=4;continue}else c!==4?(Dr(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+1),l.inputIndex+=1,d=2):(Dr(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+2049),l.inputIndex+=1,d=3);if(g<0||l.outputIndex+d+p>r.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");l.outputIndex=bC(r,l.outputIndex,g,d),c=p,ud(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 by=16,wy=8,wC=24*1024*1024,cb=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]=cb?(a|r<<8|l<<16|4278190080)>>>0:(a<<24|r<<16|l<<8|255)>>>0}function Rr(n,a){return n[a]|n[a+1]<<8}function SC(n,a){const r=Number(a);if(!Number.isSafeInteger(r)||r<by||r>wC)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const l=n instanceof Uint8Array?n:new Uint8Array(n),c=ob(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=Rr(c,6),p=Rr(c,8),g=Rr(c,10),v=Rr(c,12);if(m<=0||p<=0||m>3840||p>2160)throw new Error(`Invalid Mode 5 frame size: ${m}x${p}.`);if(g<=0||g>256||v>8192)throw new Error(`Invalid Mode 5 tile header: ${g}/${v}.`);const w=[];let x=by;for(let b=0;b<v;b+=1){if(x+wy>c.length)throw new Error("Mode 5 tile header is truncated.");const C=Rr(c,x),j=Rr(c,x+2),A=Rr(c,x+4),N=Rr(c,x+6);x+=wy;const k=A*N*2;if(A<=0||N<=0||A>g||N>g||C+A>m||j+N>p||x+k>c.length)throw new Error(`Invalid Mode 5 tile ${b}.`);w.push({x:C,y:j,width:A,height:N,pixels:c.subarray(x,x+k)}),x+=k}if(x!==c.length)throw new Error(`Mode 5 packet has ${c.length-x} trailing bytes.`);return{keyFrame:d,width:m,height:p,tileSize:g,tiles:w}}function CC(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 g=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const v of l.tiles){const w=cb&&(v.pixels.byteOffset&1)===0?new Uint16Array(v.pixels.buffer,v.pixels.byteOffset,v.pixels.byteLength>>>1):null;let x=0;for(let b=0;b<v.height;b+=1){let C=(v.y+b)*a+v.x;for(let j=0;j<v.width;j+=1){const A=x<<1,N=w?w[x]:v.pixels[A]|v.pixels[A+1]<<8;g[C]=Nh[N],x+=1,C+=1}}c=Math.min(c,v.x),d=Math.min(d,v.y),m=Math.max(m,v.x+v.width),p=Math.max(p,v.y+v.height)}return l.tiles.length>0?{x:c,y:d,width:m-c,height:p-d}:null}const Da=new WeakMap,$c=new WeakMap,Mh=new WeakMap,Uc=new Set,Al=new Set,Pd=new WeakMap,Th=new WeakMap,Eh=new WeakMap,$d=new WeakMap,ub=4,jC=2,kC=2,AC=2,NC=18,MC=40,TC=0,EC=250,db=80,Sy=5,RC=150,DC=24,LC=180,_C=1200,zC=18,IC=.65,OC=2e3,HC=500,Zh=250,BC=globalThis.LIVEDESK_ENABLE_CANVAS_VISUAL_SAMPLING===!0;let Ud=!1;function FC(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function PC(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Dl={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:PC()};function $C(n){n.h264DecodeAcceleration&&(Dl={...Dl,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Dl.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function fb(n,a=Dl.h264DecodeAcceleration){const r=Pd.get(n);return r?.requested===a?(r.actual!=="prefer-hardware"&&Al.delete(n),r.actual):(r&&Pd.delete(n),a!=="prefer-hardware"?(Al.delete(n),a):Al.has(n)?"prefer-hardware":Al.size<Dl.h264HardwareDecoderBudget?(Al.add(n),"prefer-hardware"):"prefer-software")}function ef(n,a){return a!=="prefer-hardware"?!1:(Pd.set(n,{requested:a,actual:"prefer-software"}),Al.delete(n),!0)}function UC(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 g=p.getImageData(0,0,d,m).data;let v=2166136261;for(let b=0;b<g.length;b+=4)v^=g[b],v=Math.imul(v,16777619),v^=g[b+1],v=Math.imul(v,16777619),v^=g[b+2],v=Math.imul(v,16777619);const w=(v>>>0).toString(16).padStart(8,"0"),x=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:x}}catch{return{visualHash:"",visualChanged:!0}}}function Rh(n,a,r,l=Zh,c=64,d){if(!BC&&d)return mb(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 g=UC(n,a,r,c);return m.initialized=!0,m.lastHash=g.visualHash,m.lastCanvasSampleAt=p,g}function mb(n,a){let r=$d.get(n);r||(r={lastHash:"",initialized:!1},$d.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 hb(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 qC(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 GC(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function VC(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 Cy(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 WC(n,a){const r=new Uint8Array(a);let l=0,c=0;for(;l<n.length;){const d=n[l];l+=1;const m=Cy(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 g=n[l]|n[l+1]<<8;if(l+=2,g<=0||g>c)throw new Error("Invalid LZ4 block: bad match offset.");const v=Cy(n,l,d&15);l=v.cursor;const w=v.length+4;if(c+w>r.length)throw new Error("Invalid LZ4 block: match overrun.");let x=c-g;for(let b=0;b<w;b+=1)r[c]=r[x],c+=1,x+=1}if(c!==r.length)throw new Error("Invalid LZ4 block: incomplete output.");return r}function YC(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)),x=a*r*2,b=Math.floor(n.uncompressedByteLength||x);if(w!==2||b!==x)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 C=ob(n.payload,x),j=new Uint8ClampedArray(a*r*4);for(let A=0,N=0;A<C.length;A+=2,N+=4){const k=C[A]|C[A+1]<<8,T=k>>11&31,R=k>>5&63,U=k&31;j[N]=T<<3|T>>2,j[N+1]=R<<2|R>>4,j[N+2]=U<<3|U>>2,j[N+3]=255}return new ImageData(j,a,r)}const m=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*r*m,Math.floor(n.uncompressedByteLength||0)),g=WC(n.payload,p);if(m!==4)throw new Error(`Unsupported mode2 pixel size: ${m}`);const v=new Uint8ClampedArray(a*r*4);if(c==="rgba32"||c==="rgba")v.set(g.subarray(0,v.length));else for(let w=0,x=0;x<v.length;w+=4,x+=4)v[x]=g[w+2],v[x+1]=g[w+1],v[x+2]=g[w],v[x+3]=g[w+3];return new ImageData(v,a,r)}function jy(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=Da.get(n);if(l&&l.decoder.state!=="closed"&&l.latencyMode===a)return l;l&&Rs(n);let c;return c={decoder:new r({output:m=>{if(Da.get(n)!==c){m.close();return}const p=Number(m.timestamp||0);c.outputSerial+=1;let g=c.pendingFrames.get(p);if(g)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const j=c.pendingFrames.entries().next().value;j&&(c.pendingFrames.delete(j[0]),g=j[1],c.timestampFallbacks+=1)}const v=m.displayWidth||m.codedWidth||n.width||960,w=m.displayHeight||m.codedHeight||n.height||540,x=Number(g?.frame.durationUs||0),b=Number(m.duration||0),C=Math.max(16,Math.min(250,(x>0?x:b||83333)/1e3));for(c.targetPaintIntervalMs=C,c.decodedFrames.push({videoFrame:m,pending:g,decodedAt:performance.now(),width:v,height:w,durationMs:C}),c.lastOutputAt=performance.now();c.decodedFrames.length>ep(c);)qd(c,c.decodedFrames.shift());pb(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>HC&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=ub&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),Gd(n,c)},error:()=>{Da.get(n)===c&&(ef(n,c.hardwareAcceleration),Jh(c),Uc.delete(n),Da.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:fb(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},Da.set(n,c),Uc.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 qd(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function ep(n){return n.latencyMode==="interactive"?kC:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?jC:ub}function pb(n,a=performance.now()){const r=ep(n);for(;n.decodedFrames.length>r;)qd(n,n.decodedFrames.shift());const l=n.latencyMode==="interactive"?db:EC;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>l;)qd(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function gb(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const r=a.latencyMode==="interactive"?DC:RC,l=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,g]of a.pendingFrames.entries())c-g.queuedAt>OC&&a.pendingFrames.delete(p);if(Da.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{Da.get(n)===a&&Ld(a)}finally{a.flushInFlight=!1;const p=performance.now()-m;if(l&&p>=LC&&a.hardwareAcceleration==="prefer-hardware"){Ud=!0,ef(n,a.hardwareAcceleration),Rs(n);return}Da.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(l||performance.now()-a.lastOutputAt>=r)&&gb(n,a)}},r)}function ky(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=hb(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"?mb(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 Gd(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(pb(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const g=a.targetPaintIntervalMs<=MC,v=a.targetPaintIntervalMs<=20;if(v&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const A=a.decodedFrames.length>=AC,N=c-a.interactiveBufferStartedAt>=NC;if(!A&&!N){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else v||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],x=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+r:c;if(!(!g||c+Sy>=b||x>=db)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const j=a.decodedFrames.shift();if(j)try{ky(n,a,j)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),Gd(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+r:c+TC;if(!(c+Sy>=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{ky(n,a,p)}catch{}Gd(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l)}function vb(n,a){if(Da.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;)qd(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,Gd(n,a),!0}function Km(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of Uc){const a=Da.get(n);if(!a||a.decoder.state==="closed"){Uc.delete(n);continue}vb(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Km),window.addEventListener("focus",Km),window.addEventListener("pageshow",Km));function Rs(n){Al.delete(n),Uc.delete(n),$d.delete(n);const a=Da.get(n);if(a){Da.delete(n);try{Jh(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function kc(n){n&&(Pd.delete(n),Mh.delete(n),Eh.delete(n),Th.delete(n),$d.delete(n),$c.delete(n),Rs(n))}function Ld(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 dd(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 KC(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const r=performance.now();if(r-a.healthSampleStartedAt<_C)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<zC||c/Math.max(1,l)>=IC?!1:(Ud=!0,ef(n,a.hardwareAcceleration),Rs(n),!0)}function Qm(n,a=1){if(!n)return!1;const r=Da.get(n);return r?(r.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),Rs(n),!0):!1}function QC(n){if(!n)return!1;const a=Da.get(n);return a?vb(n,a):!1}function XC(n,a,r,l="interactive"){Rs(n);const c=performance.now(),d=SC(a.payload,a.uncompressedByteLength||0),m=String(a.streamId||"mode5");let p=$c.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 N=3;N<A.length;N+=4)A[N]=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},$c.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const v=Number(a.streamFrameSeq||0);if(v>0&&(p.lastStreamFrameSeq=v),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const w=CC(p.rgba,p.width,p.height,d),x=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const b=hb(n,l),C=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const j=performance.now();p.outputSerial+=1,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,j-c),decodedForMs:Math.max(0,x-c),scheduledForMs:0,drawMs:Math.max(0,j-C),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:b?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:j})}const Xm=[{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 Ay(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 ZC(n){let a=0;for(;a<n.length;){const r=Ay(n,a);if(!r)break;const l=r.index+r.length,c=Ay(n,l),d=c?.index??n.length;if(l<d&&(n[l]&31)===7){const m=[];let p=0;for(let g=l+1;g<d;g+=1){const v=n[g];if(p>=2&&v===3){p=0;continue}m.push(v),p=v===0?p+1:0}if(m.length>=3)return`avc1.${m.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}a=c?c.index:n.length}return""}function JC(n,a,r,l,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),m=r>0?1e6/r:30,p=d*m,g=Xm.find(v=>d<=v.maxFrameSize&&p<=v.maxMacroblocksPerSecond)||Xm[Xm.length-1];return ZC(l)||c||`avc1.42E0${g.code.toString(16).toUpperCase().padStart(2,"0")}`}function ej(n,a,r,l,c="smooth"){$c.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)),g=Math.max(1,Math.floor(a.durationUs||1e6/12));let v=jy(n,c);const w=JC(m,p,g,a.payload,v.codec),x=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&l==="prefer-hardware"&&FC(),j=x==="mode4-h264-atlas"?"prefer-software":fb(n,c==="interactive"&&(Ud||b)?"prefer-software":l),A=[a.streamId||"",a.commandId||"",m,p,w,d,j,c].join("|");v.onPaint=r,v.configured&&v.decoder.state!=="configured"&&(v.configured=!1,v.configKey=""),v.configured&&v.configKey!==A&&(Rs(n),v=jy(n,c),v.onPaint=r);const N={codec:w,codedWidth:m,codedHeight:p,hardwareAcceleration:j,optimizeForLatency:!0,avc:{format:d}};v.configured||dd(v,N,A,j);const k=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const T=Number(a.streamFrameSeq||0);if(T>0&&v.lastInputFrameSeq!==void 0){if(T<=v.lastInputFrameSeq){if(!k||T===v.lastInputFrameSeq)return;Ld(v,v.lastInputFrameSeq-T+1),dd(v,N,A,j)}if(T>v.lastInputFrameSeq+1){if(Ld(v,T-v.lastInputFrameSeq-1),!k)return;dd(v,N,A,j)}}if(T>0&&(v.lastInputFrameSeq=T),!k&&!v.keyFrameSeen)return;k&&(v.keyFrameSeen=!0);const R=Number(v.decoder.decodeQueueSize||0);if(R>8){if(v.latencyMode==="interactive"&&v.hardwareAcceleration==="prefer-hardware"){Ud=!0,ef(n,v.hardwareAcceleration),Rs(n);return}if(Ld(v),!k)return;dd(v,N,A,j),v.keyFrameSeen=!0}const U=v.nextChunkTimestampUs;v.nextChunkTimestampUs+=g,v.pendingFrames.set(U,{frame:a,queuedAt:performance.now(),queueSize:R}),v.inputSerial+=1,v.lastInputAt=performance.now();const O=new EncodedVideoChunk({type:k?"key":"delta",timestamp:U,duration:g,data:a.payload});try{v.decoder.decode(O)}catch(Y){throw Rs(n),Y}gb(n,v),KC(n,v)}async function Zm(n,a,r,l,c,d="smooth"){if(VC(a)){r()||XC(n,a,l,d);return}if(GC(a)){r()||ej(n,a,l,c,d);return}if($c.delete(n),qC(a)){Rs(n);const x=YC(a);if(r())return;(n.width!==x.width||n.height!==x.height)&&(n.width=x.width,n.height=x.height);const b=n.getContext("2d"),C=performance.now();b?.putImageData(x,0,0);const j=performance.now(),A=Rh(n,x.width,x.height,Zh,64,a);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:x.width,height:x.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,j-C),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Dl.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:j});return}Rs(n);const m=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(m);if(r()){p.close();return}const g=a.width||p.width||960,v=a.height||p.height||540;(n.width!==g||n.height!==v)&&(n.width=g,n.height=v);const w=n.getContext("2d");if(w){const x=performance.now();w.clearRect(0,0,g,v),w.drawImage(p,0,0,g,v);const b=performance.now(),C=Rh(n,g,v);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:g,height:v,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-x),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Dl.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:C.visualHash,visualChanged:C.visualChanged,paintedAt:b})}p.close()}const Ny="livedesk_remote_host_targets",tj="livedesk_entitlements",tp=new TextDecoder;function nj(n){const r=(Array.isArray(n)?n:[n||Cn]).map(l=>Or(l||Cn));return[...new Set(r.filter(Boolean))]}function aj(){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&&pt.auth.setSession(p.session)});(window.liveDesk?.auth?.getSession?.()||pt.auth.getSession()).then(p=>{c&&(a(tb(p)),l(!1))});const{data:{subscription:m}}=pt.auth.onAuthStateChange((p,g)=>{a(g),l(!1),window.liveDesk?.auth?.persistSession?.(g)});return()=>{c=!1,d?.(),m.unsubscribe()}},[]),{session:n,loading:r}}function sj(n,a=!0){const[r,l]=u.useState(null),[c,d]=u.useState([]),[m,p]=u.useState(""),[g,v]=u.useState(""),[w,x]=u.useState(0),b=u.useRef(new Map),C=Array.isArray(n)?n.join(`
|
|
12
|
-
`):String(n||""),j=u.useMemo(()=>nj(n),[C]),A=u.useMemo(()=>j.find(T=>zc(T)==="loopback")||j[0]||Cn,[j]),N=u.useCallback(async()=>{if(!a){l(null),d([]),v(""),p("");return}let T=null;const R=Date.now(),U=j.filter(O=>(b.current.get(O)||0)<=R);if(U.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const O of U)try{const[Y,_]=await Promise.all([Ge("/api/remote/status",void 0,O),Ge("/api/remote/devices",void 0,O)]);if(!Array.isArray(_.devices))throw new Error("Invalid Hub devices response.");b.current.delete(O),l(Y),d(_.devices),v(O),p("");return}catch(Y){T=Y,b.current.set(O,Date.now()+1e4)}throw v(""),T||new Error("No LiveDesk Hub endpoint is reachable.")},[a,j]),k=u.useCallback(()=>{b.current.clear(),N().catch(T=>{p(T instanceof Error?T.message:String(T))}),x(T=>T+1)},[N]);return u.useEffect(()=>{if(!a){l(null),d([]),v(""),p("");return}let T=!0;const R=async()=>{try{await N()}catch(O){T&&p(O instanceof Error?O.message:String(O))}};R();const U=window.setInterval(R,2500);return()=>{T=!1,window.clearInterval(U)}},[a,N,w]),{status:r,devices:c,error:m,refresh:k,hubBaseUrl:g||A,hubCandidates:j}}function ij(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:g}=await pt.from(Ny).select("*").eq("user_id",d).maybeSingle();if(g){c(g.message);return}r(p),c("")},[d]);return u.useEffect(()=>{m()},[m]),u.useEffect(()=>{if(!d)return;const p=pt.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:Ny,filter:`user_id=eq.${d}`},g=>r(g.new)).subscribe();return()=>{pt.removeChannel(p)}},[d]),{target:a,error:l,refresh:m}}function rj(n){const[a,r]=u.useState(null),[l,c]=u.useState(!1),[d,m]=u.useState(""),p=n?.user?.id||"",g=u.useCallback(async()=>{if(!p){r(null),m(""),c(!1);return}c(!0);const{data:w,error:x}=await pt.from(tj).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(x){m(x.message),c(!1);return}r(w),m(""),c(!1)},[p]);u.useEffect(()=>{g()},[g]);const v=u.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:v,loading:l,error:d,refresh:g}}const Ic={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},lj=2500,oj=3e4,cj=64*1024,uj=6,dj=uj,yb=new Map;function fj(n){return yb.get(n)}const My={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function Ty(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const r=Date.now()-a;return r>0&&r<=oj?r:0}function Ey(n,a,r=Cn,l={}){const[c,d]=u.useState(new Map),[m,p]=u.useState("idle"),[g,v]=u.useState(""),[w,x]=u.useState(Ic),b=u.useRef(new Map),C=u.useRef(new Map),j=u.useRef(0),A=u.useRef(new Map),N=u.useRef({enabled:!1,token:"",reason:""}),k=u.useRef(new Set),[T,R]=u.useState(0),U=u.useRef(l.onFrame),O=u.useRef(l.onStreamReady),Y=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),_=u.useMemo(()=>[...n].sort().join(","),[n]),D=Number.isFinite(l.fps)?Number(l.fps):2,ne=Number.isFinite(l.maxWidth)?Number(l.maxWidth):640,G=Number.isFinite(l.maxHeight)?Number(l.maxHeight):360,te=Number.isFinite(l.quality)?Number(l.quality):45,B=String(l.frameMode||l.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",xe=l.streamPurpose==="control"?"control":"wall",se=l.forceRestart===!0,K=String(l.forceRestartToken||"").trim(),I=String(l.restartReason||"").trim();N.current={enabled:se,token:K,reason:I};const Q=u.useMemo(()=>{const ue=Object.entries(l.monitorSelections||{}).filter(([he])=>!!he).sort(([he],[ve])=>he.localeCompare(ve));return JSON.stringify(Object.fromEntries(ue))},[l.monitorSelections]);u.useEffect(()=>{U.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{O.current=l.onStreamReady},[l.onStreamReady]);const q=u.useCallback((ue,he="livedesk-frame-socket-release")=>{ue.disposed=!0;try{ue.socket.readyState===WebSocket.CONNECTING||ue.socket.readyState===WebSocket.OPEN?ue.socket.close(1e3,he):ue.socket.close()}catch{}},[]),V=u.useCallback(()=>{const ue=[...C.current.values()].map(he=>he.socket);if(ue.length===0){p("idle");return}if(ue.some(he=>he.readyState===WebSocket.OPEN)){p("open");return}if(ue.some(he=>he.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),ce=u.useCallback((ue,he,ve,Se)=>{if(he.disposed||he.socket.readyState!==WebSocket.OPEN)return!1;try{return he.socket.send(JSON.stringify({...he.payload,type:"restart-live",deviceIds:[ue],forceRestart:!0,restartReason:ve,restartToken:Se})),!0}catch{return!1}},[]),be=u.useCallback((ue,he)=>{if(!ue||ue.byteLength<5)return;const ve=Date.now(),_e=new DataView(ue).getUint32(0,!1);if(_e<=0||_e+4>ue.byteLength)return;const re=new Uint8Array(ue,4,_e),Z=JSON.parse(tp.decode(re));if(Math.max(Ty(Z.receivedAt),Ty(Z.capturedAt))>lj)return;const De=new Uint8Array(ue,4+_e),ae={deviceId:String(Z.deviceId||""),kind:Z.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(Z.frameSeq||0),streamFrameSeq:Number(Z.streamFrameSeq||0)||void 0,streamId:String(Z.streamId||""),commandId:Z.commandId?String(Z.commandId):void 0,sessionId:Z.sessionId?String(Z.sessionId):void 0,captureGeneration:Number(Z.captureGeneration||0)||void 0,streamPurpose:Z.streamPurpose?String(Z.streamPurpose):void 0,width:Number(Z.width||0),height:Number(Z.height||0),sourceWidth:Number(Z.sourceWidth||0)||void 0,sourceHeight:Number(Z.sourceHeight||0)||void 0,mimeType:String(Z.mimeType||"image/jpeg"),mode:Z.mode?String(Z.mode):void 0,frameMode:Z.frameMode?String(Z.frameMode):void 0,frameProfile:Z.frameProfile?String(Z.frameProfile):void 0,encoding:Z.encoding?String(Z.encoding):void 0,codec:Z.codec?String(Z.codec):void 0,compression:Z.compression?String(Z.compression):void 0,pixelFormat:Z.pixelFormat?String(Z.pixelFormat):void 0,bytesPerPixel:Number(Z.bytesPerPixel||0)||0,uncompressedByteLength:Number(Z.uncompressedByteLength||0)||0,h264Format:Z.h264Format?String(Z.h264Format):void 0,isKeyFrame:Z.isKeyFrame===!0,chunkType:Z.chunkType?String(Z.chunkType):void 0,timestampUs:Number(Z.timestampUs||0)||0,durationUs:Number(Z.durationUs||0)||0,sourceGapMs:Number(Z.sourceGapMs||0)||0,agentSendGapMs:Number(Z.agentSendGapMs||0)||0,agentSendDurationMs:Number(Z.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(Z.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(Z.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(Z.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(Z.agentFrameAgeMs||0)||0,droppedByAgent:Number(Z.droppedByAgent||0)||0,hubIngressDropped:Number(Z.hubIngressDropped||0)||0,hubClientDropped:Number(Z.hubClientDropped||0)||0,hardwareEncoder:Z.hardwareEncoder?String(Z.hardwareEncoder):void 0,platformProfile:Z.platformProfile?String(Z.platformProfile):void 0,monitorIndex:Number.isFinite(Number(Z.monitorIndex))?Number(Z.monitorIndex):void 0,monitorCount:Number.isFinite(Number(Z.monitorCount))?Number(Z.monitorCount):void 0,requestedFps:Number(Z.requestedFps||0)||0,effectiveFps:Number(Z.effectiveFps||0)||0,captureAverageMs:Number(Z.captureAverageMs||0)||0,captureP95Ms:Number(Z.captureP95Ms||0)||0,slowFrameCount:Number(Z.slowFrameCount||0)||0,captureHelperRestarts:Number(Z.captureHelperRestarts||0)||0,capturedAt:String(Z.capturedAt||""),receivedAt:String(Z.receivedAt||""),hubPacketAt:Z.hubPacketAt?String(Z.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(Z.hubPacketEpochMs))?Number(Z.hubPacketEpochMs):void 0,browserReceivedEpochMs:ve,byteLength:Number(Z.byteLength||De.byteLength),contentHash:Z.contentHash?String(Z.contentHash):void 0,captureMs:Number(Z.captureMs||0)||0,captureStageMs:Number(Z.captureStageMs||0)||0,convertMs:Number(Z.convertMs||0)||0,compressMs:Number(Z.compressMs||0)||0,captureSourceSerial:Number(Z.captureSourceSerial||0)||0,captureSourceSkipped:Number(Z.captureSourceSkipped||0)||0,deltaTileSize:Number(Z.deltaTileSize||0)||0,deltaTileCount:Number(Z.deltaTileCount||0)||0,deltaVisualTileCount:Number(Z.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(Z.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(Z.deltaTotalTiles||0)||0,payload:De};if(!ae.deviceId)return;const fe={streamId:he.lastFrameStreamId,commandId:he.lastFrameCommandId,order:he.lastFrameOrder},Ae=Number(ae.streamFrameSeq||ae.frameSeq||0),Te=!!fe.commandId&&!!ae.commandId,Be=fe.streamId===ae.streamId&&(!Te||fe.commandId===ae.commandId),Ve=fe.order;if(Be&&Ve>=Ae&&(Ve===Ae||Te))return;he.lastFrameStreamId=ae.streamId,he.lastFrameCommandId=ae.commandId||"",he.lastFrameOrder=Ae;const Je=Y.current;Je.totalFrames+=1,Je.totalBytes+=De.byteLength,Je.sampleFrames+=1,Je.sampleBytes+=De.byteLength;const Et=!b.current.has(ae.deviceId);b.current.set(ae.deviceId,ae),Et&&d(new Map(b.current)),U.current?.(ae)},[]);u.useEffect(()=>{const ue=window.setInterval(()=>{const he=performance.now(),ve=Y.current,Se=Math.max(1,he-ve.sampleStartedAt);x({totalFrames:ve.totalFrames,totalBytes:ve.totalBytes,framesPerSecond:ve.sampleFrames*1e3/Se,bytesPerSecond:ve.sampleBytes*1e3/Se,sampleMs:Se,lastUpdatedAt:Date.now()}),d(new Map(b.current)),ve.sampleFrames=0,ve.sampleBytes=0,ve.sampleStartedAt=he},2e3);return()=>{window.clearInterval(ue)}},[]),u.useEffect(()=>{const ue=_?_.split(",").filter(Boolean):[],he=new Set(ue),ve=performance.now();for(const[Se,_e]of C.current.entries())he.has(Se)||(q(_e,"livedesk-device-unsubscribed"),C.current.delete(Se),A.current.delete(Se),b.current.delete(Se));if(ue.length===0){for(const Se of C.current.values())q(Se,"livedesk-no-devices");C.current.clear(),A.current.clear(),b.current=new Map,d(new Map),v(""),Y.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},x(Ic),V();return}Y.current.sampleStartedAt<=0&&(Y.current.sampleStartedAt=ve,x({...Ic,lastUpdatedAt:Date.now()}));for(const Se of ue){const _e=l.monitorSelections?.[Se],re=Number.isFinite(Number(_e))?{[Se]:Number(_e)}:{},Z={type:"subscribe",deviceIds:[Se],autoStartLive:a,fps:D,maxWidth:ne,maxHeight:G,quality:te,mode:B,frameMode:B,streamPurpose:xe,monitorSelections:re},ze=JSON.stringify(Z),De=C.current.get(Se);if(De){const Te=De.socket.readyState===WebSocket.CONNECTING||De.socket.readyState===WebSocket.OPEN;if(De.payloadKey===ze&&Te&&!De.disposed)continue}const ae=De&&(De.socket.readyState===WebSocket.CONNECTING||De.socket.readyState===WebSocket.OPEN)&&!De.disposed?De.handoffFrom&&!De.handoffCompleted?De.handoffFrom:De:void 0;De&&De!==ae&&q(De,"livedesk-subscription-superseded");const fe=new WebSocket(Jd(`/api/remote/frames/ws?devices=${encodeURIComponent(Se)}`,r));fe.binaryType="arraybuffer";const Ae={socket:fe,payload:Z,payloadKey:ze,generation:j.current+1,disposed:!1,handoffFrom:ae,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};j.current=Ae.generation,C.current.set(Se,Ae),fe.addEventListener("open",()=>{if(Ae.disposed||C.current.get(Se)!==Ae){q(Ae,"livedesk-stale-frame-socket");return}v("");const Te=N.current,Be=Te.enabled&&(!Te.token||A.current.get(Se)!==Te.token);fe.send(JSON.stringify({...Ae.payload,forceRestart:Be,restartReason:Be?Te.reason:"",restartToken:Be?Te.token:""})),Be&&Te.token&&A.current.set(Se,Te.token);const Ve=Ae.handoffFrom;Ae.handoffFrom=void 0,Ae.handoffCompleted=!0,Ve&&!Ve.disposed&&q(Ve,"livedesk-subscription-replaced"),V()}),fe.addEventListener("message",Te=>{if(Ae.disposed||C.current.get(Se)!==Ae)return;if(typeof Te.data=="string"){try{const Ve=JSON.parse(Te.data);if(Ve?.type==="RemoteFrameSubscriptionError")v(String(Ve.error||"control-stream-start-failed"));else if(Ve?.type==="RemoteFrameLiveAutoStart"){const Et=(Array.isArray(Ve.skipped)?Ve.skipped:[]).find(je=>je?.deviceId===Se);if(Et)v(String(Et.reason||"control-stream-start-failed"));else if(Array.isArray(Ve.started)){const je=Ve.started.find(We=>We?.deviceId===Se);je&&(v(""),je.ready===!0&&je.streamPurpose==="control"&&je.sessionId&&je.commandId&&Number(je.captureGeneration||0)>0&&O.current?.({deviceId:Se,sessionId:String(je.sessionId),streamId:String(je.streamId||""),streamPurpose:"control",commandId:String(je.commandId),captureGeneration:Number(je.captureGeneration),monitorIndex:Number(je.monitorIndex||0)}))}}else Ve?.type==="RemoteFrameStreamReady"&&Ve.deviceId===Se&&Ve.streamPurpose==="control"&&Ve.sessionId&&Ve.commandId&&Number(Ve.captureGeneration||0)>0&&(v(""),O.current?.({deviceId:Se,sessionId:String(Ve.sessionId),streamId:String(Ve.streamId||""),streamPurpose:"control",commandId:String(Ve.commandId),captureGeneration:Number(Ve.captureGeneration),monitorIndex:Number(Ve.monitorIndex||0)}))}catch{}return}const Be=Te.data instanceof ArrayBuffer?Te.data:null;Be&&(v(""),be(Be,Ae))}),fe.addEventListener("error",()=>{Ae.disposed||C.current.get(Se)!==Ae||p("connecting")}),fe.addEventListener("close",()=>{const Te=!Ae.disposed;Ae.disposed=!0;const Be=C.current.get(Se);let Ve=!1;if(Be===Ae){const Je=Ae.handoffFrom;Ae.handoffFrom=void 0,Je&&!Je.disposed&&(Je.socket.readyState===WebSocket.CONNECTING||Je.socket.readyState===WebSocket.OPEN)?(C.current.set(Se,Je),Ve=!0):C.current.delete(Se)}if(V(),Te&&Be===Ae&&!Ve){const Je=window.setTimeout(()=>{k.current.delete(Je),R(Et=>Et+1)},750);k.current.add(Je)}})}V()},[a,q,_,D,B,be,r,G,ne,Q,l.monitorSelections,te,T,xe,V]),u.useEffect(()=>{if(!se||!K)return;const ue=_?_.split(",").filter(Boolean):[];for(const he of ue){if(A.current.get(he)===K)continue;const ve=C.current.get(he);!ve||!ce(he,ve,I,K)||A.current.set(he,K)}},[_,se,K,I,ce]),u.useEffect(()=>()=>{for(const ue of C.current.values())q(ue,"livedesk-hook-unmount");C.current.clear();for(const ue of k.current)window.clearTimeout(ue);k.current.clear()},[q]);const X=u.useCallback((ue,he="browser-stale")=>{const ve=Array.isArray(ue)&&ue.length>0?ue:_.split(",").filter(Boolean);if(ve.length===0)return!1;let Se=!1;for(const _e of ve){const re=C.current.get(_e);!re||re.socket.readyState!==WebSocket.OPEN||(Se=ce(_e,re,he,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||Se)}return Se},[_,ce]),$=u.useCallback((ue,he="browser-reconnect")=>{const ve=Array.isArray(ue)&&ue.length>0?ue:_.split(",").filter(Boolean);if(ve.length===0)return!1;let Se=!1;for(const _e of ve){const re=C.current.get(_e);re&&(q(re,`livedesk-${he}`),C.current.delete(_e),A.current.delete(_e),b.current.delete(_e),Se=!0)}return Se&&d(new Map(b.current)),R(_e=>_e+1),V(),!0},[q,_,V]);return{frames:c,state:m,error:g,stats:w,restartLive:X,reconnectLive:$}}function mj(n,a,r=Cn,l={}){const[c,d]=u.useState(null),[m,p]=u.useState(null),[g,v]=u.useState("idle"),[w,x]=u.useState(Ic),b=u.useRef(null),C=u.useRef(l.onFrame),j=u.useRef(null),A=u.useRef(0),N=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),k=u.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),T=u.useMemo(()=>[...new Set((l.captureDeviceIds||n).filter(Boolean))].join(","),[n,l.captureDeviceIds]),R=u.useMemo(()=>JSON.stringify(l.monitorSelections||{}),[l.monitorSelections]),U=u.useMemo(()=>({deviceIds:k.split(",").filter(Boolean),captureDeviceIds:T.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||{}}),[T,k,R,l.fps,l.height,l.monitorSelections,l.tileHeight,l.tileWidth,l.width]),O=u.useMemo(()=>JSON.stringify(U),[U]),Y=u.useRef(U);Y.current=U;const _=a&&U.deviceIds.length>0,D=u.useCallback(G=>G.readyState!==WebSocket.OPEN?!1:(G.send(JSON.stringify({type:"configure",...Y.current})),!0),[]);u.useEffect(()=>{C.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{const G=window.setInterval(()=>{const te=N.current,B=performance.now(),xe=Math.max(1,B-te.sampleStartedAt);x({totalFrames:te.totalFrames,totalBytes:te.totalBytes,framesPerSecond:te.sampleFrames*1e3/xe,bytesPerSecond:te.sampleBytes*1e3/xe,sampleMs:xe,lastUpdatedAt:Date.now()});const se=j.current;se&&se.frameSeq!==A.current&&(A.current=se.frameSeq,d(se)),te.sampleFrames=0,te.sampleBytes=0,te.sampleStartedAt=B},1e3);return()=>window.clearInterval(G)},[]),u.useEffect(()=>{if(!_){b.current?.close(),b.current=null,d(null),j.current=null,A.current=0,p(null),v("idle"),x(Ic);return}let G=!1,te=0;const B=()=>{if(G)return;const xe=new WebSocket(Jd("/api/remote/atlas/ws",r));xe.binaryType="arraybuffer",b.current=xe,v("connecting"),xe.addEventListener("open",()=>{N.current.sampleStartedAt=performance.now(),v("open"),D(xe)}),xe.addEventListener("message",se=>{if(typeof se.data=="string"){try{const I=JSON.parse(se.data);I?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(I.layoutVersion||0),width:Number(I.width||1920),height:Number(I.height||1080),columns:Number(I.columns||1),rows:Number(I.rows||1),tiles:Array.isArray(I.tiles)?I.tiles:[]})}catch{}return}const K=se.data instanceof ArrayBuffer?se.data:null;if(!(!K||K.byteLength<5))try{const I=Date.now(),q=new DataView(K).getUint32(0,!1);if(q<=0||q+4>K.byteLength)return;const V=JSON.parse(tp.decode(new Uint8Array(K,4,q))),ce=new Uint8Array(K,4+q),be={deviceId:String(V.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(V.frameSeq||0),streamFrameSeq:Number(V.streamFrameSeq||0)||void 0,streamId:String(V.streamId||"mode4-atlas"),commandId:V.commandId?String(V.commandId):void 0,width:Number(V.width||1920),height:Number(V.height||1080),sourceWidth:Number(V.sourceWidth||V.width||1920),sourceHeight:Number(V.sourceHeight||V.height||1080),mimeType:String(V.mimeType||"video/h264"),mode:String(V.mode||"mode4-h264-atlas"),frameMode:String(V.frameMode||"mode4-h264-atlas"),frameProfile:String(V.frameProfile||"mode4-h264-atlas-v1"),encoding:String(V.encoding||"video-atlas"),codec:String(V.codec||"h264"),compression:String(V.compression||"video/h264"),h264Format:String(V.h264Format||"annexb"),isKeyFrame:V.isKeyFrame===!0,chunkType:String(V.chunkType||""),timestampUs:Number(V.timestampUs||0),durationUs:Number(V.durationUs||0),hardwareEncoder:V.hardwareEncoder?String(V.hardwareEncoder):void 0,platformProfile:V.platformProfile?String(V.platformProfile):void 0,capturedAt:String(V.capturedAt||""),receivedAt:String(V.receivedAt||""),hubPacketAt:V.hubPacketAt?String(V.hubPacketAt):void 0,hubPacketEpochMs:Number(V.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:I,byteLength:ce.byteLength,layoutVersion:Number(V.layoutVersion||0),atlasComposeMs:Number(V.atlasComposeMs||0),atlasPoolStarved:Number(V.atlasPoolStarved||0),atlasReadyTiles:Number(V.atlasReadyTiles||0),atlasTileCount:Number(V.atlasTileCount||0),atlasInputRevision:Number(V.atlasInputRevision||0),atlasSourceNewestAtEpochMs:Number(V.atlasSourceNewestAtEpochMs||0),atlasSourceOldestAtEpochMs:Number(V.atlasSourceOldestAtEpochMs||0),atlasSourceMaxAgeMs:Number(V.atlasSourceMaxAgeMs||0),payload:ce},X=N.current;X.totalFrames+=1,X.totalBytes+=ce.byteLength,X.sampleFrames+=1,X.sampleBytes+=ce.byteLength,j.current=be,A.current===0&&(A.current=be.frameSeq,d(be)),C.current?.(be)}catch{}}),xe.addEventListener("error",()=>v("error")),xe.addEventListener("close",()=>{b.current===xe&&(b.current=null),!G&&(v("closed"),te=window.setTimeout(B,1200))})};return B(),()=>{G=!0,window.clearTimeout(te),b.current?.close(),b.current=null}},[_,r,D]),u.useEffect(()=>{if(!_)return;const G=b.current;G&&D(G)},[O,_,D]);const ne=u.useCallback(()=>{const G=b.current;return G?D(G):!1},[D]);return{frame:c,layout:m,state:g,stats:w,refreshInputs:ne}}function hj(n,a=Cn){const r=u.useRef(null),l=u.useRef(0),c=u.useRef(0),d=u.useRef(new Map),[m,p]=u.useState("idle"),[g,v]=u.useState(""),[w,x]=u.useState(My),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"),v(""),x(My);return}let j=!1,A=0;const N=()=>{if(j)return;const k=new WebSocket(Jd("/api/remote/input/ws",a));r.current=k,b.current.sampleStartedAt=performance.now(),p("connecting"),v(""),k.addEventListener("open",()=>{j||r.current!==k||(v(""),p("open"))}),k.addEventListener("message",T=>{if(!(j||r.current!==k||typeof T.data!="string"))try{const R=JSON.parse(T.data);if(R?.type==="RemoteInputError"){v(String(R.error||R.result?.error||"Remote input failed.")),p("error");return}if(R?.type!=="RemoteInputApplied")return;const U=Number(R.inputSeq||0),O=d.current.get(U);O!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-O),d.current.delete(U)),b.current.lastInputSeq=U,b.current.lastAgentApplyMs=Math.max(0,Number(R.agentApplyMs||0))}catch{}}),k.addEventListener("close",()=>{j||r.current!==k||(r.current=null,p("closed"),A=window.setTimeout(N,1200))}),k.addEventListener("error",()=>{!j&&r.current===k&&p("error")})};return N(),()=>{j=!0,window.clearTimeout(A);const k=r.current;r.current=null,k?.close(),d.current.clear()}},[n,a]),u.useEffect(()=>{if(!n)return;const j=window.setInterval(()=>{const A=performance.now(),N=b.current,k=Math.max(1,A-N.sampleStartedAt);x({totalSent:N.totalSent,totalDropped:N.totalDropped,sentPerSecond:N.sampleSent*1e3/k,droppedPerSecond:N.sampleDropped*1e3/k,bufferedAmount:r.current?.bufferedAmount||0,lastInputType:N.lastInputType,lastInputSeq:N.lastInputSeq,lastRoundTripMs:N.lastRoundTripMs,lastAgentApplyMs:N.lastAgentApplyMs,lastUpdatedAt:Date.now()}),N.sampleSent=0,N.sampleDropped=0,N.sampleStartedAt=A},1e3);return()=>window.clearInterval(j)},[n]);const C=u.useCallback((j,A)=>{const N=r.current;if(!N||N.readyState!==WebSocket.OPEN||!j)return!1;const k=String(A.type||"").toLowerCase(),T=k==="pointermove",U=T||k==="wheel",O=b.current;if(T&&N.bufferedAmount>cj)return O.totalDropped+=1,O.sampleDropped+=1,O.lastInputType="pointermove-drop",!1;const Y=l.current+1;l.current=Y;const _=Date.now(),D=!U||Y-c.current>=dj;for(D&&(d.current.set(Y,performance.now()),U&&(c.current=Y)),T||yb.set(j,{inputSeq:Y,inputType:k||"input",sentAt:performance.now()});d.current.size>256;){const ne=d.current.keys().next().value;if(ne===void 0)break;d.current.delete(ne)}return N.send(JSON.stringify({type:"input",requestId:U?"":crypto.randomUUID(),fireAndForget:U,deviceId:j,input:{...A,inputSeq:Y,requestAck:D,issuedAtEpochMs:_,issuedAt:new Date(_).toISOString()}})),O.totalSent+=1,O.sampleSent+=1,O.lastInputType=k||"input",!0},[]);return{state:m,sendInput:C,stats:w,error:g}}function pj(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const fd={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},gj=.08,vj=.25,yj=.02,Ry=300,xj=4,md=1500,Jm=5e3,bj=2e3,wj=1e4,hd=[0,1e3,3e3];function Dy(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function Sj(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,g=Math.floor(r.byteLength/p),v=Math.floor(g/l),w=n.createBuffer(l,v,c),x=new DataView(r);for(let b=0;b<l;b+=1){const C=w.getChannelData(b);for(let j=0;j<v;j+=1){const N=(j*l+b)*p;C[j]=m?Math.max(-1,Math.min(1,x.getInt16(N,!0)/32768)):Math.max(-1,Math.min(1,x.getFloat32(N,!0)))}}return w}function Cj(n,a,r=Cn){const l=u.useRef(null),c=u.useRef(0),[d,m]=u.useState("idle"),[p,g]=u.useState(null),[v,w]=u.useState(fd),[x,b]=u.useState("");return u.useEffect(()=>{if(!a||!n){m("idle"),g(null),w(fd),b("");return}m("connecting"),g(null),w(fd),b("");const C=window.AudioContext||window.webkitAudioContext;if(!C){m("unsupported"),w(fd),b("Audio playback is not supported in this browser.");return}const j=new C;l.current=j,c.current=j.currentTime;const A=new WebSocket(Jd("/api/remote/audio/ws?devices="+encodeURIComponent(n),r));A.binaryType="arraybuffer";const N=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(j.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let T=!1,R=0,U=!1,O=0,Y=0;const _=(I=!0)=>{for(const Q of N)try{Q.stop()}catch{}N.clear(),I&&(c.current=j.currentTime+gj)},D=()=>{k.audioContextState=String(j.state),!T&&(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.")))},ne=async()=>{if(T||String(j.state)==="closed")return!1;try{if(String(j.state)!=="running"&&await j.resume(),k.audioContextState=String(j.state),!T&&!U&&k.audioContextState==="running"){const I=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=md,Q=k.lastCaptureStatusAt>0&&performance.now()-k.lastCaptureStatusAt<=Jm&&k.captureAlive&&k.helperAlive;m(I?"playing":Q?"silent":"open")}return k.audioContextState==="running"}catch(I){return T||(m("suspended"),b(I instanceof Error?"Audio playback is suspended: "+I.message:"Audio playback is suspended.")),!1}},G=async()=>{if(T||U||A.readyState!==WebSocket.OPEN)return;if(O>=hd.length){m("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const I=O;O+=1,U=!0,k.stalledCount+=1,k.automaticRestarts+=1,m("reconnecting");try{const Q=await Ge("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},r);if(Q.ok===!1)throw new Error(Q.error||"Remote audio stop failed.");if(T)return;const q=await Ge("/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(q.ok===!1)throw new Error(q.error||"Remote audio start failed.");const V=performance.now();R=V,k.lastPacketAt=V,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,Y=V+(hd[I+1]??3e3),b(""),T||m("open")}catch(Q){T||(Y=performance.now()+(hd[I+1]??3e3),m("error"),b(Q instanceof Error?"Remote audio restart failed: "+Q.message:"Remote audio restart failed."))}finally{U=!1}},te=()=>{k.drops+=1},B=window.setInterval(()=>{if(T)return;const I=performance.now(),Q=k.lastPacketAt>0?Math.max(0,I-k.lastPacketAt):R>0?Math.max(0,I-R):0,q=k.lastAcceptedAt>0?Math.max(0,I-k.lastAcceptedAt):0,V=k.lastCaptureStatusAt>0?Math.max(0,I-k.lastCaptureStatusAt):0,ce=A.readyState===WebSocket.OPEN,be=k.lastCaptureStatusAt>0,X=be&&V<=Jm,$=be&&(!k.captureAlive||!k.helperAlive)&&V>bj,ue=be&&V>Jm,he=!be&&R>0&&I-R>wj,ve=R>0&&(k.lastAcceptedAt<=0?I-R>md:q>md);ce&&R>0&&($||ue||he)?O>=hd.length&&!U?(m("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!U&&I>=Y?G():U||m("stalled"):ce&&ve&&!U&&k.audioContextState!=="suspended"&&k.audioContextState!=="interrupted"&&m(X?"silent":"open"),w({queuedMs:Math.max(0,(c.current-j.currentTime)*1e3),browserAgeMs:k.browserAgeMs,captureAgeMs:k.captureAgeMs,captureStatusAgeMs:V,silentForMs:k.silentForMs,captureAlive:k.captureAlive,helperAlive:k.helperAlive,captureRestartCount:k.captureRestartCount,localProcessingAgeMs:k.localProcessingAgeMs,lastPacketAgeMs:Q,lastAcceptedAgeMs:q,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),xe=()=>{D(),(String(j.state)==="suspended"||String(j.state)==="interrupted")&&ne()},se=()=>{document.visibilityState==="visible"&&ne()},K=()=>{ne()};return j.addEventListener("statechange",xe),document.addEventListener("visibilitychange",se),window.addEventListener("pageshow",K),window.addEventListener("pointerdown",K),window.addEventListener("keydown",K),m("connecting"),b(""),D(),A.addEventListener("open",()=>{T||(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]})),ne())}),A.addEventListener("message",I=>{if(typeof I.data=="string")return;const Q=I.data instanceof ArrayBuffer?I.data:null;if(!Q||Q.byteLength<5)return;const q=performance.now();k.lastPacketAt=q,(async()=>{try{const ce=new DataView(Q).getUint32(0,!1);if(ce<=0||ce+4>Q.byteLength){te();return}const be=new Uint8Array(Q,4,ce),X=JSON.parse(tp.decode(be)),$=Q.slice(4+ce),ue=String(X.frameKind||X.kind||"").toLowerCase();if(X.type==="remote.audio.status"||ue==="audio-status"){if(k.lastCaptureStatusAt=q,k.captureAlive=X.captureAlive===!0,k.helperAlive=X.helperAlive===!0,k.captureRestartCount=Math.max(0,Number(X.restartCount||0)||0),k.lastPcmAtEpochMs=Math.max(0,Number(X.lastPcmAtEpochMs||0)||0),k.silentForMs=Math.max(0,Number(X.silentForMs||0)||0),k.captureAgeMs=k.lastPcmAtEpochMs>0?Math.max(0,Date.now()-k.lastPcmAtEpochMs):k.silentForMs,k.captureAlive&&k.helperAlive){if(O=0,Y=0,!U){b("");const ve=String(j.state)==="running",Se=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=md;m(ve?Se?"playing":"silent":"suspended")}}else U||m("stalled");return}const he={deviceId:String(X.deviceId||""),frameSeq:Number(X.frameSeq||0),streamId:String(X.streamId||""),mimeType:String(X.mimeType||"audio/webm;codecs=opus"),sampleRate:Number(X.sampleRate||48e3),channels:Number(X.channels||2),capturedAt:String(X.capturedAt||""),receivedAt:String(X.receivedAt||""),byteLength:Number(X.byteLength||$.byteLength),payload:$};if(!he.deviceId||T)return;if(performance.now()-q>Ry){te();return}if(k.pendingDecodes>=xj){te();return}k.pendingDecodes+=1;try{const ve=pj(he.mimeType)?Sj(j,he,$):await j.decodeAudioData($.slice(0));if(k.localProcessingAgeMs=Math.max(0,performance.now()-q),T)return;if(k.localProcessingAgeMs>Ry){te();return}if(he.frameSeq>0&&he.frameSeq<=k.lastFrameSeq){te();return}if(k.activeStreamId&&he.streamId!==k.activeStreamId&&he.frameSeq<=k.lastFrameSeq){te();return}he.streamId&&he.streamId!==k.activeStreamId&&(k.activeStreamId=he.streamId,k.lastFrameSeq=0,_());const Se=j.currentTime;Math.max(0,c.current-Se)>vj&&(_(),k.resyncs+=1);const re=j.createBufferSource();re.buffer=ve,re.connect(j.destination),N.add(re),re.onended=()=>{N.delete(re),re.onended=null};const Z=Math.max(j.currentTime+yj,c.current);re.start(Z),c.current=Z+ve.duration,k.browserAgeMs=Dy(he.receivedAt),k.captureAgeMs=Dy(he.capturedAt),k.lastAcceptedAt=performance.now(),k.framesReceived+=1,k.lastFrameSeq=he.frameSeq,O=0,Y=0,g(he),ne();const ze=String(j.state)==="running";ze&&b(""),m(ze?"playing":"suspended")}finally{k.pendingDecodes=Math.max(0,k.pendingDecodes-1)}}catch(V){T||(m("error"),b(V instanceof Error?V.message:String(V)))}})()}),A.addEventListener("error",()=>{T||(m("error"),b("Remote audio WebSocket error."))}),A.addEventListener("close",()=>{T||m("closed")}),()=>{T=!0,window.clearInterval(B),j.removeEventListener("statechange",xe),document.removeEventListener("visibilitychange",se),window.removeEventListener("pageshow",K),window.removeEventListener("pointerdown",K),window.removeEventListener("keydown",K),_(!1),A.close(),j.close().catch(()=>{}),l.current===j&&(l.current=null)}},[n,a,r]),{state:d,lastFrame:p,stats:v,error:x}}const jj=3;function Ly(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,jj);return c<=d?0:c>=l-d?1:c/l}function kj(n,a,r){return{normalizedX:Ly(n,r.left,r.width),normalizedY:Ly(a,r.top,r.height)}}const ei=Object.freeze({smallDirectDeviceLimit:4,interactiveDirectFps:30,controlWallReuseMaxFps:30,scalableAtlasInputFps:8,atlasOutputFps:20,maxDirectFramesPerSecond:96,directDecodeAcceleration:"prefer-software",directLatencyMode:"interactive",configuredLatencyMode:"smooth"});function Aj(n,a){const r=Math.max(0,Math.floor(Number(a)||0));return n===!0&&r>0&&r<=ei.smallDirectDeviceLimit}function Ac({mode4Enabled:n,directMode4WallEnabled:a,isMac:r}){return!n||a||r?"direct":"atlas"}function Nj({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(ei.interactiveDirectFps,c);const d=Math.max(1,Math.floor(Number(l)||1));return Math.max(1,Math.min(c,Math.floor(ei.maxDirectFramesPerSecond/d)))}function Mj(n,a){return n?{acceleration:ei.directDecodeAcceleration,latencyMode:ei.directLatencyMode}:{acceleration:a,latencyMode:ei.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}}},Tj=[{id:"connection",label:"Connection",icon:Rl},{id:"security",label:"Security",icon:Bt},{id:"control",label:"Control",icon:an},{id:"wall",label:"Wall",icon:Fc},{id:"files-audio",label:"Files & Audio",icon:jo},{id:"agent",label:"Agent",icon:Es},{id:"advanced",label:"Advanced",icon:Bd}];function bl(n,a){return n?.settings?.[a]||Dh.settings[a]}function ht({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 Tt({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 Li({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 Ej({hubUrl:n="",runtimeRole:a="hub",runtimeDeviceId:r="",sessionAccessToken:l="",initialTab:c="connection",pin:d,wall:m,control:p,agent:g,advancedExtras:v,captureGallery:w}){const[x,b]=u.useState(c),[C,j]=u.useState(null),[A,N]=u.useState("loading"),[k,T]=u.useState(""),[R,U]=u.useState("idle"),[O,Y]=u.useState("");u.useEffect(()=>{let ve=!0;return N("loading"),Ge("/api/settings",void 0,n).then(Se=>{ve&&(j({revision:Number(Se.revision||0),updatedAt:Se.updatedAt,settings:Se.settings}),N("saved"))}).catch(Se=>{ve&&(T(Se instanceof Error?Se.message:String(Se)),j(Dh),N("failed"))}),()=>{ve=!1}},[n]);const _=async(ve,Se,_e)=>{const re=C||Dh,Z=re,ze={...re,settings:{...re.settings,[ve]:{...bl(re,ve),[Se]:_e}}};j(ze),N("saving"),T("");try{const De=await Ge("/api/settings",{method:"PATCH",body:JSON.stringify({revision:re.revision,[ve]:{[Se]:_e}})},n);j({revision:De.revision,updatedAt:De.updatedAt,settings:De.settings}),N("saved")}catch(De){j(Z),N("failed"),T(De instanceof Error?De.message:String(De))}},D=(ve,Se)=>_e=>{_(ve,Se,_e)},ne=async()=>{if(a!=="hub"||!r||!l){U("failed"),Y("Sign in to this Hub before changing its runtime role.");return}U("changing"),Y("");try{const ve=await Ge("/api/runtime/status",void 0,n);await Ge("/api/runtime/role",{method:"POST",headers:{Authorization:`Bearer ${l}`},body:JSON.stringify({role:"client"})},n),U("accepted"),await nb({baseUrl:n,targetRole:"client",previousRuntimePid:Number(ve.runtimePid||0),allowedStates:["running","waiting-auth"]}),lC(5179)}catch(ve){U("failed"),Y(ve instanceof Error?ve.message:String(ve))}},G=bl(C,"security"),te=bl(C,"connection"),B=bl(C,"control"),xe=bl(C,"wall"),se=bl(C,"filesAudio"),K=bl(C,"agent"),I=u.useMemo(()=>G.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:G.requireEncryptedConnections&&G.requireNewDeviceApproval&&G.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."},[G]),Q=`settings-panel-${x}`,q=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(Rl,{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(Yx,{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(No,{size:20})]}),s.jsx(ht,{icon:No,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:s.jsx(Tt,{checked:!!te.usePinToAddDevices,onChange:D("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),s.jsx(ht,{icon:Bt,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:s.jsx(Tt,{checked:!!te.approveNewDevices,onChange:D("connection","approveNewDevices"),label:"Approve new devices"})}),s.jsx(ht,{icon:pn,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:s.jsx(Tt,{checked:!!te.showConnectionNotifications,onChange:D("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(Bd,{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."}):O?s.jsx("p",{className:"settings-help runtime-role-error",role:"alert",children:O}):null,s.jsx("button",{className:"settings-reset",onClick:()=>{ne()},disabled:R==="changing"||a!=="hub",type:"button",children:R==="changing"?"Switching role…":"Switch this computer to Client"})]})]}),V=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:`security-status-card ${I.tone}`,children:[s.jsxs("div",{children:[s.jsx("span",{children:"Security status"}),s.jsx("strong",{children:I.label}),s.jsx("small",{children:I.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(Ts,{size:20})]}),s.jsx(ht,{icon:Bt,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:s.jsx(Li,{value:String(G.accessMode),onChange:D("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(ht,{icon:Rl,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:s.jsx(Tt,{checked:!!G.requireEncryptedConnections,onChange:D("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),s.jsx(ht,{icon:Rl,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:s.jsx(Tt,{checked:!!G.allowInternetConnections,onChange:D("security","allowInternetConnections"),label:"Allow internet connections"})}),s.jsx(ht,{icon:an,title:"Allow LAN connections",description:"Permit connections from the local network.",children:s.jsx(Tt,{checked:!!G.allowLanConnections,onChange:D("security","allowLanConnections"),label:"Allow LAN connections"})}),s.jsx(ht,{icon:Bt,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:s.jsx(Tt,{checked:!!G.requireNewDeviceApproval,onChange:D("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(pn,{size:20})]}),s.jsx(ht,{icon:an,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:s.jsx(Tt,{checked:!!G.visibleControlIndicator,onChange:D("security","visibleControlIndicator"),label:"Show Control indicator"})}),s.jsx(ht,{icon:Ts,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:s.jsx(Tt,{checked:!!G.lockOnControlEnd,onChange:D("security","lockOnControlEnd"),label:"Lock after Control ends"})}),s.jsx(ht,{icon:pn,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:s.jsx(Tt,{checked:!!G.disconnectIdleControlSessions,onChange:D("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),s.jsx(ht,{icon:pn,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!G.disconnectIdleControlSessions,children:s.jsx(Li,{value:Number(G.idleControlMinutes),onChange:ve=>D("security","idleControlMinutes")(Number(ve)),disabled:!G.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),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:"Remote use"}),s.jsx("h3",{children:"What can a connected user do?"})]}),s.jsx(an,{size:20})]}),s.jsx(ht,{icon:an,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:s.jsx(Tt,{checked:!!B.allowKeyboardMouse,onChange:D("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),s.jsx(ht,{icon:GS,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:s.jsx(Tt,{checked:!!B.allowSystemShortcuts,onChange:D("control","allowSystemShortcuts"),label:"System shortcuts"})}),s.jsx(ht,{icon:No,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:s.jsx(Tt,{checked:!!B.allowClipboardText,onChange:D("control","allowClipboardText"),label:"Clipboard text sharing"})}),s.jsx(ht,{icon:pn,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!B.allowKeyboardMouse,children:s.jsx(Tt,{checked:!!B.allowRemoteRestart,onChange:D("control","allowRemoteRestart"),disabled:!B.allowKeyboardMouse,label:"Remote restart"})}),s.jsx(ht,{icon:an,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:s.jsx(Tt,{checked:!!B.allowSwitchingMonitors,onChange:D("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(Fn,{size:20})]}),s.jsx(ht,{icon:an,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:s.jsx(Tt,{checked:!!B.openControlOnDoubleClick,onChange:D("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),s.jsx(ht,{icon:pn,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:s.jsx(Tt,{checked:!!B.startRemoteAudioWithControl,onChange:D("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),s.jsx(ht,{icon:an,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:s.jsx(Tt,{checked:!!B.fitRemoteScreen,onChange:D("control","fitRemoteScreen"),label:"Fit remote screen"})}),s.jsx(ht,{icon:pn,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:s.jsx(Tt,{checked:!!B.keepControlReadyBetweenPages,onChange:D("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),be=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(Fc,{size:20})]}),s.jsx(ht,{icon:Es,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:s.jsx(Li,{value:String(xe.performanceMode),onChange:D("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(pn,{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(([ve,Se,_e])=>s.jsx(ht,{icon:an,title:Se,description:_e,children:s.jsx(Tt,{checked:!!xe[ve],onChange:D("wall",ve),label:Se})},ve))]})]}),X=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(jo,{size:20})]}),s.jsx(ht,{icon:jo,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:s.jsx(Tt,{checked:!!se.allowFileTransfer,onChange:D("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),s.jsx(ht,{icon:Fc,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!se.allowFileTransfer,children:s.jsx(Tt,{checked:!!se.allowFolderSync,onChange:D("filesAudio","allowFolderSync"),disabled:!se.allowFileTransfer,label:"Allow folder sync"})}),s.jsx(ht,{icon:Bt,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:s.jsx(Tt,{checked:!!se.askBeforeReceivingFiles,onChange:D("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),s.jsx(ht,{icon:jo,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:s.jsx(Tt,{checked:!!se.allowOverwrite,onChange:D("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(pn,{size:20})]}),s.jsx(ht,{icon:pn,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:s.jsx(Tt,{checked:!!se.allowRemoteAudio,onChange:D("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),s.jsx(ht,{icon:pn,title:"Start audio muted",description:"New audio sessions begin silent.",children:s.jsx(Tt,{checked:!!se.startAudioMuted,onChange:D("filesAudio","startAudioMuted"),label:"Start audio muted"})}),s.jsx(ht,{icon:pn,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:s.jsx(Tt,{checked:!!se.automaticallyRecoverAudio,onChange:D("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(an,{size:20})]}),s.jsx(ht,{icon:pn,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:s.jsx(Tt,{checked:!!se.rollingBufferEnabled,onChange:D("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),s.jsx(ht,{icon:pn,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:s.jsx(Li,{value:String(se.recordingQuality),onChange:D("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),s.jsx(ht,{icon:pn,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:s.jsx(Li,{value:Number(se.timelapseIntervalSeconds),onChange:ve=>D("filesAudio","timelapseIntervalSeconds")(Number(ve)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),s.jsx(ht,{icon:an,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:s.jsx(Tt,{checked:!!se.includeRemoteCursor,onChange:D("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),s.jsx(ht,{icon:jo,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:s.jsx(Li,{value:String(se.captureSaveLocation),onChange:D("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(se.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),s.jsx(ht,{icon:jo,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:s.jsx(Li,{value:String(se.captureAutoDelete),onChange:D("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),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:"Agent safety"}),s.jsx("h3",{children:"AI workstation operations"})]}),s.jsx(Es,{size:20})]}),s.jsx(ht,{icon:Es,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:s.jsx(Tt,{checked:!!K.enabled,onChange:D("agent","enabled"),label:"Enable AI Agent"})}),s.jsx(ht,{icon:Bt,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:s.jsx(Li,{value:String(K.defaultPermissionMode),onChange:D("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),s.jsx(ht,{icon:Bt,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!K.enabled,children:s.jsx(Tt,{checked:!!K.askBeforeDestructive,onChange:D("agent","askBeforeDestructive"),disabled:!K.enabled,label:"Ask before destructive operations"})}),s.jsx(ht,{icon:pn,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:s.jsx(Tt,{checked:!!K.keepAuditHistory,onChange:D("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),s.jsx(ht,{icon:pn,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:s.jsx(Li,{value:Number(K.timeoutMinutes),onChange:ve=>D("agent","timeoutMinutes")(Number(ve)),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(([ve,Se])=>s.jsx(ht,{icon:Bt,title:Se,description:ve.includes("allowCommand")||ve.includes("Installation")||ve.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:s.jsx(Tt,{checked:!!K[ve],onChange:D("agent",ve),label:Se})},ve))]}),s.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),he=x==="connection"?q:x==="security"?V:x==="control"?ce:x==="wall"?be:x==="files-audio"?X:x==="agent"?s.jsxs(s.Fragment,{children:[$,g]}):s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[v,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(Bd,{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:Tj.map(({id:ve,label:Se,icon:_e})=>s.jsxs("button",{className:x===ve?"active":"",id:`settings-tab-${ve}`,role:"tab","aria-selected":x===ve,"aria-controls":`settings-panel-${ve}`,tabIndex:x===ve?0:-1,onClick:()=>b(ve),type:"button",children:[s.jsx(_e,{size:16}),Se]},ve))}),k&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:k}),s.jsx("section",{className:"settings-page-panel",id:Q,role:"tabpanel","aria-labelledby":`settings-tab-${x}`,tabIndex:0,children:he})]})}function Rj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function Dj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function Lj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}const xb={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 _y(n){return{...xb,...n||{}}}function _j({hubUrl:n}){const[a,r]=u.useState(xb),[l,c]=u.useState(null),[d,m]=u.useState(""),[p,g]=u.useState(""),[v,w]=u.useState(""),[x,b]=u.useState("");u.useEffect(()=>{let D=!0;return Ge("/api/settings/agent",void 0,n).then(ne=>{D&&(c(ne.settings),r(_y(ne.settings)))}).catch(ne=>{D&&b(ne instanceof Error?ne.message:String(ne))}),()=>{D=!1}},[n]);const C=(D,ne)=>r(G=>({...G,[D]:ne})),j=D=>{c(D),r(_y(D))},A=async()=>{g("save"),b(""),w("");try{const D={...a};d.trim()&&(D.apiKey=d.trim());const ne=await Ge("/api/settings/agent",{method:"PUT",body:JSON.stringify(D)},n);j(ne.settings),m(""),w("Agent settings saved.")}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},N=async()=>{g("reset"),b("");try{const D=await Ge("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);j(D.settings),w("Codex defaults restored.")}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},k=async()=>{g("test"),b(""),w("");try{const D=await Ge("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),ne=await Ge("/api/settings/agent",void 0,n);j(ne.settings),w(`Codex connection verified with ${D.connection?.modelName||"the configured model"}${D.connection?.latencyMs?` in ${D.connection.latencyMs} ms.`:"."}`)}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},T=async()=>{g("clear-key"),b("");try{const D=await Ge("/api/settings/agent/api-key",{method:"DELETE"},n);j(D.settings),m(""),w("The optional OpenCode Go key was removed.")}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},R=l?.codexInstallation==="installed"&&l.codexAuth==="signed-in",U=l?.securityStatus,O=U?.state||"unavailable",Y=O==="verified"?"Verified":O==="configured"?"Configured":"Unavailable",_=[["Codex home",U?.isolatedCodexHome],["Environment variables",U?.restrictedEnvironment],["LiveDesk MCP only",U?.livedeskMcpOnly],["Selected-device scope",U?.selectedDeviceScopeEnforced],["Fail-closed execution",U?.failClosed]];return s.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[s.jsx("section",{className:"settings-section-card agent-enable-card",children:s.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,onChange:D=>C("enabled",D.target.checked)}),s.jsx("span",{children:"Enable Agent AI"})]})}),x&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:x}),v&&s.jsx("div",{className:"agent-settings-alert success",role:"status",children:v}),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(No,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Agent provider"}),s.jsxs("select",{value:a.provider,onChange:D=>C("provider",D.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(VS,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),s.jsxs("p",{className:"settings-help",children:[s.jsx(WS,{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(YS,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Model"}),s.jsx("input",{value:a.codexModelId,onChange:D=>C("codexModelId",D.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:D=>C("codexReasoningEffort",D.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:D=>C("codexTaskTimeoutMs",Number(D.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:D=>C("codexMaxToolCalls",Number(D.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:D=>C("codexResumeSessions",D.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:D=>C("codexShowDetailedEvents",D.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(No,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{value:a.baseUrl,onChange:D=>C("baseUrl",D.target.value)})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"API key"}),s.jsx("input",{type:"password",value:d,onChange:D=>m(D.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:()=>{T()},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(Fn,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:D=>C("deterministicParserFirst",D.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:D=>C("generateSummary",D.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:D=>C("fallbackSummary",D.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:D=>C("includeRawDeviceDetails",D.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(D=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Wx,{size:15}),s.jsx("span",{children:D}),s.jsx("strong",{children:"Blocked"})]},D)),_.map(([D])=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Bt,{size:15}),s.jsx("span",{children:D}),s.jsx("strong",{className:O==="unavailable"?"agent-safety-failed":O==="configured"?"agent-safety-configured":"agent-safety-verified",children:Y})]},D)),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:()=>{N()},disabled:p!=="",type:"button",children:[s.jsx(Lc,{size:15})," Reset defaults"]}),s.jsxs("button",{className:"text-button primary",onClick:()=>{A()},disabled:p!=="",type:"button",children:[s.jsx(Yx,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function ti(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 Do(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 zj(n,a="data-id"){const r=Do(n,a);return r?r.getAttribute(a):null}function qc(n,a="data-id"){const r=Do(n,a);return r?tf(r,a):null}function tf(n,a="data-id"){const r=n.getAttribute(a);return r?Ij(r):null}function Pn(n){return typeof n=="string"?":"+n:n}function Ij(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function Oj(){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 La=Oj();function ap(n){Object.assign(La,n)}function zy(n,a,r){function l(c){const d=Do(c);if(!d)return;const m=tf(d);if(typeof a=="function")return a(m,c);let p,g=c.target;for(;g!=d;){if(p=g.dataset?g.dataset.action:null,p&&a[p]){a[p](m,c);return}g=g.parentNode}a[r]&&a[r](m,c)}La.addEvent(n,r,l)}function Lo(n,a){zy(n,a,"click"),a.dblclick&&zy(n,a.dblclick,"dblclick")}function Hj(n,a){for(let r=n.length-1;r>=0;r--)if(n[r]===a){n.splice(r,1);break}}function Bj(n,a,r){for(let l=0;l<Oi.length;l++){if(l===r)continue;const c=Oi[l],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var bb=new Date,Vd=!1,pd=[],Oi=[],Iy=n=>{const a=n.target;if(Vd||!a.isConnected){Vd=!1;return}for(let r=Oi.length-1;r>=0;r--){const{node:l,date:c,props:d}=Oi[r];if(!(c>bb)&&!l.contains(a)&&l!==a&&(Bj(l,a,r)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},Fj=n=>{bb=new Date,Vd=!0;for(let a=Oi.length-1;a>=0;a--){const{node:r}=Oi[a];if(!r.contains(n.target)&&r!==n.target){Vd=!1;break}}};function ni(n,a){pd.length||(pd=[La.addGlobalEvent("click",Iy,n),La.addGlobalEvent("contextmenu",Iy,n),La.addGlobalEvent("mousedown",Fj,n)]),typeof a!="object"&&(a={callback:a});const r={node:n,date:new Date,props:a};return Oi.push(r),{destroy(){Hj(Oi,r),Oi.length||(pd.forEach(l=>l()),pd=[])}}}var gd=n=>n.indexOf("bottom")!==-1,vd=n=>n.indexOf("left")!==-1,yd=n=>n.indexOf("right")!==-1,eh=n=>n.indexOf("top")!==-1,Oy=n=>n.indexOf("fit")!==-1,Nc=n=>n.indexOf("overlap")!==-1,Pj=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),$j=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function Uj(n,a){let r=0;const l=La.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 Ln,ia,Mc,Qn;function wb(n,a,r="bottom",l=0,c=0){if(!n)return null;Ln=l,ia=c,Mc="auto";let d=0,m=0,p=r;const g=Sb(n),v=Nc(r)?La.getTopNode(n):g;if(!g)return null;const w=g.getBoundingClientRect(),x=n.getBoundingClientRect(),b=v.getBoundingClientRect(),C=window.getComputedStyle(v),j={left:0,top:0,bottom:0,right:0};for(const U in j){const O=`border-${U}-width`;j[U]=parseFloat(C.getPropertyValue(O))}if(a){const U=Uj(a,g);d=Math.max(U+1,20)}if(a){if(Qn=a.getBoundingClientRect(),Oy(r)&&(Mc=Qn.width+"px"),r!=="point")if(Pj(r))Oy(r)?Ln=0:(Ln=b.width/2,m=1),ia=(b.height-x.height)/2;else{const U=Nc(r)?0:1;Ln=yd(r)?Qn.right+U:Qn.left-U,ia=gd(r)?Qn.bottom+1:Qn.top;const O=$j(r);O&&(yd(r)||vd(r)?O==="center"?ia-=(x.height-Qn.height)/2:O==="end"&&(ia-=x.height-Qn.height):(gd(r)||eh(r))&&(O==="center"?Ln-=(x.width-Qn.width)/2:O==="end"&&(Ln-=x.width-Qn.width),Nc(r)||(Ln+=1)))}}else Qn={left:l,right:l,top:c,bottom:c};const A=(vd(r)||yd(r))&&(gd(r)||eh(r));vd(r)&&(m=2);const N=Ln-x.width-b.left;a&&vd(r)&&!A&&N<0&&(Ln=Qn.right,m=0,p=p.replace("left","right"));const k=Ln+x.width*(1-m/2)-b.right;if(k>0)if(!yd(r))Ln=b.right-j.right-x.width;else{const U=Qn.left-b.x-x.width;a&&!A&&U>=0?(Ln=Qn.left-x.width,p=p.replace("right","left")):Ln-=k+j.right}m&&(Ln=Math.round(Ln-x.width*m/2));const T=N<0||k>0||!A;eh(r)&&(ia=Qn.top-x.height,a&&ia<b.y&&T&&(ia=Qn.bottom,p=p.replace("top","bottom")));const R=ia+x.height-b.bottom;return R>0&&(a&&gd(r)&&T?(ia-=x.height+Qn.height+1,p=p.replace("bottom","top")):ia-=R+j.bottom),Ln-=w.left+j.left,ia-=w.top+j.top,Ln=(Nc(r)?Ln:Math.max(Ln,0))+v.scrollLeft,ia=(Nc(r)?ia:Math.max(ia,0))+v.scrollTop,Mc=Mc||"auto",{at:p,x:Ln,y:ia,z:d,width:Mc}}function Sb(n){const a=La.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 qj(n){const a=[];let r=n;const l=La.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 Hy=new Date().valueOf();function sp(){return Hy+=1,Hy}function la(n){return n<10?"0"+n:n.toString()}function Gj(n){const a=la(n);return a.length==2?"0"+a:a}function Cb(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function th(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 By=["",""];function Vj(n,a,r){switch(n){case"%d":return la(a.getDate());case"%m":return la(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return la(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 la((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return la(a.getHours());case"%i":return la(a.getMinutes());case"%a":return((a.getHours()>11?r.pm:r.am)||By)[0];case"%A":return((a.getHours()>11?r.pm:r.am)||By)[1];case"%s":return la(a.getSeconds());case"%S":return Gj(a.getMilliseconds());case"%W":return la(th(a));case"%w":{const l=r.weekStart??1;if(l===1)return la(th(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)),la(th(m))}case"%c":{let l=a.getFullYear()+"";return l+="-"+la(a.getMonth()+1),l+="-"+la(a.getDate()),l+="T",l+=la(a.getHours()),l+=":"+la(a.getMinutes()),l+=":"+la(a.getSeconds()),l}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var Wj=/%[a-zA-Z]/g;function Mo(n,a){return typeof n=="function"?n:function(r){return r?(r.getMonth||(r=new Date(r)),n.replace(Wj,l=>Vj(l,r,a))):""}}function Fy(n){return n&&typeof n=="object"&&!Array.isArray(n)}function Lh(n,a){for(const r in a){const l=a[r];Fy(n[r])&&Fy(l)?n[r]=Lh({...n[r]},a[r]):n[r]=a[r]}return n}function Vc(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=Lh({...a},n):l=Lh({...n},a),Vc(l)}}}var Yj=Jx();const Kj="en-US",Qj={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},Xj={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},Zj={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},jb={core:Xj,calendar:Qj,formats:Zj,lang:Kj},ip=u.createContext(""),kb=u.createContext({}),Ds=u.createContext(null),Ab=u.createContext(null),Un=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Ab,helpers:kb,i18n:Ds,theme:ip},Symbol.toStringTag,{value:"Module"}));function Nb(n){const a=u.useContext(Ab),[r]=u.useState(()=>n||a||sp());return r}function Oc({type:n="",css:a="",icon:r="",disabled:l=!1,title:c="",tooltip:d,text:m="",children:p,onClick:g}){const v=u.useMemo(()=>{let x=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+x},[n,a]),w=x=>{g&&g(x)};return s.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${v} ${r&&!p?"wx-icon":""}`,disabled:l,onClick:w,"data-tooltip-text":d,children:[r&&s.jsx("i",{className:"wx-2ZWgb4 "+r}),p||m||" "]})}function Jj({id:n,label:a="",inputValue:r="",value:l=!1,onChange:c,disabled:d=!1,css:m=""}){const p=Nb(n),[g,v]=ti(l),w=({target:x})=>{const b=x.checked;v(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:g,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||ek(c.current)||La.getTopNode(c.current))},[c.current]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?Yj.createPortal(s.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:r}),d):null]})}function ek(n){const a=La.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function tk({left:n=0,top:a=0,at:r="bottom",parent:l=null,width:c="auto",css:d="",onCancel:m,children:p,trackScroll:g=!1}){const[v,w]=u.useState(0),[x,b]=u.useState(0),[C,j]=u.useState("auto"),[A,N]=u.useState(!1),k=u.useRef(null),T=u.useRef(null),R=u.useRef(m);u.useEffect(()=>{R.current=m},[m]);function U(Y){return l&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(_,D)=>(D=D*l.offsetWidth/100+"px",c.replace(_,D))):c&&c!=="auto"?c:Y}const O=u.useCallback(()=>{if(!k.current)return;const Y=wb(k.current,l,r,n,a);Y&&(w(Y.x),b(Y.y),j(U(Y.width)))},[k,l,r,n,a,c]);return u.useLayoutEffect(()=>{const Y=D=>{R.current&&D.target!==T.current&&k.current&&!k.current.contains(D.target)&&R.current(D)};let _;return requestAnimationFrame(()=>{O(),N(!0),g&&k.current&&(T.current=Sb(k.current),T.current&&T.current.addEventListener("scroll",Y,!0)),l&&(_=new ResizeObserver(O),_.observe(l))}),()=>{g&&T.current&&T.current.removeEventListener("scroll",Y,!0),_?.disconnect()}},[]),u.useLayoutEffect(()=>{O()},[l,r,n,a]),u.useEffect(()=>{const Y=_=>{R.current&&R.current(_)};if(k.current)return ni(k.current,{callback:Y,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:x+"px",left:v+"px",width:C},children:p})}function nk({position:n="bottom",align:a="start",autoFit:r=!0,onCancel:l=null,width:c="100%",css:d="",children:m}){const p=u.useRef(null),[g,v]=u.useState(n),[w,x]=u.useState(a),b=u.useRef(l);return u.useEffect(()=>{b.current=l},[l]),u.useEffect(()=>{if(r){const C=p.current;if(C){const j=C.getBoundingClientRect(),A=document.body.getBoundingClientRect();j.right>=A.right&&x("end"),j.bottom>=A.bottom&&v("top")}}},[]),u.useEffect(()=>{if(p.current){const C=j=>{b.current&&b.current(j)};return ni(p.current,C).destroy}},[]),s.jsx("div",{ref:p,className:["wx-dropdown",`wx-${g}-${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[g,v]=u.useState(void 0),w=u.useRef(null),x=u.useMemo(()=>`${n}-${a}`,[n,a]);return u.useLayoutEffect(()=>{w.current&&v(w.current.parentNode)},[]),s.jsxs(s.Fragment,{children:[g&&(l?s.jsx(nk,{onCancel:c,position:n,align:a,autoFit:r,width:d,...p,children:m}):s.jsx(rp,{children:s.jsx(tk,{parent:g,at:x,onCancel:c,width:d,...p,children:m})})),s.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function nf(){return Vc(jb)}function ak(){let n=null,a=!1,r=!1,l,c,d,m;const p=(x,b,C,j,A)=>{l=x,c=b,d=C,m=j,r=A},g=x=>{n=x,a=n!==null,d(n)},v=(x,b)=>{if(!r&&x!==null&&l){const C=l.querySelectorAll(".wx-list > .wx-item")[x];C&&(C.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(x,b)=>{const C=x===null?null:Math.max(0,Math.min(n+x,c.length-1));C!==n&&(g(C),l?v(C,b):requestAnimationFrame(()=>v(C,b)))};return{move:x=>{const b=qc(x),C=c.findIndex(j=>j.id===b);C!==n&&g(C)},keydown:(x,b)=>{switch(x.code){case"Enter":a?m():g(0);break;case"Space":a||g(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":w(a?1:b||0,x);break;case"ArrowUp":w(a?-1:b||0,x);break}},init:p,navigate:w}}const Py=10,sk=u.memo(function({data:n,checkboxes:a,itemTemplate:r,value:l}){return s.jsxs(s.Fragment,{children:[a&&s.jsx(Jj,{id:n.id,css:"wx-list-checkbox",value:l&&l.includes(n.id)}),r?np(r,{option:n}):n.label]})});function $y({visibleItems:n,visibleRange:a,navIndex:r,checkboxes:l,itemTemplate:c,value:d,measureRefCallback:m}){return n.map((p,g)=>{const v=a.start+g;return s.jsx("div",{ref:g===0?m:void 0,className:`wx-233fr7 wx-item ${v===r?"wx-focus":""}`,"data-id":p.id,children:s.jsx(sk,{data:p,checkboxes:l,itemTemplate:c,value:d})},p.id)})}function af({items:n=[],children:a,onSelect:r,onReady:l,virtualized:c=!1,checkboxes:d,multiselect:m,value:p,...g}){const v=u.useRef(),w=u.useRef(!1),x=u.useRef(ak()),[b,C]=u.useState(null),j=u.useRef(b),[A,N]=u.useState(0),[k,T]=u.useState(24),R=u.useRef(!1),U=(u.useContext(Ds)||nf()).getGroup("core"),O=u.useRef(n);u.useEffect(()=>{O.current=n},[n]);const Y=u.useRef(p);u.useEffect(()=>{Y.current=p},[p]);const _=u.useRef(0);u.useEffect(()=>{_.current=k},[k]);const D=u.useCallback(X=>{X&&X.stopPropagation();const $=O.current,ue=Y.current,he=j.current;let ve;const Se=$[he]?.id;m?ue&&ue.includes(Se)?ve=ue.filter(_e=>_e!==Se):ve=[...ue||[],Se]:ve=Se,r&&r({id:ve})},[m,r]),ne=u.useRef(D);u.useEffect(()=>{ne.current=D},[D]);const G=u.useCallback(X=>{if(v.current){let $=X*_.current-v.current.clientHeight+_.current;N($),v.current.scrollTop=$}},[_.current]),te=u.useCallback(X=>{v.current=X,c&&(X&&!w.current&&j.current!==null&&requestAnimationFrame(()=>{v.current&&(G(j.current),w.current=!0)}),X||(w.current=!1))},[G]),B=u.useCallback(X=>{if(!X||R.current)return;const $=X.getBoundingClientRect().height;$&&(T($),_.current=$,R.current=!0)},[]);u.useEffect(()=>{x.current.init(v.current,n,X=>{C(X),j.current=X},X=>ne.current(X),c)},[n,v.current,c]),u.useEffect(()=>{const X=(ue,he)=>{x.current.navigate(ue,he),G(j.current)},$=(ue,he)=>{const ve=j.current,Se=O.current;if(ve!==0&&ve!==Se.length-1&&(ue.key==="ArrowDown"||ue.key==="ArrowUp")&&ue.preventDefault(),x.current.keydown(ue,he),v.current){const _e=v.current.scrollTop<=j.current*_.current,re=v.current.scrollTop+v.current.clientHeight>=j.current*_.current+_.current;_e?re||G(j.current):(v.current.scrollTop=j.current*_.current,N(v.current.scrollTop))}};l&&l({navigate:c?X:x.current.navigate,keydown:c?$:x.current.keydown,move:x.current.move})},[]);const xe=u.useRef(0),se=u.useRef(n);se.current!==n&&(se.current=n,xe.current+=1);const K=u.useCallback(()=>{x.current.navigate(null)},[x]),I=u.useCallback(X=>{c&&N(X.target.scrollTop)},[c]),Q=u.useMemo(()=>Math.ceil((v.current?.clientHeight||0)/k),[k,A]),q=u.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const X=Math.floor(A/k),$=X+Q;return{start:Math.max(0,X-Py),end:Math.min(n.length,$+Py)}},[c,n,A,k,Q]),V=u.useMemo(()=>{if(!c)return n;const{start:X,end:$}=q;return n.slice(X,$).map(ue=>({...ue}))},[c,n,q]),ce=q.start*k,be=n.length*k;return u.useEffect(()=>{c&&N(0)},[n,c]),u.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:s.jsx(lp,{onCancel:K,...g,children:s.jsx("div",{className:"wx-233fr7 wx-list",ref:te,onClick:D,onMouseMove:x.current.move,onScroll:I,children:n.length?c?s.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${be}px`},children:s.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${ce}px)`},children:s.jsx($y,{visibleRange:q,visibleItems:V,navIndex:b,measureRefCallback:B,checkboxes:d,itemTemplate:a,value:p})})}):s.jsx($y,{visibleRange:q,visibleItems:V,navIndex:b,measureRefCallback:B,checkboxes:d,itemTemplate:a,value:p}):s.jsx("div",{className:"wx-233fr7 wx-no-data",children:U("No data")})})},xe.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:g=!1,title:v="",tooltip:w,css:x="",icon:b="",clear:C=!1,onChange:j}){const A=Nb(a),[N,k]=ti(n),T=u.useRef(null),R=u.useMemo(()=>b&&x.indexOf("wx-icon-left")===-1?"wx-icon-right "+x:x,[b,x]),U=u.useMemo(()=>b&&x.indexOf("wx-icon-left")!==-1,[b,x]);u.useEffect(()=>{const ne=setTimeout(()=>{l&&T.current&&T.current.focus(),c&&T.current&&T.current.select()},1);return()=>clearTimeout(ne)},[l,c]);const O=u.useCallback(ne=>{const G=ne.target.value;k(G),j&&j({value:G,input:!0})},[j]),Y=u.useCallback(ne=>j&&j({value:ne.target.value}),[j]);function _(ne){ne.stopPropagation(),k(""),j&&j({value:""})}let D=d;return d!=="password"&&d!=="number"&&(D="text"),u.useEffect(()=>{const ne=Y,G=T.current;return G.addEventListener("change",ne),()=>{G&&G.removeEventListener("change",ne)}},[Y]),s.jsxs("div",{className:`wx-hQ64J4 wx-text ${R} ${g?"wx-error":""} ${p?"wx-disabled":""} ${C?"wx-clear":""}`,"data-tooltip-text":w,children:[s.jsx("input",{className:"wx-hQ64J4 wx-input",ref:T,id:A,readOnly:r,disabled:p,placeholder:m,type:D,title:v,value:N,onInput:O}),C&&!p&&N?s.jsxs(s.Fragment,{children:[s.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:_}),U&&s.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?s.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function ik({date:n,type:a,part:r,onShift:l}){const{calendar:c,formats:d}=u.useContext(Ds).getRaw(),m=n.getFullYear(),p=u.useMemo(()=>{switch(a){case"month":return Mo(d.monthYearFormat,c)(n);case"year":return Mo(d.yearFormat,c)(n);case"duodecade":{const{start:v,end:w}=Cb(m),x=Mo(d.yearFormat,c);return`${x(new Date(v,0,1))} - ${x(new Date(w,11,31))}`}default:return""}},[n,a,m,c,d]);function g(){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:g,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 rk({value:n,current:a,part:r="",markers:l=null,css:c="",onCancel:d,onChange:m}){const p=(u.useContext(Ds)||nf()).getRaw().calendar,g=(p.weekStart||7)%7,v=p.dayShort.slice(g).concat(p.dayShort.slice(0,g)),w=(O,Y,_)=>new Date(O.getFullYear(),O.getMonth()+(Y||0),O.getDate()+(_||0));let x=r!=="normal";function b(O){const Y=O.getDay();return Y===0||Y===6}function C(){const O=w(a,0,1-a.getDate());return O.setDate(O.getDate()-(O.getDay()-(g-7))%7),O}function j(){const O=w(a,1,-a.getDate());return O.setDate(O.getDate()+(6-O.getDay()+g)%7),O}const A=u.useRef(0);function N(O,Y){Y.timeStamp!==A.current&&(A.current=Y.timeStamp,Y.stopPropagation(),m&&m(new Date(O)),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]),T=u.useMemo(()=>{const O=C(),Y=j(),_=a.getMonth();let D=[];for(let ne=O;ne<=Y;ne.setDate(ne.getDate()+1)){const G={day:ne.getDate(),in:ne.getMonth()===_,date:ne.valueOf()};let te="";if(te+=G.in?"":" wx-inactive",te+=k.indexOf(G.date)>-1?" wx-selected":"",x){const B=G.date==k[0],xe=G.date==k[1];B&&!xe?te+=" wx-left":xe&&!B&&(te+=" wx-right"),G.date>k[0]&&G.date<k[1]&&(te+=" wx-inrange")}if(te+=b(ne)?" wx-weekend":"",l){const B=l(ne);B&&(te+=" "+B)}D.push({...G,css:te})}return D},[a,k,x,l]),R=u.useRef(null);let U=u.useRef({});return U.current.click=N,u.useEffect(()=>{Lo(R.current,U.current)},[]),s.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[s.jsx("div",{className:"wx-398RBS wx-weekdays",children:v.map(O=>s.jsx("div",{className:"wx-398RBS wx-weekday",children:O},O))}),s.jsx("div",{className:"wx-398RBS wx-days",ref:R,children:T.map(O=>s.jsx("div",{className:`wx-398RBS wx-day ${O.css} ${O.in?"":"wx-out"}`,"data-id":O.date,children:O.day},O.date))})]})}function lk({value:n,current:a,part:r,onCancel:l,onChange:c,onShift:d}){const m=u.useRef(new Date),[p,g]=ti(n||m.current),[v,w]=ti(a||m.current),x=u.useContext(Ds).getRaw().calendar,b=x.monthShort||[],C=u.useMemo(()=>v.getMonth(),[v]),j=u.useCallback((k,T)=>{if(k!=null){T.stopPropagation();const R=new Date(v);R.setMonth(k),w(R),d&&d({current:R})}r==="normal"&&g(new Date(v)),l&&l()},[v,r,d,l]),A=u.useCallback(()=>{const k=new Date(Mb(p,r)||v);k.setMonth(v.getMonth()),k.setFullYear(v.getFullYear()),c&&c(k)},[p,v,r,c]),N=u.useCallback(k=>{const T=k.target.closest("[data-id]");if(T){const R=parseInt(T.getAttribute("data-id"),10);j(R,k)}},[j]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-34U8T8 wx-months",onClick:N,children:b.map((k,T)=>s.jsx("div",{className:"wx-34U8T8 wx-month"+(C===T?" wx-current":""),"data-id":T,children:k},T))}),s.jsx("div",{className:"wx-34U8T8 wx-buttons",children:s.jsx(cp,{onClick:A,children:x.done})})]})}const nh="wx-1XEF33",ok=({value:n,current:a,onCancel:r,onChange:l,onShift:c,part:d})=>{const m=u.useContext(Ds).getRaw().calendar,[p,g]=ti(a),[v,w]=ti(n),x=u.useMemo(()=>p.getFullYear(),[p]),b=u.useMemo(()=>{const{start:k,end:T}=Cb(x),R=[];for(let U=k;U<=T;++U)R.push(U);return R},[x]),C={click:j};function j(k,T){if(k){T.stopPropagation();const R=new Date(p);R.setFullYear(k),g(R),c&&c({current:R})}d==="normal"&&w(new Date(p)),r&&r()}function A(){const k=new Date(Mb(v,d)||p);k.setFullYear(p.getFullYear()),l&&l(k)}const N=u.useRef(null);return u.useEffect(()=>{N.current&&Lo(N.current,C)},[]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:nh+" wx-years",ref:N,children:b.map((k,T)=>s.jsx("div",{className:nh+` wx-year ${x==k?"wx-current":""} ${T===0?"wx-prev-decade":""} ${T===11?"wx-next-decade":""}`,"data-id":k,children:k},T))}),s.jsx("div",{className:nh+" wx-buttons",children:s.jsx(cp,{onClick:A,children:m.done})})]})},Uy={month:{component:rk,next:uk,prev:ck},year:{component:lk,next:fk,prev:dk},duodecade:{component:ok,next:hk,prev:mk}};function ck(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function uk(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function dk(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function fk(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function mk(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function hk(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Mb(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 pk=["clear","today"];function gk(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function vk({value:n,current:a,onCurrentChange:r,part:l="normal",markers:c=null,buttons:d,css:m="",onShift:p,onChange:g}){const v=u.useContext(Ds).getGroup("calendar"),[w,x]=u.useState("month"),b=Array.isArray(d)?d:d?pk:[],C=(T,R)=>{T.preventDefault(),g&&g({value:R})},j=()=>{w==="duodecade"?x("year"):w==="year"&&x("month")},A=T=>{const{diff:R,current:U}=T;if(R===0){w==="month"?x("year"):w==="year"&&x("duodecade");return}if(R){const O=Uy[w];r(R>0?O.next(a):O.prev(a))}else U&&r(U);p&&p()},N=T=>{x("month"),g&&g({select:!0,value:T})},k=u.useMemo(()=>Uy[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(ik,{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:j,onChange:N,onShift:A}),w==="month"&&b.length>0&&s.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(T=>s.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:s.jsx(cp,{onClick:R=>C(R,gk(T)),children:v(T)})},T))})]})]})})}function up(n){let{words:a=null,optional:r=!1,children:l}=n,c=u.useContext(Ds);const d=u.useMemo(()=>{let m=c;return(!m||!m.extend)&&(m=Vc(jb)),a!==null&&(m=m.extend(a,r)),m},[a,r,c]);return s.jsx(Ds.Provider,{value:d,children:l})}function qy(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 yk=["clear","today"];function Tb({value:n,current:a,markers:r=null,buttons:l=yk,css:c="",onChange:d}){const[m,p]=ti(n),[g,v]=ti(a);u.useEffect(()=>{qy(g,m,v,!1)},[m,g]);const w=u.useCallback(b=>{const C=b.value;C?(p(new Date(C)),qy(g,new Date(C),v,!0)):p(null),d&&d({value:C?new Date(C):null})},[d,g]),x=u.useCallback(b=>{v(b)},[v]);return g?s.jsx(up,{children:s.jsx(vk,{value:m,current:g,markers:r,buttons:l,css:c,onChange:w,onCurrentChange:x})}):null}function xk(n){return n||(n={}),n.width||(n.width="unset"),n}const bk=["clear","today"];function wk({value:n,id:a,disabled:r=!1,error:l=!1,placeholder:c="",format:d="",buttons:m=bk,css:p="",title:g="",tooltip:v,editable:w=!1,clear:x=!1,onChange:b,dropdown:C={}}){const{calendar:j,formats:A}=(u.useContext(Ds)||nf()).getRaw(),N=d||A?.dateFormat;let k=typeof N=="function"?N:Mo(N,j);const[T,R]=u.useState(n),[U,O]=u.useState(!1);u.useEffect(()=>{R(n)},[n]);function Y(){O(!1)}function _(G){const te=G===T||G&&T&&G.valueOf()===T.valueOf()||!G&&!T;R(G),te||b&&b({value:G}),setTimeout(Y,1)}const D=u.useMemo(()=>T?k(T):"",[T,k]);function ne({value:G,input:te}){if(!w&&!x||te)return;let B=typeof w=="function"?w(G):G?new Date(G):null;B=isNaN(B)?T||null:B||null,_(B)}return u.useEffect(()=>{const G=Y;return window.addEventListener("scroll",G),()=>window.removeEventListener("scroll",G)},[]),s.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>O(!0),children:[s.jsx(op,{css:`wx-date-input ${p}`,title:g,tooltip:v,value:D,id:a,readonly:!w,disabled:r,error:l,placeholder:c,onInput:Y,onChange:ne,icon:"wxi-calendar",clear:x}),U&&!r&&s.jsx(lp,{onCancel:Y,...xk(C),children:s.jsx(Tb,{buttons:m,value:T,onChange:G=>_(G.value)})})]})}function Sk({value:n="",options:a=[],textOptions:r=null,placeholder:l="",disabled:c=!1,error:d=!1,title:m="",tooltip:p,textField:g="label",clear:v=!1,css:w="",children:x,onChange:b,dropdown:C={}}){const j=u.useRef(null),A=u.useRef(null);let[N,k]=ti(n);function T(_){j.current=_.navigate,A.current=_.keydown}const R=u.useMemo(()=>N||N===0?(r||a).find(_=>_.id===N):null,[N,r,a]),U=u.useCallback(({id:_})=>{(_||_===0)&&(k(_),j.current(null),b&&b({value:_}))},[k,b]),O=u.useCallback(_=>{_.stopPropagation(),k(""),b&&b({value:""})},[k,b]),Y=u.useCallback(()=>a.findIndex(_=>_.id===N),[a,N]);return s.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${x?"":"wx-2YgblL wx-nowrap"}`,title:m,onClick:()=>j.current(Y()),onKeyDown:_=>A.current(_,Y()),tabIndex:0,"data-tooltip-text":p,children:[s.jsx("div",{className:"wx-2YgblL wx-label",children:R?x?x(R):R[g]:l?s.jsx("span",{className:"wx-2YgblL wx-placeholder",children:l}):" "}),v&&!c&&N?s.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:O}):s.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&s.jsx(af,{items:a,onReady:T,onSelect:U,...C,children:({option:_})=>x?x(_):_[g]})]})}const Ck=({options:n=[],value:a="",css:r="",children:l,onChange:c})=>{const[d,m]=u.useState(a),p=g=>{m(g),c&&c({value:g})};return u.useEffect(()=>{m(a)},[a]),s.jsx("div",{className:`wx-0hMO7P wx-segmented ${r}`,children:n.map(g=>s.jsx("button",{className:`wx-0hMO7P wx-segment ${g.css} ${g.id===d?"wx-selected":""}`,title:g.title,onClick:()=>p(g.id),"data-tooltip-text":g.tooltip,children:l?np(l,{option:g}):s.jsxs(s.Fragment,{children:[g.icon&&s.jsx("i",{className:`wx-0hMO7P wx-icon ${g.icon} ${g.label?"":"wx-only"}`}),g.label&&s.jsx("span",{className:"wx-0hMO7P wx-label",children:g.label})]})},g.id))})};function jk({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 kk({data:n=[]}){return s.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>s.jsx(jk,{notice:a},a.id))})}function _h({title:n="",buttons:a=["cancel","ok"],header:r,children:l,footer:c,css:d="",onConfirm:m,onCancel:p}){const g=(u.useContext(Ds)||nf()).getGroup("core"),v=u.useRef(null);u.useEffect(()=>{v.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const C=b.target.tagName;if(C==="TEXTAREA"||C==="BUTTON")return;m&&m({event:b});break}case"Escape":p&&p({event:b});break}}function x(b,C){const j={event:b,button:C};C==="cancel"?p&&p(j):m&&m(j)}return s.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:v,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(Oc,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:C=>x(C,b),children:g(b)})},b))})]})})}function Ak({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((g,v)=>{p.resolve=w=>{l(null),g(w)},p.reject=w=>{l(null),v(w)}})},showNotice:m=>{m={...m},m.id=m.id||sp(),m.remove=()=>d(p=>p.filter(g=>g.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(_h,{title:r.title,buttons:r.buttons,onConfirm:r.resolve,onCancel:r.reject,children:r.message}),s.jsx(kk,{data:c})]})}const Nk=u.forwardRef(Ak);function Mk(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(kb.Provider,{value:l,children:s.jsx(Nk,{ref:r,children:a})})}const Tk=({value:n=!1,type:a="",icon:r="",disabled:l=!1,iconActive:c="",onClick:d,title:m="",tooltip:p,css:g="",text:v="",textActive:w="",children:x,active:b,onChange:C})=>{const[j,A]=ti(n),N=u.useMemo(()=>(j?"pressed":"")+(a?" "+a:""),[j,a]),k=u.useCallback(T=>{let R=!j;d&&d(T),T.defaultPrevented||(A(R),C&&C({value:R}))},[j,d,C]);return j&&b?s.jsx(Oc,{title:m,tooltip:p,text:j&&w||v,css:g,type:N,icon:j&&c||r,onClick:k,disabled:l,children:np(b,{value:j})}):x?s.jsx(Oc,{title:m,tooltip:p,text:j&&w||v,css:g,type:N,icon:j&&c||r,onClick:k,disabled:l,children:x}):s.jsx(Oc,{title:m,tooltip:p,text:j&&w||v,css:g,type:N,icon:j&&c||r,onClick:k,disabled:l})};function Ek(){return s.jsx(s.Fragment,{})}function Gy(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(Ek,{}),s.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}ap(La);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 Eb=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 Rk=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]:Vy(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=xd(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=xd(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),g=c?d:this._pool.get(d.parent);g.data||(g.data=[]);const v=xd(p,l.id);Dk(p,v);const w=c?g.data.length:xd(g,d.id)+(a==="after"?1:0);if(Vy(g,w,l),p.id===g.id&&v===w)return null;l.parent=g.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&&Rb(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 Rb(n,a){n.forEach(r=>{a.push(r),r.open===!0&&Rb(r.data,a)})}function Dk(n,a){const r=[...n.data];r.splice(a,1),n.data=r}function Vy(n,a,r){const l=[...n.data];l.splice(a,0,r),n.data=l}function xd(n,a){return n?.data.findIndex(r=>r.id===a)}var Db=2,Lk=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 g=r[p],v=l[p],w=a[p];if(g&&(v===w&&typeof w!="object"||w instanceof Date&&v instanceof Date&&v.getTime()===w.getTime()))continue;const x=c+(c?".":"")+p;g?(g.__parse(w,x,d,m)&&(l[p]=w),m&Db?d[x]=g.__trigger:g.__trigger()):(w&&w.__reactive?r[p]=this._wrapNested(w,w,x,d):r[p]=this._wrapWritable(w),l[p]=w),d[x]=d[x]||null}}_wrapNested(a,r,l,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,r,l,c,0),d.__parse=(m,p,g,v)=>(this._wrapProperties(m,d,r,p,g,v),!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 Wy(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var _k=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(g=>p[g]=!0),this._sources.set(m,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(m=>Lb(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,Db);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(g=>{r.indexOf(g)==-1&&r.push(g)})}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 Lb(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>Lb(d,a,r+1));return Math.max(...c)}var zk=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 wo=1024;function Gc(n){return n<wo?`${n} B`:n<wo**2?`${(n/wo).toFixed(1)} KB`:n<wo**3?`${(n/wo**2).toFixed(1)} MB`:`${(n/wo**3).toFixed(1)} GB`}function Yy(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(Ky(a)),d=l.sort(Ky(a));return[...c,...d]}function Ik(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 Ok(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 Ky({key:n,order:a}){const r=a==="asc"?Ik:Ok;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 Hk(n){return n.length>1?n[n.length-2].id:null}let Bk=class extends Rk{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:g,lazy:v}=c,w={id:d,date:m,type:p??"file"};v&&(w.lazy=v),g&&(w.size=g),r.push(w);const x=this.serialize(d);x.length&&r.push(...x)}),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,g=r+(r==="/"?"":"/")+p;for(;this.byId(g+m);){const v=".new";g+=v,p+=v}return{...a,id:g+m,name:p+m,parent:r,ext:d.toLocaleLowerCase()}}},Fk=class extends Lk{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:g}=this.getState(),v=[];v[d]={_crumbs:p.getParents(g[d].path)},this.setState({panels:v},m)}}),r.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:m=>{const{data:p,panels:g,search:v}=this.getState();let w;v?w=p.findFiles(v,g[d].path):w=p.byId(g[d].path)?.data||[];const{path:x,_sorts:b}=g[d];w=Yy(w,b[x]);const C=[];C[d]={_files:w},this.setState({panels:C},m)}}),r.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:m=>{const{data:p,panels:g}=this.getState(),v=[];g[d].selected.forEach(j=>{const A=p.byId(j);A&&v.push(A)});const{path:w,_sorts:x}=g[d],b=Yy(v,x[w]),C=[];C[d]={_selected:b},this.setState({panels:C},m)}});this._router=new _k(super.setState.bind(this),r,{data:d=>new Bk(d)});const l=this.in=new zk;l.on("select-file",({id:d,toggle:m,range:p,panel:g,type:v})=>{const{panels:w,activePanel:x}=this.getState();typeof g>"u"&&(g=x),d||(m=p=!1);let b=[...w[g].selected];if(m){const j=b.indexOf(d);j===-1?b.push(d):b.splice(j,1)}else if(p&&w[g]._lastSelected){const j=w[g]._files;let A=j.findIndex(T=>T.id==w[g]._lastSelected),N=j.findIndex(T=>T.id==d);N<A&&([A,N]=[N,A]);const k=j.slice(A,N+1).map(T=>T.id);b=[...new Set([...b,...k])]}else b=d?[d]:[];const C=[];C[g]={selected:b,_lastSelected:d,_selectNavigation:v==="navigation"},this.setState({panels:C})}),l.on("set-path",({id:d,panel:m,selected:p})=>{const{data:g,activePanel:v}=this.getState(),w=g.byId(d);if(w){const x=[];typeof m>"u"&&(m=v),x[m]={path:d},this.setState({panels:x}),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:g}=this.getState(),v=g.byId(d);v&&(v.lazy||(v.data=[]),v.lazy=!1,g.parse(m,d,p==="search"),this.setState({data:g}))}),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:g,panels:v}=this.getState(),w=g.byId(m);if(w.name!==p){w.name=p;const x=g.normalizeFile(w,w.parent);d.newId=x.id,x.data=null,g.add(x);let b={[m]:x.id};w.data?.forEach(j=>b={...g.moveFiles([j.id],x.id),...b});const C=v.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));g.remove(m),this._updatePanels(C,b),this.setState({data:g,panels:C})}}),l.on("create-file",d=>{const{file:m,parent:p}=d,{data:g}=this.getState(),v=g.normalizeFile(m,p);v.type=m.type||"file",d.newId=v.id,g.add(v),this.setState({data:g}),l.exec("select-file",{id:v.id})}),l.on("delete-files",({ids:d})=>{const{data:m,panels:p}=this.getState(),g=p.map(v=>({selected:v.selected,_crumbs:v._crumbs,_lastSelected:v._lastSelected,_sorts:v._sorts}));d.forEach(v=>m.remove(v)),this._updatePanels(g,{}),this.setState({data:m,panels:g})}),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:g,panels:v,activePanel:w}=this.getState(),x=g.copyFiles(m,p);d.newIds=m.map(b=>x[b]),this.setState({data:g}),v[w].path==p&&(l.exec("select-file",{}),m.forEach(b=>{l.exec("select-file",{id:x[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:g,panels:v,activePanel:w}=this.getState(),x=g.moveFiles(m,p);if(x){d.newIds=m.map(C=>x[C]);const b=v.map(C=>({selected:C.selected,_crumbs:C._crumbs,_lastSelected:C._lastSelected,_sorts:C._sorts}));this._updatePanels(b,x,!0),this.setState({data:g,panels:b}),v[w].path==p&&(l.exec("select-file",{}),m.forEach(C=>{l.exec("select-file",{id:x[C],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 g={mode:d,search:"",panels:p};c=null,this.setState(g)}),l.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),l.on("sort-files",({key:d,order:m,panel:p,path:g})=>{const{activePanel:v,panels:w}=this.getState();p=p??v,g=g??w[p].path;const x=[];x[p]={_sorts:{...w[p]._sorts,[g]:{key:d,order:m}}},this.setState({panels:x})}),this.initOnce()}initOnce(){const a=[];for(let l=0;l<2;l++)a[l]=Wy({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[l]});const r={panels:Wy(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(v=>{c.byId(v)?m.push(v):!l&&r[v]&&m.push(r[v])}),d.selected=m,c.byId(d._lastSelected)||(d._lastSelected=l?null:r[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(v=>{c.byId(v)?p[v]=d._sorts[v]:r[v]&&!l&&(p[r[v]]=d._sorts[v])}),d._sorts=p;const g=d._crumbs[d._crumbs.length-1];g?.id!=="/"&&(r[g.id]?d.path=r[g.id]:c.byId(g.id)||(d.path="/"))})}_isPlacedIntoSelf(a,r){return a.some(l=>l===r||this.getState().data.getParents(r).some(c=>c.id===l))}};function Pk(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 $k(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 Uk(n,a="data-id"){const r=$k(n,a);return r?r.getAttribute(a):null}new Date().valueOf();function qk(n,a){const{api:r}=a;function l(d,m){const p=a.getPanel(),g=p.selected,v=m.ctrlKey||m.metaKey,w=m.shiftKey;let x;const b=g?.[0]?r.getFile(g[0]):null;g?.length?g.length>1?x=a.menuOptions("multiselect"):x=a.menuOptions(b.type,b):x=a.menuOptions("body");const C=`${v?"ctrl+":""}${w?"shift+":""}${d}`,j=x?x.find(N=>N.hotkey?.toLowerCase()===C):!1,A=a.performAction;if(j)switch(C){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:j.handler?.({context:b})}switch(d){case"enter":{if(v||w)break;const{_crumbs:N,_selectNavigation:k}=p;if(k){const T=Hk(N);if(T){const R=fp(T,N);r.exec("set-path",{id:T,selected:[R]})}}else if(g.length===1){const T=r.getFile(g[0]);T&&r.exec(T.type==="folder"?"set-path":"open-file",{id:T.id})}break}case"arrowup":case"arrowleft":{const{_files:N,_selected:k,path:T,_selectNavigation:R}=p;let U;if(k.length){const O=k.at(0).id,Y=N.findIndex(_=>_.id===O);if(Y!==-1){const _=Y-1;N[_]?U=N[_].id:T!=="/"&&!(v||w)&&r.exec("select-file",{type:"navigation"})}}else{if(R)break;if(T!=="/"){r.exec("select-file",{type:"navigation"});break}U=N.at(0)?.id}U&&r.exec("select-file",{id:U,toggle:v,range:w});break}case"arrowdown":case"arrowright":{const{_files:N,_selected:k,path:T,_selectNavigation:R}=p;let U;if(k.length){const O=k.at(-1).id,Y=N.findIndex(_=>_.id===O);if(Y!==-1){const _=Y+1;N[_]&&(U=N[_].id)}}else{if(T!=="/"&&!R){r.exec("select-file",{type:"navigation"});break}U=N.at(0)?.id}U&&r.exec("select-file",{id:U,toggle:v,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:+Uk(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function Gk(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 Vk(n,a="data-id"){const r=n.getAttribute(a);return r?Wk(r):null}function Wk(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function Yk(){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 Kk=Yk();new Date().valueOf();function _b(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 Qk(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 lt(n,a){const r=n.getState(),l=n.getReactiveState();return Qk(l[a],r[a],a)}function Xk(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 hs(n,a){const r=n.getState(),l=n.getReactiveState();return Xk(l[a],r[a])}function zb(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 Ib(n){let a=n,r=[];return{subscribe:p=>{r.push(p),p(a)},unsubscribe:p=>{r=r.filter(g=>g!==p)},set:p=>{a=p,r.forEach(g=>g(a))},update:p=>{a=p(a),r.forEach(g=>g(a))}}}function Qy(n,a,r){function l(c){const d=Gk(c);if(!d)return;const m=Vk(d);if(typeof a=="function")return a(m,c);let p,g=c.target;for(;g!=d;){if(p=g.dataset?g.dataset.action:null,p&&a[p]){a[p](m,c);return}g=g.parentNode}a[r]&&a[r](m,c)}return Kk.addEvent(n,r,l)}function Zk(n,a){const r=[Qy(n,a,"click")];return a.dblclick&&r.push(Qy(n,a.dblclick,"dblclick")),()=>{r.forEach(l=>l())}}function Ob(n,a){return n.map((r,l)=>{const c=a(r,l);return r.data&&r.data.length&&(c.data=Ob(r.data,a)),c}).filter(Boolean)}function Hb(n,a){const r=[];return n.forEach(l=>{if(l.data){const c=Hb(l.data,a);c.length&&r.push({...l,data:c})}else a(l)&&r.push(l)}),r}function Jk(n){return Ob(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 Bb={};function e1(n){return Bb[n]||n}function t1(n,a){Bb[n]=a}function n1({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?e1(r.comp):null,[r]);return s.jsxs("div",{ref:l,className:`wx-cDCz9rZQ wx-option ${r.css||""} ${r.disabled?"wx-disabled":""}`,"data-id":Pn(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:g,onCancel:v}){const[w,x]=u.useState(-1e4),[b,C]=u.useState(-1e4),[j,A]=u.useState(20),[N,k]=u.useState(),T=u.useRef(null),[R,U]=u.useState(!1),[O,Y]=u.useState(null),_=u.useCallback(()=>{const se=wb(T.current,c,l,a,r);se&&(x(se.x),C(se.y),k(se.width));let K=se?.z??20;const I=c?qj(c):[];let Q=0;for(const q of I){const V=parseInt(getComputedStyle(q).zIndex,10);V>Q&&(Q=V)}Q>=K&&(K=Q+1),A(K)},[c,l,a,r]);u.useEffect(()=>{d&&d(_)},[]);const D=u.useCallback(()=>{U(!1)},[]),ne=u.useCallback((se,K)=>{U(se),Y(K)},[]),G=u.useMemo(()=>Jk(n),[n]);u.useEffect(()=>{_()},[c,_]);const te=u.useRef(g),B=u.useRef(v),xe=u.useRef(c);return u.useEffect(()=>{te.current=g},[g]),u.useEffect(()=>{B.current=v},[v]),u.useEffect(()=>{xe.current=c},[c]),u.useEffect(()=>{if(!T.current)return;function se(K){B.current?B.current(K):te.current&&te.current({action:null,option:null})}return ni(T.current,{callback:se,modal:!0,parent:()=>xe.current}).destroy},[]),s.jsx("div",{ref:T,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:N,zIndex:j},onMouseLeave:D,children:G.map(se=>s.jsxs(u.Fragment,{children:[se.comp==="separator"?s.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):s.jsx(n1,{option:se,onShow:ne,onClick:K=>{if(!se.data&&!K.defaultPrevented){const I={context:m,action:se,option:se,event:K};se.handler&&se.handler(I),g&&g(I),K.stopPropagation()}}}),se.data&&R===se.id?s.jsx(mp,{css:p,options:se.data,at:"right-overlap",parent:O,context:m,onClick:g,onCancel:v}):null]},se.id))})}const Fb=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:g,onClick:v}=n,[w,x]=u.useState(null),[b,C]=u.useState(null),[j,A]=u.useState(0),[N,k]=u.useState(0),T=u.useRef(null),R=u.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),U=u.useMemo(()=>w!==null&&m?Hb(r,D=>m(D,w)):r,[w,m,r]);function O(D){C(null),v&&v(D)}function Y(D){if(T.current===D){T.current=null;return}C(null),v&&v({action:null,option:null})}const _=u.useCallback((D,ne)=>{if(!D){C(null);return}if(D.defaultPrevented)return;const G=D.target;if(G&&G.dataset&&G.dataset.menuIgnore)return;if(b&&b===G){C(null),D.preventDefault();return}A(D.clientX+1),k(D.clientY+1);let te=typeof ne<"u"?ne:qc(G,R);c&&(te=c(te,D),!te)||(x(te),C(G),T.current=D.nativeEvent||D,D.preventDefault())},[b,R,c]);return u.useImperativeHandle(a,()=>({show:_}),[_]),s.jsxs(s.Fragment,{children:[g?s.jsx("span",{onClick:_,"data-menu-ignore":"true",children:typeof g=="function"?g():g}):null,b?s.jsx(rp,{children:s.jsx(mp,{css:p,at:l,top:N,left:j,parent:b,context:w,onClick:O,onCancel:Y,options:U},b)}):null]})}),a1=u.forwardRef(function(n,a){const{options:r,at:l="bottom",css:c="",children:d,onClick:m}=n,[p,g]=u.useState(null),v=u.useRef(null);function w(j){g(null),m&&m(j)}function x(j){if(v.current===j){v.current=null;return}g(null),m&&m({action:null,option:null})}const b=u.useCallback(j=>{g(j.target),v.current=j.nativeEvent||j,j.preventDefault()},[]);u.useImperativeHandle(a,()=>({show:b}),[b]);function C(j){let A=j.target;for(;!A.dataset.menuIgnore;)g(A),A=A.parentNode}return s.jsxs(s.Fragment,{children:[s.jsx("span",{onClick:C,"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:x})}):null]})}),s1=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:g,onClick:v}=n,w=u.useRef(null),x=u.useCallback((b,C)=>{w.current.show(b,C)},[]);return u.useImperativeHandle(a,()=>({show:x}),[x]),s.jsxs(s.Fragment,{children:[g?s.jsx("span",{onContextMenu:x,"data-menu-ignore":"true",children:g}):null,s.jsx(Fb,{css:p,at:l,options:r,resolver:c,dataKey:d,filter:m,ref:w,onClick:v})]})}),i1={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 r1=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 Pb(n){const[a,r]=u.useState([]),[l,c]=u.useState(Promise.resolve(null)),[d,m]=u.useState(null),[p,g]=u.useState(!1),v=u.useRef();return v.current||(v.current=new r1(r,c,m,g,n)),v.current.files=a,v.current.ready=l,v.current.signal=d,v.current.drag=p,v.current}function l1(n,a){{if(n){const r=n.getGroup(a);if(r)return r}return Vc(i1).getGroup(a)}}const o1=()=>Math.random().toString(36).substr(2,9),c1=({data:n,accept:a="",multiple:r=!0,folder:l=!1,uploadURL:c="",apiOnly:d=!1,disabled:m=!1,children:p,onChange:g,onUpload:v})=>{const w=u.useRef(null),x=u.useRef(null),[b,C]=u.useState({}),j=Pb(),A=n||j,N=u.useContext(Un.i18n),k=l1(N,"uploader");u.useEffect(()=>{w.current&&l&&(w.current.webkitdirectory=!0)},[l]),u.useEffect(()=>{if(!d&&x.current&&!m)return A.droparea(x.current)},[d,m,x]);const T=G=>{const te=new FormData;return te.append("upload",G.file),fetch(c,{method:"POST",body:te}).then(B=>B.json()).then(B=>({id:G.id,...B}),()=>({id:G.id,status:"error"})).catch(B=>(console.log(B),{id:G.id,status:"error"}))},R=(G,te)=>{const B=A.updateFile(G,te),xe={...B,status:A.getState()};B&&B.uploaded&&B.uploaded(xe),v&&v(xe),B.temp&&A.deleteFile(B.id)},U=G=>{if(!G)return;const te=typeof c=="function"?c(G):T(G);A.setReady(te.then(B=>{B.status=B.status||"server",R(G.id,B)}).catch(B=>{R(G.id,{status:"error",error:B})}))},O=(G,te)=>{const B={...te||b,id:o1(),status:"client",name:G.name,file:G};B.selected&&B.selected(B),g&&g(B),A.addFile(B,r),U(B),w.current&&(w.current.value="")},Y=(G,te,B)=>{G.isFile?G.file(xe=>{O(xe,B)}):G.isDirectory&&G.createReader().readEntries(xe=>{xe.forEach(se=>{Y(se,te+se.name+"/",B)})})},_=G=>{Array.from(G.target.files).forEach(te=>O(te))},D=(G,te)=>{Array.from(G.dataTransfer.items).forEach(B=>{const xe=B.webkitGetAsEntry();xe&&Y(xe,"",te)})},ne=()=>{w.current&&w.current.click()};return u.useEffect(()=>{if(A.signal){const[G,te,B]=A.signal;C(te),G==="click"?ne():G==="drop"&&D(B,te),A.setSignal(null)}},[A.signal]),d?s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:_,accept:a,multiple:r,disabled:m}),p]}):s.jsxs("div",{className:`wx-at1A8tb8 wx-label ${A.drag?"wx-active":""} ${m?"wx-disabled":""}`,ref:x,children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:_,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:ne,children:k("select files")})]})})]})};new Date().valueOf();function u1(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(!sf(l,c))return!1}return!0}function sf(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(!sf(n[r],a[r]))return!1;return!0}else return u1(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 $b=2,d1=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],g=r[m],v=n[m];if(p&&(g===v&&typeof v!="object"||v instanceof Date&&g instanceof Date&&g.getTime()===v.getTime()))continue;const w=l+(l?".":"")+m;p?(p.__parse(v,w,c,d)&&(r[m]=v),d&$b?c[w]=p.__trigger:p.__trigger()):(v&&v.__reactive?a[m]=this._wrapNested(v,v,w,c):a[m]=this._wrapWritable(v),r[m]=v),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,g)=>(this._wrapProperties(d,c,a,m,p,g),!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}}}},f1=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=>Ub(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,$b);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 Ub(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>Ub(d,a,r+1));return Math.max(...c)}var m1=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 h1(n){return a=>a[n]}function p1(n){return(a,r)=>a[n]=r}function Ir(n,a){return(a.getter||h1(a.id))(n)}function ah(n,a,r){return(a.setter||p1(a.id))(n,r)}function g1(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 zr(n,a){let r=Ir(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 v1(n,a){const r=/\n|"|;|,/;let l="";const c=a.rows||`
|
|
13
|
-
`,d=a.cols||" ",m=n._columns,p=n.flatData;a.header!==!1&&m[0].header&&(l=Xy("header",m,l,d,c));for(let g=0;g<p.length;g++){const v=[];for(let w=0;w<m.length;w++){let x=zr(p[g],m[w]);r.test(x)&&(x='"'+x.replace(/"/g,'""')+'"'),v.push(x)}l+=(l?c:"")+v.join(d)}return a.footer!==!1&&m[0].footer&&(l=Xy("footer",m,l,d,c)),l}function Xy(n,a,r,l,c){const d=/\n|"|;|,/;for(let m=0;m<a[0][n].length;m++){const p=[];for(let g=0;g<a.length;g++){let v=(a[g][n][m].text||"")+"";d.test(v)&&(v='"'+v.replace(/"/g,'""')+'"'),p.push(v)}r+=(r?c:"")+p.join(l)}return r}const y1="portrait",x1=100,b1="a4",w1={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function S1(n,a){const r=[];let l=[],c=0;const d=n.filter(p=>!p.hidden),m=C1(a);return d.forEach((p,g)=>{c+p.width<=m?(c+=p.width,l.push(p)):(l.length&&r.push(l),l=[p],c=p.width),g===d.length-1&&l.length&&r.push(l)}),r}function Zy(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 g={...m[p]};if(l[p][d]!==null){if(!d&&!g.rowspan&&!g.colspan){let v=1,w=n[d+v][a][p],x=g.width;for(;!w.rowspan&&!w.colspan;)v++,w=n[d+v][a][p],x+=w.width;g.colspan=v,g.width=x,g.height=r[p]}if(l[p].push(g),!g.collapsed&&g.colspan>1){let v=g.colspan-1;if(g.colspan+d>n.length){const w=g.colspan-(g.colspan+d-n.length);g.colspan=w,g.width=n.slice(d,d+v+1).reduce((x,b)=>x+b.width,0),w>1&&(v=w-1)}for(let w=0;w<v;w++)l[p].push(null)}if(g.rowspan>1){const v=g.rowspan;for(let w=1;w<v;w++)l[p+w]||(l[p+w]=[]),l[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<l.length;p++){const g=l[p],v=g[d];if(v&&v.collapsed){if(g[d]=null,!p)break}else{const w=v||g.findLast(x=>x?.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 C1(n){const{mode:a,ppi:r,paper:l}=n,{width:c,height:d}=w1[l];return j1(a==="portrait"?c:d,r)}function j1(n,a){return n*a}function k1(n={}){const{mode:a,ppi:r,paper:l}=n;return{mode:a||y1,ppi:r||x1,paper:l||b1}}function qb(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 A1(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 Jy=["resize-column","hide-column","update-cell"],N1=["delete-row","update-row","update-cell"],M1=["move-item"],T1=["resize-column","move-item"];class E1{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=Ir(c,d);return sf(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(T1.includes(r)){(l.inProgress&&!this.progress[r]||typeof l.inProgress!="boolean")&&(M1.includes(r)&&this.setPrev("flatData"),Jy.includes(r)&&this.setPrev("columns")),this.progress[r]=l.inProgress;return}N1.includes(r)&&this.setPrev("data"),Jy.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 Gb(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function R1(n,a){return-Gb(n,a)}function D1(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"?Gb:R1;return function(l,c){return r(Ir(l,a),Ir(c,a))}}function L1(n,a){if(!n||!n.length)return;const r=n.map(l=>{const c=a.find(d=>d.id==l.key);return D1(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,_1=20;function z1(){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 Wd(n,a,r,l,c){const d=document.createElement("div"),m=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let g,v;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 x=d.getBoundingClientRect(),b=Math.ceil(x.width)+(l&&l.length?l[w]:0),C=Math.ceil(x.height);g=Math.max(g||0,b),v=Math.max(v||0,C)}return d.remove(),{width:g,height:v}}function ex(n,a,r,l,c){const d=[];for(let m=0;m<n.length;m++){const p=n[m][a],g=p.length;for(let v=0;v<g;v++){const{text:w,vertical:x,collapsed:b,rowspan:C,css:j}=p[v];if(!w){d[v]=Math.max(d[v]||0,l);continue}let A=0;if(x&&!b){let N=`wx-measure-cell-${a}`;if(N+=j?` ${j}`:"",A=Wd(w,N,c).width,(C>1||!p[v+1])&&r>v+1){const k=C||r-v,T=d.slice(v,v+k).reduce((R,U)=>R+U,0);if(T<A){const R=Math.ceil((A-T)/k);for(let U=v;U<v+k;U++)d[U]=(d[U]||l)+R}continue}}d[v]=Math.max(d[v]||l,A)}}return d}function I1(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],g=zr(p,n);g&&(l.push(g),n.treetoggle?c.push(a[m].$level*bd+(a[m].$count?bd:0)+(n.draggable?bd:0)):n.draggable&&c.push(bd))}return Wd(l,d,r,c).width}function O1(n,a){const r="wx-measure-cell-header",l=n.sort?_1:0;let c=n.header;if(typeof c=="string")return Wd(c,r,a).width+l;let d;Array.isArray(c)||(c=[c]);for(let m=0;m<c.length;m++){const p=c[m],g=typeof p=="string"?p:p.text,v=r+(typeof p=="string"?"":` ${p.css}`);let w=Wd(g,v,a).width;m===c.length-1&&(w+=l),d=Math.max(d||0,w)}return d}const H1={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&&F1(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 Vb(n){return H1[n]}function B1(n,a){const r=[];for(const l in n){const c=a.find(g=>g.id==l),{config:d,type:m}=c.header.find(g=>g.filter).filter,p=n[l];r.push(g=>{const v=Ir(g,c);return d?.handler?d.handler(v,p):Vb(m)(v,p)})}return l=>{for(let c=0;c<r.length;c++)if(!r[c](l))return!1;return!0}}function F1(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let P1=class extends d1{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 f1(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:m,_skin:p}=this.getState(),g=this.copyColumns(d),v=g.reduce((b,C)=>Math.max(C.header.length,b),0),w=g.reduce((b,C)=>Math.max(C.footer.length,b),0);g.forEach(this.setCollapsibleColumns);const x=this.normalizeSizes(g,m,v,w,p);for(let b=0;b<g.length;b++)this.normalizeColumns(g,b,"header",v,x),this.normalizeColumns(g,b,"footer",w,x);this.setState({_columns:g,_sizes:x},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:m,dynamic:p,_filterIds:g}=this.getState(),v=g&&new Set(g),w=m?this.flattenRows(d,[],g):v?d.filter(b=>v.has(b.id)):d,x=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:x},c)}}],{sizes:c=>({...r,...c})});const l=this.in=new m1;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),g=d?this.getColumn(d):this.getNextEditor(p);if(g?.editor){let v=g.editor;if(typeof v=="function"&&(v=v(p,g)),!v)return;m={column:g.id,id:c,value:Ir(p,g)??"",renderedValue:zr(p,g),type:v.type||v},typeof v=="object"&&v.config&&(m.config=v.config,v.config.options&&(m.options=v.config.options)),g.options&&!m.options&&(m.options=g.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)};ah(p,m,c),d.renderedValue=zr(p,m),this.setState({editor:d})}}),l.on("add-row",c=>{const d=this.getState();let{data:m}=d;const{select:p,_filterIds:g}=d,{row:v,before:w,after:x,select:b}=c;if(c.id=v.id=c.id||v.id||wd(),w||x){const j=w||x,A=m.findIndex(N=>N.id===j);m=[...m],m.splice(A+(x?1:0),0,c.row)}else m=[...m,c.row];const C={data:m};g&&(C._filterIds=[...g,c.id]),this.setState(C),!(typeof b=="boolean"&&!b)&&(b||p)&&l.exec("select-row",{id:v.id,show:!0})}),l.on("delete-row",c=>{const{data:d,selectedRows:m,focusCell:p,editor:g}=this.getState(),{id:v}=c,w={data:d.filter(x=>x.id!==v)};this.isSelected(v)&&(w.selectedRows=m.filter(x=>x!==v)),g?.id===v&&(w.editor=null),this.setState(w),p?.row===v&&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:g,column:v,value:w}=c,x=this.getColumn(v);if(p){const b={...this._branches[g]};ah(b,x,w);const C=this.updateTreeRow(b);b.$parent===0&&(m=C)}else{const b=m.findIndex(j=>j.id===g),C={...m[b]};ah(C,x,w),m[b]=C}this.setState({data:m})}),l.on("update-row",c=>{let{data:d}=this.getState();const{id:m,row:p}=c,g=d.findIndex(v=>v.id===m);d=[...d],d[g]={...d[g],...p},this.setState({data:d})}),l.on("select-row",({id:c,toggle:d,range:m,mode:p,show:g,column:v})=>{const w=this.getState(),{focusCell:x}=w;let{selectedRows:b}=w;if(b.length||(m=d=!1),m){const{data:C}=this.getState();let j=C.findIndex(N=>N.id===b[b.length-1]),A=C.findIndex(N=>N.id===c);j>A&&([j,A]=[A,j]),C.slice(j,A+1).forEach(N=>{this.isSelected(N.id)||b.push(N.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;b=b.filter(C=>C!==c)}else if(d){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),x?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),g&&this.in.exec("scroll",{row:c,column:v})}),this.in.on("focus-cell",c=>{const{row:d,column:m,eventSource:p}=c,{_columns:g,split:v}=this.getState();d&&m?(this.setState({focusCell:{row:d,column:m}}),p!=="click"&&((!v.left||g.findIndex(w=>w.id===c.column)>=v.left)&&(!v.right||g.findIndex(w=>w.id===c.column)<g.length-v.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:g}=c;if(g===!1)return;let v=c.width||0;const w=[...this.getState().columns],x=this.getColumn(d);if(m){if(m==="data"||m===!0){const{flatData:b,_skin:C}=this.getState();let j=b.length;p&&(j=Math.min(p,j));const A=b.slice(0,j);v=I1(x,A,C)}if(m==="header"||m===!0){const{_skin:b}=this.getState();v=Math.max(O1(x,b),v)}}x.width=Math.max(17,v),delete x.flexgrow,this.setState({columns:w})}),l.on("hide-column",c=>{const{id:d,mode:m}=c,p=[...this.getState().columns],g=this.getColumn(d),v=p.reduce((w,x)=>w+(x.hidden?0:1),0);!m||v>1?(g.hidden=!g.hidden,this.setState({columns:p})):c.skipUndo=!0}),l.on("sort-rows",c=>{const{key:d,add:m,sort:p}=c,g=this.getState(),{columns:v,data:w,tree:x}=g;if(p){const T=[...w];T.sort(p),this.setState({data:T});return}const{order:b="asc"}=c;let C=g.sortMarks;const j=Object.keys(C),A=j.length;!m||!A||A===1&&C[d]?C={[d]:{order:b}}:(A===1&&(C[j[0]]={...C[j[0]],index:0}),C={...C,[d]:{order:b,index:typeof m=="number"?m:C[d]?.index??A}});const N=Object.keys(C).sort((T,R)=>C[T].index-C[R].index).map(T=>({key:T,order:C[T].order}));this.setState({sortMarks:C});const k=L1(N,v);if(k){const T=[...w];x?this.sortTree(T,k):T.sort(k),this.setState({data:T})}}),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 g=this.getState(),{data:v,tree:w,_columns:x}=g;let b=g.filterValues;const C={};m&&(b={...b,[m]:d},C.filterValues=b);const j=p??B1(b,x);let A=[];w?A=this.filterTree(v,j,A):v.forEach(N=>{j(N)&&A.push(N.id)}),C._filterIds=A,this.setState(C)}),l.on("collapse-column",c=>{const{id:d,row:m,mode:p}=c,g=[...this.getState().columns],v=this.getColumn(d).header,w=Array.isArray(v)?v[m]:v;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:g}))}),l.on("move-item",c=>{const{id:d,inProgress:m}=c;let{target:p,mode:g="after"}=c;const{data:v,flatData:w,tree:x}=this.getState(),b=w.findIndex(A=>A.id===d);let C;if(g==="up"||g==="down"){if(g==="up"){if(b===0)return;C=b-1,g="before"}else if(g==="down"){if(b===w.length-1)return;C=b+1,g="after"}p=w[C]&&w[C].id}else C=w.findIndex(A=>A.id===p);if(b===-1||C===-1||m===!1)return;let j;x||(j=this.moveItem(d,p,v,g)),this.setState({data:x?this.normalizeTreeRows(j):j})}),l.on("copy-row",c=>{const{id:d,target:m,mode:p="after"}=c,g=this.getState(),{flatData:v,_filterIds:w}=g;let{data:x}=g;const b=this.getRow(d);if(!b)return;const C={...b,id:wd()};c.id=C.id;const j=v.findIndex(N=>N.id===m);if(j===-1)return;x.splice(j+(p==="after"?1:0),0,C),x=[...x];const A={data:x};w&&(A._filterIds=[...w,C.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",g=`${c.fileName||"data"}.${p}`;if(p==="csv"){const v=v1(this.getState(),c.csv||{});c.download!==!1?g1(new Blob(["\uFEFF"+v],{type:"text/csv"}),g):c.result=v,d(!0)}else m()})),l.on("hotkey",({key:c,event:d,isInput:m})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:g,select:v}=this.getState();if(d.preventDefault(),m)return;const w=g?g.column:this._getFirstVisibleColumn()?.id,x=g?this.getPrevRow(g.row)?.id:p[p.length-1]?.id;w&&x&&(this.in.exec("focus-cell",{row:x,column:w,eventSource:"key"}),v&&this.in.exec("select-row",{id:x}));break}case"arrowdown":{const{flatData:p,focusCell:g,select:v}=this.getState();if(d.preventDefault(),m)return;const w=g?g.column:this._getFirstVisibleColumn()?.id,x=g?this.getNextRow(g.row)?.id:p[0]?.id;w&&x&&(this.in.exec("focus-cell",{row:x,column:w,eventSource:"key"}),v&&this.in.exec("select-row",{id:x}));break}case"arrowright":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const g=this.getNextColumn(p.column,!0)?.id;g&&this.in.exec("focus-cell",{row:p.row,column:g,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const g=this.getPrevColumn(p.column,!0)?.id;g&&this.in.exec("focus-cell",{row:p.row,column:g,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:g,select:v}=this.getState();if(p){d.preventDefault();const w=p.column;let x=p.id,b=this.getNextEditor(this.getRow(x),this.getColumn(w));if(!b){const C=this.getNextRow(x);C&&(x=C.id,b=this.getNextEditor(C))}b&&(this.in.exec("open-editor",{id:x,column:b.id}),this.in.exec("focus-cell",{row:x,column:b.id,eventSource:"key"}),v&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}else g&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:g,select:v}=this.getState();if(p){d.preventDefault();const w=p.column;let x=p.id,b=this.getPrevEditor(this.getRow(x),this.getColumn(w));if(!b){const C=this.getPrevRow(x);C&&(x=C.id,b=this.getPrevEditor(C))}b&&(this.in.exec("open-editor",{id:x,column:b.id}),this.in.exec("focus-cell",{row:x,column:b.id,eventSource:"key"}),v&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}else g&&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:g}=this.getState();!p&&g&&this.in.exec("open-editor",{id:g.row,column:g.column});break}case"enter":{const{focusCell:p,tree:g}=this.getState();if(!m&&g&&p&&this.getColumn(p.column).treetoggle){const v=this.getRow(p.row);if(!v.data)return;this.in.exec(v.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:g}=this.getState();if(!p&&g){d.preventDefault();const v=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:g.row,column:v,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:g,flatData:v,select:w}=this.getState();if(!p&&g){d.preventDefault();const x=v[0]?.id,b=this._getFirstVisibleColumn()?.id;x&&b&&(this.in.exec("focus-cell",{row:x,column:b,eventSource:"key"}),w&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}break}case"end":{const{editor:p,focusCell:g}=this.getState();if(!p&&g){d.preventDefault();const v=this._getLastVisibleColumn()?.id,w=g.row;this.in.exec("focus-cell",{row:w,column:v,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:g,flatData:v,select:w}=this.getState();if(!p&&g){d.preventDefault();const x=v.at(-1).id,b=this._getLastVisibleColumn()?.id;x&&b&&(this.in.exec("focus-cell",{row:x,column:b,eventSource:"key"}),w&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}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:g,dynamic:v,_rowHeightFromData:w}=this.getState();let x=-1,b=-1,C=0,j=0;if(c.column){x=0;const A=d.findIndex(N=>N.id===c.column);C=d[A].width;for(let N=m.left??0;N<A;N++){const k=d[N];k.hidden||(x+=k.width)}}if(c.row&&!v){const A=g.findIndex(N=>N.id===c.row);A>=0&&(w?(b=g.slice(0,A).reduce((N,k)=>N+(k.rowHeight||p.rowHeight),0),j=g[A].rowHeight):b=p.rowHeight*A)}this.setState({scroll:{top:b,left:x,width:C,height:j||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=k1(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=z1()),a.columns&&a.columns.forEach(r=>{r.options&&(r.optionsMap=new Map(r.options.map(l=>[l.id,l.label])))}),sf(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 E1(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 g=d>0?a[d-1]:null;return g?.data&&g.open?a[d-1]={...g,data:[...g.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 g=c.length-d;c=c.slice(0,d+1),c[d].rowspan=g}const p=m.colspan;if(p){const g=c[d+1];let v=1;g&&g.colspan&&!g.collapsed&&(v=g.colspan);for(let w=v;w<p;w++){const x=l[r+w];x&&(x.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],g=d[`${l}RowHeights`];for(let v=0;v<c;v++){const w=p[v];w.id=m.id,v===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-v):c-v);for(let x=1;x<w.rowspan;x++){p.splice(v+x,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[r+b][l].splice(v+x,0,{})}if(w.rowspan){const x=(w.rowspan===c?g:g.slice(v,w.rowspan+v)).reduce((b,C)=>b+C,0);w.height=x,v+w.rowspan!=c&&w.height--}if(w.colspan){let x=m.width,b=m.flexgrow||0;const C=w.colspan;for(let j=1;j<C;j++){const A=a[r+j];A&&(A.hidden?w.colspan-=1:A.flexgrow?b+=A.flexgrow:x+=A.width||d.columnWidth),b?w.flexgrow=b:w.width=x}}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=wd());return a}normalizeTreeRows(a,r,l){return!r&&!l&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=wd()),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(v=>v.id==c),{config:m,type:p}=d.header.find(v=>v.filter).filter,g=a[c];l.push(v=>{const w=Ir(v,d);return m?.handler?m.handler(w,g):Vb(p)(w,g)})}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 g={};m.forEach(v=>{const w=zr(p,v);String(w).toLowerCase().includes(a)&&(g[v.id]=!0)}),Object.keys(g).length&&(l[p.id]=g)}),l}normalizeSizes(a,r,l,c,d){const m=ex(a,"header",l,r.headerHeight,d),p=ex(a,"footer",c,r.footerHeight,d),g=m.reduce((w,x)=>w+x,0),v=p.reduce((w,x)=>w+x,0);return{...r,headerRowHeights:m,footerRowHeights:p,headerHeight:g,footerHeight:v}}},$1=new Date().valueOf();function wd(){return"temp://"+$1++}function U1(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 q1=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)}}},To=[],G1={subscribe:n=>{V1();const a=new q1;return To.push(a),n(a),()=>{const r=To.findIndex(l=>l===a);r>=0&&To.splice(r,1)}}},tx=!1;function V1(){tx||(tx=!0,document.addEventListener("keydown",n=>{if(To.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=To.length-1;c>=0;c--){const d=To[c],m=d.store.get(l)||d.store.get(r);m&&d.node.contains(n.target)&&m(n,{key:l,evKey:r})}}}))}const W1={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 Y1(n,{keys:a,exec:r}){if(!a)return;function l(m){const p=m.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||U1(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]=g=>{const v=l(g);r({key:m,event:g,isInput:v})}))}const d=G1.subscribe(m=>{m.configure(c,n)});return{destroy:()=>{d()}}}function K1(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,g=a.getHeight(),v=a.getWidth(),w=a.getScrollMargin();if(d>=0){const x=n.scrollTop;d<x?n.scrollTop=d:d+m>x+g&&(n.scrollTop=d-g+m)}if(c>=0){const x=n.scrollLeft;c<x?n.scrollLeft=c:c+p>x+v-w&&(n.scrollLeft=c-v+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 Ka=u.createContext(null);function Q1(n,a){const r=new ResizeObserver(l=>{requestAnimationFrame(()=>a(l[0].contentRect))});return r.observe(n.parentNode),{destroy(){r.disconnect()}}}const nx=5,X1=700;function _d(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=_d(a);return{x:n.clientX-r.x,y:n.clientY-r.y}}function Z1(n,a){const r=a.current;let l=null,c,d,m=!1,p=!1;const g=document.createElement("DIV");g.className="wx-drag-zone",g.setAttribute("tabindex",-1);function v(){clearTimeout(c),c=null}function w(_){const D=Do(_);D&&(l={container:g,sourceNode:_.target,from:tf(D),pos:Ih(_,n)},d=l.pos,x(_))}function x(_){if(!l)return;const D=l.pos=Ih(_,n);if(!m){if(!p&&!_?.target?.getAttribute("draggable-data")&&Math.abs(d.x-D.x)<nx&&Math.abs(d.y-D.y)<nx)return;if(O(_)===!1)return Y()}if(p){const ne=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,G=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;l.targetNode=document.elementFromPoint(_.pageX-ne,_.pageY-G)}else l.targetNode=_.target;r.move&&r.move(_,l),g.style.left=-(l.offset?l.offset.x:0)+"px",g.style.top=l.pos.y+(l.offset?l.offset.y:0)+"px"}function b(_){g.parentNode&&g.parentNode.removeChild(g),g.innerHTML="",m&&r.end&&r.end(_,l),l=d=null,Y()}function C(_){r.getReorder&&!r.getReorder()||_.button===0&&(U(_),window.addEventListener("mousemove",j),window.addEventListener("mouseup",A),w(_))}function j(_){x(_)}function A(_){b(_)}function N(_){if(r.getReorder&&!r.getReorder())return;c=setTimeout(()=>{p=!0,w(_.touches[0])},X1),U(_);function D(){c&&v(),_.target.removeEventListener("touchmove",k),_.target.removeEventListener("touchend",D),b(_)}_.target.addEventListener("touchmove",k),_.target.addEventListener("touchend",D),n.addEventListener("contextmenu",T)}function k(_){m?(_.preventDefault(),x(_.touches[0])):c&&v()}function T(_){if(m||c)return _.preventDefault(),!1}function R(_){_.preventDefault()}function U(_){if(!r.getDraggableInfo)return;const{hasDraggable:D}=r.getDraggableInfo();(!D||_.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function O(_){if(m=!0,r.start){if(r.start(_,l)===!1)return!1;n.appendChild(g),document.body.style.cursor="move"}}function Y(_){m=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",A),_&&(n.removeEventListener("mousedown",C),n.removeEventListener("touchstart",N),n.removeEventListener("dragstart",R))}return n.addEventListener("mousedown",C),n.addEventListener("touchstart",N),n.addEventListener("dragstart",R),{destroy(){Y(!0)}}}const J1=.004;function eA(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function tA(n,a,r,l){const{node:c,left:d,top:m,bottom:p,sense:g,xScroll:v,yScroll:w}=l,x=Ih(n,c);r.scrollState||(r.scrollState=eA());let b=0,C=0;x.x<d+g?b=-1:x.x>a.width-g&&(b=1),x.y<m+Math.round(g/2)?C=-1:x.y>a.height-p-Math.round(g/2)&&(C=1),(r.scrollState.dirX!==b||r.scrollState.dirY!==C)&&(Wb(r),r.scrollState.dirX=b,r.scrollState.dirY=C),(v&&r.scrollState.dirX!==0||w&&r.scrollState.dirY!==0)&&nA(r,l,{x:r.scrollState.dirX,y:r.scrollState.dirY})}function nA(n,a,r){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(aA,15,n,a,r)},250))}function Wb(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function aA(n,a,r){const{x:l,y:c}=r;n.scrollSpeedFactor+=J1,l!==0&&iA(n,a,l),c!==0&&sA(n,a,c)}function sA(n,a,r){const l=a.node.scrollTop;Yb(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollTop",a)}function iA(n,a,r){const l=a.node.scrollLeft;Yb(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollLeft",a)}function Yb(n,a,r){r.node[a]=n}function rf(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 Kb(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 rA(n){const{row:a,column:r,cellStyle:l=null,columnStyle:c=null,children:d,focusable:m}=n,p=u.useContext(Ka),g=lt(p,"focusCell"),v=lt(p,"search"),w=lt(p,"reorder"),x=u.useMemo(()=>v?.rows[a.id]&&v.rows[a.id][r.id],[v,a.id,r.id]),b=u.useMemo(()=>rf(r.width,r.flexgrow,r.fixed,r.left,r.right),[r.width,r.flexgrow,r.fixed,r.left,r.right]);function C(O,Y){let _="wx-cell";return _+=r.fixed?" "+(r.fixed===-1?"wx-shadow":"wx-fixed"):"",_+=O?" "+O(r):"",_+=Y?" "+Y(a,r):"",_+=r.treetoggle?" wx-tree-cell":"",_}const j=u.useMemo(()=>C(c,l),[c,l,r,a]),A=u.useMemo(()=>typeof r.draggable=="function"?r.draggable(a,r)!==!1:r.draggable,[r,a]),N=u.useRef(null);u.useEffect(()=>{N.current&&m&&g?.row===a.id&&g?.column===r.id&&N.current.focus()},[g,m,a.id,r.id]);const k=u.useCallback(()=>{m&&!g&&p.exec("focus-cell",{row:a.id,column:r.id,eventSource:"focus"})},[p,m,g,a.id,r.id]);function T(O){const Y=new RegExp(`(${v.value.trim()})`,"gi");return String(O).split(Y).map(_=>({text:_,highlight:Y.test(_)}))}const R=u.useMemo(()=>{const O=r.fixed&&r.fixed.left===-1||r.fixed.right===-1,Y=r.fixed&&r.fixed.right;return[j,O?"wx-shadow":"",Y?"wx-fixed-right":""].filter(Boolean).join(" ")},[j,r]),U=r.cell;return s.jsxs("div",{className:"wx-TSCaXsGV "+R,ref:N,onFocus:k,style:b,"data-row-id":Pn(a.id),"data-col-id":Pn(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,U?s.jsx(U,{api:p,row:a,column:r,onAction:({action:O,data:Y})=>p.exec(O,Y)}):d?d():x?s.jsx("span",{children:T(zr(a,r)).map(({highlight:O,text:Y},_)=>O?s.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:Y},_):s.jsx("span",{children:Y},_))}):zr(a,r)]})}function ax(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 lA({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 oA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Ka),d=lt(c,"flatData"),m=u.useMemo(()=>n?.config?.options||a?.options||g(),[n,a,d]),p=u.useMemo(()=>n?.config?.template,[n]);function g(){const x=[];return d.forEach(b=>{const C=Ir(b,a);x.includes(C)||x.push(C)}),x.map(b=>({id:b,label:b}))}function v({value:x}){r({value:x,key:a.id})}function w(x){x.key!=="Tab"&&x.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:w,children:s.jsx(Sk,{placeholder:"",clear:!0,...n?.config??{},options:m,value:l,onChange:v,children:x=>p?p(x):x.label})})}function cA({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(wk,{placeholder:"",clear:!0,...n?.config??{},value:l,onChange:c})})}function Qb(n){const{value:a,options:r=[],placeholder:l="",clear:c=!1,text:d=null,template:m=null,cell:p=null,dropdown:g={},autoOpen:v=!1,onChange:w,onAction:x}=n,[b,C]=_b(a||[]),j=u.useMemo(()=>(b||[]).map(G=>r.find(te=>te.id===G)).filter(Boolean),[b,r]),A=u.useRef(null),N=u.useRef(null),[k,T]=u.useState(null),R=()=>{const G=b||[];if(!G.length)return 0;const te=r.find(B=>G.includes(B.id));return te?r.indexOf(te):0};function U(G){N.current=G.navigate,T(()=>G.keydown),v&&G.navigate(R())}u.useEffect(()=>{v&&(A.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function O({id:G}){C(G),w&&w({value:G})}function Y(G){G.stopPropagation(),C([]),w&&w({value:[]})}function _(){N.current?.(R())}function D(){N.current?.(null)}function ne(G){k?.(G,R())}return s.jsxs("div",{ref:A,className:"wx-multiselect wx-aadNNOwy",onClick:_,onKeyDown:ne,tabIndex:0,children:[s.jsx("div",{className:"wx-label wx-aadNNOwy",children:m?m(j):p?s.jsx(p,{data:j,onAction:x}):d?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):j.length?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:j.map(G=>G.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:Y}):s.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),s.jsx(af,{items:r,onReady:U,onSelect:O,multiselect:!0,checkboxes:!0,value:b||[],onCancel:D,...g,children:({option:G})=>s.jsx("div",{className:"wx-option wx-aadNNOwy",children:m?m(G):p?s.jsx(p,{data:G,onAction:x}):G.label})})]})}function uA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Un.i18n)?.getGroup("grid")||Vc(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(x=>a.optionsMap.get(x)).join(", "):w+" "+c("selected"):""},[l,a,c]);function g({value:w}){r({value:w,key:a.id})}function v(w){w.key!=="Tab"&&w.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:v,children:s.jsx(Qb,{placeholder:"",...d,options:m,value:l||[],text:p,onChange:g})})}const dA={text:lA,richselect:oA,datepicker:cA,multiselect:uA};function fA({filter:n,column:a}){const r=u.useContext(Ka),l=lt(r,"filterValues");function c(m){r.exec("filter-rows",m)}const d=u.useMemo(()=>dA[n.type],[n.type]);return s.jsx(d,{filter:n,column:a,action:c,filterValue:l[a.id]})}function mA(n){const{cell:a,column:r,row:l,lastRow:c,sortRow:d,columnStyle:m,bodyHeight:p,hasSplit:g}=n,v=u.useContext(Ka),w=lt(v,"sortMarks"),x=u.useMemo(()=>w?w[r.id]:void 0,[w,r.id]),b=u.useRef(),C=u.useCallback(se=>{b.current=a.flexgrow?se.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),j=u.useCallback((se,K)=>{v.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+se),inProgress:K})},[v,a.id]),A=u.useCallback(se=>j(se,!0),[j]),N=u.useCallback(se=>j(se,!1),[j]),k=u.useCallback(se=>{if(!r.sort||a.filter)return;let K=x?.order;K&&(K=K==="asc"?"desc":"asc"),v.exec("sort-rows",{key:a.id,add:se.ctrlKey||se.metaKey,order:K})},[v,a.id,a.filter,r.sort,x?.order]),T=u.useCallback(se=>{se&&se.stopPropagation(),v.exec("collapse-column",{id:a.id,row:l})},[v,a.id,l]),R=u.useCallback(se=>{se.key==="Enter"&&T()},[T]),U=u.useCallback(se=>{se.key==="Enter"&&!a.filter&&k(se)},[k,a.filter]),O=u.useMemo(()=>a.collapsed&&r.collapsed,[a.collapsed,r.collapsed]),Y=u.useMemo(()=>O&&!g&&a.collapsible!=="header",[O,g,a.collapsible]),_=u.useMemo(()=>Y?{top:-p/2,position:"absolute"}:{},[Y,p]),D=u.useMemo(()=>rf(a.width,a.flexgrow,r.fixed,r.left,a.right??r.right,a.height+(O&&Y?p:0)),[a.width,a.flexgrow,r.fixed,r.left,a.right,r.right,a.height,O,Y,p]),ne=u.useMemo(()=>Kb(r,a,m),[r,a,m]),G=u.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([se])=>se!=="cell")),[a]),te=`wx-cell ${ne} ${a.css||""} wx-collapsed`,B=["wx-cell",ne,a.css||"",a.filter?"wx-filter":"",r.fixed&&r.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),xe=u.useRef(null);return u.useEffect(()=>{const se=xe.current;if(!se)return;const K=ax(se,{down:C,move:A,up:N});return()=>{typeof K=="function"&&K()}},[C,A,N,ax]),O?s.jsx("div",{className:"wx-RsQD74qC "+te,style:D,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:T,"data-header-id":Pn(r.id),children:s.jsx("div",{className:"wx-RsQD74qC wx-text",style:_,children:a.text||""})}):s.jsxs("div",{className:"wx-RsQD74qC "+B,style:D,onClick:k,"data-header-id":Pn(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":!x?.order||a.filter?"none":x?.order==="asc"?"ascending":"descending",onKeyDown:U,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:T,children:s.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const se=a.cell;return s.jsx(se,{api:v,cell:G(),column:r,row:l,onAction:({action:K,data:I})=>v.exec(K,I)})})():a.filter?s.jsx(fA,{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:xe,onClick:se=>se.stopPropagation(),children:s.jsx("div",{})}):null,d?s.jsx("div",{className:"wx-RsQD74qC wx-sort",children:x?s.jsxs(s.Fragment,{children:[typeof x.index<"u"?s.jsx("div",{className:"wx-RsQD74qC wx-order",children:x.index+1}):null,s.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${x.order==="asc"?"up":"down"}`})]}):null}):null]})}function hA({cell:n,column:a,row:r,columnStyle:l}){const c=u.useContext(Ka),d=u.useMemo(()=>rf(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(()=>Kb(a,n,l),[a,n,l]),p=u.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([v])=>v!=="cell")),[n]),g=`wx-6Sdi3Dfd wx-cell ${m||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return s.jsx("div",{className:g,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?Yh.createElement(n.cell,{api:c,cell:p(),column:a,row:r,onAction:({action:v,data:w})=>c.exec(v,w)}):s.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function sx({deltaLeft:n,contentWidth:a,columns:r,type:l="header",columnStyle:c,bodyHeight:d}){const m=u.useContext(Ka),p=lt(m,"_sizes"),g=lt(m,"split"),v=u.useMemo(()=>p?.[`${l}RowHeights`],[p,l]),w=u.useMemo(()=>{let A=[];if(r&&r.length){const N=r[0][l].length;for(let k=0;k<N;k++){let T=0;A.push([]),r.forEach((R,U)=>{const O={...R[l][k]};T||A[k].push(O),O.colspan>1?T=O.colspan-1:T&&T--})}}return A},[r,l]),x=u.useMemo(()=>g?.left||g?.right,[g]);function b(A){return r.find(N=>N.id===A)}function C(A,N){let k=N;return A.rowspan&&(k+=A.rowspan-1),k===w.length-1}function j(A,N,k){if(!k.sort)return!1;for(let T=w.length-1;T>=0;T--){const R=k.header[T];if(!R.filter&&!R._hidden)return N===T}return C(A,N)}return s.jsx("div",{className:`wx-sAsPVaUK wx-${l}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((A,N)=>s.jsx("div",{className:l==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${v?.[N]}px`,display:"flex"},role:"row",children:A.map(k=>{const T=b(k.id);return l==="header"?s.jsx(mA,{cell:k,columnStyle:c,column:T,row:N,lastRow:C(k,N),bodyHeight:d,sortRow:j(k,N,T),hasSplit:x},k.id):s.jsx(hA,{cell:k,columnStyle:c,column:b(k.id),row:N},k.id)})},N))})}function pA({overlay:n}){const a=u.useContext(Ka);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 gA(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=ni(p.current,()=>r(!0));return()=>w.destroy()},[r]);function g(){p.current&&(d(p.current.value),l(p.current.value))}function v({key:w}){w==="Enter"&&r()}return s.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:g,onKeyDown:v,ref:p,type:m,value:c})}function vA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d,m]=u.useState(n?.value),[p,g]=u.useState(n?.renderedValue),[v,w]=u.useState(n?.options||[]),x=u.useMemo(()=>n?.config?.template,[n]),b=u.useMemo(()=>n?.config?.cell,[n]),C=u.useMemo(()=>n?.config?.dropdown||{},[n]),j=u.useMemo(()=>({trackScroll:!0,...C}),[C]),A=u.useMemo(()=>(v||[]).findIndex(_=>_.id===d),[v,d]),N=u.useRef(null),k=u.useRef(null),T=u.useCallback(_=>{N.current=_.navigate,k.current=_.keydown,N.current(A)},[A,N]),R=u.useCallback(_=>{const D=_?.target?.value??"";g(D);const ne=D?(n?.options||[]).filter(G=>(G.label||"").toLowerCase().includes(D.toLowerCase())):n?.options||[];w(ne),ne.length?N.current(-1/0):N.current(null)},[n]),U=u.useRef(null);u.useEffect(()=>{U.current&&U.current.focus()},[]);const O=u.useRef(r);u.useEffect(()=>{O.current=r},[r]),u.useEffect(()=>{if(!U.current)return;const _=ni(U.current,()=>O.current(!0));return()=>_.destroy()},[]),u.useEffect(()=>{m(n?.value),g(n?.renderedValue),w(n?.options||[])},[n]);const Y=u.useCallback(({id:_})=>{l(_),r()},[l,r]);return s.jsxs(s.Fragment,{children:[s.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:U,value:p??"",onChange:R,onKeyDown:_=>k.current?k.current(_,A):void 0}),s.jsx(af,{items:v,onReady:T,onSelect:Y,...j,onCancel:c,children:({option:_})=>x?x(_):b?s.jsx(b,{data:_,onAction:a}):_.label})]})}function yA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d]=u.useState(()=>n.value||new Date),{template:m,cell:p,dropdown:g={}}=n?.config||{},v=u.useMemo(()=>({trackScroll:!0,width:"auto",...g}),[g]);function w({value:j}){l(j),r()}const x=u.useRef(null),[b,C]=u.useState(null);return u.useEffect(()=>{x.current&&x.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!b)return;const j=ni(b,()=>r(!0));return()=>j.destroy()},[b,r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:x,tabIndex:0,onClick:c,onKeyDown:j=>j.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,{...v,onCancel:c,children:s.jsx("div",{ref:C,className:"wx-lNWNYUb6",children:s.jsx(Tb,{value:d,onChange:w,buttons:n.config?.buttons})})})]})}function xA(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,g=u.useMemo(()=>({trackScroll:!0,...p}),[p]),[v]=u.useState(a.options.find(R=>R.id===a.value)),[w]=u.useState(a.value),[x]=u.useState(a.options),b=u.useMemo(()=>x.findIndex(R=>R.id===w),[x,w]);function C({id:R}){c(R),l()}let j;const[A,N]=u.useState();function k(R){j=R.navigate,N(()=>R.keydown),j(b)}const T=u.useRef(null);return u.useEffect(()=>{T.current&&T.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!T.current)return;const R=ni(T.current,()=>l(!0));return()=>R.destroy()},[l]),s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:T,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:R=>{A(R,b),R.preventDefault()},children:m.template?m.template(v):m.cell?(()=>{const R=m.cell;return s.jsx(R,{data:v,onAction:r})})():s.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),s.jsx(af,{items:x,onReady:k,onSelect:C,...g,onCancel:d,children:({option:R})=>m.template?m.template(R):m.cell?(()=>{const U=m.cell;return s.jsx(U,{data:R,onAction:r})})():R.label})]})}function bA(n){const{editor:a,onAction:r,onSave:l,onApply:c}=n,d=a?.config||{},m=a?.options??[],p=a?.value||[],g=a?.renderedValue,v=u.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function w({value:b}){c(b)}const x=u.useRef(null);return u.useEffect(()=>{if(!x.current)return;const b=ni(x.current,()=>l(!0));return()=>b.destroy()},[l]),s.jsx("div",{ref:x,className:"wx-value wx-aacZ4gNU",onClick:()=>l(!0),children:s.jsx(Qb,{value:p,options:m,text:g,template:d.template,cell:d.cell,clear:d.clear,dropdown:v,autoOpen:!0,onChange:w,onAction:r})})}const wA={text:gA,combo:vA,datepicker:yA,richselect:xA,multiselect:bA};function SA({column:n,row:a}){const r=u.useContext(Ka),l=lt(r,"editor"),c=u.useCallback((j,A)=>{r.exec("close-editor",{ignore:j}),A&&r.exec("focus-cell",{...A,eventSource:"click"})},[r]),d=u.useCallback(j=>{const A=j?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(j=>{r.exec("editor",{value:j})},[r]),g=u.useCallback(j=>{j.key==="Enter"&&l&&(n.editor.type==="multiselect"?p(l.value):m())},[l,n.editor,m,p]),v=u.useMemo(()=>rf(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=u.useMemo(()=>{let j=n.editor;if(typeof j=="function"&&(j=j(a,n)),!j)return null;let A=typeof j=="string"?j:j.type;return wA[A]},[n,a]),x=u.useRef(null);u.useEffect(()=>{x.current&&typeof v=="string"&&x.current.setAttribute("style",v)},[v]);const b=typeof a.$parent<"u"?"gridcell":"cell",C=typeof a.$parent<"u"?!n.editor:void 0;return s.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:x,style:typeof v=="object"&&v!==null?v:void 0,role:b,"aria-readonly":C,tabIndex:-1,onClick:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),onKeyDown:g,children:w?s.jsx(w,{editor:l,onSave:d,onApply:p,onCancel:m,onAction:({action:j,data:A})=>r.exec(j,A)}):null})}function ix(n){const{columns:a,type:r,columnStyle:l}=n,c=u.useContext(Ka),{filterValues:d,_columns:m,_sizes:p}=c.getState();function g(v){return l?" "+l(v):""}return s.jsx(s.Fragment,{children:a.map((v,w)=>s.jsx("tr",{children:v.map(x=>{const b=m.find(A=>A.id===x.id),C=`wx-print-cell-${r}${g(b)}${x.filter?" wx-print-cell-filter":""}${x.vertical?" wx-vertical":""}`,j=x.cell;return s.jsx("th",{style:zb(qb(x,p.columnWidth)),className:"wx-Gy81xq2u "+C,rowSpan:x.rowspan,colSpan:x.colspan,children:j?s.jsx(j,{api:c,cell:Object.fromEntries(Object.entries(x).filter(([A])=>A!=="cell")),column:b,row:w}):x.filter?s.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:A1(d,m,x)}):s.jsx("div",{className:"wx-Gy81xq2u wx-text",children:x.text??""})},x.id)})},w))})}function CA(n){const{columns:a,rowStyle:r,columnStyle:l,cellStyle:c,header:d,footer:m,reorder:p}=n,g=u.useContext(Ka),{flatData:v,_sizes:w}=g.getState(),x=d&&Zy(a,"header",w.headerRowHeights),b=m&&Zy(a,"footer",w.footerRowHeights);function C(A,N){let k="";return k+=l?" "+l(N):"",k+=c?" "+c(A,N):"",k}function j(A,N){return typeof N.draggable=="function"?N.draggable(A,N)!==!1:N.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(ix,{columns:x,type:"header",columnStyle:l})}):null,s.jsx("tbody",{children:v.map((A,N)=>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 ${C(A,k)}`,style:zb(qb(k,w.columnWidth)),children:[p&&k.draggable?s.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:j(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 T=k.cell;return s.jsx(T,{api:g,row:A,column:k})})():s.jsx("span",{children:zr(A,k)})]},k.id))},N))}),m?s.jsx("tfoot",{children:s.jsx(ix,{columns:b,type:"footer",columnStyle:l})}):null]})}function jA(n){const{config:a,...r}=n,l=u.useContext(Ka),{_skin:c,_columns:d}=l.getState(),m=u.useMemo(()=>S1(d,a),[]),p=u.useRef(null);return u.useEffect(()=>{const g=document.body;g.classList.add("wx-print");const v=p.current;if(!v)return;const w=v.cloneNode(!0);g.appendChild(w);const x=`@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(x)),window.print(),b.remove(),g.classList.remove("wx-print"),w.remove()},[]),s.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:m.map((g,v)=>s.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:s.jsx(CA,{columns:g,...r})},v))})}function kA(n){const{header:a,footer:r,overlay:l,multiselect:c,onreorder:d,rowStyle:m,columnStyle:p,cellStyle:g,autoRowHeight:v,resize:w,clientWidth:x,clientHeight:b,responsiveLevel:C,hotkeys:j}=n,A=u.useContext(Ka),N=lt(A,"dynamic"),k=lt(A,"_columns"),T=lt(A,"flatData"),R=lt(A,"split"),U=lt(A,"_sizes"),[O,Y]=hs(A,"selectedRows"),_=lt(A,"select"),D=lt(A,"editor"),ne=lt(A,"scrollLeft"),G=lt(A,"scrollTop"),te=lt(A,"tree"),B=lt(A,"focusCell"),xe=lt(A,"_print"),se=lt(A,"undo"),K=lt(A,"reorder"),I=lt(A,"_rowHeightFromData"),[Q,q]=u.useState(0);u.useEffect(()=>{q(ps())},[]);const[V,ce]=u.useState(0),be=u.useMemo(()=>(k||[]).some(ee=>!ee.hidden&&ee.flexgrow),[k]),X=u.useMemo(()=>U?.rowHeight||0,[U]),$=u.useRef(null),[ue,he]=u.useState(null),[ve,Se]=u.useState(null),_e=u.useMemo(()=>{let ee=[],Ne=0;return R&&R.left&&(ee=(k||[]).slice(0,R.left).filter(qe=>!qe.hidden).map(qe=>({...qe})),ee.forEach(qe=>{qe.fixed={left:1,leftSize:R.left},qe.left=Ne,Ne+=qe.width}),ee.length&&(ee[ee.length-1].fixed.left=-1)),{columns:ee,width:Ne}},[R,k]),re=u.useMemo(()=>{let ee=[],Ne=0;if(R&&R.right){ee=(k||[]).slice(R.right*-1).filter(qe=>!qe.hidden).map(qe=>({...qe}));for(let qe=ee.length-1;qe>=0;qe--){const rt=ee[qe];rt.fixed={right:1},rt.right=Ne,Ne+=rt.width}ee.length&&(ee[0].fixed={right:-1})}return{columns:ee,width:Ne}},[R,k]),Z=u.useMemo(()=>{const ee=(k||[]).slice(R?.left||0,(k||[]).length-(R?.right??0)).filter(Ne=>!Ne.hidden);return ee.forEach(Ne=>{Ne.fixed=0}),ee},[k,R]),ze=u.useMemo(()=>(k||[]).reduce((ee,Ne)=>(Ne.hidden||(ee+=Ne.width),ee),0),[k]),De=1;function ae(ee,Ne,qe){let rt=Ne,Nt=ee;if(Z.length){let Mt=Z.length;for(let Qe=ee;Qe>=0;Qe--)Z[Qe][qe].forEach(ut=>{ut.colspan>1&&Qe>ee-ut.colspan&&Qe<Mt&&(Mt=Qe)});if(Mt!==Z.length&&Mt<ee){for(let Qe=Mt;Qe<ee;Qe++)rt-=Z[Qe].width;Nt=Mt}}return{index:Nt,delta:rt}}const fe=u.useMemo(()=>{let ee,Ne,qe;const rt=ne||0,Nt=(ne||0)+(x||0);let Mt=0,Qe=0,ut=0,kn=0;Z.forEach((cn,vn)=>{rt>ut&&(Mt=vn,kn=ut),ut=ut+cn.width,Nt>ut&&(Qe=vn+De)});const Wt={header:0,footer:0};for(let cn=Qe;cn>=Mt;cn--)["header","footer"].forEach(vn=>{Z[cn]&&Z[cn][vn].forEach(Br=>{const zs=Br.colspan;if(zs&&zs>1){const Fr=zs-(Qe-cn+1);Fr>0&&(Wt[vn]=Math.max(Wt[vn],Fr))}})});const An=ae(Mt,kn,"header"),St=ae(Mt,kn,"footer"),rn=An.delta,Pt=An.index,ya=St.delta,ca=St.index;return be&&ze>(x||0)?ee=Ne=qe=[..._e.columns,...Z,...re.columns]:(ee=[..._e.columns,...Z.slice(Mt,Qe+1),...re.columns],Ne=[..._e.columns,...Z.slice(Pt,Qe+Wt.header+1),...re.columns],qe=[..._e.columns,...Z.slice(ca,Qe+Wt.footer+1),...re.columns]),{data:ee||[],header:Ne||[],footer:qe||[],d:kn,df:ya,dh:rn}},[Z,_e,re,ne,x,be,ze]),Ae=u.useMemo(()=>a&&U?.headerHeight||0,[a,U]),Te=u.useMemo(()=>r&&U?.footerHeight||0,[r,U]),Be=u.useMemo(()=>x&&b?ze>=x:!1,[x,b,ze]),[Ve,Je]=u.useState(!1),Et=u.useMemo(()=>(b||0)-Ae-Te-(Be?Q:0),[b,Ae,Te,Be,Q]),je=u.useMemo(()=>Math.ceil((Et||0)/(X||1))+1,[Et,X]),We=u.useRef([]),[it,ot]=u.useState(0),[gn,Kt]=u.useState(void 0),Ie=u.useMemo(()=>{let ee=0,Ne=0;const qe=2,rt=G||0;if(v){let Qe=rt;for(;Qe>0;)Qe-=We.current[ee]||X,ee++;Ne=rt-Qe;for(let ut=Math.max(0,ee-qe-1);ut<ee;ut++)Ne-=We.current[ee-ut]||X;ee=Math.max(0,ee-qe)}else{if(I){let Qe=0,ut=0;for(let St=0;St<(T||[]).length;St++){const rn=T[St].rowHeight||X;if(ut+rn>rt){Qe=St;break}ut+=rn}ee=Math.max(0,Qe-qe);for(let St=0;St<ee;St++)Ne+=T[St].rowHeight||X;let kn=0,Wt=0;for(let St=Qe+1;St<(T||[]).length;St++){const rn=T[St].rowHeight||X;if(kn++,Wt+rn>Et)break;Wt+=rn}const An=Math.min(N?N.rowCount:(T||[]).length,Qe+kn+qe);return{d:Ne,start:ee,end:An}}ee=Math.floor(rt/(X||1)),ee=Math.max(0,ee-qe),Ne=ee*(X||0)}const Nt=N?N.rowCount:(T||[]).length,Mt=Math.min(Nt,ee+(je||0)+qe);return{d:Ne,start:ee,end:Mt}},[v,I,G,X,N,T,je,Et]),ct=u.useMemo(()=>{const ee=N?N.rowCount:(T||[]).length;if(v)return it+Ie.d+(ee-(gn||0))*(X||0);if(!I)return ee*(X||0);let Ne=0;for(let qe=0;qe<ee;qe++)Ne+=T[qe]?.rowHeight||X;return Ne},[N,T,X,v,I,it,Ie.d,gn]),_t=u.useRef({});_t.current={clientWidth:x,clientHeight:b,fullHeight:ct,headerHeight:Ae,footerHeight:Te,fullWidth:ze,SCROLLSIZE:Q};const Ft=u.useCallback(()=>{const ee=_t.current;Je(ee.clientWidth&&ee.clientHeight?ee.fullHeight+ee.headerHeight+ee.footerHeight>=ee.clientHeight-(ee.fullWidth>=ee.clientWidth?ee.SCROLLSIZE:0):!1)},[]);u.useEffect(()=>{const ee=requestAnimationFrame(Ft);return()=>window.cancelAnimationFrame(ee)},[V,Ft]),u.useEffect(()=>{Ft()},[b,Ft]);const ge=u.useMemo(()=>be&&ze<=(x||0)?(x||0)-0-(Ve?Q:0):ze,[be,ze,x,Ve,Q,Be]),Oe=u.useMemo(()=>be&&ze<=(x||0)?x||0:ge<(x||0)?ze+(Ve?Q:0):-1,[be,ze,x,ge,Ve,Q]),Fe=u.useRef({});u.useEffect(()=>{if(N&&(Fe.current.start!==Ie.start||Fe.current.end!==Ie.end)){const{start:ee,end:Ne}=Ie;Fe.current={start:ee,end:Ne},A&&A.exec&&A.exec("request-data",{row:{start:ee,end:Ne}})}},[N,Ie,A]);const ke=u.useMemo(()=>N?T||[]:(T||[]).slice(Ie.start,Ie.end),[N,T,Ie]),at=u.useMemo(()=>(O||[]).filter(ee=>(ke||[]).some(Ne=>Ne.id===ee)),[Y,ke]),gt=u.useMemo(()=>Ie.start,[Ie.start]),Ee=u.useRef({top:G,left:ne});Ee.current={top:G,left:ne};const jn=u.useCallback(ee=>{const Ne=ee.target.scrollTop,qe=ee.target.scrollLeft,rt=Ee.current;(Ne!==rt.top||qe!==rt.left)&&A.exec("scroll-to",{top:Ne,left:qe})},[A]),Ls=u.useCallback(ee=>{ee.shiftKey&&ee.preventDefault(),$.current&&$.current.focus&&$.current.focus()},[]),nt=u.useCallback(()=>!!(k||[]).find(ee=>!!ee.draggable),[k]),zt=u.useRef(null),zn=u.useRef(null),He=u.useRef({dblclick:(ee,Ne)=>{const qe={id:ee,column:qc(Ne,"data-col-id")};A.exec("open-editor",qe)},click:(ee,Ne)=>{if(Ne.target.closest("input")||zt.current)return;const qe=qc(Ne,"data-col-id");if(B?.id!==ee&&A.exec("focus-cell",{row:ee,column:qe,eventSource:"click"}),_===!1)return;const rt=c&&(Ne.ctrlKey||Ne.metaKey),Nt=c&&Ne.shiftKey;(rt||O.length>1||!O.includes(ee))&&A.exec("select-row",{id:ee,toggle:rt,range:Nt})},"toggle-row":ee=>{const Ne=A.getRow(ee);A.exec(Ne.open!==!1?"close-row":"open-row",{id:ee})},"ignore-click":()=>!1}),va=u.useMemo(()=>({top:Ae,bottom:Te,left:_e.width,xScroll:Be,yScroll:Ve,sense:v&&ve?ve.offsetHeight:Math.max(U?.rowHeight||0,40),node:$.current&&$.current.firstElementChild}),[Ae,Te,_e.width,Be,Ve,v,ve,U]);function dt(ee,Ne){const{container:qe,sourceNode:rt,from:Nt}=Ne;if(nt()&&!rt.getAttribute("draggable-data"))return!1;he(Nt),te&&A.getRow(Nt).open&&A.exec("close-row",{id:Nt,nested:!0});const Mt=Do(rt),Qe=Mt.cloneNode(!0);Qe.classList.remove("wx-selected"),Qe.querySelectorAll("[tabindex]").forEach(An=>An.setAttribute("tabindex","-1")),qe.appendChild(Qe),Se(Qe);const ut=(ne||0)-fe.d,kn=Ve?Q:0;qe.style.width=Math.min((x||0)-kn,be&&ze<=(x||0)?ge:ge-kn)+ut+"px";const Wt=_d(Mt);Ne.offset={x:ut,y:-Math.round(Wt.height/2)},zn.current||(zn.current=ee.clientY)}function Hi(ee,Ne){const{from:qe}=Ne,rt=Ne.pos,Nt=_d($.current);rt.x=Nt.x;const Mt=va.top;if(rt.y<Mt)rt.y=Mt;else{const Qe=Nt.height-(Be&&Q>0?Q:Math.round(va.sense/2))-va.bottom;rt.y>Qe&&(rt.y=Qe)}if($.current.contains(Ne.targetNode)){const Qe=Do(Ne.targetNode),ut=Qe&&tf(Qe);if(ut&&ut!==qe){Ne.to=ut;const kn=v?ve?.offsetHeight:U?.rowHeight;if(ve&&((G||0)===0||rt.y>Mt+kn-1)){const Wt=Qe.getBoundingClientRect(),An=_d(ve).y,St=Wt.y,rn=An>St?-1:1,Pt=rn===1?"after":"before",ya=A.getState().flatData,ca=Math.abs(ya.findIndex(vn=>vn.id===qe)-ya.findIndex(vn=>vn.id===ut)),cn=ca!==1?Pt==="before"?"after":"before":Pt;if(ca===1&&(rn===-1&&ee.clientY>zn.current||rn===1&&ee.clientY<zn.current))return;zn.current=ee.clientY,A.exec("move-item",{id:qe,target:ut,mode:cn,inProgress:!0})}}d&&d({event:ee,context:Ne})}tA(ee,Nt,Ne,va)}function Qt(ee,Ne){const{from:qe,to:rt}=Ne;A.exec("move-item",{id:qe,target:rt,inProgress:!1}),zt.current=setTimeout(()=>{zt.current=0},1),he(null),Se(null),zn.current=null,Wb(Ne)}function ps(){const ee=document.createElement("div");ee.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(ee);const Ne=ee.offsetWidth-ee.clientWidth;return document.body.removeChild(ee),Ne}const bt=u.useMemo(()=>Oe>0?{width:`${Oe}px`}:void 0,[Oe]),qn=u.useRef(null);function _s(){Promise.resolve().then(()=>{let ee=0,Ne=gt;const qe=qn.current;qe&&(Array.from(qe.children).forEach((rt,Nt)=>{We.current[gt+Nt]=rt.offsetHeight,ee+=rt.offsetHeight,Ne++}),ot(ee),Kt(Ne))})}u.useEffect(()=>{ke&&v&&_s()},[ke,v,gt]);let[H,Pe]=u.useState();u.useEffect(()=>{if(B&&(!_||!at.length||at.includes(B.row)))Pe({...B});else if(ke.length&&fe.data.length){if(!H||at.length&&!at.includes(H.row)||ke.findIndex(ee=>ee.id===H.row)===-1||fe.data.findIndex(ee=>ee.id===H.column&&!ee.collapsed)===-1){const ee=at[0]||ke[0].id,Ne=fe.data.findIndex(qe=>!qe.collapsed);Pe(Ne!==-1?{row:ee,column:fe.data[Ne].id}:null)}}else Pe(null)},[B]);const vt=u.useRef(null);u.useEffect(()=>{const ee=$.current;if(!ee)return;const Ne=Q1(ee,w);return()=>{typeof Ne=="function"&&Ne()}},[w]);const sn=u.useRef({});Object.assign(sn.current,{start:dt,move:Hi,end:Qt,getReorder:()=>K,getDraggableInfo:()=>({hasDraggable:nt()})}),u.useEffect(()=>{const ee=$.current;return ee?Z1(ee,sn).destroy:void 0},[K,$.current]),u.useEffect(()=>{const ee=$.current;return ee?Y1(ee,{keys:j!==!1&&{...W1,"ctrl+z":se,"ctrl+y":se,...j},exec:Ne=>A.exec("hotkey",Ne)}).destroy:void 0},[A,se,j]);const Qa=u.useRef({scroll:A.getReactiveState().scroll,scrollLeft:A.getReactiveState().scrollLeft,scrollTop:A.getReactiveState().scrollTop});Qa.current.getWidth=()=>(x||0)-(Ve?Q:0),Qa.current.getHeight=()=>Et,Qa.current.getScrollMargin=()=>_e.width+re.width,u.useEffect(()=>{K1(vt.current,Qa.current)},[]);const Hr=u.useRef(null);u.useEffect(()=>{const ee=Hr.current;if(!ee)return;const Ne=[];Ne.push(ni(ee,()=>B&&A.exec("focus-cell",{eventSource:"click"})).destroy),Ne.push(Zk(ee,He.current)),ce(ee.clientHeight);const qe=new ResizeObserver(()=>{ce(ee.clientHeight)});return qe.observe(ee),Ne.push(()=>qe.disconnect()),()=>Ne.forEach(rt=>rt())},[]);const Xa=`wx-grid ${C?`wx-responsive-${C}`:""}`;return u.useEffect(()=>{B&&(ke.some(ee=>ee.id===B.row)&&fe.data.some(ee=>ee.id===B.column&&!ee.collapsed)||A.exec("focus-cell",{eventSource:"destroy"}))},[B,ke,fe.data,A]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-4VuBwK2D "+Xa,style:{"--header-height":`${Ae}px`,"--footer-height":`${Te}px`,"--split-left-width":`${_e.width}px`,"--split-right-width":`${re.width}px`},children:s.jsx("div",{ref:$,className:"wx-4VuBwK2D wx-table-box",style:bt,role:te?"treegrid":"grid","aria-colcount":fe.data.length,"aria-rowcount":ke.length,"aria-multiselectable":te&&c?!0:void 0,tabIndex:-1,children:s.jsxs("div",{ref:vt,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:Be?"scroll":"hidden",overflowY:Ve?"scroll":"hidden"},onScroll:jn,children:[a?s.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:s.jsx(sx,{contentWidth:ge,deltaLeft:fe.dh,columns:fe.header,columnStyle:p,bodyHeight:Et-+r})}):null,s.jsxs("div",{ref:Hr,className:"wx-4VuBwK2D wx-body",style:{width:`${ge}px`,height:`${ct}px`},onMouseDown:ee=>Ls(ee),children:[l?s.jsx(pA,{overlay:l}):null,s.jsx("div",{ref:qn,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${Ie.d}px`,paddingLeft:`${fe.d}px`},children:ke.map((ee,Ne)=>{const qe=O.indexOf(ee.id)!==-1,rt=ue===ee.id,Nt="wx-row"+(v?" wx-autoheight":"")+(m?" "+m(ee):"")+(qe?" wx-selected":"")+(rt?" wx-inactive":""),Mt=v?{minHeight:`${ee.rowHeight||X}px`}:{height:`${ee.rowHeight||X}px`};return s.jsx("div",{className:"wx-4VuBwK2D "+Nt,"data-id":Pn(ee.id),"data-context-id":Pn(ee.id),style:Mt,role:"row","aria-rowindex":Ne,"aria-expanded":ee.open,"aria-level":te?ee.$level+1:void 0,"aria-selected":te?qe:void 0,tabIndex:-1,children:fe.data.map(Qe=>Qe.collapsed?s.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},Qe.id):D?.id===ee.id&&D.column===Qe.id?s.jsx(SA,{row:ee,column:Qe},Qe.id):s.jsx(rA,{row:ee,column:Qe,columnStyle:p,cellStyle:g,reorder:K,focusable:H?.row===ee.id&&H?.column===Qe.id},Qe.id))},ee.id)})})]}),r&&(T||[]).length?s.jsx(sx,{type:"footer",contentWidth:ge,deltaLeft:fe.df,columns:fe.footer,columnStyle:p}):null]})})}),xe?s.jsx(jA,{config:xe,rowStyle:m,columnStyle:p,cellStyle:g,header:a,footer:r,reorder:K}):null]})}const AA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),NA=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:g=!0,footer:v=!1,dynamic:w=null,overlay:x=null,reorder:b=!1,onReorder:C=null,autoRowHeight:j=!1,sizes:A,split:N,tree:k=!1,autoConfig:T=!1,init:R=null,responsive:U=null,sortMarks:O,undo:Y=!1,hotkeys:_=null,filterValues:D,...ne},G){const te=u.useRef();te.current=ne;const B=u.useMemo(()=>new P1(Ib),[]),xe=u.useMemo(()=>B.in,[B]),se=u.useRef(null);se.current===null&&(se.current=new Eb((re,Z)=>{const ze="on"+AA(re);te.current&&te.current[ze]&&te.current[ze](Z)}),xe.setNext(se.current));const K=u.useMemo(()=>({getState:B.getState.bind(B),getReactiveState:B.getReactive.bind(B),getStores:()=>({data:B}),exec:xe.exec,setNext:re=>(se.current=se.current.setNext(re),se.current),intercept:xe.intercept.bind(xe),on:xe.on.bind(xe),detach:xe.detach.bind(xe),getRow:B.getRow.bind(B),getColumn:B.getColumn.bind(B)}),[B,xe]),[I,Q]=u.useState(0),[q,V]=u.useState(0),[ce,be]=u.useState(null),[X,$]=u.useState(null),ue=u.useMemo(()=>{if(T&&!a.length&&n.length){const re=n[0],Z=[];for(let ze in re)if(ze!=="id"&&ze[0]!=="$"){let De={id:ze,header:ze[0].toUpperCase()+ze.slice(1)};typeof T=="object"&&(De={...De,...T}),Z.push(De)}return Z}return(X&&X.columns)??a},[T,a,n,X]),he=u.useMemo(()=>(X&&X.sizes)??A,[X,A]),ve=u.useCallback(re=>{if(Q(re.width),V(re.height),U){const Z=Object.keys(U).map(Number).sort((ze,De)=>ze-De).find(ze=>re.width<=ze)??null;Z!==ce&&($(U[Z]),be(Z))}},[U,ce]),Se=u.useContext(Un.theme),_e=u.useRef(0);return u.useEffect(()=>{if(!_e.current)R&&R(K);else{const re=B.getState();B.init({data:n,columns:ue,split:N||re.split,sizes:he||re.sizes,selectedRows:d||re.selectedRows,dynamic:w,tree:k,sortMarks:O||re.sortMarks,filterValues:D||re.filterValues,undo:Y,reorder:b,_skin:Se,_select:m})}_e.current++},[B,n,ue,N,he,d,w,k,O,D,Y,b,Se,m,R,K]),_e.current===0&&B.init({data:n,columns:ue,split:N||{left:0},sizes:he||{},selectedRows:d||[],dynamic:w,tree:k,sortMarks:O||{},filterValues:D||{},undo:Y,reorder:b,_skin:Se,select:m}),u.useImperativeHandle(G,()=>({...K}),[K]),s.jsx(Ka.Provider,{value:K,children:s.jsx(up,{words:dp,optional:!0,children:s.jsx(kA,{header:g,footer:v,overlay:x,rowStyle:r,columnStyle:l,cellStyle:c,onReorder:C,multiselect:p,autoRowHeight:j,clientWidth:I,clientHeight:q,responsiveLevel:ce,resize:ve,hotkeys:_})})})});ap(La);const $n=u.createContext(null),hp=u.createContext(null),pp=u.createContext(null);function MA({children:n}){const a=u.useContext(Un.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=u.useContext($n),[c]=hs(l,"panels"),d=lt(l,"activePanel"),m=c[d].path,[p,g]=u.useState(null),[v,w]=u.useState(null),[x,b]=u.useState(""),[C,j]=u.useState(""),[A,N]=u.useState(!1);function k(){const O=x.trim();if(!O){N(!0);return}p.add?l.exec("create-file",{file:{...p.item,name:O},parent:m}):C!==O&&l.exec("rename-file",{id:p.item.id,name:O}),T()}function T(){g(null),N(null),j(""),b("")}function R(){l.exec("delete-files",{ids:v.selected}),w(null)}const U=u.useMemo(()=>({showPrompt(O){const Y=O.item.name||(O.item.type==="folder"?r("New folder"):`${r("New file")}.txt`);j(Y),b(Y),g({...O})},showConfirm(O){w({...O})}}),[r]);return s.jsxs(hp.Provider,{value:U,children:[s.jsx(Mk,{children:n}),p?s.jsx(_h,{title:r(`Enter ${p.item.type} name`),onConfirm:k,onCancel:T,children:s.jsx(op,{error:A,select:!0,focus:!0,value:x,onChange:({value:O})=>b(O)})}):null,v?s.jsx(_h,{title:r("Are you sure you want to delete these items:"),onConfirm:R,onCancel:()=>w(null),children:v.selected?s.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:v.selected.map((O,Y)=>s.jsx("li",{children:O},Y))}):null}):null]})}let rx={"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 TA(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 EA({item:n}){const a=u.useContext($n),r=u.useContext(Un.i18n).getGroup("filemanager"),l=u.useContext($n).templates,[c]=hs(a,"panels"),d=lt(a,"activePanel"),m=lt(a,"mode"),p=c[d].selected,g=u.useMemo(()=>l.preview(n,214,163),[l,n]),v=u.useMemo(()=>l.icon(n,"big"),[l,n]),[w,x]=u.useMemo(()=>TA(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":Pn("/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":Pn(n.id),children:[g?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:g})}):v?s.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:s.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:v})}):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:x})]})]}),s.jsx("div",{"data-action-id":Pn(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:x})]})}),s.jsx("div",{"data-action-id":Pn(n.id),className:"wx-GAOa4kDV wx-more",children:s.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function Xb(){const n=u.useContext($n),a=u.useContext(Un.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),[l]=hs(n,"panels"),c=lt(n,"activePanel"),d=lt(n,"mode"),m=l[c]._files,p=l[c].selected,g=l[c].path,v=l[c]._crumbs,w=l[c]._selectNavigation,x=u.useCallback((T,R)=>{const U=R&&(R.ctrlKey||R.metaKey),O=R&&R.shiftKey;if(T==="/wx-filemanager-parent-link"){if(p.length&&(U||O))return;n.exec("select-file",{type:"navigation"});return}let Y=T==="body"&&R?null:T;const _=R.target.className.indexOf("wx-more")!==-1||R.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:Y,toggle:U&&!_,range:O&&!_,panel:c})},1)},[n,p,c]),b=u.useCallback(()=>{v.length>1&&n.exec("set-path",{id:v[v.length-2].id,panel:c,selected:[v[v.length-1].id]})},[n,v,c]),C=u.useCallback(T=>{if(T==="/wx-filemanager-parent-link")return b();d==="search"&&n.exec("filter-files",{text:""});const R=m.find(U=>U.id===T);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]),j=u.useCallback((T,R)=>{(!p?.length||!p.filter(U=>U?.id===T).length>0)&&x(T,R)},[p,x]),A=u.useMemo(()=>g!=="/"?[{id:"/wx-filemanager-parent-link",name:r("Back to parent folder"),navigation:w},...m]:m,[g,r,w,m]),N=u.useRef(null),k=u.useRef();return u.useEffect(()=>{N.current&&(k.current?(k.current.click=x,k.current._dblclick=C,k.current.context=j):(k.current={click:x,dblclick:T=>k.current._dblclick(T),_dblclick:C,context:j},Lo(N.current,k.current)))},[x,C,j]),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"+(g!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":Pn("body"),ref:N,children:A.map(T=>s.jsx(EA,{item:T},T.id))})}function Ll({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 RA(){const n=u.useContext(Un.i18n).getGroup("filemanager"),a=u.useContext($n),r=lt(a,"activePanel"),[l]=hs(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(Ll,{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(Xb,{})]})}function sh({narrowMode:n,extraInfo:a}){const r=u.useContext($n),{preview:l,icon:c}=r.templates,d=u.useContext(Un.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>Mo("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[g,v]=hs(r,"panels"),w=lt(r,"activePanel"),x=lt(r,"preview"),b=lt(r,"search"),C=u.useMemo(()=>{const _=g&&w!=null&&g[w]?._selected?.length||0;return b&&!_},[b,v,w]),j=u.useMemo(()=>{const _=g&&w!=null?g[w]:null;return _?C?_._files:_._selected:[]},[C,v,w]),A=u.useCallback((_,D)=>(_?`${_} ${m(_>1?"folders":"folder")} `:"")+(D?`${D} ${m(D>1?"files":"file")}`:""),[m]),N=u.useCallback(()=>{r.exec("show-preview",{mode:!x})},[r,x]),k=u.useCallback(_=>_.type==="folder"?m("Folder"):_.ext||m("Unknown file"),[m]),T=u.useMemo(()=>{let _,D,ne,G,te,B,xe,se;if(j.length===1&&!C){D=j[0],_=D.name;const K=l(D,400,500);K?(ne=K,G=""):(G=c(D,"big"),ne=""),te=D.type!=="folder"}else{if(D=te=null,_="",j.length){let K=0,I=0,Q=0,q=[],V;j.forEach(be=>{typeof be.size>"u"&&(V=!0,K=void 0),V||(K+=be.size),q.push(k(be)),be.type==="folder"?I++:Q++});const ce=new Set(q);B=ce.size>1?m("multiple"):[...ce][0],xe=A(I,Q),se=K,C||(_=m("Multiple files"))}G=c({type:C?"search":j.length?"multiple":"none"},"big"),ne=""}return{name:_,item:D,previewSrc:ne,iconSrc:G,showDownloadIcon:te,type:B,totalCount:xe,totalSize:se}},[j,C,l,c,m,k,A]),R=u.useCallback(()=>{r.exec("download-file",{id:j[0].id})},[r,j]),U=u.useCallback(async _=>{if(!a||!_)return null;try{return await a(_)}catch(D){return console.log(D),null}},[a]),[O,Y]=u.useState(null);return u.useEffect(()=>{let _=!1;return Y(null),Promise.resolve(U(T.item)).then(D=>{_||Y(D)}).catch(()=>{_||Y(null)}),()=>{_=!0}},[U,T.item]),s.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:j&&j.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:T.name}),s.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[T.showDownloadIcon?s.jsx(Ll,{name:"download",onClick:R}):null,n?s.jsx(Ll,{name:"close",onClick:N}):null]})]}),T.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:T.previewSrc,alt:m("A miniature file preview")})}):T.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:T.iconSrc,alt:m("A miniature file preview")})}):s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:T.item?s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${T.item.type}`}):s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${C?"search":"file-multiple-outline"}`})})]}),s.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-title",children:m(C?"Found":"Information")}),s.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[T.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(T.item)}),typeof T.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:Gc(T.item.size)})]}):null,s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Date")}),s.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(T.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:T.totalCount}),s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:T.type}),typeof T.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:Gc(T.totalSize)})]}):null]}),O?Object.entries(O).map(([_,D])=>s.jsxs(Yh.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:_}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:D})]},_)):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:T.name}),s.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?s.jsx(Ll,{name:"close",onClick:N}):null})]}),s.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:s.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[T.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:T.previewSrc,alt:m("A miniature file preview")})}):T.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:T.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-${C?"search":"message-question-outline"}`})}),s.jsx("span",{className:"wx-O0BTtRrH wx-text",children:C?"":m("Select file or folder to view details")})]})})]})})}function Zb({panel:n}){const a=u.useContext($n),r=u.useContext(Un.i18n),l=u.useMemo(()=>r.getGroup("filemanager"),[r]),[c,d]=hs(a,"panels"),m=u.useMemo(()=>c[n]._files,[d,n]),p=u.useMemo(()=>c[n]._crumbs||[],[d,n]);function g(j){const A=fp(j,p);a.exec("set-path",{id:j,panel:n,...A&&{selected:[A]}})}const[v,w]=u.useState(null);u.useEffect(()=>{m&&w(null)},[m]);function x(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=u.useRef(null),C=u.useRef();return u.useEffect(()=>{C.current?C.current.click=g:(C.current={click:g},Lo(b.current,C.current))},[g]),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(Ll,{name:"refresh",spin:!!v,onClick:x})}),p.map((j,A)=>s.jsxs(Yh.Fragment,{children:[A?s.jsx(Ll,{name:"angle-right"}):null,s.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":Pn(j.id),"data-menu-ignore":"true",children:j.id=="/"?l(j.name):j.name})]},A))]})}function DA({row:n}){const a=u.useContext(Un.i18n),[r]=u.useState(()=>a.getGroup("filemanager")),l=u.useContext($n).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 Jb({children:n}){const a=u.useContext($n),r=lt(a,"activePanel"),l=u.useContext(pp),c=u.useRef(null);let d=u.useRef({});return d.current.drop=()=>{const m=c.current,p=zj(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($n),d=u.useContext(Un.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>Mo("%d %M %Y",d.getRaw().calendar),[d]),[g]=hs(c,"panels"),v=g[n].selected,w=g[n].path,x=g[n]._crumbs,b=g[n]._sorts,C=g[n]._selectNavigation,j=g[n]._files,A=u.useMemo(()=>[{id:"name",header:m("Name"),flexgrow:3,sort:!0,resize:!0,cell:DA},{id:"size",header:m("Size"),width:100,sort:!0,resize:!0,template:B=>typeof B=="number"?Gc(B):""},{id:"date",header:m("Date"),width:120,sort:!0,resize:!0,template:B=>B?p(B):""}],[m,p]),N=u.useRef(null),k=u.useRef(null),T=u.useMemo(()=>C?["/wx-filemanager-parent-link"]:[...v],[C,v]);function R(B,xe){if(xe&&xe.target&&xe.target.className&&xe.target.className.indexOf("wx-grip")!==-1)return;const se=xe&&(xe.ctrlKey||xe.metaKey),K=xe&&xe.shiftKey;if(B==="/wx-filemanager-parent-link"){if(v.length&&(se||K))return;c.exec("select-file",{type:"navigation"});return}let I=B==="body"&&xe?null:B;!N.current&&!k.current?c.exec("select-file",{id:I,toggle:se,range:K,panel:n}):(N.current=null,k.current=null)}function U(){x.length>1&&c.exec("set-path",{id:x[x.length-2].id,panel:n,selected:[x[x.length-1].id]})}function O(B){if(B==="/wx-filemanager-parent-link")return U();const xe=j.find(se=>se.id===B);xe&&(xe.type==="folder"?c.exec("set-path",{id:xe.id,panel:n}):c.exec("open-file",{id:xe.id}))}function Y(B){const xe=B.key,se=b[w];let K=se?"asc":"desc";se&&se.key===xe&&(K=se.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:xe,order:K,panel:n,path:w})}function _(B){B.intercept("sort-rows",xe=>(N.current=!0,Y(xe),!1)),B.intercept("select-row",()=>!1),B.on("resize-column",()=>k.current=!0),B.intercept("hotkey",()=>!1)}const D=u.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:m("Back to parent folder")},...j]:j,[w,j,m]),ne=u.useMemo(()=>{if(D&&b&&b[w]){const{key:B,order:xe}=b[w];return{[B]:{order:xe}}}},[D,b,w]),G=u.useRef(null),te=u.useRef();return u.useEffect(()=>{te.current?(te.current.click=R,te.current._dblclick=O):(te.current={click:R,dblclick:B=>te.current._dblclick(B),_dblclick:O},Lo(G.current,te.current))},[R,O]),s.jsxs("div",{onClick:r,onContextMenu:l,className:"wx-SSaVhET7 wx-wrapper",children:[s.jsx(Zb,{panel:n}),s.jsx("div",{"data-id":Pn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:G,children:s.jsx(Jb,{children:s.jsx(NA,{init:_,data:D,columns:A,selectedRows:T,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:ne})})})]})}function LA(){const n=u.useContext($n),a=lt(n,"activePanel");function r(l){n.exec("set-active-panel",{panel:l})}return s.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":Pn("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 ew({folderIcon:n=!1,folder:a={}}){const r=u.useContext($n),[l,c]=hs(r,"panels"),d=lt(r,"activePanel"),m=u.useMemo(()=>l[d].path,[c,d]),p=u.useContext(Un.i18n),g=u.useMemo(()=>p.getGroup("filemanager"),[p]),v=u.useMemo(()=>!!a.data?.find(C=>C.type==="folder"),[a]),w=u.useMemo(()=>a.id=="/"?g(a.name):a.name,[a,g]),x=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":Pn(a.id),className:`wx-NYfhvGIt wx-folder${m===a.id?" wx-selected":""}`,style:{paddingLeft:`${x}px`},children:[v?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&&v?s.jsx(s.Fragment,{children:a.data.map(C=>C.type==="folder"?s.jsx(ew,{folder:C},C.id):null)}):null]})}function _A(){const n=u.useContext($n),[a,r]=hs(n,"data"),[l,c]=hs(n,"panels"),d=lt(n,"activePanel"),m=u.useMemo(()=>l[d]._crumbs,[c,d]),p=u.useCallback(C=>{n.exec("open-tree-folder",{id:C,mode:!a.byId(C).open})},[n,r]),g=u.useCallback(C=>{const j=fp(C,m);n.exec("set-path",{id:C,panel:d,...j&&{selected:[j]}})},[n,m,d]),[v,w]=u.useState([]);u.useEffect(()=>{w(a.byId(0).data)},[r]);const x=u.useRef(null),b=u.useRef();return u.useEffect(()=>{b.current?(b.current.click=g,b.current.toggle=p):(b.current={click:g,toggle:p},Lo(x.current,b.current))},[g,p]),s.jsx("ul",{ref:x,className:"wx-LyHJ6R6A",children:v.map(C=>C.type==="folder"?s.jsx(ew,{folder:C},C.id):null)})}function zA(){const n=u.useContext($n),a=u.useContext(Un.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=lt(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:[Gc(c)," ",r("of")," ",Gc(d)," ",r("used")]})]}):null}function IA({option:n}){const a=u.useContext(Un.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 OA({readonly:n,menuOptions:a}){const r=u.useContext(Un.i18n).getGroup("filemanager"),{showPrompt:l}=u.useContext(hp);u.useEffect(()=>{t1("upload",IA)},[]);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(a1,{options:d,at:"bottom-fit",onClick:c,children:s.jsx(Oc,{type:"primary block",children:r("Add New")})})}),s.jsx("div",{className:"wx-FlucfALM wx-tree",children:s.jsx(_A,{})}),s.jsx(zA,{})]})}function HA({value:n="",onSearch:a}){const[r,l]=_b(n),c=u.useContext(Un.i18n).getGroup("filemanager"),d=u.useRef(null),m=u.useMemo(()=>r!==""?"wxi-close":"wxi-search",[r]);function p(v){const w=v.target.value;l(w),a&&a({value:w})}function g(){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:g}),s.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:r,onInput:p,placeholder:c("Search")})]})}function BA({narrowMode:n=!1,onShowTree:a}){const r=u.useContext($n),l=u.useContext(Un.i18n).getGroup("filemanager"),c=lt(r,"mode"),d=lt(r,"preview"),m=lt(r,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function g({value:x}){r.exec("set-mode",{mode:x})}function v(x){x.preventDefault(),r.exec("show-preview",{mode:!d})}function w(x){r.exec("filter-files",{text:x.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":Pn("toggle-tree"),children:s.jsx(Ll,{onClick:()=>a&&a(),name:"subtask"})}):s.jsx("div",{className:"wx-5PZQQztG wx-name",children:l("Files")}),s.jsx(HA,{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(Tk,{onClick:v,value:d,children:s.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),s.jsx("div",{className:"wx-5PZQQztG wx-modes",children:s.jsx(Ck,{value:c,options:p,onChange:g})})]})]})}function FA(){const n=u.useContext($n),a=lt(n,"activePanel");return s.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[s.jsx(Zb,{panel:a}),s.jsx(Jb,{children:s.jsx(Xb,{})})]})}function PA({readonly:n=!1,menuOptions:a,extraInfo:r}){const l=u.useRef(null),c=u.useRef(null),[d,m]=u.useState(void 0),[p,g]=u.useState(void 0),[v,w]=u.useState(!1),x=Pb(),b=u.useContext($n),{showPrompt:C,showConfirm:j}=u.useContext(hp),A=u.useContext(Un.i18n),N=u.useMemo(()=>A.getGroup("filemanager"),[A]),k=lt(b,"mode"),T=lt(b,"preview"),R=lt(b,"activePanel"),[U,O]=hs(b,"panels"),Y=u.useMemo(()=>(U&&R!=null?U[R]:null)?.selected??[],[O,R]),_=u.useMemo(()=>(U&&R!=null?U[R]:null)?.path,[O,R]),[D,ne]=u.useState([]);u.useEffect(()=>{const ce=l.current;if(!ce)return;const be=new ResizeObserver(X=>{const $=X[0]?.borderBoxSize?.[0]?.inlineSize;typeof $=="number"&&g($<768)});return be.observe(ce),()=>{be.disconnect()}},[]);const G=u.useCallback(()=>{w(ce=>!ce)},[]),te=u.useCallback(ce=>{p&&qc(ce)!=="toggle-tree"&&w(!1)},[p]);u.useEffect(()=>{const ce=c.current;if(ce)return ni(ce,te).destroy},[te]),u.useEffect(()=>{const ce=c.current;if(!ce)return;const be=new ResizeObserver(()=>{ce&&m(ce.clientWidth)});return be.observe(ce),ce&&m(ce.clientWidth),()=>{be.disconnect()}},[]);const B=u.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),xe=u.useCallback(ce=>{let be=p?[B]:[];return ce==="file"&&(be=[...be,...a().filter(X=>X.id==="download")]),be},[p,B,a]),se=u.useRef(null),K=u.useCallback((ce,be,X)=>{const $=X?[be.id]:Y;switch(ce){case"download":b.exec("download-file",{id:be.id});break;case"copy":case"move":se.current={action:ce,ids:$};break;case"paste":se.current&&b.exec(se.current.action==="copy"?"copy-files":"move-files",{ids:se.current.ids,target:be?.type==="folder"?be.id:_});break;case"rename":C({item:be});break;case"delete":j({selected:$});break;case"preview":b.exec("show-preview",{mode:!T});break}},[b,Y,_,C,j,T]),I=u.useCallback(()=>U?.[R],[U,R]);u.useEffect(()=>{const ce=l.current;if(!ce)return;const be=qk(ce,{api:b,menuOptions:n?xe:a,performAction:K,getPanel:I});return()=>{typeof be=="function"?be():be&&typeof be.destroy=="function"&&be.destroy()}},[b,n,xe,a,K,I]);const Q=u.useCallback((ce,be)=>{const X=ce?b.getFile(ce):null,$=be.target.closest(".tree-item.folder");let ue;if(n)ue=xe(X?.type);else{switch(ce){case"body":ue=a(ce);break;default:if(X)if(!$&&Y.length>1)ue=p?[B,...a("multiselect")]:a("multiselect");else if(ce==="/")ue=a("folder",X).filter(he=>he.id==="paste");else{const he=a(X.type,X);he&&(ue=p?[B,...he]:he)}}k==="search"&&(ue=ue?.filter(he=>he.id!=="paste"))}if(X?.id&&(!Y.length||!Y.some(he=>he===X.id))&&!$&&b.exec("select-file",{id:X.id}),ue?.length)return ue.forEach(he=>{$&&(he.hotkey=""),he.text&&(he.text=N(he.text)),he.hotkey&&(he.subtext=he.hotkey)}),ne(ue),X||{}},[b,n,xe,a,Y,p,B,k,N]),q=u.useCallback(ce=>{const{action:be,context:X}=ce;be&&K(be.id,X,!be.hotkey)},[K]);async function V(ce){await Promise.resolve();const{name:be,size:X}=ce.file;b.exec("create-file",{file:{name:be,size:X,date:new Date,file:ce.file},parent:_})}return s.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:l,"data-menu-ignore":"false",children:p&&T?s.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:s.jsx(sh,{narrowMode:p,extraInfo:r})}):s.jsxs(s.Fragment,{children:[s.jsx(BA,{narrowMode:p,onShowTree:G}),s.jsx(s1,{dataKey:"id",at:"point",options:D,resolver:Q,onClick:q,children:s.jsxs(Fb,{dataKey:"actionId",options:D,resolver:Q,onClick:q,children:[s.jsx(c1,{data:x,apiOnly:!0,uploadURL:V}),s.jsx(pp.Provider,{value:x,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":"",v?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:s.jsx(OA,{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${T?"":"-fit"}`,"data-id":Pn("body"),children:k==="table"?s.jsx(Oh,{panel:R}):s.jsx(FA,{})}),T?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(sh,{extraInfo:r})}):null]})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:`wx-RJbNonjJ wx-content-item${T?"":"-fit"}`,children:k==="panels"?s.jsx(LA,{}):s.jsx(RA,{})}),T?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(sh,{extraInfo:r})}):null]})})})]})})]})})}const $A=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function UA(n,a){const{type:r,ext:l}=n;if(r==="folder")return!1;let c;return r&&r!=="file"&&rx[r]?c=r:l?c=rx[l]?l:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const qA=u.forwardRef(function(n,a){const{data:r=[],mode:l="cards",drive:c=null,preview:d=!1,panels:m=null,activePanel:p=0,readonly:g=!1,menuOptions:v=Pk,extraInfo:w=null,init:x=null,icons:b=UA,previews:C=null,...j}=n,A=u.useRef();A.current=j;const N=u.useMemo(()=>new Fk(Ib),[]),k=u.useMemo(()=>N.in,[N]),T=u.useRef(null);T.current===null&&(T.current=new Eb((O,Y)=>{const _="on"+$A(O);A.current&&A.current[_]&&A.current[_](Y)}),k.setNext(T.current));const R=u.useMemo(()=>({getState:N.getState.bind(N),getReactiveState:N.getReactive.bind(N),getStores:()=>({data:N}),exec:k.exec,setNext:O=>(T.current=T.current.setNext(O),T.current),intercept:k.intercept.bind(k),on:k.on.bind(k),detach:k.detach.bind(k),getFile:N.getFile.bind(N),serialize:N.serialize.bind(N),templates:{preview:C||(()=>null),icon:b==="simple"?(()=>null):b}}),[N,k]),U=u.useRef(0);return u.useEffect(()=>{if(!U.current)x&&x(R);else{const O=N.getState();N.init({data:r,mode:l,drive:c,preview:d,panels:m||O.panels||[],activePanel:p})}U.current++},[N,r,l,c,d,m,p,x,R]),U.current===0&&N.init({data:r,mode:l,drive:c,preview:d,panels:m||[],activePanel:p}),u.useImperativeHandle(a,()=>({...R}),[R]),s.jsx($n.Provider,{value:R,children:s.jsx(up,{words:dp,optional:!0,children:s.jsx(MA,{children:s.jsx(PA,{readonly:g,menuOptions:v,extraInfo:w})})})})});function GA({fonts:n=!0,children:a}){return a?s.jsx(Gy,{fonts:n,children:a}):s.jsx(Gy,{fonts:n})}ap(La);function gp(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function Wc(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 VA(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 WA(n,a=!1){return Wc(await Ge(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function ih(n,a){const r=await Ge(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:VA(r,"folder","filesystem entries"),entries:Wc(r,"entries","filesystem entries")}}async function YA(n,a){return Ge("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function KA(n,a,r,l){return Ge("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:r})},l)}async function QA(n,a=!1){const r=await Ge(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:Wc(r,"jobs","file transfer jobs")}}async function XA(n,a){return Ge(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function ZA(n,a){return Ge(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function lx(n){return Wc(await Ge("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function JA(n,a){return Ge("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function eN(n,a,r){return Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},r)}async function tN(n,a){return Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function nN(n,a,r,l){const c=await Ge(`/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:Wc(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function aN(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 ox(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 zd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function sN(n){const a=n.filter(r=>zd(r)==="local");return a.find(r=>/\bC:/i.test(`${r.name} ${r.displayPath||""}`))||a[0]||n[0]||null}function iN({hubUrl:n,roots:a,loading:r,error:l,onRefreshRoots:c,onImportFiles:d,onImportFolder:m,onSelectionChange:p,onShareItem:g,onAddSyncFolder:v,onNotice:w}){const x=u.useRef(null),b=u.useRef("/"),C=u.useRef(0),j=u.useRef([]),A=u.useRef(new Map),[N,k]=u.useState(null),[T,R]=u.useState([]),[U,O]=u.useState([]),[Y,_]=u.useState(0),[D,ne]=u.useState(null),[G,te]=u.useState(!1),[B,xe]=u.useState(""),[se,K]=u.useState(new Set),I=a.find(ae=>ae.id===N)||null,Q=T[T.length-1]||null,q=I?Q?.svarPath||`/${I.name}`:null,V=q;u.useEffect(()=>{j.current=T,b.current=V||"/"},[V,T]);const ce=u.useMemo(()=>(A.current.clear(),!I||!V||T.length===0?[]:(T.forEach(ae=>A.current.set(ae.svarPath,ae.hubId)),[...T.map((ae,fe)=>({id:ae.svarPath,parent:fe===0?"/":T[fe-1].svarPath,type:"folder",name:ae.name,date:ae.modifiedAt?new Date(ae.modifiedAt):void 0,lazy:!1})),...U.map(ae=>{const fe=`${V}/${ae.name}`;return A.current.set(fe,ae.id),{id:fe,parent:V,name:ae.name,type:ae.type==="file"?"file":"folder",...ae.type==="file"?{size:ae.size}:{},date:ae.modifiedAt?new Date(ae.modifiedAt):void 0,lazy:ae.type!=="file"&&ae.hasChildren===!0,displayPath:ae.displayPath,locked:ae.locked,driveType:ae.driveType,totalBytes:ae.totalBytes,freeBytes:ae.freeBytes}})])),[I,U,V,T]),be=ae=>A.current.get(String(ae))||String(ae),X=ae=>aN({...ae,id:be(String(ae.id)),parent:be(String(ae.parent))}),$=async(ae,fe)=>{const Ae=ae[ae.length-1];if(!Ae)return;const Te=++C.current;te(!0),xe("");try{const Be=await ih(Ae.hubId,n);if(Te!==C.current)return;if(!Array.isArray(Be.entries))throw new Error("Invalid Hub filesystem entries response.");const Ve={...Ae,displayPath:Be.folder.displayPath||Ae.displayPath,modifiedAt:Be.folder.modifiedAt||Ae.modifiedAt},Je=[...ae.slice(0,-1),Ve];j.current=Je,R(Je),O(Be.entries),_(Et=>Et+1)}catch(Be){if(Te!==C.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:Ae.hubId,error:Be}),xe(Be instanceof Error?`${fe}: ${Be.message}`:`${fe}: Unable to read this folder.`)}finally{Te===C.current&&te(!1)}},ue=async ae=>{const fe={svarPath:`/${ae.name}`,hubId:ae.id,name:ae.name,displayPath:ae.displayPath,modifiedAt:ae.modifiedAt},Ae=++C.current;k(ae.id),j.current=[fe],R([fe]),b.current=fe.svarPath,O([]),xe(""),te(!0),ne(ae.id),K(Te=>{const Be=new Set(Te);return Be.delete(ae.id),Be});try{const Te=await ih(ae.id,n);if(Ae!==C.current)return;if(!Array.isArray(Te.entries))throw new Error("Invalid Hub filesystem entries response.");const Be={...fe,displayPath:Te.folder.displayPath||fe.displayPath,modifiedAt:Te.folder.modifiedAt||fe.modifiedAt};j.current=[Be],R([Be]),O(Te.entries),_(Ve=>Ve+1)}catch(Te){if(Ae!==C.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:ae.id,error:Te}),K(Be=>new Set(Be).add(ae.id)),xe(Te instanceof Error?`${ae.name}: ${Te.message}`:`${ae.name}: Unable to read this drive.`),w(Te instanceof Error?`${ae.name}: ${Te.message}`:`${ae.name}: Unable to read this drive.`)}finally{Ae===C.current&&(ne(null),te(!1))}},he=ae=>{const fe=j.current;ae<0||ae>=fe.length||ae===fe.length-1||$(fe.slice(0,ae+1),fe[ae].name)},ve=(ae,fe)=>{if(ae.type!=="folder")return;const Ae=j.current,Te=Ae.findIndex(Ve=>Ve.svarPath===fe);if(Te<0)return;const Be={svarPath:`${fe}/${ae.name}`,hubId:ae.id,name:ae.name,displayPath:ae.displayPath,modifiedAt:ae.modifiedAt};$([...Ae.slice(0,Te+1),Be],ae.name)},Se=()=>he(j.current.length-2),_e=ae=>{if(ae.key!=="Enter"&&ae.code!=="Enter"&&ae.code!=="NumpadEnter"||ae.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const Ae=x.current;if(!Ae)return;const Te=Ae.getState().panels?.flatMap(Ve=>Ve.selected||[])||[];if(Te.length!==1)return;const Be=Ae.getFile(String(Te[0]));Be?.type==="folder"&&(ae.preventDefault(),ae.stopPropagation(),ve(X(Be),String(Be.parent||b.current)))};u.useEffect(()=>{const ae=a.find(fe=>fe.id===N)||sN(a);if(K(fe=>new Set([...fe].filter(Ae=>a.some(Te=>Te.id===Ae)))),!ae){k(null),j.current=[],R([]),O([]);return}ue(ae)},[a]);const re=ae=>{x.current=ae,ae.on("request-data",async({id:fe})=>{const Ae=String(fe),Te=be(Ae);try{const Be=await ih(Te,n);if(!Array.isArray(Be.entries))throw new Error("Invalid Hub filesystem entries response.");const Ve=Be.entries.map(Je=>{const Et=`${Ae}/${Je.name}`;return A.current.set(Et,Je.id),{id:Et,parent:Ae,name:Je.name,type:Je.type==="file"?"file":"folder",...Je.type==="file"?{size:Je.size}:{},date:Je.modifiedAt?new Date(Je.modifiedAt):void 0,lazy:Je.type!=="file"&&Je.hasChildren===!0,displayPath:Je.displayPath,locked:Je.locked,driveType:Je.driveType,totalBytes:Je.totalBytes,freeBytes:Je.freeBytes}});await ae.exec("provide-data",{id:Ae,data:Ve})}catch(Be){console.error("[LiveDesk FS] nested getEntries failed",{id:Te,error:Be}),w(Be instanceof Error?Be.message:"Unable to read this folder.")}}),ae.intercept("set-path",({id:fe})=>{const Ae=String(fe),Te=j.current.findIndex(Ve=>Ve.svarPath===Ae);if(Te>=0)return he(Te),!1;const Be=ae.getFile(Ae);if(Be?.type==="folder")return ve(X(Be),String(Be.parent||b.current)),!1}),ae.intercept("open-file",()=>!1),ae.on("select-file",()=>{window.setTimeout(()=>{const Te=(ae.getState().panels?.flatMap(Be=>Be.selected||[])||[]).map(Be=>ae.getFile(Be)).filter(Boolean).map(Be=>X(Be));p(Te.map(Be=>Be.id),Te)},0)})},Z=(ae,fe)=>{const Ae=fe?X(fe):null,Te=()=>{const Be=Ae?.type==="file"?String(fe?.parent||b.current):String(fe?.id||b.current);x.current?.exec("request-data",{id:Be})};return ae==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Te},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w("Select a file or folder to view its properties.")}]:ae==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(x.current?.getState().panels?.flatMap(Ve=>Ve.selected||[])||[]).forEach(Ve=>{const Je=x.current?.getFile(Ve);Je&&g(X(Je))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Te}]:Ae?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>g(Ae)},...Ae.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>v(Ae)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{kl(Ae.displayPath||Ae.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Te},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${Ae.name}
|
|
14
|
-
${Ae.displayPath||""}`)}]:[]},ze=async()=>{try{await c()}catch(ae){w(ae instanceof Error?ae.message:"Unable to refresh Hub drives.")}},De=[{id:"local",label:"Local drives",icon:Nl,roots:a.filter(ae=>zd(ae)==="local")},{id:"removable",label:"Removable drives",icon:KS,roots:a.filter(ae=>zd(ae)==="removable")},{id:"network",label:"Network drives",icon:Kh,roots:a.filter(ae=>zd(ae)==="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(Nl,{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(Kx,{size:16})}),s.jsx("button",{className:"icon-button",onClick:m,title:"Import folder from this browser",type:"button",children:s.jsx(QS,{size:16})}),s.jsx("button",{className:"icon-button",onClick:()=>{ze()},title:"Refresh drives",type:"button",children:s.jsx(Ro,{size:16})})]})]}),r?s.jsxs("div",{className:"hub-file-explorer-state",children:[s.jsx(Nl,{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(Ts,{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(Nl,{size:15}),s.jsx("strong",{children:"This PC"})]}),De.map(ae=>ae.roots.length>0&&s.jsxs("section",{className:"hub-drive-group",children:[s.jsxs("h3",{children:[s.jsx(ae.icon,{size:13}),ae.label]}),s.jsx("div",{className:"hub-drive-list",children:ae.roots.map(fe=>{const Ae=ae.icon,Te=se.has(fe.id)||fe.locked===!0;return s.jsxs("button",{className:`hub-drive-item ${N===fe.id?"active":""} ${Te?"unavailable":""}`,onClick:()=>{ue(fe)},"aria-pressed":N===fe.id,type:"button",children:[s.jsx("span",{className:"hub-drive-item-icon",children:s.jsx(Ae,{size:16})}),s.jsxs("span",{className:"hub-drive-item-copy",children:[s.jsx("strong",{children:fe.name}),s.jsx("small",{children:fe.displayPath||fe.name}),s.jsxs("em",{children:[ox(fe.freeBytes||0)," free / ",ox(fe.totalBytes||0)]})]}),D===fe.id?s.jsx(Js,{className:"hub-drive-item-status spin",size:15}):Te?s.jsx(ay,{className:"hub-drive-item-status",size:15}):null]},fe.id)})})]},ae.id)),a.length===0&&s.jsxs("div",{className:"hub-drive-sidebar-empty",children:[s.jsx(Ts,{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:T.map((ae,fe)=>s.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[fe>0&&s.jsx(Qh,{size:13,"aria-hidden":"true"}),s.jsx("button",{className:`hub-file-explorer-breadcrumb ${fe===T.length-1?"current":""}`,onClick:()=>he(fe),"aria-current":fe===T.length-1?"location":void 0,type:"button",children:ae.name})]},ae.svarPath))}),s.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[G&&s.jsx(Js,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),s.jsx("button",{className:"icon-button",onClick:Se,disabled:T.length<=1||G,title:"Back to parent folder",type:"button",children:s.jsx($x,{size:16})})]})]}),B&&s.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[s.jsx(ay,{size:15}),s.jsx("span",{children:B})]}),s.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:_e,children:s.jsx(GA,{fonts:!1,children:s.jsx(qA,{data:ce,panels:q?[{path:q,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:re,icons:"simple",menuOptions:Z},`${I?.id||"no-root"}:${Y}`)})})]})]})]})}class rN 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(Zd,{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(Ro,{size:15})," Retry"]})]}):this.props.children}}function lN(n){return n.deviceName||n.hostname||n.deviceId}function oN({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(Pc,{size:14})," All connected"]}),s.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>l("selected"),type:"button",children:[s.jsx(an,{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(an,{size:20,"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:lN(m)}),s.jsxs("small",{children:["Slot ",m.slotNumber?String(m.slotNumber).padStart(3,"0"):"-"," / ",m.platform||"unknown OS"]})]}),s.jsx(Fn,{size:17,"aria-hidden":"true"})]},m.deviceId)})})]})}function cN(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 uN({folders:n,loading:a,busy:r,canSync:l,onSyncAll:c,onSync:d,onToggleAuto:m,onRemove:p,onAdd:g}){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(Ed,{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:g,type:"button",children:[s.jsx(Ed,{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(v=>s.jsxs("article",{className:`file-share-sync-row state-${v.status}`,children:[s.jsx("div",{className:"file-share-sync-icon",children:s.jsx(Ed,{size:19})}),s.jsxs("div",{className:"file-share-sync-info",children:[s.jsx("strong",{children:v.name}),s.jsx("span",{children:v.displayPath}),s.jsxs("small",{children:[v.fileCount," files / ",cN(v.totalBytes)," · ",v.lastSyncedAt?`Last sync ${ab(v.lastSyncedAt)} ago`:v.message||"Not synced yet"]})]}),s.jsxs("label",{className:"file-share-auto-sync",children:[s.jsx("input",{type:"checkbox",checked:v.autoSync,onChange:()=>m(v)}),s.jsx("span",{children:"Auto"})]}),s.jsxs("button",{className:"text-button compact",onClick:()=>d(v),disabled:r||!l||v.status==="syncing",type:"button",children:[s.jsx(Ro,{size:14})," Sync now"]}),s.jsx("button",{className:"icon-button",onClick:()=>p(v),title:"Remove sync folder",type:"button",children:s.jsx(Wh,{size:15})})]},v.id))})]})}function dN(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(Bc,{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(oN,{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(Ao,{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(Bc,{size:17})," Share selected"]}),s.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[s.jsx(Ao,{size:16})," Add selected folder to Sync"]})]}):s.jsx(uN,{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 fN(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 cx(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 ux(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 dx(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function mN({hubUrl:n,devices:a,localFeatureAccess:r,upgradeNotice:l,remoteDirectory:c,onRemoteDirectoryChange:d,targetMode:m,selectedTargetIds:p,onTargetModeChange:g,onTargetToggle:v,filePickerRef:w,folderPickerRef:x,onBrowserFileImport:b,onBrowserFolderImport:C,onNotice:j,onTransferChange:A}){const N=Array.isArray(a)?a:[],[k,T]=u.useState([]),[R,U]=u.useState(!0),[O,Y]=u.useState(""),[_,D]=u.useState([]),[ne,G]=u.useState([]),[te,B]=u.useState(null),[xe,se]=u.useState(!1),[K,I]=u.useState([]),[Q,q]=u.useState(!0),[V,ce]=u.useState(!1),[be,X]=u.useState("send"),[$,ue]=u.useState([]),he=u.useRef(new Set),ve=u.useMemo(()=>m==="all"?N.map(je=>je.deviceId):p.filter(je=>N.some(We=>We.deviceId===je)),[N,p,m]),Se=$.find(je=>!dx(je.state)),_e=ne.length===1&&ne[0].type==="folder"?ne[0]:null,re=ne.length===0?"Select files or folders from the Hub explorer.":xe?"Calculating selection size...":te?`${te.files} files, ${te.folders} folders · ${fN(te.totalBytes)}`:`${ne.length} item${ne.length===1?"":"s"} selected`,Z=je=>{A({id:je.jobId,state:je.state,progress:cx(je),message:ux(je)})},ze=u.useCallback(async()=>{const je=await WA(n,!0);return T(je),Y(""),je},[n]),De=async()=>{try{const We=(await QA(n,!0)).jobs||[],it=await Promise.all([...he.current].map(async Kt=>{try{return await XA(Kt,n)}catch{return null}})),ot=[...We,...it.filter(Boolean)],gn=[...new Map(ot.map(Kt=>[Kt.jobId,Kt])).values()];ue(gn),gn.forEach(Z),gn.filter(Kt=>dx(Kt.state)).forEach(Kt=>he.current.delete(Kt.jobId))}catch{}};u.useEffect(()=>{let je=!0;U(!0),Y(""),Promise.all([ze(),lx(n).then(it=>{je&&I(it)})]).catch(it=>{je&&(Y(it instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),j(it instanceof Error?it.message:"Hub file system is unavailable."))}).finally(()=>{je&&(U(!1),q(!1))}),De();const We=window.setInterval(()=>{De()},800);return()=>{je=!1,window.clearInterval(We)}},[n,ze]),u.useEffect(()=>{if(_.length===0){B(null);return}let je=!1;return se(!0),YA(_,n).then(We=>{je||B(We)}).catch(We=>{je||j(We instanceof Error?We.message:"Unable to calculate selected size.")}).finally(()=>{je||se(!1)}),()=>{je=!0}},[n,_.join("|")]);const ae=(je,We)=>{D(je),G(We)},fe=je=>{je.forEach(We=>he.current.add(We.jobId)),ue(We=>[...new Map([...We,...je].map(it=>[it.jobId,it])).values()]),je.forEach(Z)},Ae=async()=>{if(!r){j(l);return}if(_.length===0){j("Select files or folders from the Hub explorer.");return}if(ve.length===0){j("Choose at least one connected workstation.");return}if(Se){j("A Hub transfer is already running.");return}try{const je=await KA(_,ve,c.trim(),n);he.current.add(je.jobId),j("Hub transfer queued."),await De()}catch(je){j(je instanceof Error?je.message:"Unable to start Hub transfer.")}},Te=async je=>{const We=je||_e;if(!We||We.type!=="folder"){j("Select one folder to add it to Sync.");return}try{const it=await JA(We.id,n);I(ot=>[...ot.filter(gn=>gn.id!==it.folder.id),it.folder]),X("sync"),j(`${We.name} is ready for Hub sync.`)}catch(it){j(it instanceof Error?it.message:"Unable to add the Hub folder to Sync.")}},Be=async je=>{if(ve.length===0){j("Choose at least one connected workstation.");return}ce(!0),I(We=>We.map(it=>it.id===je.id?{...it,status:"syncing"}:it));try{const We=await nN(je.id,ve,c.trim(),n);fe(We.jobs||[]),j(We.jobs?.length?"Hub sync queued.":"No changed files to sync.");const it=await lx(n);I(it)}catch(We){j(We instanceof Error?We.message:"Unable to sync the Hub folder."),I(it=>it.map(ot=>ot.id===je.id?{...ot,status:"error",message:"Sync failed"}:ot))}finally{ce(!1)}},Ve=async()=>{ce(!0);try{for(const je of K)await Be(je)}finally{ce(!1)}},Je=async je=>{try{const We=await eN(je.id,{autoSync:!je.autoSync},n);I(it=>it.map(ot=>ot.id===je.id?We.folder:ot))}catch(We){j(We instanceof Error?We.message:"Unable to update auto sync.")}},Et=async je=>{try{await tN(je.id,n),I(We=>We.filter(it=>it.id!==je.id))}catch(We){j(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:je=>{je.currentTarget.files&&b(je.currentTarget.files),je.currentTarget.value=""}}),s.jsx("input",{ref:x,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:je=>{je.currentTarget.files&&C(je.currentTarget.files),je.currentTarget.value=""}}),s.jsx("div",{className:"file-share-workspace",children:s.jsxs(rN,{onRetry:()=>window.location.reload(),children:[s.jsx(iN,{hubUrl:n,roots:k,loading:R,error:O,onRefreshRoots:ze,onImportFiles:()=>w.current?.click(),onImportFolder:()=>x.current?.click(),onSelectionChange:ae,onShareItem:je=>{D([je.id]),G([je]),X("send")},onAddSyncFolder:je=>{D([je.id]),G([je]),Te(je)},onNotice:j}),s.jsx(dN,{devices:N,targetMode:m,selectedTargetIds:p,onTargetModeChange:g,onTargetToggle:v,remoteDirectory:c,onRemoteDirectoryChange:d,selectedEntries:ne,selectedSummary:re,canShare:r&&!Se&&_.length>0&&ve.length>0&&!xe,onShare:()=>{Ae()},canAddSync:!!_e,onAddSync:()=>{Te()},tab:be,onTabChange:X,folders:K,foldersLoading:Q,syncBusy:V,onSyncAll:()=>{Ve()},onSync:je=>{Be(je)},onToggleAuto:je=>{Je(je)},onRemove:je=>{Et(je)},onAddFolder:()=>{Te()}})]})}),Se&&s.jsx("footer",{className:"file-share-workspace-footer",children:s.jsxs("span",{children:[ux(Se)," · ",cx(Se),"% ",s.jsx("button",{className:"icon-button",onClick:()=>{ZA(Se.jobId,n).then(je=>{ue(We=>We.map(it=>it.jobId===je.jobId?je:it)),Z(je)})},title:"Cancel transfer",type:"button",children:s.jsx(Ya,{size:14})})]})})]})}const hN=u.forwardRef(function({value:a,onChange:r,onSubmit:l,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:m,disabled:p=!1,placeholder:g="Ask LiveDesk to work across your machines..."},v){return s.jsxs("form",{className:"agents-composer",onSubmit:w=>{w.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(XS,{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:w=>r(w.target.value.slice(0,4e3)),placeholder:g,"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(Js,{className:"spin",size:16}):s.jsx(Bc,{size:16}),p?"Running":"Run"]})]})}),pN=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function Yd(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function Kd(n){return n.connected!==!0?!1:n.synthetic===!0?!0:!n.channels||n.channels.control===!0}function gN(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function vN(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 yN(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Va(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Sd(n){const a=Va(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 xN(n){const a=Va(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function bN(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function Qd(n,a){if(a.error)return a.error;const r=yN(a.data),l=bN(a.result||"");if(!r)return l||a.stage||a.status;if(n==="system.health"){const c=typeof r.machine=="string"?r.machine:"",d=Sd(r.freeMemoryBytes),m=Sd(r.totalMemoryBytes),p=Va(r.totalMemoryBytes)&&Va(r.freeMemoryBytes)!==null?`${Math.round(Va(r.freeMemoryBytes)/Va(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=Sd(r.freeBytes),m=Va(r.totalBytes)&&Va(r.freeBytes)!==null?`${Math.round(Va(r.freeBytes)/Va(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=xN(r.usageRatio),m=Va(r.temperatureC)!==null?`${Math.round(Va(r.temperatureC))}°C`:"",p=Sd(r.freeMemoryBytes);return[c,d&&`GPU ${d}`,m,p&&`${p} free`].filter(Boolean).join(" · ")||l||a.status}if(n==="process.list"){const c=Va(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 fx(n,a){const r=Qd(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 wN({state:n,operation:a}){const r=n.status==="completed"?Ii:n.status==="failed"||n.status==="cancelled"?Ya:n.status==="running"?Js:Qx,l=n.status==="running"?n.stage||"Working":n.status==="completed"?a?Qd(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 SN({operation:n,states:a,status:r,onCancel:l,onRetry:c,busy:d=!1}){const m=["running","queued"].includes(r),[p,g]=u.useState(!1),[v,w]=u.useState("all"),x=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=>fx(n,R)),C=b.filter(R=>R.status==="completed").length,j=x.failed>0,A=b.length>0,N=a.filter(R=>v==="issues"?fx(n,R):v==="running"?R.status==="running"||R.status==="queued":v==="completed"?R.status==="completed":v==="failed"?R.status==="failed":!0),k=A&&!m||r==="completed-with-failures"?"Completed with issues":r[0]?.toUpperCase()+r.slice(1),T=a.filter(R=>R.status==="completed").map(R=>Qd(n,R)).filter(Boolean).filter((R,U,O)=>O.indexOf(R)===U).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:vN(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:[x.total," targets"]}),s.jsxs("span",{className:"summary-completed",children:[x.completed," completed"]}),x.running>0&&s.jsxs("span",{className:"summary-running",children:[x.running," running"]}),x.queued>0&&s.jsxs("span",{children:[x.queued," queued"]}),j&&s.jsxs("span",{className:"summary-failed",children:[x.failed," failed"]}),C>0&&s.jsxs("span",{className:"summary-cancelled",children:[C," warning"]}),x.cancelled>0&&s.jsxs("span",{className:"summary-cancelled",children:[x.cancelled," cancelled"]})]}),T.length>0&&s.jsxs("div",{className:"agent-task-result-preview",title:T.join(" · "),children:[s.jsx("span",{children:"Result"}),T.join(" · ")]}),s.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((R,U)=>{const O=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}: ${Qd(n,R)}`,"aria-label":`${U+1}. ${R.deviceName}: ${R.status}`,children:[s.jsx("b",{children:String(U+1).padStart(2,"0")}),s.jsx("span",{children:O})]},R.deviceId)})}),a.length>0&&s.jsx("div",{className:"agent-task-details-toggle",children:s.jsxs("button",{type:"button",onClick:()=>g(R=>!R),"aria-expanded":p,children:[p?s.jsx(ZS,{size:14}):s.jsx(Xx,{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:v===R?"active":"",onClick:()=>w(R),role:"tab","aria-selected":v===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:N.length>0?N.map(R=>s.jsx(wN,{operation:n,state:R},R.deviceId)):s.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(m||j)&&s.jsxs("div",{className:"agent-task-actions",children:[m&&l&&s.jsxs("button",{onClick:l,disabled:d,type:"button",children:[s.jsx(JS,{size:14})," Cancel"]}),!m&&j&&c&&s.jsxs("button",{onClick:c,disabled:d,type:"button",children:[s.jsx(Lc,{size:14})," Retry failed"]})]})]})}function CN(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function jN({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:CN(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(Ya,{size:14})," Reject"]}),s.jsxs("button",{disabled:a,onClick:()=>r("once"),type:"button",children:[s.jsx(Ii,{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(Zd,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function kN(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 AN({items:n,onCancel:a,onRetry:r,busyBatchId:l,approvals:c,onApprove:d,onReject:m,busyApprovalId:p,progress:g,emptyTitle:v="Ask LiveDesk to work across your machines.",emptyBody:w="Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."}){const x=u.useRef(null),b=u.useRef(!0),C=u.useRef(""),j=n[n.length-1];return u.useLayoutEffect(()=>{const A=x.current;A&&(j?.type==="user"&&j.id!==C.current&&(b.current=!0),C.current=j?.id||"",b.current&&(A.scrollTop=A.scrollHeight))},[c,n,j?.id,j?.type,g?.message,g?.stage]),s.jsxs("section",{className:"agents-conversation","aria-live":"polite",ref:x,onScroll:A=>{const N=A.currentTarget;b.current=N.scrollHeight-N.scrollTop-N.clientHeight<72},children:[c.filter(A=>A.status==="pending").map(A=>s.jsx(jN,{approval:A,busy:p===A.approvalId,onApprove:N=>d(A,N),onReject:()=>m(A)},A.approvalId)),n.length===0&&s.jsxs("div",{className:"agents-empty-conversation",children:[s.jsx("strong",{children:v}),s.jsx("span",{children:w})]}),n.map(A=>{if(A.type==="task"){const N=A;return s.jsx(SN,{operation:N.operation,states:N.states,status:N.status,onCancel:()=>a(N.batchId,N.agentRunId),onRetry:()=>r(N.batchId),busy:l===N.batchId},N.id)}return s.jsxs("article",{className:`agents-message ${A.type}`,children:[s.jsx("span",{children:A.type==="user"?"You":"LiveDesk Agent"}),s.jsx("p",{children:A.text})]},A.id)}),g&&s.jsxs("article",{className:"agents-message agent agents-progress-message",role:"status",children:[s.jsxs("span",{children:[s.jsx(Js,{"aria-hidden":"true",size:15}),kN(g.stage)]}),s.jsx("p",{children:g.message})]})]})}const mx=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],Sn=["windows","macos","linux"],Lr={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:Sn},"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:Sn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:Sn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:Sn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:Sn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:Sn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:Sn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:Sn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:Sn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn}};new Set(Object.keys(Lr));const NN={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","문제해결","복구","장애"]},hx=["low","medium","high","critical"];function MN(n){return n.reduce((a,r)=>{const l=Lr[r].risk;return hx.indexOf(l)>hx.indexOf(a)?l:a},"low")}function TN(n){return Sn.filter(a=>n.every(r=>Lr[r].supportedPlatforms.includes(a)))}function Ue(n,a,r,l,c,d,m={}){const p=m.description||l,g=c.flatMap(w=>w.split(".")),v=[...new Set([...NN[a],...d,...g])];return{id:n,category:a,title:r,prompt:l,description:p,requiredOperations:c,risk:m.risk||MN(c),targetSupport:m.targetSupport||"single-or-multiple",supportedPlatforms:m.supportedPlatforms||TN(c),keywords:v,recommended:m.recommended??!1,enabled:!0}}const tw=[Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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","높은 사용량"]),Ue("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Ue("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Ue("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"]),Ue("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","디스크"]),Ue("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Ue("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","경고"]),Ue("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"]),Ue("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","실행 중"]),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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","서비스 상태"]),Ue("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"}),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"]),Ue("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"]),Ue("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"}),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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","구성"]),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"]}),Ue("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"]}),Ue("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"]}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"]),Ue("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"}),Ue("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Ue("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Ue("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Ue("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"]),Ue("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"]),Ue("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"]),Ue("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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","장애 보고서"])],rh={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 EN(n,a){return n==="safe-auto"?rh:n==="full-access"?{...rh,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{...rh,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function RN(n,a,r){const l=EN(a,r),c=n.requiredOperations.map(d=>l[Lr[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(m=>l[Lr[m].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${Lr[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=>Lr[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function DN(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 LN(n,a,r){const l=new Set(r);return n.filter(c=>c.connected&&(a==="all"||a==="auto"||l.has(c.deviceId)))}function _N(n,a){const r=DN(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=>Lr[c].readOnly):a.requiredOperations.every(c=>l.includes(c))}function nw(n,a,r,l,c,d){const m=RN(n,c,d),p=LN(a,r,l),g=p.map(C=>C.deviceId),v={...m,available:!1,availableDeviceIds:[],unsupportedDeviceIds:g,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...v,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...v,reason:"This task supports one workstation at a time."};if(m.state==="blocked")return v;const w=p.filter(C=>_N(C,n)),x=w.map(C=>C.deviceId),b=g.filter(C=>!x.includes(C));return w.length===0?{...v,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...v,available:!0,availableDeviceIds:x,unsupportedDeviceIds:b}}function zN(n,a,r,l,c,d){return n.filter(m=>m.enabled&&nw(m,a,r,l,c,d).available).length}const lh="livedesk.agentPromptRecent",oh="livedesk.agentPromptFavorites",IN={Recommended:Es,"Health & capacity":pn,"Processes & services":s0,"AI workloads":Vx,"Files & configuration":a0,"Software & automation":Bd,"Network & connectivity":Kh,"Power & maintenance":Bt,"Troubleshooting & recovery":n0};function px(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 Cd(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function ch(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 ON(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 HN(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 BN(n){return`permission-${n}`}function FN(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function PN(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function $N({devices:n,targetMode:a,selectedIds:r,permissionMode:l,customCategories:c,onSelectPrompt:d,onClose:m}){const[p,g]=u.useState(""),[v,w]=u.useState("all"),[x,b]=u.useState(()=>px(lh)),[C,j]=u.useState(()=>px(oh)),[A,N]=u.useState(0),[k,T]=u.useState(""),R=u.useRef(null),U=u.useRef(null),O=u.useMemo(()=>tw.filter(K=>K.enabled),[]),Y=u.useMemo(()=>new Map(O.map(K=>[K.id,nw(K,n,a,r,l,c)])),[c,n,l,r,a,O]),_=u.useMemo(()=>[...Y.values()].filter(K=>K.available).length,[Y]),D=u.useMemo(()=>n.filter(K=>K.connected&&(a==="all"||a==="auto"||r.includes(K.deviceId))).length,[n,r,a]),ne=u.useMemo(()=>{const K=O.filter(I=>HN(I,Y.get(I.id),p));return v==="recent"?x.map(I=>K.find(Q=>Q.id===I)).filter(I=>!!I):v==="favorites"?C.map(I=>K.find(Q=>Q.id===I)).filter(I=>!!I):v==="all"?K:K.filter(I=>{const Q=Y.get(I.id);return v==="read-only"?Q.state==="read-only":v==="auto"?Q.state==="auto":v==="approval"?Q.state==="approval":v==="full-access"?Q.state==="full-access":v==="available"?Q.available:v==="unavailable"?!Q.available:I.category===v})},[Y,C,v,x,p,O]),G=u.useMemo(()=>v!=="all"?[{category:ch(v),templates:ne}]:mx.map(K=>({category:K,templates:ne.filter(I=>I.category===K)})).filter(K=>K.templates.length>0),[v,ne]);u.useEffect(()=>{N(K=>Math.min(K,Math.max(0,ne.length-1)))},[ne.length]),u.useEffect(()=>{Cd(lh,x)},[x]),u.useEffect(()=>{Cd(oh,C)},[C]),u.useEffect(()=>{U.current?.focus();const K=Q=>{Q.target instanceof Node&&!R.current?.contains(Q.target)&&m()},I=Q=>{Q.key==="Escape"&&(Q.preventDefault(),m())};return document.addEventListener("pointerdown",K),document.addEventListener("keydown",I),()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",I)}},[m]);const te=K=>{const I=Y.get(K.id);if(!I.available){T(I.reason||"This task is not available for the current targets and permission policy.");return}const Q=[K.id,...x.filter(q=>q!==K.id)].slice(0,10);b(Q),Cd(lh,Q),d(K.prompt),m()},B=K=>{j(I=>{const Q=I.includes(K)?I.filter(q=>q!==K):[K,...I];return Cd(oh,Q),Q})},xe=K=>{K.key==="ArrowDown"?(K.preventDefault(),N(I=>Math.min(I+1,Math.max(0,ne.length-1)))):K.key==="ArrowUp"?(K.preventDefault(),N(I=>Math.max(I-1,0))):K.key==="Enter"&&ne[A]&&(K.preventDefault(),te(ne[A]))};let se=-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(Es,{size:15})," Suggested tasks"]}),s.jsxs("small",{children:[_," available · ",O.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(Ya,{size:16})})]}),s.jsxs("label",{className:"agents-suggested-search",children:[s.jsx(e0,{size:15,"aria-hidden":"true"}),s.jsx("input",{ref:U,value:p,onChange:K=>g(K.target.value),onKeyDown:xe,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",...mx].map(K=>{const I=K==="recent"?Gx:K==="favorites"?Sh:K==="all"?Es:K==="available"?Fn:K==="unavailable"?t0:K==="read-only"||K==="auto"||K==="approval"||K==="full-access"?Bt:IN[K];return s.jsxs("button",{className:v===K?"active":"",type:"button",title:ch(K),"aria-label":ch(K),"aria-pressed":v===K,onClick:()=>{w(K),N(0),T("")},children:[s.jsx(I,{size:12})," ",ON(K)]},K)})}),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:[G.map(K=>s.jsxs("div",{className:"agents-suggested-group",children:[s.jsx("strong",{children:K.category}),K.templates.map(I=>{se+=1;const Q=se===A,q=C.includes(I.id),V=Y.get(I.id),ce=V.availableDeviceIds.length+V.unsupportedDeviceIds.length||D,be=V.available?`Available on ${V.availableDeviceIds.length} of ${ce} target${ce===1?"":"s"}`:`Unavailable: ${V.reason||"not supported by the current targets"}`;return s.jsxs("div",{className:`agents-suggested-item ${Q?"active":""} ${V.available?"":"unavailable"}`,children:[s.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Q,"aria-disabled":!V.available,onClick:()=>te(I),children:[s.jsx("span",{children:I.title}),s.jsx("small",{className:"agents-suggested-description",children:I.description}),s.jsxs("span",{className:"agents-suggested-meta",children:[s.jsx("em",{children:I.category}),s.jsx("em",{className:BN(V.state),children:V.label}),s.jsx("em",{className:`risk-${I.risk}`,children:FN(I.risk)}),s.jsx("em",{children:I.supportedPlatforms.map(PN).join(" · ")}),s.jsx("em",{className:V.available?"availability-ok":"availability-unavailable",children:be}),V.available&&V.unsupportedDeviceIds.length>0&&s.jsxs("em",{className:"availability-warning",children:["Unsupported on ",V.unsupportedDeviceIds.length]})]})]}),s.jsx("button",{className:`agents-suggested-favorite ${q?"favorite":""}`,type:"button","aria-label":q?`Remove ${I.title} from favorites`:`Add ${I.title} to favorites`,"aria-pressed":q,onClick:()=>B(I.id),children:s.jsx(Sh,{size:14,fill:q?"currentColor":"none"})})]},I.id)})]},K.category)),ne.length===0&&s.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function UN({devices:n,mode:a,selectedIds:r,onModeChange:l,onToggle:c,permissionMode:d,onPermissionModeChange:m}){const p=n.filter(Kd),g=r.filter(v=>p.some(w=>w.deviceId===v)).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(Pc,{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(Ii,{size:14})," Selected ",g]}),s.jsxs("button",{className:a==="auto"?"active":"",onClick:()=>l("auto"),type:"button",children:[s.jsx(Es,{size:14})," Auto"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Saved workstation groups are coming next.",children:[s.jsx(Pc,{size:14})," Group ",s.jsx("small",{children:"Soon"})]})]}),s.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[s.jsx(Zd,{size:14}),s.jsx("span",{children:"Permission"}),s.jsxs("select",{value:d,onChange:v=>m(v.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(Xx,{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(v=>{const w=Kd(v),x=a==="all"||a==="auto"?w:r.includes(v.deviceId);return s.jsxs("label",{className:`agents-target-option ${x?"selected":""} ${w?"":"offline"}`,children:[s.jsx("input",{type:"checkbox",checked:x,disabled:!w||a!=="selected",onChange:()=>c(v.deviceId)}),s.jsx("span",{className:"agents-target-icon",children:s.jsx(an,{size:15})}),s.jsxs("span",{children:[s.jsx("strong",{children:Yd(v)}),s.jsx("small",{children:w?"Ready":v.connected?"Agent reconnecting":"Offline"})]}),x&&s.jsx(Ii,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},v.deviceId)})})]})}async function qN(n,a){return Ge("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function GN(n,a){return Ge("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function VN(n,a){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function WN(n,a){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function YN(n){return Ge("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function KN(n,a,r,l){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/approve`,{method:"POST",body:JSON.stringify({scope:l})},n)}async function QN(n,a,r,l="User rejected this action."){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify({reason:l})},n)}async function XN(n,a,r){return Ge(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:r})},n)}async function ZN(n,a){return Ge("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function JN(n,a){return Ge("/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 eM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function tM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function nM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function wl(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function jd(n,a){const r=new Map(a.map(l=>[l.deviceId,Yd(l)]));return n.results.map(l=>({deviceId:l.deviceId,deviceName:l.deviceName||r.get(l.deviceId)||l.deviceId,status:gN(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 aM(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 sM(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 g=p.result||"";return!/not running|no process/i.test(g)&&/running|online|found/i.test(g)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return l.length>0?`${m}
|
|
8
|
+
`+o.stack}}var Je=Object.prototype.hasOwnProperty,Et=n.unstable_scheduleCallback,je=n.unstable_cancelCallback,We=n.unstable_shouldYield,it=n.unstable_requestPaint,ot=n.unstable_now,gn=n.unstable_getCurrentPriorityLevel,Kt=n.unstable_ImmediatePriority,Ie=n.unstable_UserBlockingPriority,ct=n.unstable_NormalPriority,_t=n.unstable_LowPriority,Ft=n.unstable_IdlePriority,ge=n.log,Oe=n.unstable_setDisableYieldValue,Fe=null,ke=null;function st(e){if(typeof ge=="function"&&Oe(e),ke&&typeof ke.setStrictMode=="function")try{ke.setStrictMode(Fe,e)}catch{}}var gt=Math.clz32?Math.clz32:Ls,Re=Math.log,jn=Math.LN2;function Ls(e){return e>>>=0,e===0?32:31-(Re(e)/jn|0)|0}var nt=256,zt=262144,zn=4194304;function He(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 ya(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 E=o&134217727;return E!==0?(o=E&~h,o!==0?f=He(o):(S&=E,S!==0?f=He(S):i||(i=E&~e,i!==0&&(f=He(i))))):(E=o&~h,E!==0?f=He(E):S!==0?f=He(S):i||(i=o&~e,i!==0&&(f=He(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 dt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Hi(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 Qt(){var e=zn;return zn<<=1,(zn&62914560)===0&&(zn=4194304),e}function ps(e){for(var t=[],i=0;31>i;i++)t.push(e);return t}function bt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qn(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 E=e.entanglements,P=e.expirationTimes,le=e.hiddenUpdates;for(i=S&~i;0<i;){var ye=31-gt(i),Ce=1<<ye;E[ye]=0,P[ye]=-1;var oe=le[ye];if(oe!==null)for(le[ye]=null,ye=0;ye<oe.length;ye++){var me=oe[ye];me!==null&&(me.lane&=-536870913)}i&=~Ce}o!==0&&_s(e,o,0),h!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=h&~(S&~t))}function _s(e,t,i){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-gt(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|i&261930}function H(e,t){var i=e.entangledLanes|=t;for(e=e.entanglements;i;){var o=31-gt(i),f=1<<o;f&t|e[o]&t&&(e[o]|=t),i&=~f}}function Pe(e,t){var i=t&-t;return i=(i&42)!==0?1:vt(i),(i&(e.suspendedLanes|t))!==0?0:i}function vt(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 sn(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Qa(){var e=Q.p;return e!==0?e:(e=window.event,e===void 0?32:Yv(e.type))}function Br(e,t){var i=Q.p;try{return Q.p=e,t()}finally{Q.p=i}}var Xa=Math.random().toString(36).slice(2),ee="__reactFiber$"+Xa,Ne="__reactProps$"+Xa,qe="__reactContainer$"+Xa,rt="__reactEvents$"+Xa,Nt="__reactListeners$"+Xa,Mt="__reactHandles$"+Xa,Qe="__reactResources$"+Xa,ut="__reactMarker$"+Xa;function kn(e){delete e[ee],delete e[Ne],delete e[rt],delete e[Nt],delete e[Mt]}function Wt(e){var t=e[ee];if(t)return t;for(var i=e.parentNode;i;){if(t=i[qe]||i[ee]){if(i=t.alternate,t.child!==null||i!==null&&i.child!==null)for(e=Dv(e);e!==null;){if(i=e[ee])return i;e=Dv(e)}return t}e=i,i=e.parentNode}return null}function An(e){if(e=e[ee]||e[qe]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function St(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(l(33))}function rn(e){var t=e[Qe];return t||(t=e[Qe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Pt(e){e[ut]=!0}var xa=new Set,ca={};function cn(e,t){vn(e,t),vn(e+"Capture",t)}function vn(e,t){for(ca[e]=t,e=0;e<t.length;e++)xa.add(t[e])}var Fr=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]*$"),zs={},Pr={};function zo(e){return Je.call(Pr,e)?!0:Je.call(zs,e)?!1:Fr.test(e)?Pr[e]=!0:(zs[e]=!0,!1)}function Bi(e,t,i){if(zo(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 Il(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 Za(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 Zt(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ol(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ja(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 Xn(e){if(!e._valueTracker){var t=Ol(e)?"checked":"value";e._valueTracker=Ja(e,t,""+e[t])}}function Is(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var i=t.getValue(),o="";return e&&(o=Ol(e)?e.checked?"true":"false":e.value),e=o,e!==i?(t.setValue(e),!0):!1}function Os(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 $r=/[\n"\\]/g;function Gn(e){return e.replace($r,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function ai(e,t,i,o,f,h,S,E){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=""+Zt(t)):e.value!==""+Zt(t)&&(e.value=""+Zt(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?Hs(e,S,Zt(t)):i!=null?Hs(e,S,Zt(i)):o!=null&&e.removeAttribute("value"),f==null&&h!=null&&(e.defaultChecked=!!h),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+Zt(E):e.removeAttribute("name")}function si(e,t,i,o,f,h,S,E){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)){Xn(e);return}i=i!=null?""+Zt(i):"",t=t!=null?""+Zt(t):i,E||t===e.value||(e.value=t),e.defaultValue=t}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=E?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),Xn(e)}function Hs(e,t,i){t==="number"&&Os(e.ownerDocument)===e||e.defaultValue===""+i||(e.defaultValue=""+i)}function Bs(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=""+Zt(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 Fi(e,t,i){if(t!=null&&(t=""+Zt(t),t!==e.value&&(e.value=t),i==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=i!=null?""+Zt(i):""}function Ur(e,t,i,o){if(t==null){if(o!=null){if(i!=null)throw Error(l(92));if(K(o)){if(1<o.length)throw Error(l(93));o=o[0]}i=o}i==null&&(i=""),t=i}i=Zt(t),e.defaultValue=i,o=e.textContent,o===i&&o!==""&&o!==null&&(e.value=o),Xn(e)}function gs(e,t){if(t){var i=e.firstChild;if(i&&i===e.lastChild&&i.nodeType===3){i.nodeValue=t;return}}e.textContent=t}var Hl=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 Bl(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||Hl.has(t)?t==="float"?e.cssFloat=i:e[t]=(""+i).trim():e[t]=i+"px"}function Io(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&&Bl(e,f,o)}else for(var h in t)t.hasOwnProperty(h)&&Bl(e,h,t[h])}function es(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 ii=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"]]),Fs=/^[\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 Fl(e){return Fs.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function _a(){}var Kc=null;function Oo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var za=null,Pi=null;function ri(e){var t=An(e);if(t&&(e=t.stateNode)){var i=e[Ne]||null;e:switch(e=t.stateNode,t.type){case"input":if(ai(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="'+Gn(""+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));ai(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&&Is(o)}break e;case"textarea":Fi(e,i.value,i.defaultValue);break e;case"select":t=i.value,t!=null&&Bs(e,!!i.multiple,t,!1)}}}var qr=!1;function cf(e,t,i){if(qr)return e(t,i);qr=!0;try{var o=e(t);return o}finally{if(qr=!1,(za!==null||Pi!==null)&&(Fu(),za&&(t=za,e=Pi,Pi=za=null,ri(t),e)))for(t=0;t<e.length;t++)ri(e[t])}}function Pl(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 Ps=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ho=!1;if(Ps)try{var $i={};Object.defineProperty($i,"passive",{get:function(){Ho=!0}}),window.addEventListener("test",$i,$i),window.removeEventListener("test",$i,$i)}catch{Ho=!1}var vs=null,Bo=null,$l=null;function Qc(){if($l)return $l;var e,t=Bo,i=t.length,o,f="value"in vs?vs.value:vs.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 $l=f.slice(e,1<o?1-o:void 0)}function Ui(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 qi(){return!0}function Gi(){return!1}function ln(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 E in e)e.hasOwnProperty(E)&&(i=e[E],this[E]=i?i(h):h[E]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?qi:Gi,this.isPropagationStopped=Gi,this}return x(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=qi)},stopPropagation:function(){var i=this.nativeEvent;i&&(i.stopPropagation?i.stopPropagation():typeof i.cancelBubble!="unknown"&&(i.cancelBubble=!0),this.isPropagationStopped=qi)},persist:function(){},isPersistent:qi}),t}var ts={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gr=ln(ts),Vi=x({},ts,{view:0,detail:0}),Xc=ln(Vi),li,Vr,Wi,at=x({},Vi,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ee,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!==Wi&&(Wi&&e.type==="mousemove"?(li=e.screenX-Wi.screenX,Vr=e.screenY-Wi.screenY):Vr=li=0,Wi=e),li)},movementY:function(e){return"movementY"in e?e.movementY:Vr}}),ft=ln(at),ba=x({},at,{dataTransfer:0}),Yi=ln(ba),$s=x({},Vi,{relatedTarget:0}),et=ln($s),Zc=x({},ts,{animationName:0,elapsedTime:0,pseudoElement:0}),uf=ln(Zc),Ul=x({},ts,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Wr=ln(Ul),Fo=x({},ts,{data:0}),oi=ln(Fo),ua={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ki={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"},Vn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Us(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Vn[e])?!!t[e]:!1}function Ee(){return Us}var Jc=x({},Vi,{key:function(e){if(e.key){var t=ua[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Ki[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ee,charCode:function(e){return e.type==="keypress"?Ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),df=ln(Jc),ff=x({},at,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ql=ln(ff),Yr=x({},Vi,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ee}),eu=ln(Yr),tu=x({},ts,{propertyName:0,elapsedTime:0,pseudoElement:0}),nu=ln(tu),Yt=x({},at,{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}),au=ln(Yt),Gl=x({},ts,{newState:0,oldState:0}),Qi=ln(Gl),mf=[9,13,27,32],Po=Ps&&"CompositionEvent"in window,It=null;Ps&&"documentMode"in document&&(It=document.documentMode);var Kr=Ps&&"TextEvent"in window&&!It,su=Ps&&(!Po||It&&8<It&&11>=It),ns=" ",$o=!1;function Qr(e,t){switch(e){case"keyup":return mf.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xr(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var In=!1;function qs(e,t){switch(e){case"compositionend":return Xr(t);case"keypress":return t.which!==32?null:($o=!0,ns);case"textInput":return e=t.data,e===ns&&$o?null:e;default:return null}}function Vl(e,t){if(In)return e==="compositionend"||!Po&&Qr(e,t)?(e=Qc(),$l=Bo=vs=null,In=!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 su&&t.locale!=="ko"?null:t.data;default:return null}}var as={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 da(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!as[e.type]:t==="textarea"}function Zn(e,t,i,o){za?Pi?Pi.push(o):Pi=[o]:za=o,t=Wu(t,"onChange"),0<t.length&&(i=new Gr("onChange","change",null,i,o),e.push({event:i,listeners:t}))}var Zr=null,Xi=null;function Zi(e){yv(e,0)}function Wl(e){var t=St(e);if(Is(t))return e}function On(e,t){if(e==="change")return t}var ci=!1;if(Ps){var Ia;if(Ps){var Gs="oninput"in document;if(!Gs){var Jr=document.createElement("div");Jr.setAttribute("oninput","return;"),Gs=typeof Jr.oninput=="function"}Ia=Gs}else Ia=!1;ci=Ia&&(!document.documentMode||9<document.documentMode)}function el(){Zr&&(Zr.detachEvent("onpropertychange",ss),Xi=Zr=null)}function ss(e){if(e.propertyName==="value"&&Wl(Xi)){var t=[];Zn(t,Xi,e,Oo(e)),cf(Zi,t)}}function iu(e,t,i){e==="focusin"?(el(),Zr=t,Xi=i,Zr.attachEvent("onpropertychange",ss)):e==="focusout"&&el()}function hf(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Wl(Xi)}function Yl(e,t){if(e==="click")return Wl(t)}function Kl(e,t){if(e==="input"||e==="change")return Wl(t)}function ru(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Nn=typeof Object.is=="function"?Object.is:ru;function Ji(e,t){if(Nn(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(!Je.call(t,f)||!Nn(e[f],t[f]))return!1}return!0}function Uo(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function lu(e,t){var i=Uo(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=Uo(i)}}function ui(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ui(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function ou(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Os(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=Os(e.document)}return t}function Ql(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 pf=Ps&&"documentMode"in document&&11>=document.documentMode,er=null,Xl=null,tl=null,Zl=!1;function tr(e,t,i){var o=i.window===i?i.document:i.nodeType===9?i:i.ownerDocument;Zl||er==null||er!==Os(o)||(o=er,"selectionStart"in o&&Ql(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}),tl&&Ji(tl,o)||(tl=o,o=Wu(Xl,"onSelect"),0<o.length&&(t=new Gr("onSelect","select",null,t,i),e.push({event:t,listeners:o}),t.target=er)))}function Vs(e,t){var i={};return i[e.toLowerCase()]=t.toLowerCase(),i["Webkit"+e]="webkit"+t,i["Moz"+e]="moz"+t,i}var fa={animationend:Vs("Animation","AnimationEnd"),animationiteration:Vs("Animation","AnimationIteration"),animationstart:Vs("Animation","AnimationStart"),transitionrun:Vs("Transition","TransitionRun"),transitionstart:Vs("Transition","TransitionStart"),transitioncancel:Vs("Transition","TransitionCancel"),transitionend:Vs("Transition","TransitionEnd")},nr={},di={};Ps&&(di=document.createElement("div").style,"AnimationEvent"in window||(delete fa.animationend.animation,delete fa.animationiteration.animation,delete fa.animationstart.animation),"TransitionEvent"in window||delete fa.transitionend.transition);function ma(e){if(nr[e])return nr[e];if(!fa[e])return e;var t=fa[e],i;for(i in t)if(t.hasOwnProperty(i)&&i in di)return nr[e]=t[i];return e}var Jl=ma("animationend"),cu=ma("animationiteration"),qo=ma("animationstart"),Go=ma("transitionrun"),Vo=ma("transitionstart"),nl=ma("transitioncancel"),uu=ma("transitionend"),al=new Map,eo="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(" ");eo.push("scrollEnd");function Jn(e,t){al.set(e,t),cn(t,[e])}var ar=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)},ea=[],ys=0,sr=0;function Ws(){for(var e=ys,t=sr=ys=0;t<e;){var i=ea[t];ea[t++]=null;var o=ea[t];ea[t++]=null;var f=ea[t];ea[t++]=null;var h=ea[t];if(ea[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&&Wo(i,f,h)}}function fi(e,t,i,o){ea[ys++]=e,ea[ys++]=t,ea[ys++]=i,ea[ys++]=o,sr|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Ys(e,t,i,o){return fi(e,t,i,o),is(e)}function wa(e,t){return fi(e,null,null,t),is(e)}function Wo(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-gt(i),e=h.hiddenUpdates,o=e[f],o===null?e[f]=[t]:o.push(t),t.lane=i|536870912),h):null}function is(e){if(50<fc)throw fc=0,cm=null,Error(l(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var xs={};function Yo(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 ta(e,t,i,o){return new Yo(e,t,i,o)}function Sa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function rs(e,t){var i=e.alternate;return i===null?(i=ta(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 ir(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 Ks(e,t,i,o,f,h){var S=0;if(o=e,typeof e=="function")Sa(e)&&(S=1);else if(typeof e=="string")S=SS(e,i,ue.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case ne:return e=ta(31,i,t,f),e.elementType=ne,e.lanes=h,e;case A:return mi(i.children,f,h,t);case N:S=8,f|=24;break;case k:return e=ta(12,i,t,f|2),e.elementType=k,e.lanes=h,e;case O:return e=ta(13,i,t,f),e.elementType=O,e.lanes=h,e;case Y:return e=ta(19,i,t,f),e.elementType=Y,e.lanes=h,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:S=10;break e;case T:S=9;break e;case U:S=11;break e;case _:S=14;break e;case D:S=16,o=null;break e}S=29,i=Error(l(130,e===null?"null":typeof e,"")),o=null}return t=ta(S,i,t,f),t.elementType=e,t.type=o,t.lanes=h,t}function mi(e,t,i,o){return e=ta(7,e,o,t),e.lanes=i,e}function to(e,t,i){return e=ta(6,e,null,t),e.lanes=i,e}function Hn(e){var t=ta(18,null,null,0);return t.stateNode=e,t}function no(e,t,i){return t=ta(4,e.children!==null?e.children:[],e.key,t),t.lanes=i,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var sl=new WeakMap;function na(e,t){if(typeof e=="object"&&e!==null){var i=sl.get(e);return i!==void 0?i:(t={value:e,source:t,stack:Ve(t)},sl.set(e,t),t)}return{value:e,source:t,stack:Ve(t)}}var ls=[],rr=0,il=null,rl=0,Ca=[],aa=0,bs=null,sa=1,Oa="";function Ha(e,t){ls[rr++]=rl,ls[rr++]=il,il=e,rl=t}function du(e,t,i){Ca[aa++]=sa,Ca[aa++]=Oa,Ca[aa++]=bs,bs=e;var o=sa;e=Oa;var f=32-gt(o)-1;o&=~(1<<f),i+=1;var h=32-gt(t)+f;if(30<h){var S=f-f%5;h=(o&(1<<S)-1).toString(32),o>>=S,f-=S,sa=1<<32-gt(t)+f|i<<f|o,Oa=h+e}else sa=1<<h|i<<f|o,Oa=e}function lr(e){e.return!==null&&(Ha(e,1),du(e,1,0))}function Ko(e){for(;e===il;)il=ls[--rr],ls[rr]=null,rl=ls[--rr],ls[rr]=null;for(;e===bs;)bs=Ca[--aa],Ca[aa]=null,Oa=Ca[--aa],Ca[aa]=null,sa=Ca[--aa],Ca[aa]=null}function fu(e,t){Ca[aa++]=sa,Ca[aa++]=Oa,Ca[aa++]=bs,sa=t.id,Oa=t.overflow,bs=e}var un=null,Gt=null,wt=!1,ws=null,ha=!1,Qo=Error(l(519));function Ba(e){var t=Error(l(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Me(na(t,e)),Qo}function Ss(e){var t=e.stateNode,i=e.type,o=e.memoizedProps;switch(t[ee]=e,t[Ne]=o,i){case"dialog":jt("cancel",t),jt("close",t);break;case"iframe":case"object":case"embed":jt("load",t);break;case"video":case"audio":for(i=0;i<hc.length;i++)jt(hc[i],t);break;case"source":jt("error",t);break;case"img":case"image":case"link":jt("error",t),jt("load",t);break;case"details":jt("toggle",t);break;case"input":jt("invalid",t),si(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":jt("invalid",t);break;case"textarea":jt("invalid",t),Ur(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||Sv(t.textContent,i)?(o.popover!=null&&(jt("beforetoggle",t),jt("toggle",t)),o.onScroll!=null&&jt("scroll",t),o.onScrollEnd!=null&&jt("scrollend",t),o.onClick!=null&&(t.onclick=_a),t=!0):t=!1,t||Ba(e,!0)}function ll(e){for(un=e.return;un;)switch(un.tag){case 5:case 31:case 13:ha=!1;return;case 27:case 3:ha=!0;return;default:un=un.return}}function or(e){if(e!==un)return!1;if(!wt)return ll(e),wt=!0,!1;var t=e.tag,i;if((i=t!==3&&t!==27)&&((i=t===5)&&(i=e.type,i=!(i!=="form"&&i!=="button")||jm(e.type,e.memoizedProps)),i=!i),i&&Gt&&Ba(e),ll(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Gt=Rv(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(l(317));Gt=Rv(e)}else t===27?(t=Gt,kr(e.type)?(e=Tm,Tm=null,Gt=e):Gt=t):Gt=un?us(e.stateNode.nextSibling):null;return!0}function Cs(){Gt=un=null,wt=!1}function ol(){var e=ws;return e!==null&&(Na===null?Na=e:Na.push.apply(Na,e),ws=null),e}function Me(e){ws===null?ws=[e]:ws.push(e)}var cr=be(null),Qs=null,js=null;function hi(e,t,i){$(cr,t._currentValue),t._currentValue=i}function Fa(e){e._currentValue=cr.current,X(cr)}function ur(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 yn(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 E=h;h=f;for(var P=0;P<t.length;P++)if(E.context===t[P]){h.lanes|=i,E=h.alternate,E!==null&&(E.lanes|=i),ur(h.return,i,e),o||(S=null);break e}h=E.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),ur(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 Mn(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 E=f.type;Nn(f.pendingProps.value,S.value)||(e!==null?e.push(E):e=[E])}}else if(f===Se.current){if(S=f.alternate,S===null)throw Error(l(387));S.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(xc):e=[xc])}f=f.return}e!==null&&yn(t,e,i,o),t.flags|=262144}function xt(e){for(e=e.firstContext;e!==null;){if(!Nn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function pi(e){Qs=e,js=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Jt(e){return ao(Qs,e)}function cl(e,t){return Qs===null&&pi(e),ao(e,t)}function ao(e,t){var i=t._currentValue;if(t={context:t,memoizedValue:i,next:null},js===null){if(e===null)throw Error(l(308));js=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else js=js.next=t;return i}var gf=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()})}},vf=n.unstable_scheduleCallback,mu=n.unstable_NormalPriority,en={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xo(){return{controller:new gf,data:new Map,refCount:0}}function ul(e){e.refCount--,e.refCount===0&&vf(mu,function(){e.controller.abort()})}var xn=null,dr=0,gi=0,fr=null;function xp(e,t){if(xn===null){var i=xn=[];dr=0,gi=pm(),fr={status:"pending",value:void 0,then:function(o){i.push(o)}}}return dr++,t.then(hu,hu),t}function hu(){if(--dr===0&&xn!==null){fr!==null&&(fr.status="fulfilled");var e=xn;xn=null,gi=0,fr=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function yf(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 Zo=I.S;I.S=function(e,t){Vg=ot(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&xp(e,t),Zo!==null&&Zo(e,t)};var os=be(null);function vi(){var e=os.current;return e!==null?e:Vt.pooledCache}function dl(e,t){t===null?$(os,os.current):$(os,t.pool)}function pu(){var e=vi();return e===null?null:{parent:en._currentValue,pool:e}}var mr=Error(l(460)),Jo=Error(l(474)),so=Error(l(542)),io={then:function(){}};function gu(e){return e=e.status,e==="fulfilled"||e==="rejected"}function vu(e,t,i){switch(i=e[i],i===void 0?e.push(t):i!==t&&(t.then(_a,_a),t=i),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,xi(e),e;default:if(typeof t.status=="string")t.then(_a,_a);else{if(e=Vt,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,xi(e),e}throw yi=t,mr}}function Tn(e){try{var t=e._init;return t(e._payload)}catch(i){throw i!==null&&typeof i=="object"&&typeof i.then=="function"?(yi=i,mr):i}}var yi=null;function yu(){if(yi===null)throw Error(l(459));var e=yi;return yi=null,e}function xi(e){if(e===mr||e===so)throw Error(l(483))}var hr=null,bi=0;function ks(e){var t=bi;return bi+=1,hr===null&&(hr=[]),vu(hr,e,t)}function fl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function ml(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 y(e){function t(J,W){if(e){var ie=J.deletions;ie===null?(J.deletions=[W],J.flags|=16):ie.push(W)}}function i(J,W){if(!e)return null;for(;W!==null;)t(J,W),W=W.sibling;return null}function o(J){for(var W=new Map;J!==null;)J.key!==null?W.set(J.key,J):W.set(J.index,J),J=J.sibling;return W}function f(J,W){return J=rs(J,W),J.index=0,J.sibling=null,J}function h(J,W,ie){return J.index=ie,e?(ie=J.alternate,ie!==null?(ie=ie.index,ie<W?(J.flags|=67108866,W):ie):(J.flags|=67108866,W)):(J.flags|=1048576,W)}function S(J){return e&&J.alternate===null&&(J.flags|=67108866),J}function E(J,W,ie,we){return W===null||W.tag!==6?(W=to(ie,J.mode,we),W.return=J,W):(W=f(W,ie),W.return=J,W)}function P(J,W,ie,we){var Ze=ie.type;return Ze===A?ye(J,W,ie.props.children,we,ie.key):W!==null&&(W.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===D&&Tn(Ze)===W.type)?(W=f(W,ie.props),fl(W,ie),W.return=J,W):(W=Ks(ie.type,ie.key,ie.props,null,J.mode,we),fl(W,ie),W.return=J,W)}function le(J,W,ie,we){return W===null||W.tag!==4||W.stateNode.containerInfo!==ie.containerInfo||W.stateNode.implementation!==ie.implementation?(W=no(ie,J.mode,we),W.return=J,W):(W=f(W,ie.children||[]),W.return=J,W)}function ye(J,W,ie,we,Ze){return W===null||W.tag!==7?(W=mi(ie,J.mode,we,Ze),W.return=J,W):(W=f(W,ie),W.return=J,W)}function Ce(J,W,ie){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=to(""+W,J.mode,ie),W.return=J,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case C:return ie=Ks(W.type,W.key,W.props,null,J.mode,ie),fl(ie,W),ie.return=J,ie;case j:return W=no(W,J.mode,ie),W.return=J,W;case D:return W=Tn(W),Ce(J,W,ie)}if(K(W)||B(W))return W=mi(W,J.mode,ie,null),W.return=J,W;if(typeof W.then=="function")return Ce(J,ks(W),ie);if(W.$$typeof===R)return Ce(J,cl(J,W),ie);ml(J,W)}return null}function oe(J,W,ie,we){var Ze=W!==null?W.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return Ze!==null?null:E(J,W,""+ie,we);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case C:return ie.key===Ze?P(J,W,ie,we):null;case j:return ie.key===Ze?le(J,W,ie,we):null;case D:return ie=Tn(ie),oe(J,W,ie,we)}if(K(ie)||B(ie))return Ze!==null?null:ye(J,W,ie,we,null);if(typeof ie.then=="function")return oe(J,W,ks(ie),we);if(ie.$$typeof===R)return oe(J,W,cl(J,ie),we);ml(J,ie)}return null}function me(J,W,ie,we,Ze){if(typeof we=="string"&&we!==""||typeof we=="number"||typeof we=="bigint")return J=J.get(ie)||null,E(W,J,""+we,Ze);if(typeof we=="object"&&we!==null){switch(we.$$typeof){case C:return J=J.get(we.key===null?ie:we.key)||null,P(W,J,we,Ze);case j:return J=J.get(we.key===null?ie:we.key)||null,le(W,J,we,Ze);case D:return we=Tn(we),me(J,W,ie,we,Ze)}if(K(we)||B(we))return J=J.get(ie)||null,ye(W,J,we,Ze,null);if(typeof we.then=="function")return me(J,W,ie,ks(we),Ze);if(we.$$typeof===R)return me(J,W,ie,cl(W,we),Ze);ml(W,we)}return null}function Ye(J,W,ie,we){for(var Ze=null,Rt=null,Ke=W,yt=W=0,At=null;Ke!==null&&yt<ie.length;yt++){Ke.index>yt?(At=Ke,Ke=null):At=Ke.sibling;var Dt=oe(J,Ke,ie[yt],we);if(Dt===null){Ke===null&&(Ke=At);break}e&&Ke&&Dt.alternate===null&&t(J,Ke),W=h(Dt,W,yt),Rt===null?Ze=Dt:Rt.sibling=Dt,Rt=Dt,Ke=At}if(yt===ie.length)return i(J,Ke),wt&&Ha(J,yt),Ze;if(Ke===null){for(;yt<ie.length;yt++)Ke=Ce(J,ie[yt],we),Ke!==null&&(W=h(Ke,W,yt),Rt===null?Ze=Ke:Rt.sibling=Ke,Rt=Ke);return wt&&Ha(J,yt),Ze}for(Ke=o(Ke);yt<ie.length;yt++)At=me(Ke,J,yt,ie[yt],we),At!==null&&(e&&At.alternate!==null&&Ke.delete(At.key===null?yt:At.key),W=h(At,W,yt),Rt===null?Ze=At:Rt.sibling=At,Rt=At);return e&&Ke.forEach(function(Er){return t(J,Er)}),wt&&Ha(J,yt),Ze}function tt(J,W,ie,we){if(ie==null)throw Error(l(151));for(var Ze=null,Rt=null,Ke=W,yt=W=0,At=null,Dt=ie.next();Ke!==null&&!Dt.done;yt++,Dt=ie.next()){Ke.index>yt?(At=Ke,Ke=null):At=Ke.sibling;var Er=oe(J,Ke,Dt.value,we);if(Er===null){Ke===null&&(Ke=At);break}e&&Ke&&Er.alternate===null&&t(J,Ke),W=h(Er,W,yt),Rt===null?Ze=Er:Rt.sibling=Er,Rt=Er,Ke=At}if(Dt.done)return i(J,Ke),wt&&Ha(J,yt),Ze;if(Ke===null){for(;!Dt.done;yt++,Dt=ie.next())Dt=Ce(J,Dt.value,we),Dt!==null&&(W=h(Dt,W,yt),Rt===null?Ze=Dt:Rt.sibling=Dt,Rt=Dt);return wt&&Ha(J,yt),Ze}for(Ke=o(Ke);!Dt.done;yt++,Dt=ie.next())Dt=me(Ke,J,yt,Dt.value,we),Dt!==null&&(e&&Dt.alternate!==null&&Ke.delete(Dt.key===null?yt:Dt.key),W=h(Dt,W,yt),Rt===null?Ze=Dt:Rt.sibling=Dt,Rt=Dt);return e&&Ke.forEach(function(LS){return t(J,LS)}),wt&&Ha(J,yt),Ze}function qt(J,W,ie,we){if(typeof ie=="object"&&ie!==null&&ie.type===A&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case C:e:{for(var Ze=ie.key;W!==null;){if(W.key===Ze){if(Ze=ie.type,Ze===A){if(W.tag===7){i(J,W.sibling),we=f(W,ie.props.children),we.return=J,J=we;break e}}else if(W.elementType===Ze||typeof Ze=="object"&&Ze!==null&&Ze.$$typeof===D&&Tn(Ze)===W.type){i(J,W.sibling),we=f(W,ie.props),fl(we,ie),we.return=J,J=we;break e}i(J,W);break}else t(J,W);W=W.sibling}ie.type===A?(we=mi(ie.props.children,J.mode,we,ie.key),we.return=J,J=we):(we=Ks(ie.type,ie.key,ie.props,null,J.mode,we),fl(we,ie),we.return=J,J=we)}return S(J);case j:e:{for(Ze=ie.key;W!==null;){if(W.key===Ze)if(W.tag===4&&W.stateNode.containerInfo===ie.containerInfo&&W.stateNode.implementation===ie.implementation){i(J,W.sibling),we=f(W,ie.children||[]),we.return=J,J=we;break e}else{i(J,W);break}else t(J,W);W=W.sibling}we=no(ie,J.mode,we),we.return=J,J=we}return S(J);case D:return ie=Tn(ie),qt(J,W,ie,we)}if(K(ie))return Ye(J,W,ie,we);if(B(ie)){if(Ze=B(ie),typeof Ze!="function")throw Error(l(150));return ie=Ze.call(ie),tt(J,W,ie,we)}if(typeof ie.then=="function")return qt(J,W,ks(ie),we);if(ie.$$typeof===R)return qt(J,W,cl(J,ie),we);ml(J,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,W!==null&&W.tag===6?(i(J,W.sibling),we=f(W,ie),we.return=J,J=we):(i(J,W),we=to(ie,J.mode,we),we.return=J,J=we),S(J)):i(J,W)}return function(J,W,ie,we){try{bi=0;var Ze=qt(J,W,ie,we);return hr=null,Ze}catch(Ke){if(Ke===mr||Ke===so)throw Ke;var Rt=ta(29,Ke,null,J.mode);return Rt.lanes=we,Rt.return=J,Rt}}}var M=y(!0),L=y(!1),F=!1;function z(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function pe(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 de(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function De(e,t,i){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(Lt&2)!==0){var f=o.pending;return f===null?t.next=t:(t.next=f.next,f.next=t),o.pending=t,t=is(e),Wo(e,null,i),t}return fi(e,o,t,i),is(e)}function $e(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,H(e,i)}}function Xe(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 tn=!1;function dn(){if(tn){var e=fr;if(e!==null)throw e}}function Wn(e,t,i,o){tn=!1;var f=e.updateQueue;F=!1;var h=f.firstBaseUpdate,S=f.lastBaseUpdate,E=f.shared.pending;if(E!==null){f.shared.pending=null;var P=E,le=P.next;P.next=null,S===null?h=le:S.next=le,S=P;var ye=e.alternate;ye!==null&&(ye=ye.updateQueue,E=ye.lastBaseUpdate,E!==S&&(E===null?ye.firstBaseUpdate=le:E.next=le,ye.lastBaseUpdate=P))}if(h!==null){var Ce=f.baseState;S=0,ye=le=P=null,E=h;do{var oe=E.lane&-536870913,me=oe!==E.lane;if(me?(kt&oe)===oe:(o&oe)===oe){oe!==0&&oe===gi&&(tn=!0),ye!==null&&(ye=ye.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Ye=e,tt=E;oe=t;var qt=i;switch(tt.tag){case 1:if(Ye=tt.payload,typeof Ye=="function"){Ce=Ye.call(qt,Ce,oe);break e}Ce=Ye;break e;case 3:Ye.flags=Ye.flags&-65537|128;case 0:if(Ye=tt.payload,oe=typeof Ye=="function"?Ye.call(qt,Ce,oe):Ye,oe==null)break e;Ce=x({},Ce,oe);break e;case 2:F=!0}}oe=E.callback,oe!==null&&(e.flags|=64,me&&(e.flags|=8192),me=f.callbacks,me===null?f.callbacks=[oe]:me.push(oe))}else me={lane:oe,tag:E.tag,payload:E.payload,callback:E.callback,next:null},ye===null?(le=ye=me,P=Ce):ye=ye.next=me,S|=oe;if(E=E.next,E===null){if(E=f.shared.pending,E===null)break;me=E,E=me.next,me.next=null,f.lastBaseUpdate=me,f.shared.pending=null}}while(!0);ye===null&&(P=Ce),f.baseState=P,f.firstBaseUpdate=le,f.lastBaseUpdate=ye,h===null&&(f.shared.lanes=0),br|=S,e.lanes=S,e.memoizedState=Ce}}function hl(e,t){if(typeof e!="function")throw Error(l(191,e));e.call(t)}function pl(e,t){var i=e.callbacks;if(i!==null)for(e.callbacks=null,e=0;e<i.length;e++)hl(i[e],t)}var pr=be(null),wi=be(0);function xu(e,t){e=Ei,$(wi,e),$(pr,t),Ei=e|t.baseLanes}function xf(){$(wi,Ei),$(pr,pr.current)}function bf(){Ei=wi.current,X(pr),X(wi)}var Pa=be(null),cs=null;function gr(e){var t=e.alternate;$(bn,bn.current&1),$(Pa,e),cs===null&&(t===null||pr.current!==null||t.memoizedState!==null)&&(cs=e)}function wf(e){$(bn,bn.current),$(Pa,e),cs===null&&(cs=e)}function bp(e){e.tag===22?($(bn,bn.current),$(Pa,e),cs===null&&(cs=e)):vr()}function vr(){$(bn,bn.current),$(Pa,Pa.current)}function $a(e){X(Pa),cs===e&&(cs=null),X(bn)}var bn=be(0);function bu(e){for(var t=e;t!==null;){if(t.tag===13){var i=t.memoizedState;if(i!==null&&(i=i.dehydrated,i===null||Nm(i)||Mm(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 Si=0,mt=null,$t=null,En=null,wu=!1,ro=!1,gl=!1,Su=0,ec=0,lo=null,Cw=0;function fn(){throw Error(l(321))}function Sf(e,t){if(t===null)return!1;for(var i=0;i<t.length&&i<e.length;i++)if(!Nn(e[i],t[i]))return!1;return!0}function Cf(e,t,i,o,f,h){return Si=h,mt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,I.H=e===null||e.memoizedState===null?ag:Hf,gl=!1,h=i(o,f),gl=!1,ro&&(h=Sp(t,i,o,f)),wp(e),h}function wp(e){I.H=ac;var t=$t!==null&&$t.next!==null;if(Si=0,En=$t=mt=null,wu=!1,ec=0,lo=null,t)throw Error(l(300));e===null||Rn||(e=e.dependencies,e!==null&&xt(e)&&(Rn=!0))}function Sp(e,t,i,o){mt=e;var f=0;do{if(ro&&(lo=null),ec=0,ro=!1,25<=f)throw Error(l(301));if(f+=1,En=$t=null,e.updateQueue!=null){var h=e.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}I.H=sg,h=t(i,o)}while(ro);return h}function jw(){var e=I.H,t=e.useState()[0];return t=typeof t.then=="function"?tc(t):t,e=e.useState()[0],($t!==null?$t.memoizedState:null)!==e&&(mt.flags|=1024),t}function jf(){var e=Su!==0;return Su=0,e}function kf(e,t,i){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i}function Af(e){if(wu){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}wu=!1}Si=0,En=$t=mt=null,ro=!1,ec=Su=0,lo=null}function pa(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return En===null?mt.memoizedState=En=e:En=En.next=e,En}function wn(){if($t===null){var e=mt.alternate;e=e!==null?e.memoizedState:null}else e=$t.next;var t=En===null?mt.memoizedState:En.next;if(t!==null)En=t,$t=e;else{if(e===null)throw mt.alternate===null?Error(l(467)):Error(l(310));$t=e,e={memoizedState:$t.memoizedState,baseState:$t.baseState,baseQueue:$t.baseQueue,queue:$t.queue,next:null},En===null?mt.memoizedState=En=e:En=En.next=e}return En}function Cu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function tc(e){var t=ec;return ec+=1,lo===null&&(lo=[]),e=vu(lo,e,t),t=mt,(En===null?t.memoizedState:En.next)===null&&(t=t.alternate,I.H=t===null||t.memoizedState===null?ag:Hf),e}function ju(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return tc(e);if(e.$$typeof===R)return Jt(e)}throw Error(l(438,String(e)))}function Nf(e){var t=null,i=mt.updateQueue;if(i!==null&&(t=i.memoCache),t==null){var o=mt.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=Cu(),mt.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]=G;return t.index++,i}function Ci(e,t){return typeof t=="function"?t(e):t}function ku(e){var t=wn();return Mf(t,$t,e)}function Mf(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 E=S=null,P=null,le=t,ye=!1;do{var Ce=le.lane&-536870913;if(Ce!==le.lane?(kt&Ce)===Ce:(Si&Ce)===Ce){var oe=le.revertLane;if(oe===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null}),Ce===gi&&(ye=!0);else if((Si&oe)===oe){le=le.next,oe===gi&&(ye=!0);continue}else Ce={lane:0,revertLane:le.revertLane,gesture:null,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},P===null?(E=P=Ce,S=h):P=P.next=Ce,mt.lanes|=oe,br|=oe;Ce=le.action,gl&&i(h,Ce),h=le.hasEagerState?le.eagerState:i(h,Ce)}else oe={lane:Ce,revertLane:le.revertLane,gesture:le.gesture,action:le.action,hasEagerState:le.hasEagerState,eagerState:le.eagerState,next:null},P===null?(E=P=oe,S=h):P=P.next=oe,mt.lanes|=Ce,br|=Ce;le=le.next}while(le!==null&&le!==t);if(P===null?S=h:P.next=E,!Nn(h,e.memoizedState)&&(Rn=!0,ye&&(i=fr,i!==null)))throw i;e.memoizedState=h,e.baseState=S,e.baseQueue=P,o.lastRenderedState=h}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function Tf(e){var t=wn(),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);Nn(h,t.memoizedState)||(Rn=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),i.lastRenderedState=h}return[h,o]}function Cp(e,t,i){var o=mt,f=wn(),h=wt;if(h){if(i===void 0)throw Error(l(407));i=i()}else i=t();var S=!Nn(($t||f).memoizedState,i);if(S&&(f.memoizedState=i,Rn=!0),f=f.queue,Df(Ap.bind(null,o,f,e),[e]),f.getSnapshot!==t||S||En!==null&&En.memoizedState.tag&1){if(o.flags|=2048,oo(9,{destroy:void 0},kp.bind(null,o,f,i,t),null),Vt===null)throw Error(l(349));h||(Si&127)!==0||jp(o,t,i)}return i}function jp(e,t,i){e.flags|=16384,e={getSnapshot:t,value:i},t=mt.updateQueue,t===null?(t=Cu(),mt.updateQueue=t,t.stores=[e]):(i=t.stores,i===null?t.stores=[e]:i.push(e))}function kp(e,t,i,o){t.value=i,t.getSnapshot=o,Np(t)&&Mp(e)}function Ap(e,t,i){return i(function(){Np(t)&&Mp(e)})}function Np(e){var t=e.getSnapshot;e=e.value;try{var i=t();return!Nn(e,i)}catch{return!0}}function Mp(e){var t=wa(e,2);t!==null&&Ma(t,e,2)}function Ef(e){var t=pa();if(typeof e=="function"){var i=e;if(e=i(),gl){st(!0);try{i()}finally{st(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:e},t}function Tp(e,t,i,o){return e.baseState=i,Mf(e,$t,typeof o=="function"?o:Ci)}function kw(e,t,i,o,f){if(Mu(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)}};I.T!==null?i(!0):h.isTransition=!1,o(h),i=t.pending,i===null?(h.next=t.pending=h,Ep(t,h)):(h.next=i.next,t.pending=i.next=h)}}function Ep(e,t){var i=t.action,o=t.payload,f=e.state;if(t.isTransition){var h=I.T,S={};I.T=S;try{var E=i(f,o),P=I.S;P!==null&&P(S,E),Rp(e,t,E)}catch(le){Rf(e,t,le)}finally{h!==null&&S.types!==null&&(h.types=S.types),I.T=h}}else try{h=i(f,o),Rp(e,t,h)}catch(le){Rf(e,t,le)}}function Rp(e,t,i){i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(function(o){Dp(e,t,o)},function(o){return Rf(e,t,o)}):Dp(e,t,i)}function Dp(e,t,i){t.status="fulfilled",t.value=i,Lp(t),e.state=i,t=e.pending,t!==null&&(i=t.next,i===t?e.pending=null:(i=i.next,t.next=i,Ep(e,i)))}function Rf(e,t,i){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=i,Lp(t),t=t.next;while(t!==o)}e.action=null}function Lp(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function _p(e,t){return t}function zp(e,t){if(wt){var i=Vt.formState;if(i!==null){e:{var o=mt;if(wt){if(Gt){t:{for(var f=Gt,h=ha;f.nodeType!==8;){if(!h){f=null;break t}if(f=us(f.nextSibling),f===null){f=null;break t}}h=f.data,f=h==="F!"||h==="F"?f:null}if(f){Gt=us(f.nextSibling),o=f.data==="F!";break e}}Ba(o)}o=!1}o&&(t=i[0])}}return i=pa(),i.memoizedState=i.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:_p,lastRenderedState:t},i.queue=o,i=eg.bind(null,mt,o),o.dispatch=i,o=Ef(!1),h=Of.bind(null,mt,!1,o.queue),o=pa(),f={state:t,dispatch:null,action:e,pending:null},o.queue=f,i=kw.bind(null,mt,f,h,i),f.dispatch=i,o.memoizedState=e,[t,i,!1]}function Ip(e){var t=wn();return Op(t,$t,e)}function Op(e,t,i){if(t=Mf(e,t,_p)[0],e=ku(Ci)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=tc(t)}catch(S){throw S===mr?so:S}else o=t;t=wn();var f=t.queue,h=f.dispatch;return i!==t.memoizedState&&(mt.flags|=2048,oo(9,{destroy:void 0},Aw.bind(null,f,i),null)),[o,h,e]}function Aw(e,t){e.action=t}function Hp(e){var t=wn(),i=$t;if(i!==null)return Op(t,i,e);wn(),t=t.memoizedState,i=wn();var o=i.queue.dispatch;return i.memoizedState=e,[t,o,!1]}function oo(e,t,i,o){return e={tag:e,create:i,deps:o,inst:t,next:null},t=mt.updateQueue,t===null&&(t=Cu(),mt.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 Bp(){return wn().memoizedState}function Au(e,t,i,o){var f=pa();mt.flags|=e,f.memoizedState=oo(1|t,{destroy:void 0},i,o===void 0?null:o)}function Nu(e,t,i,o){var f=wn();o=o===void 0?null:o;var h=f.memoizedState.inst;$t!==null&&o!==null&&Sf(o,$t.memoizedState.deps)?f.memoizedState=oo(t,h,i,o):(mt.flags|=e,f.memoizedState=oo(1|t,h,i,o))}function Fp(e,t){Au(8390656,8,e,t)}function Df(e,t){Nu(2048,8,e,t)}function Nw(e){mt.flags|=4;var t=mt.updateQueue;if(t===null)t=Cu(),mt.updateQueue=t,t.events=[e];else{var i=t.events;i===null?t.events=[e]:i.push(e)}}function Pp(e){var t=wn().memoizedState;return Nw({ref:t,nextImpl:e}),function(){if((Lt&2)!==0)throw Error(l(440));return t.impl.apply(void 0,arguments)}}function $p(e,t){return Nu(4,2,e,t)}function Up(e,t){return Nu(4,4,e,t)}function qp(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 Gp(e,t,i){i=i!=null?i.concat([e]):null,Nu(4,4,qp.bind(null,t,e),i)}function Lf(){}function Vp(e,t){var i=wn();t=t===void 0?null:t;var o=i.memoizedState;return t!==null&&Sf(t,o[1])?o[0]:(i.memoizedState=[e,t],e)}function Wp(e,t){var i=wn();t=t===void 0?null:t;var o=i.memoizedState;if(t!==null&&Sf(t,o[1]))return o[0];if(o=e(),gl){st(!0);try{e()}finally{st(!1)}}return i.memoizedState=[o,t],o}function _f(e,t,i){return i===void 0||(Si&1073741824)!==0&&(kt&261930)===0?e.memoizedState=t:(e.memoizedState=i,e=Yg(),mt.lanes|=e,br|=e,i)}function Yp(e,t,i,o){return Nn(i,t)?i:pr.current!==null?(e=_f(e,i,o),Nn(e,t)||(Rn=!0),e):(Si&42)===0||(Si&1073741824)!==0&&(kt&261930)===0?(Rn=!0,e.memoizedState=i):(e=Yg(),mt.lanes|=e,br|=e,t)}function Kp(e,t,i,o,f){var h=Q.p;Q.p=h!==0&&8>h?h:8;var S=I.T,E={};I.T=E,Of(e,!1,t,i);try{var P=f(),le=I.S;if(le!==null&&le(E,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var ye=yf(P,o);nc(e,t,ye,Ga(e))}else nc(e,t,o,Ga(e))}catch(Ce){nc(e,t,{then:function(){},status:"rejected",reason:Ce},Ga())}finally{Q.p=h,S!==null&&E.types!==null&&(S.types=E.types),I.T=S}}function Mw(){}function zf(e,t,i,o){if(e.tag!==5)throw Error(l(476));var f=Qp(e).queue;Kp(e,f,t,q,i===null?Mw:function(){return Xp(e),i(o)})}function Qp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:q,baseState:q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:q},next:null};var i={};return t.next={memoizedState:i,baseState:i,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ci,lastRenderedState:i},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Xp(e){var t=Qp(e);t.next===null&&(t=e.alternate.memoizedState),nc(e,t.next.queue,{},Ga())}function If(){return Jt(xc)}function Zp(){return wn().memoizedState}function Jp(){return wn().memoizedState}function Tw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var i=Ga();e=de(i);var o=De(t,e,i);o!==null&&(Ma(o,t,i),$e(o,t,i)),t={cache:Xo()},e.payload=t;return}t=t.return}}function Ew(e,t,i){var o=Ga();i={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Mu(e)?tg(t,i):(i=Ys(e,t,i,o),i!==null&&(Ma(i,e,o),ng(i,t,o)))}function eg(e,t,i){var o=Ga();nc(e,t,i,o)}function nc(e,t,i,o){var f={lane:o,revertLane:0,gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null};if(Mu(e))tg(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,E=h(S,i);if(f.hasEagerState=!0,f.eagerState=E,Nn(E,S))return fi(e,t,f,0),Vt===null&&Ws(),!1}catch{}if(i=Ys(e,t,f,o),i!==null)return Ma(i,e,o),ng(i,t,o),!0}return!1}function Of(e,t,i,o){if(o={lane:2,revertLane:pm(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Mu(e)){if(t)throw Error(l(479))}else t=Ys(e,i,o,2),t!==null&&Ma(t,e,2)}function Mu(e){var t=e.alternate;return e===mt||t!==null&&t===mt}function tg(e,t){ro=wu=!0;var i=e.pending;i===null?t.next=t:(t.next=i.next,i.next=t),e.pending=t}function ng(e,t,i){if((i&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,i|=o,t.lanes=i,H(e,i)}}var ac={readContext:Jt,use:ju,useCallback:fn,useContext:fn,useEffect:fn,useImperativeHandle:fn,useLayoutEffect:fn,useInsertionEffect:fn,useMemo:fn,useReducer:fn,useRef:fn,useState:fn,useDebugValue:fn,useDeferredValue:fn,useTransition:fn,useSyncExternalStore:fn,useId:fn,useHostTransitionStatus:fn,useFormState:fn,useActionState:fn,useOptimistic:fn,useMemoCache:fn,useCacheRefresh:fn};ac.useEffectEvent=fn;var ag={readContext:Jt,use:ju,useCallback:function(e,t){return pa().memoizedState=[e,t===void 0?null:t],e},useContext:Jt,useEffect:Fp,useImperativeHandle:function(e,t,i){i=i!=null?i.concat([e]):null,Au(4194308,4,qp.bind(null,t,e),i)},useLayoutEffect:function(e,t){return Au(4194308,4,e,t)},useInsertionEffect:function(e,t){Au(4,2,e,t)},useMemo:function(e,t){var i=pa();t=t===void 0?null:t;var o=e();if(gl){st(!0);try{e()}finally{st(!1)}}return i.memoizedState=[o,t],o},useReducer:function(e,t,i){var o=pa();if(i!==void 0){var f=i(t);if(gl){st(!0);try{i(t)}finally{st(!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=Ew.bind(null,mt,e),[o.memoizedState,e]},useRef:function(e){var t=pa();return e={current:e},t.memoizedState=e},useState:function(e){e=Ef(e);var t=e.queue,i=eg.bind(null,mt,t);return t.dispatch=i,[e.memoizedState,i]},useDebugValue:Lf,useDeferredValue:function(e,t){var i=pa();return _f(i,e,t)},useTransition:function(){var e=Ef(!1);return e=Kp.bind(null,mt,e.queue,!0,!1),pa().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,i){var o=mt,f=pa();if(wt){if(i===void 0)throw Error(l(407));i=i()}else{if(i=t(),Vt===null)throw Error(l(349));(kt&127)!==0||jp(o,t,i)}f.memoizedState=i;var h={value:i,getSnapshot:t};return f.queue=h,Fp(Ap.bind(null,o,h,e),[e]),o.flags|=2048,oo(9,{destroy:void 0},kp.bind(null,o,h,i,t),null),i},useId:function(){var e=pa(),t=Vt.identifierPrefix;if(wt){var i=Oa,o=sa;i=(o&~(1<<32-gt(o)-1)).toString(32)+i,t="_"+t+"R_"+i,i=Su++,0<i&&(t+="H"+i.toString(32)),t+="_"}else i=Cw++,t="_"+t+"r_"+i.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:If,useFormState:zp,useActionState:zp,useOptimistic:function(e){var t=pa();t.memoizedState=t.baseState=e;var i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=i,t=Of.bind(null,mt,!0,i),i.dispatch=t,[e,t]},useMemoCache:Nf,useCacheRefresh:function(){return pa().memoizedState=Tw.bind(null,mt)},useEffectEvent:function(e){var t=pa(),i={impl:e};return t.memoizedState=i,function(){if((Lt&2)!==0)throw Error(l(440));return i.impl.apply(void 0,arguments)}}},Hf={readContext:Jt,use:ju,useCallback:Vp,useContext:Jt,useEffect:Df,useImperativeHandle:Gp,useInsertionEffect:$p,useLayoutEffect:Up,useMemo:Wp,useReducer:ku,useRef:Bp,useState:function(){return ku(Ci)},useDebugValue:Lf,useDeferredValue:function(e,t){var i=wn();return Yp(i,$t.memoizedState,e,t)},useTransition:function(){var e=ku(Ci)[0],t=wn().memoizedState;return[typeof e=="boolean"?e:tc(e),t]},useSyncExternalStore:Cp,useId:Zp,useHostTransitionStatus:If,useFormState:Ip,useActionState:Ip,useOptimistic:function(e,t){var i=wn();return Tp(i,$t,e,t)},useMemoCache:Nf,useCacheRefresh:Jp};Hf.useEffectEvent=Pp;var sg={readContext:Jt,use:ju,useCallback:Vp,useContext:Jt,useEffect:Df,useImperativeHandle:Gp,useInsertionEffect:$p,useLayoutEffect:Up,useMemo:Wp,useReducer:Tf,useRef:Bp,useState:function(){return Tf(Ci)},useDebugValue:Lf,useDeferredValue:function(e,t){var i=wn();return $t===null?_f(i,e,t):Yp(i,$t.memoizedState,e,t)},useTransition:function(){var e=Tf(Ci)[0],t=wn().memoizedState;return[typeof e=="boolean"?e:tc(e),t]},useSyncExternalStore:Cp,useId:Zp,useHostTransitionStatus:If,useFormState:Hp,useActionState:Hp,useOptimistic:function(e,t){var i=wn();return $t!==null?Tp(i,$t,e,t):(i.baseState=e,[e,i.queue.dispatch])},useMemoCache:Nf,useCacheRefresh:Jp};sg.useEffectEvent=Pp;function Bf(e,t,i,o){t=e.memoizedState,i=i(o,t),i=i==null?t:x({},t,i),e.memoizedState=i,e.lanes===0&&(e.updateQueue.baseState=i)}var Ff={enqueueSetState:function(e,t,i){e=e._reactInternals;var o=Ga(),f=de(o);f.payload=t,i!=null&&(f.callback=i),t=De(e,f,o),t!==null&&(Ma(t,e,o),$e(t,e,o))},enqueueReplaceState:function(e,t,i){e=e._reactInternals;var o=Ga(),f=de(o);f.tag=1,f.payload=t,i!=null&&(f.callback=i),t=De(e,f,o),t!==null&&(Ma(t,e,o),$e(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var i=Ga(),o=de(i);o.tag=2,t!=null&&(o.callback=t),t=De(e,o,i),t!==null&&(Ma(t,e,i),$e(t,e,i))}};function ig(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?!Ji(i,o)||!Ji(f,h):!0}function rg(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&&Ff.enqueueReplaceState(t,t.state,null)}function vl(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=x({},i));for(var f in e)i[f]===void 0&&(i[f]=e[f])}return i}function lg(e){ar(e)}function og(e){console.error(e)}function cg(e){ar(e)}function Tu(e,t){try{var i=e.onUncaughtError;i(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function ug(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 Pf(e,t,i){return i=de(i),i.tag=3,i.payload={element:null},i.callback=function(){Tu(e,t)},i}function dg(e){return e=de(e),e.tag=3,e}function fg(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(){ug(t,i,o)}}var S=i.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){ug(t,i,o),typeof f!="function"&&(wr===null?wr=new Set([this]):wr.add(this));var E=o.stack;this.componentDidCatch(o.value,{componentStack:E!==null?E:""})})}function Rw(e,t,i,o,f){if(i.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=i.alternate,t!==null&&Mn(t,i,f,!0),i=Pa.current,i!==null){switch(i.tag){case 31:case 13:return cs===null?Pu():i.alternate===null&&mn===0&&(mn=3),i.flags&=-257,i.flags|=65536,i.lanes=f,o===io?i.flags|=16384:(t=i.updateQueue,t===null?i.updateQueue=new Set([o]):t.add(o),fm(e,o,f)),!1;case 22:return i.flags|=65536,o===io?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)),fm(e,o,f)),!1}throw Error(l(435,i.tag))}return fm(e,o,f),Pu(),!1}if(wt)return t=Pa.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=f,o!==Qo&&(e=Error(l(422),{cause:o}),Me(na(e,i)))):(o!==Qo&&(t=Error(l(423),{cause:o}),Me(na(t,i))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=na(o,i),f=Pf(e.stateNode,o,f),Xe(e,f),mn!==4&&(mn=2)),!1;var h=Error(l(520),{cause:o});if(h=na(h,i),dc===null?dc=[h]:dc.push(h),mn!==4&&(mn=2),t===null)return!0;o=na(o,i),i=t;do{switch(i.tag){case 3:return i.flags|=65536,e=f&-f,i.lanes|=e,e=Pf(i.stateNode,o,e),Xe(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"&&(wr===null||!wr.has(h))))return i.flags|=65536,f&=-f,i.lanes|=f,f=dg(f),fg(f,e,i,o),Xe(i,f),!1}i=i.return}while(i!==null);return!1}var $f=Error(l(461)),Rn=!1;function Yn(e,t,i,o){t.child=e===null?L(t,null,i,o):M(t,e.child,i,o)}function mg(e,t,i,o,f){i=i.render;var h=t.ref;if("ref"in o){var S={};for(var E in o)E!=="ref"&&(S[E]=o[E])}else S=o;return pi(t),o=Cf(e,t,i,S,h,f),E=jf(),e!==null&&!Rn?(kf(e,t,f),ji(e,t,f)):(wt&&E&&lr(t),t.flags|=1,Yn(e,t,o,f),t.child)}function hg(e,t,i,o,f){if(e===null){var h=i.type;return typeof h=="function"&&!Sa(h)&&h.defaultProps===void 0&&i.compare===null?(t.tag=15,t.type=h,pg(e,t,h,o,f)):(e=Ks(i.type,null,o,t,t.mode,f),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,!Qf(e,f)){var S=h.memoizedProps;if(i=i.compare,i=i!==null?i:Ji,i(S,o)&&e.ref===t.ref)return ji(e,t,f)}return t.flags|=1,e=rs(h,o),e.ref=t.ref,e.return=t,t.child=e}function pg(e,t,i,o,f){if(e!==null){var h=e.memoizedProps;if(Ji(h,o)&&e.ref===t.ref)if(Rn=!1,t.pendingProps=o=h,Qf(e,f))(e.flags&131072)!==0&&(Rn=!0);else return t.lanes=e.lanes,ji(e,t,f)}return Uf(e,t,i,o,f)}function gg(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 vg(e,t,h,i,o)}if((i&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&dl(t,h!==null?h.cachePool:null),h!==null?xu(t,h):xf(),bp(t);else return o=t.lanes=536870912,vg(e,t,h!==null?h.baseLanes|i:i,i,o)}else h!==null?(dl(t,h.cachePool),xu(t,h),vr(),t.memoizedState=null):(e!==null&&dl(t,null),xf(),vr());return Yn(e,t,f,i),t.child}function sc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function vg(e,t,i,o,f){var h=vi();return h=h===null?null:{parent:en._currentValue,pool:h},t.memoizedState={baseLanes:i,cachePool:h},e!==null&&dl(t,null),xf(),bp(t),e!==null&&Mn(e,t,o,!0),t.childLanes=f,null}function Eu(e,t){return t=Du({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function yg(e,t,i){return M(t,e.child,null,i),e=Eu(t,t.pendingProps),e.flags|=2,$a(t),t.memoizedState=null,e}function Dw(e,t,i){var o=t.pendingProps,f=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(wt){if(o.mode==="hidden")return e=Eu(t,o),t.lanes=536870912,sc(null,e);if(wf(t),(e=Gt)?(e=Ev(e,ha),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:bs!==null?{id:sa,overflow:Oa}:null,retryLane:536870912,hydrationErrors:null},i=Hn(e),i.return=t,t.child=i,un=t,Gt=null)):e=null,e===null)throw Ba(t);return t.lanes=536870912,null}return Eu(t,o)}var h=e.memoizedState;if(h!==null){var S=h.dehydrated;if(wf(t),f)if(t.flags&256)t.flags&=-257,t=yg(e,t,i);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(l(558));else if(Rn||Mn(e,t,i,!1),f=(i&e.childLanes)!==0,Rn||f){if(o=Vt,o!==null&&(S=Pe(o,i),S!==0&&S!==h.retryLane))throw h.retryLane=S,wa(e,S),Ma(o,e,S),$f;Pu(),t=yg(e,t,i)}else e=h.treeContext,Gt=us(S.nextSibling),un=t,wt=!0,ws=null,ha=!1,e!==null&&fu(t,e),t=Eu(t,o),t.flags|=4096;return t}return e=rs(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Ru(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 Uf(e,t,i,o,f){return pi(t),i=Cf(e,t,i,o,void 0,f),o=jf(),e!==null&&!Rn?(kf(e,t,f),ji(e,t,f)):(wt&&o&&lr(t),t.flags|=1,Yn(e,t,i,f),t.child)}function xg(e,t,i,o,f,h){return pi(t),t.updateQueue=null,i=Sp(t,o,i,f),wp(e),o=jf(),e!==null&&!Rn?(kf(e,t,h),ji(e,t,h)):(wt&&o&&lr(t),t.flags|=1,Yn(e,t,i,h),t.child)}function bg(e,t,i,o,f){if(pi(t),t.stateNode===null){var h=xs,S=i.contextType;typeof S=="object"&&S!==null&&(h=Jt(S)),h=new i(o,h),t.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Ff,t.stateNode=h,h._reactInternals=t,h=t.stateNode,h.props=o,h.state=t.memoizedState,h.refs={},z(t),S=i.contextType,h.context=typeof S=="object"&&S!==null?Jt(S):xs,h.state=t.memoizedState,S=i.getDerivedStateFromProps,typeof S=="function"&&(Bf(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&&Ff.enqueueReplaceState(h,h.state,null),Wn(t,o,h,f),dn(),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){h=t.stateNode;var E=t.memoizedProps,P=vl(i,E);h.props=P;var le=h.context,ye=i.contextType;S=xs,typeof ye=="object"&&ye!==null&&(S=Jt(ye));var Ce=i.getDerivedStateFromProps;ye=typeof Ce=="function"||typeof h.getSnapshotBeforeUpdate=="function",E=t.pendingProps!==E,ye||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(E||le!==S)&&rg(t,h,o,S),F=!1;var oe=t.memoizedState;h.state=oe,Wn(t,o,h,f),dn(),le=t.memoizedState,E||oe!==le||F?(typeof Ce=="function"&&(Bf(t,i,Ce,o),le=t.memoizedState),(P=F||ig(t,i,P,o,oe,le,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=le),h.props=o,h.state=le,h.context=S,o=P):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{h=t.stateNode,pe(e,t),S=t.memoizedProps,ye=vl(i,S),h.props=ye,Ce=t.pendingProps,oe=h.context,le=i.contextType,P=xs,typeof le=="object"&&le!==null&&(P=Jt(le)),E=i.getDerivedStateFromProps,(le=typeof E=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(S!==Ce||oe!==P)&&rg(t,h,o,P),F=!1,oe=t.memoizedState,h.state=oe,Wn(t,o,h,f),dn();var me=t.memoizedState;S!==Ce||oe!==me||F||e!==null&&e.dependencies!==null&&xt(e.dependencies)?(typeof E=="function"&&(Bf(t,i,E,o),me=t.memoizedState),(ye=F||ig(t,i,ye,o,oe,me,P)||e!==null&&e.dependencies!==null&&xt(e.dependencies))?(le||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,me,P),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,me,P)),typeof h.componentDidUpdate=="function"&&(t.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=me),h.props=o,h.state=me,h.context=P,o=ye):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&oe===e.memoizedState||(t.flags|=1024),o=!1)}return h=o,Ru(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=M(t,e.child,null,f),t.child=M(t,null,i,f)):Yn(e,t,i,f),t.memoizedState=h.state,e=t.child):e=ji(e,t,f),e}function wg(e,t,i,o){return Cs(),t.flags|=256,Yn(e,t,i,o),t.child}var qf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Gf(e){return{baseLanes:e,cachePool:pu()}}function Vf(e,t,i){return e=e!==null?e.childLanes&~i:0,t&&(e|=qa),e}function Sg(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:(bn.current&2)!==0),S&&(f=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(wt){if(f?gr(t):vr(),(e=Gt)?(e=Ev(e,ha),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:bs!==null?{id:sa,overflow:Oa}:null,retryLane:536870912,hydrationErrors:null},i=Hn(e),i.return=t,t.child=i,un=t,Gt=null)):e=null,e===null)throw Ba(t);return Mm(e)?t.lanes=32:t.lanes=536870912,null}var E=o.children;return o=o.fallback,f?(vr(),f=t.mode,E=Du({mode:"hidden",children:E},f),o=mi(o,f,i,null),E.return=t,o.return=t,E.sibling=o,t.child=E,o=t.child,o.memoizedState=Gf(i),o.childLanes=Vf(e,S,i),t.memoizedState=qf,sc(null,o)):(gr(t),Wf(t,E))}var P=e.memoizedState;if(P!==null&&(E=P.dehydrated,E!==null)){if(h)t.flags&256?(gr(t),t.flags&=-257,t=Yf(e,t,i)):t.memoizedState!==null?(vr(),t.child=e.child,t.flags|=128,t=null):(vr(),E=o.fallback,f=t.mode,o=Du({mode:"visible",children:o.children},f),E=mi(E,f,i,null),E.flags|=2,o.return=t,E.return=t,o.sibling=E,t.child=o,M(t,e.child,null,i),o=t.child,o.memoizedState=Gf(i),o.childLanes=Vf(e,S,i),t.memoizedState=qf,t=sc(null,o));else if(gr(t),Mm(E)){if(S=E.nextSibling&&E.nextSibling.dataset,S)var le=S.dgst;S=le,o=Error(l(419)),o.stack="",o.digest=S,Me({value:o,source:null,stack:null}),t=Yf(e,t,i)}else if(Rn||Mn(e,t,i,!1),S=(i&e.childLanes)!==0,Rn||S){if(S=Vt,S!==null&&(o=Pe(S,i),o!==0&&o!==P.retryLane))throw P.retryLane=o,wa(e,o),Ma(S,e,o),$f;Nm(E)||Pu(),t=Yf(e,t,i)}else Nm(E)?(t.flags|=192,t.child=e.child,t=null):(e=P.treeContext,Gt=us(E.nextSibling),un=t,wt=!0,ws=null,ha=!1,e!==null&&fu(t,e),t=Wf(t,o.children),t.flags|=4096);return t}return f?(vr(),E=o.fallback,f=t.mode,P=e.child,le=P.sibling,o=rs(P,{mode:"hidden",children:o.children}),o.subtreeFlags=P.subtreeFlags&65011712,le!==null?E=rs(le,E):(E=mi(E,f,i,null),E.flags|=2),E.return=t,o.return=t,o.sibling=E,t.child=o,sc(null,o),o=t.child,E=e.child.memoizedState,E===null?E=Gf(i):(f=E.cachePool,f!==null?(P=en._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=pu(),E={baseLanes:E.baseLanes|i,cachePool:f}),o.memoizedState=E,o.childLanes=Vf(e,S,i),t.memoizedState=qf,sc(e.child,o)):(gr(t),i=e.child,e=i.sibling,i=rs(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=Du({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Du(e,t){return e=ta(22,e,null,t),e.lanes=0,e}function Yf(e,t,i){return M(t,e.child,null,i),e=Wf(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Cg(e,t,i){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),ur(e.return,t,i)}function Kf(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 jg(e,t,i){var o=t.pendingProps,f=o.revealOrder,h=o.tail;o=o.children;var S=bn.current,E=(S&2)!==0;if(E?(S=S&1|2,t.flags|=128):S&=1,$(bn,S),Yn(e,t,o,i),o=wt?rl:0,!E&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Cg(e,i,t);else if(e.tag===19)Cg(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&&bu(e)===null&&(f=i),i=i.sibling;i=f,i===null?(f=t.child,t.child=null):(f=i.sibling,i.sibling=null),Kf(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&&bu(e)===null){t.child=f;break}e=f.sibling,f.sibling=i,i=f,f=e}Kf(t,!0,i,null,h,o);break;case"together":Kf(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function ji(e,t,i){if(e!==null&&(t.dependencies=e.dependencies),br|=t.lanes,(i&t.childLanes)===0)if(e!==null){if(Mn(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=rs(e,e.pendingProps),t.child=i,i.return=t;e.sibling!==null;)e=e.sibling,i=i.sibling=rs(e,e.pendingProps),i.return=t;i.sibling=null}return t.child}function Qf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&xt(e)))}function Lw(e,t,i){switch(t.tag){case 3:_e(t,t.stateNode.containerInfo),hi(t,en,e.memoizedState.cache),Cs();break;case 27:case 5:Z(t);break;case 4:_e(t,t.stateNode.containerInfo);break;case 10:hi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,wf(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(gr(t),t.flags|=128,null):(i&t.child.childLanes)!==0?Sg(e,t,i):(gr(t),e=ji(e,t,i),e!==null?e.sibling:null);gr(t);break;case 19:var f=(e.flags&128)!==0;if(o=(i&t.childLanes)!==0,o||(Mn(e,t,i,!1),o=(i&t.childLanes)!==0),f){if(o)return jg(e,t,i);t.flags|=128}if(f=t.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),$(bn,bn.current),o)break;return null;case 22:return t.lanes=0,gg(e,t,i,t.pendingProps);case 24:hi(t,en,e.memoizedState.cache)}return ji(e,t,i)}function kg(e,t,i){if(e!==null)if(e.memoizedProps!==t.pendingProps)Rn=!0;else{if(!Qf(e,i)&&(t.flags&128)===0)return Rn=!1,Lw(e,t,i);Rn=(e.flags&131072)!==0}else Rn=!1,wt&&(t.flags&1048576)!==0&&du(t,rl,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=Tn(t.elementType),t.type=e,typeof e=="function")Sa(e)?(o=vl(e,o),t.tag=1,t=bg(null,t,e,o,i)):(t.tag=0,t=Uf(null,t,e,o,i));else{if(e!=null){var f=e.$$typeof;if(f===U){t.tag=11,t=mg(null,t,e,o,i);break e}else if(f===_){t.tag=14,t=hg(null,t,e,o,i);break e}}throw t=se(e)||e,Error(l(306,t,""))}}return t;case 0:return Uf(e,t,t.type,t.pendingProps,i);case 1:return o=t.type,f=vl(o,t.pendingProps),bg(e,t,o,f,i);case 3:e:{if(_e(t,t.stateNode.containerInfo),e===null)throw Error(l(387));o=t.pendingProps;var h=t.memoizedState;f=h.element,pe(e,t),Wn(t,o,null,i);var S=t.memoizedState;if(o=S.cache,hi(t,en,o),o!==h.cache&&yn(t,[en],i,!0),dn(),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=wg(e,t,o,i);break e}else if(o!==f){f=na(Error(l(424)),t),Me(f),t=wg(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,Gt=us(e.firstChild),un=t,wt=!0,ws=null,ha=!0,i=L(t,null,o,i),t.child=i;i;)i.flags=i.flags&-3|4096,i=i.sibling;else{if(Cs(),o===f){t=ji(e,t,i);break e}Yn(e,t,o,i)}t=t.child}return t;case 26:return Ru(e,t),e===null?(i=Iv(t.type,null,t.pendingProps,null))?t.memoizedState=i:wt||(i=t.type,e=t.pendingProps,o=Yu(ve.current).createElement(i),o[ee]=t,o[Ne]=e,Kn(o,i,e),Pt(o),t.stateNode=o):t.memoizedState=Iv(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Z(t),e===null&&wt&&(o=t.stateNode=Lv(t.type,t.pendingProps,ve.current),un=t,ha=!0,f=Gt,kr(t.type)?(Tm=f,Gt=us(o.firstChild)):Gt=f),Yn(e,t,t.pendingProps.children,i),Ru(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&wt&&((f=o=Gt)&&(o=cS(o,t.type,t.pendingProps,ha),o!==null?(t.stateNode=o,un=t,Gt=us(o.firstChild),ha=!1,f=!0):f=!1),f||Ba(t)),Z(t),f=t.type,h=t.pendingProps,S=e!==null?e.memoizedProps:null,o=h.children,jm(f,h)?o=null:S!==null&&jm(f,S)&&(t.flags|=32),t.memoizedState!==null&&(f=Cf(e,t,jw,null,null,i),xc._currentValue=f),Ru(e,t),Yn(e,t,o,i),t.child;case 6:return e===null&&wt&&((e=i=Gt)&&(i=uS(i,t.pendingProps,ha),i!==null?(t.stateNode=i,un=t,Gt=null,e=!0):e=!1),e||Ba(t)),null;case 13:return Sg(e,t,i);case 4:return _e(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=M(t,null,o,i):Yn(e,t,o,i),t.child;case 11:return mg(e,t,t.type,t.pendingProps,i);case 7:return Yn(e,t,t.pendingProps,i),t.child;case 8:return Yn(e,t,t.pendingProps.children,i),t.child;case 12:return Yn(e,t,t.pendingProps.children,i),t.child;case 10:return o=t.pendingProps,hi(t,t.type,o.value),Yn(e,t,o.children,i),t.child;case 9:return f=t.type._context,o=t.pendingProps.children,pi(t),f=Jt(f),o=o(f),t.flags|=1,Yn(e,t,o,i),t.child;case 14:return hg(e,t,t.type,t.pendingProps,i);case 15:return pg(e,t,t.type,t.pendingProps,i);case 19:return jg(e,t,i);case 31:return Dw(e,t,i);case 22:return gg(e,t,i,t.pendingProps);case 24:return pi(t),o=Jt(en),e===null?(f=vi(),f===null&&(f=Vt,h=Xo(),f.pooledCache=h,h.refCount++,h!==null&&(f.pooledCacheLanes|=i),f=h),t.memoizedState={parent:o,cache:f},z(t),hi(t,en,f)):((e.lanes&i)!==0&&(pe(e,t),Wn(t,null,null,i),dn()),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),hi(t,en,o)):(o=h.cache,hi(t,en,o),o!==f.cache&&yn(t,[en],i,!0))),Yn(e,t,t.pendingProps.children,i),t.child;case 29:throw t.pendingProps}throw Error(l(156,t.tag))}function ki(e){e.flags|=4}function Xf(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(Zg())e.flags|=8192;else throw yi=io,Jo}else e.flags&=-16777217}function Ag(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Pv(t))if(Zg())e.flags|=8192;else throw yi=io,Jo}function Lu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?Qt():536870912,e.lanes|=t,mo|=t)}function ic(e,t){if(!wt)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 Xt(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 _w(e,t,i){var o=t.pendingProps;switch(Ko(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xt(t),null;case 1:return Xt(t),null;case 3:return i=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),Fa(en),re(),i.pendingContext&&(i.context=i.pendingContext,i.pendingContext=null),(e===null||e.child===null)&&(or(t)?ki(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,ol())),Xt(t),null;case 26:var f=t.type,h=t.memoizedState;return e===null?(ki(t),h!==null?(Xt(t),Ag(t,h)):(Xt(t),Xf(t,f,null,o,i))):h?h!==e.memoizedState?(ki(t),Xt(t),Ag(t,h)):(Xt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&ki(t),Xt(t),Xf(t,f,e,o,i)),null;case 27:if(ze(t),i=ve.current,f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ki(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Xt(t),null}e=ue.current,or(t)?Ss(t):(e=Lv(f,o,i),t.stateNode=e,ki(t))}return Xt(t),null;case 5:if(ze(t),f=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&ki(t);else{if(!o){if(t.stateNode===null)throw Error(l(166));return Xt(t),null}if(h=ue.current,or(t))Ss(t);else{var S=Yu(ve.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[ee]=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(Kn(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&&ki(t)}}return Xt(t),Xf(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,i),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&ki(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(l(166));if(e=ve.current,or(t)){if(e=t.stateNode,i=t.memoizedProps,o=null,f=un,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[ee]=t,e=!!(e.nodeValue===i||o!==null&&o.suppressHydrationWarning===!0||Sv(e.nodeValue,i)),e||Ba(t,!0)}else e=Yu(e).createTextNode(o),e[ee]=t,t.stateNode=e}return Xt(t),null;case 31:if(i=t.memoizedState,e===null||e.memoizedState!==null){if(o=or(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[ee]=t}else Cs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Xt(t),e=!1}else i=ol(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),e=!0;if(!e)return t.flags&256?($a(t),t):($a(t),null);if((t.flags&128)!==0)throw Error(l(558))}return Xt(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=or(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[ee]=t}else Cs(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Xt(t),f=!1}else f=ol(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return t.flags&256?($a(t),t):($a(t),null)}return $a(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),Lu(t,t.updateQueue),Xt(t),null);case 4:return re(),e===null&&xm(t.stateNode.containerInfo),Xt(t),null;case 10:return Fa(t.type),Xt(t),null;case 19:if(X(bn),o=t.memoizedState,o===null)return Xt(t),null;if(f=(t.flags&128)!==0,h=o.rendering,h===null)if(f)ic(o,!1);else{if(mn!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(h=bu(e),h!==null){for(t.flags|=128,ic(o,!1),e=h.updateQueue,t.updateQueue=e,Lu(t,e),t.subtreeFlags=0,e=i,i=t.child;i!==null;)ir(i,e),i=i.sibling;return $(bn,bn.current&1|2),wt&&Ha(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&ot()>Hu&&(t.flags|=128,f=!0,ic(o,!1),t.lanes=4194304)}else{if(!f)if(e=bu(h),e!==null){if(t.flags|=128,f=!0,e=e.updateQueue,t.updateQueue=e,Lu(t,e),ic(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!wt)return Xt(t),null}else 2*ot()-o.renderingStartTime>Hu&&i!==536870912&&(t.flags|=128,f=!0,ic(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=ot(),e.sibling=null,i=bn.current,$(bn,f?i&1|2:i&1),wt&&Ha(t,o.treeForkCount),e):(Xt(t),null);case 22:case 23:return $a(t),bf(),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&&(Xt(t),t.subtreeFlags&6&&(t.flags|=8192)):Xt(t),i=t.updateQueue,i!==null&&Lu(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&&X(os),null;case 24:return i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),Fa(en),Xt(t),null;case 25:return null;case 30:return null}throw Error(l(156,t.tag))}function zw(e,t){switch(Ko(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Fa(en),re(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ze(t),null;case 31:if(t.memoizedState!==null){if($a(t),t.alternate===null)throw Error(l(340));Cs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if($a(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(l(340));Cs()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return X(bn),null;case 4:return re(),null;case 10:return Fa(t.type),null;case 22:case 23:return $a(t),bf(),e!==null&&X(os),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Fa(en),null;case 25:return null;default:return null}}function Ng(e,t){switch(Ko(t),t.tag){case 3:Fa(en),re();break;case 26:case 27:case 5:ze(t);break;case 4:re();break;case 31:t.memoizedState!==null&&$a(t);break;case 13:$a(t);break;case 19:X(bn);break;case 10:Fa(t.type);break;case 22:case 23:$a(t),bf(),e!==null&&X(os);break;case 24:Fa(en)}}function rc(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(E){Ht(t,t.return,E)}}function yr(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,E=S.destroy;if(E!==void 0){S.destroy=void 0,f=t;var P=i,le=E;try{le()}catch(ye){Ht(f,P,ye)}}}o=o.next}while(o!==h)}}catch(ye){Ht(t,t.return,ye)}}function Mg(e){var t=e.updateQueue;if(t!==null){var i=e.stateNode;try{pl(t,i)}catch(o){Ht(e,e.return,o)}}}function Tg(e,t,i){i.props=vl(e.type,e.memoizedProps),i.state=e.memoizedState;try{i.componentWillUnmount()}catch(o){Ht(e,t,o)}}function lc(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){Ht(e,t,f)}}function Xs(e,t){var i=e.ref,o=e.refCleanup;if(i!==null)if(typeof o=="function")try{o()}catch(f){Ht(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){Ht(e,t,f)}else i.current=null}function Eg(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){Ht(e,e.return,f)}}function Zf(e,t,i){try{var o=e.stateNode;aS(o,e.type,i,t),o[Ne]=t}catch(f){Ht(e,e.return,f)}}function Rg(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&kr(e.type)||e.tag===4}function Jf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Rg(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&&kr(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 em(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=_a));else if(o!==4&&(o===27&&kr(e.type)&&(i=e.stateNode,t=null),e=e.child,e!==null))for(em(e,t,i),e=e.sibling;e!==null;)em(e,t,i),e=e.sibling}function _u(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&&kr(e.type)&&(i=e.stateNode),e=e.child,e!==null))for(_u(e,t,i),e=e.sibling;e!==null;)_u(e,t,i),e=e.sibling}function Dg(e){var t=e.stateNode,i=e.memoizedProps;try{for(var o=e.type,f=t.attributes;f.length;)t.removeAttributeNode(f[0]);Kn(t,o,i),t[ee]=e,t[Ne]=i}catch(h){Ht(e,e.return,h)}}var Ai=!1,Dn=!1,tm=!1,Lg=typeof WeakSet=="function"?WeakSet:Set,Bn=null;function Iw(e,t){if(e=e.containerInfo,Sm=td,e=ou(e),Ql(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,E=-1,P=-1,le=0,ye=0,Ce=e,oe=null;t:for(;;){for(var me;Ce!==i||f!==0&&Ce.nodeType!==3||(E=S+f),Ce!==h||o!==0&&Ce.nodeType!==3||(P=S+o),Ce.nodeType===3&&(S+=Ce.nodeValue.length),(me=Ce.firstChild)!==null;)oe=Ce,Ce=me;for(;;){if(Ce===e)break t;if(oe===i&&++le===f&&(E=S),oe===h&&++ye===o&&(P=S),(me=Ce.nextSibling)!==null)break;Ce=oe,oe=Ce.parentNode}Ce=me}i=E===-1||P===-1?null:{start:E,end:P}}else i=null}i=i||{start:0,end:0}}else i=null;for(Cm={focusedElem:e,selectionRange:i},td=!1,Bn=t;Bn!==null;)if(t=Bn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Bn=e;else for(;Bn!==null;){switch(t=Bn,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 Ye=vl(i.type,f);e=o.getSnapshotBeforeUpdate(Ye,h),o.__reactInternalSnapshotBeforeUpdate=e}catch(tt){Ht(i,i.return,tt)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,i=e.nodeType,i===9)Am(e);else if(i===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Am(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,Bn=e;break}Bn=t.return}}function _g(e,t,i){var o=i.flags;switch(i.tag){case 0:case 11:case 15:Mi(e,i),o&4&&rc(5,i);break;case 1:if(Mi(e,i),o&4)if(e=i.stateNode,t===null)try{e.componentDidMount()}catch(S){Ht(i,i.return,S)}else{var f=vl(i.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(f,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){Ht(i,i.return,S)}}o&64&&Mg(i),o&512&&lc(i,i.return);break;case 3:if(Mi(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{pl(e,t)}catch(S){Ht(i,i.return,S)}}break;case 27:t===null&&o&4&&Dg(i);case 26:case 5:Mi(e,i),t===null&&o&4&&Eg(i),o&512&&lc(i,i.return);break;case 12:Mi(e,i);break;case 31:Mi(e,i),o&4&&Og(e,i);break;case 13:Mi(e,i),o&4&&Hg(e,i),o&64&&(e=i.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(i=Gw.bind(null,i),dS(e,i))));break;case 22:if(o=i.memoizedState!==null||Ai,!o){t=t!==null&&t.memoizedState!==null||Dn,f=Ai;var h=Dn;Ai=o,(Dn=t)&&!h?Ti(e,i,(i.subtreeFlags&8772)!==0):Mi(e,i),Ai=f,Dn=h}break;case 30:break;default:Mi(e,i)}}function zg(e){var t=e.alternate;t!==null&&(e.alternate=null,zg(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&kn(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 nn=null,ja=!1;function Ni(e,t,i){for(i=i.child;i!==null;)Ig(e,t,i),i=i.sibling}function Ig(e,t,i){if(ke&&typeof ke.onCommitFiberUnmount=="function")try{ke.onCommitFiberUnmount(Fe,i)}catch{}switch(i.tag){case 26:Dn||Xs(i,t),Ni(e,t,i),i.memoizedState?i.memoizedState.count--:i.stateNode&&(i=i.stateNode,i.parentNode.removeChild(i));break;case 27:Dn||Xs(i,t);var o=nn,f=ja;kr(i.type)&&(nn=i.stateNode,ja=!1),Ni(e,t,i),gc(i.stateNode),nn=o,ja=f;break;case 5:Dn||Xs(i,t);case 6:if(o=nn,f=ja,nn=null,Ni(e,t,i),nn=o,ja=f,nn!==null)if(ja)try{(nn.nodeType===9?nn.body:nn.nodeName==="HTML"?nn.ownerDocument.body:nn).removeChild(i.stateNode)}catch(h){Ht(i,t,h)}else try{nn.removeChild(i.stateNode)}catch(h){Ht(i,t,h)}break;case 18:nn!==null&&(ja?(e=nn,Mv(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,i.stateNode),wo(e)):Mv(nn,i.stateNode));break;case 4:o=nn,f=ja,nn=i.stateNode.containerInfo,ja=!0,Ni(e,t,i),nn=o,ja=f;break;case 0:case 11:case 14:case 15:yr(2,i,t),Dn||yr(4,i,t),Ni(e,t,i);break;case 1:Dn||(Xs(i,t),o=i.stateNode,typeof o.componentWillUnmount=="function"&&Tg(i,t,o)),Ni(e,t,i);break;case 21:Ni(e,t,i);break;case 22:Dn=(o=Dn)||i.memoizedState!==null,Ni(e,t,i),Dn=o;break;default:Ni(e,t,i)}}function Og(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{wo(e)}catch(i){Ht(t,t.return,i)}}}function Hg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{wo(e)}catch(i){Ht(t,t.return,i)}}function Ow(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Lg),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Lg),t;default:throw Error(l(435,e.tag))}}function zu(e,t){var i=Ow(e);t.forEach(function(o){if(!i.has(o)){i.add(o);var f=Vw.bind(null,e,o);o.then(f,f)}})}function ka(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,E=S;e:for(;E!==null;){switch(E.tag){case 27:if(kr(E.type)){nn=E.stateNode,ja=!1;break e}break;case 5:nn=E.stateNode,ja=!1;break e;case 3:case 4:nn=E.stateNode.containerInfo,ja=!0;break e}E=E.return}if(nn===null)throw Error(l(160));Ig(h,S,f),nn=null,ja=!1,h=f.alternate,h!==null&&(h.return=null),f.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Bg(t,e),t=t.sibling}var As=null;function Bg(e,t){var i=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ka(t,e),Aa(e),o&4&&(yr(3,e,e.return),rc(3,e),yr(5,e,e.return));break;case 1:ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(i,i.return)),o&64&&Ai&&(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=As;if(ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(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[ut]||h[ee]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=f.createElement(o),f.head.insertBefore(h,f.querySelector("head > title"))),Kn(h,o,i),h[ee]=e,Pt(h),o=h;break e;case"link":var S=Bv("link","href",f).get(o+(i.href||""));if(S){for(var E=0;E<S.length;E++)if(h=S[E],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(E,1);break t}}h=f.createElement(o),Kn(h,o,i),f.head.appendChild(h);break;case"meta":if(S=Bv("meta","content",f).get(o+(i.content||""))){for(E=0;E<S.length;E++)if(h=S[E],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(E,1);break t}}h=f.createElement(o),Kn(h,o,i),f.head.appendChild(h);break;default:throw Error(l(468,o))}h[ee]=e,Pt(h),o=h}e.stateNode=o}else Fv(f,e.type,e.stateNode);else e.stateNode=Hv(f,o,e.memoizedProps);else h!==o?(h===null?i.stateNode!==null&&(i=i.stateNode,i.parentNode.removeChild(i)):h.count--,o===null?Fv(f,e.type,e.stateNode):Hv(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Zf(e,e.memoizedProps,i.memoizedProps)}break;case 27:ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(i,i.return)),i!==null&&o&4&&Zf(e,e.memoizedProps,i.memoizedProps);break;case 5:if(ka(t,e),Aa(e),o&512&&(Dn||i===null||Xs(i,i.return)),e.flags&32){f=e.stateNode;try{gs(f,"")}catch(Ye){Ht(e,e.return,Ye)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,Zf(e,f,i!==null?i.memoizedProps:f)),o&1024&&(tm=!0);break;case 6:if(ka(t,e),Aa(e),o&4){if(e.stateNode===null)throw Error(l(162));o=e.memoizedProps,i=e.stateNode;try{i.nodeValue=o}catch(Ye){Ht(e,e.return,Ye)}}break;case 3:if(Xu=null,f=As,As=Ku(t.containerInfo),ka(t,e),As=f,Aa(e),o&4&&i!==null&&i.memoizedState.isDehydrated)try{wo(t.containerInfo)}catch(Ye){Ht(e,e.return,Ye)}tm&&(tm=!1,Fg(e));break;case 4:o=As,As=Ku(e.stateNode.containerInfo),ka(t,e),Aa(e),As=o;break;case 12:ka(t,e),Aa(e);break;case 31:ka(t,e),Aa(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,zu(e,o)));break;case 13:ka(t,e),Aa(e),e.child.flags&8192&&e.memoizedState!==null!=(i!==null&&i.memoizedState!==null)&&(Ou=ot()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,zu(e,o)));break;case 22:f=e.memoizedState!==null;var P=i!==null&&i.memoizedState!==null,le=Ai,ye=Dn;if(Ai=le||f,Dn=ye||P,ka(t,e),Dn=ye,Ai=le,Aa(e),o&8192)e:for(t=e.stateNode,t._visibility=f?t._visibility&-2:t._visibility|1,f&&(i===null||P||Ai||Dn||yl(e)),i=null,t=e;;){if(t.tag===5||t.tag===26){if(i===null){P=i=t;try{if(h=P.stateNode,f)S=h.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{E=P.stateNode;var Ce=P.memoizedProps.style,oe=Ce!=null&&Ce.hasOwnProperty("display")?Ce.display:null;E.style.display=oe==null||typeof oe=="boolean"?"":(""+oe).trim()}}catch(Ye){Ht(P,P.return,Ye)}}}else if(t.tag===6){if(i===null){P=t;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(Ye){Ht(P,P.return,Ye)}}}else if(t.tag===18){if(i===null){P=t;try{var me=P.stateNode;f?Tv(me,!0):Tv(P.stateNode,!1)}catch(Ye){Ht(P,P.return,Ye)}}}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:ka(t,e),Aa(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,zu(e,o)));break;case 30:break;case 21:break;default:ka(t,e),Aa(e)}}function Aa(e){var t=e.flags;if(t&2){try{for(var i,o=e.return;o!==null;){if(Rg(o)){i=o;break}o=o.return}if(i==null)throw Error(l(160));switch(i.tag){case 27:var f=i.stateNode,h=Jf(e);_u(e,h,f);break;case 5:var S=i.stateNode;i.flags&32&&(gs(S,""),i.flags&=-33);var E=Jf(e);_u(e,E,S);break;case 3:case 4:var P=i.stateNode.containerInfo,le=Jf(e);em(e,le,P);break;default:throw Error(l(161))}}catch(ye){Ht(e,e.return,ye)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Fg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Fg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Mi(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)_g(e,t.alternate,t),t=t.sibling}function yl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:yr(4,t,t.return),yl(t);break;case 1:Xs(t,t.return);var i=t.stateNode;typeof i.componentWillUnmount=="function"&&Tg(t,t.return,i),yl(t);break;case 27:gc(t.stateNode);case 26:case 5:Xs(t,t.return),yl(t);break;case 22:t.memoizedState===null&&yl(t);break;case 30:yl(t);break;default:yl(t)}e=e.sibling}}function Ti(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:Ti(f,h,i),rc(4,h);break;case 1:if(Ti(f,h,i),o=h,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(le){Ht(o,o.return,le)}if(o=h,f=o.updateQueue,f!==null){var E=o.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)hl(P[f],E)}catch(le){Ht(o,o.return,le)}}i&&S&64&&Mg(h),lc(h,h.return);break;case 27:Dg(h);case 26:case 5:Ti(f,h,i),i&&o===null&&S&4&&Eg(h),lc(h,h.return);break;case 12:Ti(f,h,i);break;case 31:Ti(f,h,i),i&&S&4&&Og(f,h);break;case 13:Ti(f,h,i),i&&S&4&&Hg(f,h);break;case 22:h.memoizedState===null&&Ti(f,h,i),lc(h,h.return);break;case 30:break;default:Ti(f,h,i)}t=t.sibling}}function nm(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&&ul(i))}function am(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ul(e))}function Ns(e,t,i,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Pg(e,t,i,o),t=t.sibling}function Pg(e,t,i,o){var f=t.flags;switch(t.tag){case 0:case 11:case 15:Ns(e,t,i,o),f&2048&&rc(9,t);break;case 1:Ns(e,t,i,o);break;case 3:Ns(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&&ul(e)));break;case 12:if(f&2048){Ns(e,t,i,o),e=t.stateNode;try{var h=t.memoizedProps,S=h.id,E=h.onPostCommit;typeof E=="function"&&E(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){Ht(t,t.return,P)}}else Ns(e,t,i,o);break;case 31:Ns(e,t,i,o);break;case 13:Ns(e,t,i,o);break;case 23:break;case 22:h=t.stateNode,S=t.alternate,t.memoizedState!==null?h._visibility&2?Ns(e,t,i,o):oc(e,t):h._visibility&2?Ns(e,t,i,o):(h._visibility|=2,co(e,t,i,o,(t.subtreeFlags&10256)!==0||!1)),f&2048&&nm(S,t);break;case 24:Ns(e,t,i,o),f&2048&&am(t.alternate,t);break;default:Ns(e,t,i,o)}}function co(e,t,i,o,f){for(f=f&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var h=e,S=t,E=i,P=o,le=S.flags;switch(S.tag){case 0:case 11:case 15:co(h,S,E,P,f),rc(8,S);break;case 23:break;case 22:var ye=S.stateNode;S.memoizedState!==null?ye._visibility&2?co(h,S,E,P,f):oc(h,S):(ye._visibility|=2,co(h,S,E,P,f)),f&&le&2048&&nm(S.alternate,S);break;case 24:co(h,S,E,P,f),f&&le&2048&&am(S.alternate,S);break;default:co(h,S,E,P,f)}t=t.sibling}}function oc(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:oc(i,o),f&2048&&nm(o.alternate,o);break;case 24:oc(i,o),f&2048&&am(o.alternate,o);break;default:oc(i,o)}t=t.sibling}}var cc=8192;function uo(e,t,i){if(e.subtreeFlags&cc)for(e=e.child;e!==null;)$g(e,t,i),e=e.sibling}function $g(e,t,i){switch(e.tag){case 26:uo(e,t,i),e.flags&cc&&e.memoizedState!==null&&CS(i,As,e.memoizedState,e.memoizedProps);break;case 5:uo(e,t,i);break;case 3:case 4:var o=As;As=Ku(e.stateNode.containerInfo),uo(e,t,i),As=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=cc,cc=16777216,uo(e,t,i),cc=o):uo(e,t,i));break;default:uo(e,t,i)}}function Ug(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 uc(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];Bn=o,Gg(o,e)}Ug(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)qg(e),e=e.sibling}function qg(e){switch(e.tag){case 0:case 11:case 15:uc(e),e.flags&2048&&yr(9,e,e.return);break;case 3:uc(e);break;case 12:uc(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Iu(e)):uc(e);break;default:uc(e)}}function Iu(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];Bn=o,Gg(o,e)}Ug(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:yr(8,t,t.return),Iu(t);break;case 22:i=t.stateNode,i._visibility&2&&(i._visibility&=-3,Iu(t));break;default:Iu(t)}e=e.sibling}}function Gg(e,t){for(;Bn!==null;){var i=Bn;switch(i.tag){case 0:case 11:case 15:yr(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:ul(i.memoizedState.cache)}if(o=i.child,o!==null)o.return=i,Bn=o;else e:for(i=e;Bn!==null;){o=Bn;var f=o.sibling,h=o.return;if(zg(o),o===i){Bn=null;break e}if(f!==null){f.return=h,Bn=f;break e}Bn=h}}}var Hw={getCacheForType:function(e){var t=Jt(en),i=t.data.get(e);return i===void 0&&(i=e(),t.data.set(e,i)),i},cacheSignal:function(){return Jt(en).controller.signal}},Bw=typeof WeakMap=="function"?WeakMap:Map,Lt=0,Vt=null,Ct=null,kt=0,Ot=0,Ua=null,xr=!1,fo=!1,sm=!1,Ei=0,mn=0,br=0,xl=0,im=0,qa=0,mo=0,dc=null,Na=null,rm=!1,Ou=0,Vg=0,Hu=1/0,Bu=null,wr=null,_n=0,Sr=null,ho=null,Ri=0,lm=0,om=null,Wg=null,fc=0,cm=null;function Ga(){return(Lt&2)!==0&&kt!==0?kt&-kt:I.T!==null?pm():Qa()}function Yg(){if(qa===0)if((kt&536870912)===0||wt){var e=zt;zt<<=1,(zt&3932160)===0&&(zt=262144),qa=e}else qa=536870912;return e=Pa.current,e!==null&&(e.flags|=32),qa}function Ma(e,t,i){(e===Vt&&(Ot===2||Ot===9)||e.cancelPendingCommit!==null)&&(po(e,0),Cr(e,kt,qa,!1)),bt(e,i),((Lt&2)===0||e!==Vt)&&(e===Vt&&((Lt&2)===0&&(xl|=i),mn===4&&Cr(e,kt,qa,!1)),Zs(e))}function Kg(e,t,i){if((Lt&6)!==0)throw Error(l(327));var o=!i&&(t&127)===0&&(t&e.expiredLanes)===0||dt(e,t),f=o?$w(e,t):dm(e,t,!0),h=o;do{if(f===0){fo&&!o&&Cr(e,t,0,!1);break}else{if(i=e.current.alternate,h&&!Fw(i)){f=dm(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 E=e;f=dc;var P=E.current.memoizedState.isDehydrated;if(P&&(po(E,S).flags|=256),S=dm(E,S,!1),S!==2){if(sm&&!P){E.errorRecoveryDisabledLanes|=h,xl|=h,f=4;break e}h=Na,Na=f,h!==null&&(Na===null?Na=h:Na.push.apply(Na,h))}f=S}if(h=!1,f!==2)continue}}if(f===1){po(e,0),Cr(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:Cr(o,t,qa,!xr);break e;case 2:Na=null;break;case 3:case 5:break;default:throw Error(l(329))}if((t&62914560)===t&&(f=Ou+300-ot(),10<f)){if(Cr(o,t,qa,!xr),ya(o,0,!0)!==0)break e;Ri=t,o.timeoutHandle=Av(Qg.bind(null,o,i,Na,Bu,rm,t,qa,xl,mo,xr,h,"Throttled",-0,0),f);break e}Qg(o,i,Na,Bu,rm,t,qa,xl,mo,xr,h,null,-0,0)}}break}while(!0);Zs(e)}function Qg(e,t,i,o,f,h,S,E,P,le,ye,Ce,oe,me){if(e.timeoutHandle=-1,Ce=t.subtreeFlags,Ce&8192||(Ce&16785408)===16785408){Ce={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:_a},$g(t,h,Ce);var Ye=(h&62914560)===h?Ou-ot():(h&4194048)===h?Vg-ot():0;if(Ye=jS(Ce,Ye),Ye!==null){Ri=h,e.cancelPendingCommit=Ye(sv.bind(null,e,t,h,i,o,f,S,E,P,ye,Ce,null,oe,me)),Cr(e,h,S,!le);return}}sv(e,t,h,i,o,f,S,E,P)}function Fw(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(!Nn(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 Cr(e,t,i,o){t&=~im,t&=~xl,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var f=t;0<f;){var h=31-gt(f),S=1<<h;o[h]=-1,f&=~S}i!==0&&_s(e,i,t)}function Fu(){return(Lt&6)===0?(mc(0),!1):!0}function um(){if(Ct!==null){if(Ot===0)var e=Ct.return;else e=Ct,js=Qs=null,Af(e),hr=null,bi=0,e=Ct;for(;e!==null;)Ng(e.alternate,e),e=e.return;Ct=null}}function po(e,t){var i=e.timeoutHandle;i!==-1&&(e.timeoutHandle=-1,rS(i)),i=e.cancelPendingCommit,i!==null&&(e.cancelPendingCommit=null,i()),Ri=0,um(),Vt=e,Ct=i=rs(e.current,null),kt=t,Ot=0,Ua=null,xr=!1,fo=dt(e,t),sm=!1,mo=qa=im=xl=br=mn=0,Na=dc=null,rm=!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-gt(o),h=1<<f;t|=e[f],o&=~h}return Ei=t,Ws(),i}function Xg(e,t){mt=null,I.H=ac,t===mr||t===so?(t=yu(),Ot=3):t===Jo?(t=yu(),Ot=4):Ot=t===$f?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ua=t,Ct===null&&(mn=1,Tu(e,na(t,e.current)))}function Zg(){var e=Pa.current;return e===null?!0:(kt&4194048)===kt?cs===null:(kt&62914560)===kt||(kt&536870912)!==0?e===cs:!1}function Jg(){var e=I.H;return I.H=ac,e===null?ac:e}function ev(){var e=I.A;return I.A=Hw,e}function Pu(){mn=4,xr||(kt&4194048)!==kt&&Pa.current!==null||(fo=!0),(br&134217727)===0&&(xl&134217727)===0||Vt===null||Cr(Vt,kt,qa,!1)}function dm(e,t,i){var o=Lt;Lt|=2;var f=Jg(),h=ev();(Vt!==e||kt!==t)&&(Bu=null,po(e,t)),t=!1;var S=mn;e:do try{if(Ot!==0&&Ct!==null){var E=Ct,P=Ua;switch(Ot){case 8:um(),S=6;break e;case 3:case 2:case 9:case 6:Pa.current===null&&(t=!0);var le=Ot;if(Ot=0,Ua=null,go(e,E,P,le),i&&fo){S=0;break e}break;default:le=Ot,Ot=0,Ua=null,go(e,E,P,le)}}Pw(),S=mn;break}catch(ye){Xg(e,ye)}while(!0);return t&&e.shellSuspendCounter++,js=Qs=null,Lt=o,I.H=f,I.A=h,Ct===null&&(Vt=null,kt=0,Ws()),S}function Pw(){for(;Ct!==null;)tv(Ct)}function $w(e,t){var i=Lt;Lt|=2;var o=Jg(),f=ev();Vt!==e||kt!==t?(Bu=null,Hu=ot()+500,po(e,t)):fo=dt(e,t);e:do try{if(Ot!==0&&Ct!==null){t=Ct;var h=Ua;t:switch(Ot){case 1:Ot=0,Ua=null,go(e,t,h,1);break;case 2:case 9:if(gu(h)){Ot=0,Ua=null,nv(t);break}t=function(){Ot!==2&&Ot!==9||Vt!==e||(Ot=7),Zs(e)},h.then(t,t);break e;case 3:Ot=7;break e;case 4:Ot=5;break e;case 7:gu(h)?(Ot=0,Ua=null,nv(t)):(Ot=0,Ua=null,go(e,t,h,7));break;case 5:var S=null;switch(Ct.tag){case 26:S=Ct.memoizedState;case 5:case 27:var E=Ct;if(S?Pv(S):E.stateNode.complete){Ot=0,Ua=null;var P=E.sibling;if(P!==null)Ct=P;else{var le=E.return;le!==null?(Ct=le,$u(le)):Ct=null}break t}}Ot=0,Ua=null,go(e,t,h,5);break;case 6:Ot=0,Ua=null,go(e,t,h,6);break;case 8:um(),mn=6;break e;default:throw Error(l(462))}}Uw();break}catch(ye){Xg(e,ye)}while(!0);return js=Qs=null,I.H=o,I.A=f,Lt=i,Ct!==null?0:(Vt=null,kt=0,Ws(),mn)}function Uw(){for(;Ct!==null&&!We();)tv(Ct)}function tv(e){var t=kg(e.alternate,e,Ei);e.memoizedProps=e.pendingProps,t===null?$u(e):Ct=t}function nv(e){var t=e,i=t.alternate;switch(t.tag){case 15:case 0:t=xg(i,t,t.pendingProps,t.type,void 0,kt);break;case 11:t=xg(i,t,t.pendingProps,t.type.render,t.ref,kt);break;case 5:Af(t);default:Ng(i,t),t=Ct=ir(t,Ei),t=kg(i,t,Ei)}e.memoizedProps=e.pendingProps,t===null?$u(e):Ct=t}function go(e,t,i,o){js=Qs=null,Af(t),hr=null,bi=0;var f=t.return;try{if(Rw(e,f,t,i,kt)){mn=1,Tu(e,na(i,e.current)),Ct=null;return}}catch(h){if(f!==null)throw Ct=f,h;mn=1,Tu(e,na(i,e.current)),Ct=null;return}t.flags&32768?(wt||o===1?e=!0:fo||(kt&536870912)!==0?e=!1:(xr=e=!0,(o===2||o===9||o===3||o===6)&&(o=Pa.current,o!==null&&o.tag===13&&(o.flags|=16384))),av(t,e)):$u(t)}function $u(e){var t=e;do{if((t.flags&32768)!==0){av(t,xr);return}e=t.return;var i=_w(t.alternate,t,Ei);if(i!==null){Ct=i;return}if(t=t.sibling,t!==null){Ct=t;return}Ct=t=e}while(t!==null);mn===0&&(mn=5)}function av(e,t){do{var i=zw(e.alternate,e);if(i!==null){i.flags&=32767,Ct=i;return}if(i=e.return,i!==null&&(i.flags|=32768,i.subtreeFlags=0,i.deletions=null),!t&&(e=e.sibling,e!==null)){Ct=e;return}Ct=e=i}while(e!==null);mn=6,Ct=null}function sv(e,t,i,o,f,h,S,E,P){e.cancelPendingCommit=null;do Uu();while(_n!==0);if((Lt&6)!==0)throw Error(l(327));if(t!==null){if(t===e.current)throw Error(l(177));if(h=t.lanes|t.childLanes,h|=sr,qn(e,i,h,S,E,P),e===Vt&&(Ct=Vt=null,kt=0),ho=t,Sr=e,Ri=i,lm=h,om=f,Wg=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,Ww(ct,function(){return cv(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=I.T,I.T=null,f=Q.p,Q.p=2,S=Lt,Lt|=4;try{Iw(e,t,i)}finally{Lt=S,Q.p=f,I.T=o}}_n=1,iv(),rv(),lv()}}function iv(){if(_n===1){_n=0;var e=Sr,t=ho,i=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||i){i=I.T,I.T=null;var o=Q.p;Q.p=2;var f=Lt;Lt|=4;try{Bg(t,e);var h=Cm,S=ou(e.containerInfo),E=h.focusedElem,P=h.selectionRange;if(S!==E&&E&&E.ownerDocument&&ui(E.ownerDocument.documentElement,E)){if(P!==null&&Ql(E)){var le=P.start,ye=P.end;if(ye===void 0&&(ye=le),"selectionStart"in E)E.selectionStart=le,E.selectionEnd=Math.min(ye,E.value.length);else{var Ce=E.ownerDocument||document,oe=Ce&&Ce.defaultView||window;if(oe.getSelection){var me=oe.getSelection(),Ye=E.textContent.length,tt=Math.min(P.start,Ye),qt=P.end===void 0?tt:Math.min(P.end,Ye);!me.extend&&tt>qt&&(S=qt,qt=tt,tt=S);var J=lu(E,tt),W=lu(E,qt);if(J&&W&&(me.rangeCount!==1||me.anchorNode!==J.node||me.anchorOffset!==J.offset||me.focusNode!==W.node||me.focusOffset!==W.offset)){var ie=Ce.createRange();ie.setStart(J.node,J.offset),me.removeAllRanges(),tt>qt?(me.addRange(ie),me.extend(W.node,W.offset)):(ie.setEnd(W.node,W.offset),me.addRange(ie))}}}}for(Ce=[],me=E;me=me.parentNode;)me.nodeType===1&&Ce.push({element:me,left:me.scrollLeft,top:me.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<Ce.length;E++){var we=Ce[E];we.element.scrollLeft=we.left,we.element.scrollTop=we.top}}td=!!Sm,Cm=Sm=null}finally{Lt=f,Q.p=o,I.T=i}}e.current=t,_n=2}}function rv(){if(_n===2){_n=0;var e=Sr,t=ho,i=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||i){i=I.T,I.T=null;var o=Q.p;Q.p=2;var f=Lt;Lt|=4;try{_g(e,t.alternate,t)}finally{Lt=f,Q.p=o,I.T=i}}_n=3}}function lv(){if(_n===4||_n===3){_n=0,it();var e=Sr,t=ho,i=Ri,o=Wg;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?_n=5:(_n=0,ho=Sr=null,ov(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(wr=null),sn(i),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot=="function")try{ke.onCommitFiberRoot(Fe,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=I.T,f=Q.p,Q.p=2,I.T=null;try{for(var h=e.onRecoverableError,S=0;S<o.length;S++){var E=o[S];h(E.value,{componentStack:E.stack})}}finally{I.T=t,Q.p=f}}(Ri&3)!==0&&Uu(),Zs(e),f=e.pendingLanes,(i&261930)!==0&&(f&42)!==0?e===cm?fc++:(fc=0,cm=e):fc=0,mc(0)}}function ov(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ul(t)))}function Uu(){return iv(),rv(),lv(),cv()}function cv(){if(_n!==5)return!1;var e=Sr,t=lm;lm=0;var i=sn(Ri),o=I.T,f=Q.p;try{Q.p=32>i?32:i,I.T=null,i=om,om=null;var h=Sr,S=Ri;if(_n=0,ho=Sr=null,Ri=0,(Lt&6)!==0)throw Error(l(331));var E=Lt;if(Lt|=4,qg(h.current),Pg(h,h.current,S,i),Lt=E,mc(0,!1),ke&&typeof ke.onPostCommitFiberRoot=="function")try{ke.onPostCommitFiberRoot(Fe,h)}catch{}return!0}finally{Q.p=f,I.T=o,ov(e,t)}}function uv(e,t,i){t=na(i,t),t=Pf(e.stateNode,t,2),e=De(e,t,2),e!==null&&(bt(e,2),Zs(e))}function Ht(e,t,i){if(e.tag===3)uv(e,e,i);else for(;t!==null;){if(t.tag===3){uv(t,e,i);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(wr===null||!wr.has(o))){e=na(i,e),i=dg(2),o=De(t,i,2),o!==null&&(fg(i,o,t,e),bt(o,2),Zs(o));break}}t=t.return}}function fm(e,t,i){var o=e.pingCache;if(o===null){o=e.pingCache=new Bw;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)||(sm=!0,f.add(i),e=qw.bind(null,e,t,i),t.then(e,e))}function qw(e,t,i){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&i,e.warmLanes&=~i,Vt===e&&(kt&i)===i&&(mn===4||mn===3&&(kt&62914560)===kt&&300>ot()-Ou?(Lt&2)===0&&po(e,0):im|=i,mo===kt&&(mo=0)),Zs(e)}function dv(e,t){t===0&&(t=Qt()),e=wa(e,t),e!==null&&(bt(e,t),Zs(e))}function Gw(e){var t=e.memoizedState,i=0;t!==null&&(i=t.retryLane),dv(e,i)}function Vw(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),dv(e,i)}function Ww(e,t){return Et(e,t)}var qu=null,vo=null,mm=!1,Gu=!1,hm=!1,jr=0;function Zs(e){e!==vo&&e.next===null&&(vo===null?qu=vo=e:vo=vo.next=e),Gu=!0,mm||(mm=!0,Kw())}function mc(e,t){if(!hm&&Gu){hm=!0;do for(var i=!1,o=qu;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var h=0;else{var S=o.suspendedLanes,E=o.pingedLanes;h=(1<<31-gt(42|e)+1)-1,h&=f&~(S&~E),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(i=!0,pv(o,h))}else h=kt,h=ya(o,o===Vt?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||dt(o,h)||(i=!0,pv(o,h));o=o.next}while(i);hm=!1}}function Yw(){fv()}function fv(){Gu=mm=!1;var e=0;jr!==0&&iS()&&(e=jr);for(var t=ot(),i=null,o=qu;o!==null;){var f=o.next,h=mv(o,t);h===0?(o.next=null,i===null?qu=f:i.next=f,f===null&&(vo=i)):(i=o,(e!==0||(h&3)!==0)&&(Gu=!0)),o=f}_n!==0&&_n!==5||mc(e),jr!==0&&(jr=0)}function mv(e,t){for(var i=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,h=e.pendingLanes&-62914561;0<h;){var S=31-gt(h),E=1<<S,P=f[S];P===-1?((E&i)===0||(E&o)!==0)&&(f[S]=Hi(E,t)):P<=t&&(e.expiredLanes|=E),h&=~E}if(t=Vt,i=kt,i=ya(e,e===t?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,i===0||e===t&&(Ot===2||Ot===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&je(o),e.callbackNode=null,e.callbackPriority=0;if((i&3)===0||dt(e,i)){if(t=i&-i,t===e.callbackPriority)return t;switch(o!==null&&je(o),sn(i)){case 2:case 8:i=Ie;break;case 32:i=ct;break;case 268435456:i=Ft;break;default:i=ct}return o=hv.bind(null,e),i=Et(i,o),e.callbackPriority=t,e.callbackNode=i,t}return o!==null&&o!==null&&je(o),e.callbackPriority=2,e.callbackNode=null,2}function hv(e,t){if(_n!==0&&_n!==5)return e.callbackNode=null,e.callbackPriority=0,null;var i=e.callbackNode;if(Uu()&&e.callbackNode!==i)return null;var o=kt;return o=ya(e,e===Vt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Kg(e,o,t),mv(e,ot()),e.callbackNode!=null&&e.callbackNode===i?hv.bind(null,e):null)}function pv(e,t){if(Uu())return null;Kg(e,t,!0)}function Kw(){lS(function(){(Lt&6)!==0?Et(Kt,Yw):fv()})}function pm(){if(jr===0){var e=gi;e===0&&(e=nt,nt<<=1,(nt&261888)===0&&(nt=256)),jr=e}return jr}function gv(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:Fl(""+e)}function vv(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 Qw(e,t,i,o,f){if(t==="submit"&&i&&i.stateNode===f){var h=gv((f[Ne]||null).action),S=o.submitter;S&&(t=(t=S[Ne]||null)?gv(t.formAction):S.getAttribute("formAction"),t!==null&&(h=t,S=null));var E=new Gr("action","action",null,o,f);e.push({event:E,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(jr!==0){var P=S?vv(f,S):new FormData(f);zf(i,{pending:!0,data:P,method:f.method,action:h},null,P)}}else typeof h=="function"&&(E.preventDefault(),P=S?vv(f,S):new FormData(f),zf(i,{pending:!0,data:P,method:f.method,action:h},h,P))},currentTarget:f}]})}}for(var gm=0;gm<eo.length;gm++){var vm=eo[gm],Xw=vm.toLowerCase(),Zw=vm[0].toUpperCase()+vm.slice(1);Jn(Xw,"on"+Zw)}Jn(Jl,"onAnimationEnd"),Jn(cu,"onAnimationIteration"),Jn(qo,"onAnimationStart"),Jn("dblclick","onDoubleClick"),Jn("focusin","onFocus"),Jn("focusout","onBlur"),Jn(Go,"onTransitionRun"),Jn(Vo,"onTransitionStart"),Jn(nl,"onTransitionCancel"),Jn(uu,"onTransitionEnd"),vn("onMouseEnter",["mouseout","mouseover"]),vn("onMouseLeave",["mouseout","mouseover"]),vn("onPointerEnter",["pointerout","pointerover"]),vn("onPointerLeave",["pointerout","pointerover"]),cn("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),cn("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),cn("onBeforeInput",["compositionend","keypress","textInput","paste"]),cn("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),cn("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),cn("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var hc="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Jw=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(hc));function yv(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 E=o[S],P=E.instance,le=E.currentTarget;if(E=E.listener,P!==h&&f.isPropagationStopped())break e;h=E,f.currentTarget=le;try{h(f)}catch(ye){ar(ye)}f.currentTarget=null,h=P}else for(S=0;S<o.length;S++){if(E=o[S],P=E.instance,le=E.currentTarget,E=E.listener,P!==h&&f.isPropagationStopped())break e;h=E,f.currentTarget=le;try{h(f)}catch(ye){ar(ye)}f.currentTarget=null,h=P}}}}function jt(e,t){var i=t[rt];i===void 0&&(i=t[rt]=new Set);var o=e+"__bubble";i.has(o)||(xv(t,e,2,!1),i.add(o))}function ym(e,t,i){var o=0;t&&(o|=4),xv(i,e,o,t)}var Vu="_reactListening"+Math.random().toString(36).slice(2);function xm(e){if(!e[Vu]){e[Vu]=!0,xa.forEach(function(i){i!=="selectionchange"&&(Jw.has(i)||ym(i,!1,e),ym(i,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Vu]||(t[Vu]=!0,ym("selectionchange",!1,t))}}function xv(e,t,i,o){switch(Yv(t)){case 2:var f=NS;break;case 8:f=MS;break;default:f=_m}i=f.bind(null,t,i,e),f=void 0,!Ho||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 E=o.stateNode.containerInfo;if(E===f)break;if(S===4)for(S=o.return;S!==null;){var P=S.tag;if((P===3||P===4)&&S.stateNode.containerInfo===f)return;S=S.return}for(;E!==null;){if(S=Wt(E),S===null)return;if(P=S.tag,P===5||P===6||P===26||P===27){o=h=S;continue e}E=E.parentNode}}o=o.return}cf(function(){var le=h,ye=Oo(i),Ce=[];e:{var oe=al.get(e);if(oe!==void 0){var me=Gr,Ye=e;switch(e){case"keypress":if(Ui(i)===0)break e;case"keydown":case"keyup":me=df;break;case"focusin":Ye="focus",me=et;break;case"focusout":Ye="blur",me=et;break;case"beforeblur":case"afterblur":me=et;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":me=ft;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":me=Yi;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":me=eu;break;case Jl:case cu:case qo:me=uf;break;case uu:me=nu;break;case"scroll":case"scrollend":me=Xc;break;case"wheel":me=au;break;case"copy":case"cut":case"paste":me=Wr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":me=ql;break;case"toggle":case"beforetoggle":me=Qi}var tt=(t&4)!==0,qt=!tt&&(e==="scroll"||e==="scrollend"),J=tt?oe!==null?oe+"Capture":null:oe;tt=[];for(var W=le,ie;W!==null;){var we=W;if(ie=we.stateNode,we=we.tag,we!==5&&we!==26&&we!==27||ie===null||J===null||(we=Pl(W,J),we!=null&&tt.push(pc(W,we,ie))),qt)break;W=W.return}0<tt.length&&(oe=new me(oe,Ye,null,i,ye),Ce.push({event:oe,listeners:tt}))}}if((t&7)===0){e:{if(oe=e==="mouseover"||e==="pointerover",me=e==="mouseout"||e==="pointerout",oe&&i!==Kc&&(Ye=i.relatedTarget||i.fromElement)&&(Wt(Ye)||Ye[qe]))break e;if((me||oe)&&(oe=ye.window===ye?ye:(oe=ye.ownerDocument)?oe.defaultView||oe.parentWindow:window,me?(Ye=i.relatedTarget||i.toElement,me=le,Ye=Ye?Wt(Ye):null,Ye!==null&&(qt=d(Ye),tt=Ye.tag,Ye!==qt||tt!==5&&tt!==27&&tt!==6)&&(Ye=null)):(me=null,Ye=le),me!==Ye)){if(tt=ft,we="onMouseLeave",J="onMouseEnter",W="mouse",(e==="pointerout"||e==="pointerover")&&(tt=ql,we="onPointerLeave",J="onPointerEnter",W="pointer"),qt=me==null?oe:St(me),ie=Ye==null?oe:St(Ye),oe=new tt(we,W+"leave",me,i,ye),oe.target=qt,oe.relatedTarget=ie,we=null,Wt(ye)===le&&(tt=new tt(J,W+"enter",Ye,i,ye),tt.target=ie,tt.relatedTarget=qt,we=tt),qt=we,me&&Ye)t:{for(tt=eS,J=me,W=Ye,ie=0,we=J;we;we=tt(we))ie++;we=0;for(var Ze=W;Ze;Ze=tt(Ze))we++;for(;0<ie-we;)J=tt(J),ie--;for(;0<we-ie;)W=tt(W),we--;for(;ie--;){if(J===W||W!==null&&J===W.alternate){tt=J;break t}J=tt(J),W=tt(W)}tt=null}else tt=null;me!==null&&bv(Ce,oe,me,tt,!1),Ye!==null&&qt!==null&&bv(Ce,qt,Ye,tt,!0)}}e:{if(oe=le?St(le):window,me=oe.nodeName&&oe.nodeName.toLowerCase(),me==="select"||me==="input"&&oe.type==="file")var Rt=On;else if(da(oe))if(ci)Rt=Kl;else{Rt=hf;var Ke=iu}else me=oe.nodeName,!me||me.toLowerCase()!=="input"||oe.type!=="checkbox"&&oe.type!=="radio"?le&&es(le.elementType)&&(Rt=On):Rt=Yl;if(Rt&&(Rt=Rt(e,le))){Zn(Ce,Rt,i,ye);break e}Ke&&Ke(e,oe,le),e==="focusout"&&le&&oe.type==="number"&&le.memoizedProps.value!=null&&Hs(oe,"number",oe.value)}switch(Ke=le?St(le):window,e){case"focusin":(da(Ke)||Ke.contentEditable==="true")&&(er=Ke,Xl=le,tl=null);break;case"focusout":tl=Xl=er=null;break;case"mousedown":Zl=!0;break;case"contextmenu":case"mouseup":case"dragend":Zl=!1,tr(Ce,i,ye);break;case"selectionchange":if(pf)break;case"keydown":case"keyup":tr(Ce,i,ye)}var yt;if(Po)e:{switch(e){case"compositionstart":var At="onCompositionStart";break e;case"compositionend":At="onCompositionEnd";break e;case"compositionupdate":At="onCompositionUpdate";break e}At=void 0}else In?Qr(e,i)&&(At="onCompositionEnd"):e==="keydown"&&i.keyCode===229&&(At="onCompositionStart");At&&(su&&i.locale!=="ko"&&(In||At!=="onCompositionStart"?At==="onCompositionEnd"&&In&&(yt=Qc()):(vs=ye,Bo="value"in vs?vs.value:vs.textContent,In=!0)),Ke=Wu(le,At),0<Ke.length&&(At=new oi(At,e,null,i,ye),Ce.push({event:At,listeners:Ke}),yt?At.data=yt:(yt=Xr(i),yt!==null&&(At.data=yt)))),(yt=Kr?qs(e,i):Vl(e,i))&&(At=Wu(le,"onBeforeInput"),0<At.length&&(Ke=new oi("onBeforeInput","beforeinput",null,i,ye),Ce.push({event:Ke,listeners:At}),Ke.data=yt)),Qw(Ce,e,le,i,ye)}yv(Ce,t)})}function pc(e,t,i){return{instance:e,listener:t,currentTarget:i}}function Wu(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=Pl(e,i),f!=null&&o.unshift(pc(e,f,h)),f=Pl(e,t),f!=null&&o.push(pc(e,f,h))),e.tag===3)return o;e=e.return}return[]}function eS(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function bv(e,t,i,o,f){for(var h=t._reactName,S=[];i!==null&&i!==o;){var E=i,P=E.alternate,le=E.stateNode;if(E=E.tag,P!==null&&P===o)break;E!==5&&E!==26&&E!==27||le===null||(P=le,f?(le=Pl(i,h),le!=null&&S.unshift(pc(i,le,P))):f||(le=Pl(i,h),le!=null&&S.push(pc(i,le,P)))),i=i.return}S.length!==0&&e.push({event:t,listeners:S})}var tS=/\r\n?/g,nS=/\u0000|\uFFFD/g;function wv(e){return(typeof e=="string"?e:""+e).replace(tS,`
|
|
9
|
+
`).replace(nS,"")}function Sv(e,t){return t=wv(t),wv(e)===t}function Ut(e,t,i,o,f,h){switch(i){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||gs(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&gs(e,""+o);break;case"className":Il(e,"class",o);break;case"tabIndex":Il(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Il(e,i,o);break;case"style":Io(e,o,h);break;case"data":if(t!=="object"){Il(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=Fl(""+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"&&Ut(e,t,"name",f.name,f,null),Ut(e,t,"formEncType",f.formEncType,f,null),Ut(e,t,"formMethod",f.formMethod,f,null),Ut(e,t,"formTarget",f.formTarget,f,null)):(Ut(e,t,"encType",f.encType,f,null),Ut(e,t,"method",f.method,f,null),Ut(e,t,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(i);break}o=Fl(""+o),e.setAttribute(i,o);break;case"onClick":o!=null&&(e.onclick=_a);break;case"onScroll":o!=null&&jt("scroll",e);break;case"onScrollEnd":o!=null&&jt("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=Fl(""+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":jt("beforetoggle",e),jt("toggle",e),Bi(e,"popover",o);break;case"xlinkActuate":Za(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Za(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Za(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Za(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Za(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Za(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Za(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Za(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Za(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Bi(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=ii.get(i)||i,Bi(e,i,o))}}function wm(e,t,i,o,f,h){switch(i){case"style":Io(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"?gs(e,o):(typeof o=="number"||typeof o=="bigint")&&gs(e,""+o);break;case"onScroll":o!=null&&jt("scroll",e);break;case"onScrollEnd":o!=null&&jt("scrollend",e);break;case"onClick":o!=null&&(e.onclick=_a);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!ca.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,""):Bi(e,i,o)}}}function Kn(e,t,i){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":jt("error",e),jt("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:Ut(e,t,h,S,i,null)}}f&&Ut(e,t,"srcSet",i.srcSet,i,null),o&&Ut(e,t,"src",i.src,i,null);return;case"input":jt("invalid",e);var E=h=S=f=null,P=null,le=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":P=ye;break;case"defaultChecked":le=ye;break;case"value":h=ye;break;case"defaultValue":E=ye;break;case"children":case"dangerouslySetInnerHTML":if(ye!=null)throw Error(l(137,t));break;default:Ut(e,t,o,ye,i,null)}}si(e,h,E,P,le,S,f,!1);return;case"select":jt("invalid",e),o=S=h=null;for(f in i)if(i.hasOwnProperty(f)&&(E=i[f],E!=null))switch(f){case"value":h=E;break;case"defaultValue":S=E;break;case"multiple":o=E;default:Ut(e,t,f,E,i,null)}t=h,i=S,e.multiple=!!o,t!=null?Bs(e,!!o,t,!1):i!=null&&Bs(e,!!o,i,!0);return;case"textarea":jt("invalid",e),h=f=o=null;for(S in i)if(i.hasOwnProperty(S)&&(E=i[S],E!=null))switch(S){case"value":o=E;break;case"defaultValue":f=E;break;case"children":h=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(l(91));break;default:Ut(e,t,S,E,i,null)}Ur(e,o,f,h);return;case"option":for(P in i)i.hasOwnProperty(P)&&(o=i[P],o!=null)&&(P==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":Ut(e,t,P,o,i,null));return;case"dialog":jt("beforetoggle",e),jt("toggle",e),jt("cancel",e),jt("close",e);break;case"iframe":case"object":jt("load",e);break;case"video":case"audio":for(o=0;o<hc.length;o++)jt(hc[o],e);break;case"image":jt("error",e),jt("load",e);break;case"details":jt("toggle",e);break;case"embed":case"source":case"link":jt("error",e),jt("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(le in i)if(i.hasOwnProperty(le)&&(o=i[le],o!=null))switch(le){case"children":case"dangerouslySetInnerHTML":throw Error(l(137,t));default:Ut(e,t,le,o,i,null)}return;default:if(es(t)){for(ye in i)i.hasOwnProperty(ye)&&(o=i[ye],o!==void 0&&wm(e,t,ye,o,i,void 0));return}}for(E in i)i.hasOwnProperty(E)&&(o=i[E],o!=null&&Ut(e,t,E,o,i,null))}function aS(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,E=null,P=null,le=null,ye=null;for(me in i){var Ce=i[me];if(i.hasOwnProperty(me)&&Ce!=null)switch(me){case"checked":break;case"value":break;case"defaultValue":P=Ce;default:o.hasOwnProperty(me)||Ut(e,t,me,null,o,Ce)}}for(var oe in o){var me=o[oe];if(Ce=i[oe],o.hasOwnProperty(oe)&&(me!=null||Ce!=null))switch(oe){case"type":h=me;break;case"name":f=me;break;case"checked":le=me;break;case"defaultChecked":ye=me;break;case"value":S=me;break;case"defaultValue":E=me;break;case"children":case"dangerouslySetInnerHTML":if(me!=null)throw Error(l(137,t));break;default:me!==Ce&&Ut(e,t,oe,me,o,Ce)}}ai(e,S,E,P,le,ye,h,f);return;case"select":me=S=E=oe=null;for(h in i)if(P=i[h],i.hasOwnProperty(h)&&P!=null)switch(h){case"value":break;case"multiple":me=P;default:o.hasOwnProperty(h)||Ut(e,t,h,null,o,P)}for(f in o)if(h=o[f],P=i[f],o.hasOwnProperty(f)&&(h!=null||P!=null))switch(f){case"value":oe=h;break;case"defaultValue":E=h;break;case"multiple":S=h;default:h!==P&&Ut(e,t,f,h,o,P)}t=E,i=S,o=me,oe!=null?Bs(e,!!i,oe,!1):!!o!=!!i&&(t!=null?Bs(e,!!i,t,!0):Bs(e,!!i,i?[]:"",!1));return;case"textarea":me=oe=null;for(E in i)if(f=i[E],i.hasOwnProperty(E)&&f!=null&&!o.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:Ut(e,t,E,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":oe=f;break;case"defaultValue":me=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(l(91));break;default:f!==h&&Ut(e,t,S,f,o,h)}Fi(e,oe,me);return;case"option":for(var Ye in i)oe=i[Ye],i.hasOwnProperty(Ye)&&oe!=null&&!o.hasOwnProperty(Ye)&&(Ye==="selected"?e.selected=!1:Ut(e,t,Ye,null,o,oe));for(P in o)oe=o[P],me=i[P],o.hasOwnProperty(P)&&oe!==me&&(oe!=null||me!=null)&&(P==="selected"?e.selected=oe&&typeof oe!="function"&&typeof oe!="symbol":Ut(e,t,P,oe,o,me));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var tt in i)oe=i[tt],i.hasOwnProperty(tt)&&oe!=null&&!o.hasOwnProperty(tt)&&Ut(e,t,tt,null,o,oe);for(le in o)if(oe=o[le],me=i[le],o.hasOwnProperty(le)&&oe!==me&&(oe!=null||me!=null))switch(le){case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(l(137,t));break;default:Ut(e,t,le,oe,o,me)}return;default:if(es(t)){for(var qt in i)oe=i[qt],i.hasOwnProperty(qt)&&oe!==void 0&&!o.hasOwnProperty(qt)&&wm(e,t,qt,void 0,o,oe);for(ye in o)oe=o[ye],me=i[ye],!o.hasOwnProperty(ye)||oe===me||oe===void 0&&me===void 0||wm(e,t,ye,oe,o,me);return}}for(var J in i)oe=i[J],i.hasOwnProperty(J)&&oe!=null&&!o.hasOwnProperty(J)&&Ut(e,t,J,null,o,oe);for(Ce in o)oe=o[Ce],me=i[Ce],!o.hasOwnProperty(Ce)||oe===me||oe==null&&me==null||Ut(e,t,Ce,oe,o,me)}function Cv(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function sS(){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,E=f.duration;if(h&&E&&Cv(S)){for(S=0,E=f.responseEnd,o+=1;o<i.length;o++){var P=i[o],le=P.startTime;if(le>E)break;var ye=P.transferSize,Ce=P.initiatorType;ye&&Cv(Ce)&&(P=P.responseEnd,S+=ye*(P<E?1:(E-le)/(P-le)))}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 Sm=null,Cm=null;function Yu(e){return e.nodeType===9?e:e.ownerDocument}function jv(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 kv(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 jm(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 km=null;function iS(){var e=window.event;return e&&e.type==="popstate"?e===km?!1:(km=e,!0):(km=null,!1)}var Av=typeof setTimeout=="function"?setTimeout:void 0,rS=typeof clearTimeout=="function"?clearTimeout:void 0,Nv=typeof Promise=="function"?Promise:void 0,lS=typeof queueMicrotask=="function"?queueMicrotask:typeof Nv<"u"?function(e){return Nv.resolve(null).then(e).catch(oS)}:Av;function oS(e){setTimeout(function(){throw e})}function kr(e){return e==="head"}function Mv(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),wo(t);return}o--}else if(i==="$"||i==="$?"||i==="$~"||i==="$!"||i==="&")o++;else if(i==="html")gc(e.ownerDocument.documentElement);else if(i==="head"){i=e.ownerDocument.head,gc(i);for(var h=i.firstChild;h;){var S=h.nextSibling,E=h.nodeName;h[ut]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&h.rel.toLowerCase()==="stylesheet"||i.removeChild(h),h=S}}else i==="body"&&gc(e.ownerDocument.body);i=f}while(i);wo(t)}function Tv(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 Am(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":Am(i),kn(i);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(i.rel.toLowerCase()==="stylesheet")continue}e.removeChild(i)}}function cS(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[ut])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=us(e.nextSibling),e===null)break}return null}function uS(e,t,i){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!i||(e=us(e.nextSibling),e===null))return null;return e}function Ev(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=us(e.nextSibling),e===null))return null;return e}function Nm(e){return e.data==="$?"||e.data==="$~"}function Mm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function dS(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 us(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 Tm=null;function Rv(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var i=e.data;if(i==="/$"||i==="/&"){if(t===0)return us(e.nextSibling);t--}else i!=="$"&&i!=="$!"&&i!=="$?"&&i!=="$~"&&i!=="&"||t++}e=e.nextSibling}return null}function Dv(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 Lv(e,t,i){switch(t=Yu(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 gc(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);kn(e)}var ds=new Map,_v=new Set;function Ku(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Di=Q.d;Q.d={f:fS,r:mS,D:hS,C:pS,L:gS,m:vS,X:xS,S:yS,M:bS};function fS(){var e=Di.f(),t=Fu();return e||t}function mS(e){var t=An(e);t!==null&&t.tag===5&&t.type==="form"?Xp(t):Di.r(e)}var yo=typeof document>"u"?null:document;function zv(e,t,i){var o=yo;if(o&&typeof t=="string"&&t){var f=Gn(t);f='link[rel="'+e+'"][href="'+f+'"]',typeof i=="string"&&(f+='[crossorigin="'+i+'"]'),_v.has(f)||(_v.add(f),e={rel:e,crossOrigin:i,href:t},o.querySelector(f)===null&&(t=o.createElement("link"),Kn(t,"link",e),Pt(t),o.head.appendChild(t)))}}function hS(e){Di.D(e),zv("dns-prefetch",e,null)}function pS(e,t){Di.C(e,t),zv("preconnect",e,t)}function gS(e,t,i){Di.L(e,t,i);var o=yo;if(o&&e&&t){var f='link[rel="preload"][as="'+Gn(t)+'"]';t==="image"&&i&&i.imageSrcSet?(f+='[imagesrcset="'+Gn(i.imageSrcSet)+'"]',typeof i.imageSizes=="string"&&(f+='[imagesizes="'+Gn(i.imageSizes)+'"]')):f+='[href="'+Gn(e)+'"]';var h=f;switch(t){case"style":h=xo(e);break;case"script":h=bo(e)}ds.has(h)||(e=x({rel:"preload",href:t==="image"&&i&&i.imageSrcSet?void 0:e,as:t},i),ds.set(h,e),o.querySelector(f)!==null||t==="style"&&o.querySelector(vc(h))||t==="script"&&o.querySelector(yc(h))||(t=o.createElement("link"),Kn(t,"link",e),Pt(t),o.head.appendChild(t)))}}function vS(e,t){Di.m(e,t);var i=yo;if(i&&e){var o=t&&typeof t.as=="string"?t.as:"script",f='link[rel="modulepreload"][as="'+Gn(o)+'"][href="'+Gn(e)+'"]',h=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=bo(e)}if(!ds.has(h)&&(e=x({rel:"modulepreload",href:e},t),ds.set(h,e),i.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(i.querySelector(yc(h)))return}o=i.createElement("link"),Kn(o,"link",e),Pt(o),i.head.appendChild(o)}}}function yS(e,t,i){Di.S(e,t,i);var o=yo;if(o&&e){var f=rn(o).hoistableStyles,h=xo(e);t=t||"default";var S=f.get(h);if(!S){var E={loading:0,preload:null};if(S=o.querySelector(vc(h)))E.loading=5;else{e=x({rel:"stylesheet",href:e,"data-precedence":t},i),(i=ds.get(h))&&Em(e,i);var P=S=o.createElement("link");Pt(P),Kn(P,"link",e),P._p=new Promise(function(le,ye){P.onload=le,P.onerror=ye}),P.addEventListener("load",function(){E.loading|=1}),P.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Qu(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:E},f.set(h,S)}}}function xS(e,t){Di.X(e,t);var i=yo;if(i&&e){var o=rn(i).hoistableScripts,f=bo(e),h=o.get(f);h||(h=i.querySelector(yc(f)),h||(e=x({src:e,async:!0},t),(t=ds.get(f))&&Rm(e,t),h=i.createElement("script"),Pt(h),Kn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function bS(e,t){Di.M(e,t);var i=yo;if(i&&e){var o=rn(i).hoistableScripts,f=bo(e),h=o.get(f);h||(h=i.querySelector(yc(f)),h||(e=x({src:e,async:!0,type:"module"},t),(t=ds.get(f))&&Rm(e,t),h=i.createElement("script"),Pt(h),Kn(h,"link",e),i.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(f,h))}}function Iv(e,t,i,o){var f=(f=ve.current)?Ku(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=xo(i.href),i=rn(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=xo(i.href);var h=rn(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(vc(e)))&&!h._p&&(S.instance=h,S.state.loading=5),ds.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},ds.set(e,i),h||wS(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=bo(i),i=rn(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 xo(e){return'href="'+Gn(e)+'"'}function vc(e){return'link[rel="stylesheet"]['+e+"]"}function Ov(e){return x({},e,{"data-precedence":e.precedence,precedence:null})}function wS(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}),Kn(t,"link",i),Pt(t),e.head.appendChild(t))}function bo(e){return'[src="'+Gn(e)+'"]'}function yc(e){return"script[async]"+e}function Hv(e,t,i){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Gn(i.href)+'"]');if(o)return t.instance=o,Pt(o),o;var f=x({},i,{"data-href":i.href,"data-precedence":i.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Pt(o),Kn(o,"style",f),Qu(o,i.precedence,e),t.instance=o;case"stylesheet":f=xo(i.href);var h=e.querySelector(vc(f));if(h)return t.state.loading|=4,t.instance=h,Pt(h),h;o=Ov(i),(f=ds.get(f))&&Em(o,f),h=(e.ownerDocument||e).createElement("link"),Pt(h);var S=h;return S._p=new Promise(function(E,P){S.onload=E,S.onerror=P}),Kn(h,"link",o),t.state.loading|=4,Qu(h,i.precedence,e),t.instance=h;case"script":return h=bo(i.src),(f=e.querySelector(yc(h)))?(t.instance=f,Pt(f),f):(o=i,(f=ds.get(h))&&(o=x({},i),Rm(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),Pt(f),Kn(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,Qu(o,i.precedence,e));return t.instance}function Qu(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 E=o[S];if(E.dataset.precedence===t)h=E;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 Em(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function Rm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Xu=null;function Bv(e,t,i){if(Xu===null){var o=new Map,f=Xu=new Map;f.set(i,o)}else f=Xu,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[ut]||h[ee]||e==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var S=h.getAttribute(t)||"";S=e+S;var E=o.get(S);E?E.push(h):o.set(S,[h])}}return o}function Fv(e,t,i){e=e.ownerDocument||e,e.head.insertBefore(i,t==="title"?e.querySelector("head > title"):null)}function SS(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 Pv(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function CS(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=xo(o.href),h=t.querySelector(vc(f));if(h){t=h._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Zu.bind(e),t.then(e,e)),i.state.loading|=4,i.instance=h,Pt(h);return}h=t.ownerDocument||t,o=Ov(o),(f=ds.get(f))&&Em(o,f),h=h.createElement("link"),Pt(h);var S=h;S._p=new Promise(function(E,P){S.onload=E,S.onerror=P}),Kn(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=Zu.bind(e),t.addEventListener("load",i),t.addEventListener("error",i))}}var Dm=0;function jS(e,t){return e.stylesheets&&e.count===0&&ed(e,e.stylesheets),0<e.count||0<e.imgCount?function(i){var o=setTimeout(function(){if(e.stylesheets&&ed(e,e.stylesheets),e.unsuspend){var h=e.unsuspend;e.unsuspend=null,h()}},6e4+t);0<e.imgBytes&&Dm===0&&(Dm=62500*sS());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ed(e,e.stylesheets),e.unsuspend)){var h=e.unsuspend;e.unsuspend=null,h()}},(e.imgBytes>Dm?50:800)+t);return e.unsuspend=i,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function Zu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ed(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Ju=null;function ed(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Ju=new Map,t.forEach(kS,e),Ju=null,Zu.call(e))}function kS(e,t){if(!(t.state.loading&4)){var i=Ju.get(e);if(i)var o=i.get(null);else{i=new Map,Ju.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=Zu.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 xc={$$typeof:R,Provider:null,Consumer:null,_currentValue:q,_currentValue2:q,_threadCount:0};function AS(e,t,i,o,f,h,S,E,P){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=ps(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ps(0),this.hiddenUpdates=ps(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=h,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function $v(e,t,i,o,f,h,S,E,P,le,ye,Ce){return e=new AS(e,t,i,S,P,le,ye,Ce,E),t=1,h===!0&&(t|=24),h=ta(3,null,null,t),e.current=h,h.stateNode=e,t=Xo(),t.refCount++,e.pooledCache=t,t.refCount++,h.memoizedState={element:o,isDehydrated:i,cache:t},z(h),e}function Uv(e){return e?(e=xs,e):xs}function qv(e,t,i,o,f,h){f=Uv(f),o.context===null?o.context=f:o.pendingContext=f,o=de(t),o.payload={element:i},h=h===void 0?null:h,h!==null&&(o.callback=h),i=De(e,o,t),i!==null&&(Ma(i,e,t),$e(i,e,t))}function Gv(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){Gv(e,t),(e=e.alternate)&&Gv(e,t)}function Vv(e){if(e.tag===13||e.tag===31){var t=wa(e,67108864);t!==null&&Ma(t,e,67108864),Lm(e,67108864)}}function Wv(e){if(e.tag===13||e.tag===31){var t=Ga();t=vt(t);var i=wa(e,t);i!==null&&Ma(i,e,t),Lm(e,t)}}var td=!0;function NS(e,t,i,o){var f=I.T;I.T=null;var h=Q.p;try{Q.p=2,_m(e,t,i,o)}finally{Q.p=h,I.T=f}}function MS(e,t,i,o){var f=I.T;I.T=null;var h=Q.p;try{Q.p=8,_m(e,t,i,o)}finally{Q.p=h,I.T=f}}function _m(e,t,i,o){if(td){var f=zm(o);if(f===null)bm(e,t,o,nd,i),Kv(e,o);else if(ES(f,e,t,i,o))o.stopPropagation();else if(Kv(e,o),t&4&&-1<TS.indexOf(e)){for(;f!==null;){var h=An(f);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var S=He(h.pendingLanes);if(S!==0){var E=h;for(E.pendingLanes|=2,E.entangledLanes|=2;S;){var P=1<<31-gt(S);E.entanglements[1]|=P,S&=~P}Zs(h),(Lt&6)===0&&(Hu=ot()+500,mc(0))}}break;case 31:case 13:E=wa(h,2),E!==null&&Ma(E,h,2),Fu(),Lm(h,2)}if(h=zm(o),h===null&&bm(e,t,o,nd,i),h===f)break;f=h}f!==null&&o.stopPropagation()}else bm(e,t,o,null,i)}}function zm(e){return e=Oo(e),Im(e)}var nd=null;function Im(e){if(nd=null,e=Wt(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 nd=e,null}function Yv(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(gn()){case Kt:return 2;case Ie:return 8;case ct:case _t:return 32;case Ft:return 268435456;default:return 32}default:return 32}}var Om=!1,Ar=null,Nr=null,Mr=null,bc=new Map,wc=new Map,Tr=[],TS="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 Kv(e,t){switch(e){case"focusin":case"focusout":Ar=null;break;case"dragenter":case"dragleave":Nr=null;break;case"mouseover":case"mouseout":Mr=null;break;case"pointerover":case"pointerout":bc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":wc.delete(t.pointerId)}}function Sc(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=An(t),t!==null&&Vv(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,f!==null&&t.indexOf(f)===-1&&t.push(f),e)}function ES(e,t,i,o,f){switch(t){case"focusin":return Ar=Sc(Ar,e,t,i,o,f),!0;case"dragenter":return Nr=Sc(Nr,e,t,i,o,f),!0;case"mouseover":return Mr=Sc(Mr,e,t,i,o,f),!0;case"pointerover":var h=f.pointerId;return bc.set(h,Sc(bc.get(h)||null,e,t,i,o,f)),!0;case"gotpointercapture":return h=f.pointerId,wc.set(h,Sc(wc.get(h)||null,e,t,i,o,f)),!0}return!1}function Qv(e){var t=Wt(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,Br(e.priority,function(){Wv(i)});return}}else if(t===31){if(t=p(i),t!==null){e.blockedOn=t,Br(e.priority,function(){Wv(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 ad(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var i=zm(e.nativeEvent);if(i===null){i=e.nativeEvent;var o=new i.constructor(i.type,i);Kc=o,i.target.dispatchEvent(o),Kc=null}else return t=An(i),t!==null&&Vv(t),e.blockedOn=i,!1;t.shift()}return!0}function Xv(e,t,i){ad(e)&&i.delete(t)}function RS(){Om=!1,Ar!==null&&ad(Ar)&&(Ar=null),Nr!==null&&ad(Nr)&&(Nr=null),Mr!==null&&ad(Mr)&&(Mr=null),bc.forEach(Xv),wc.forEach(Xv)}function sd(e,t){e.blockedOn===t&&(e.blockedOn=null,Om||(Om=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,RS)))}var id=null;function Zv(e){id!==e&&(id=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){id===e&&(id=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(Im(o||i)===null)continue;break}var h=An(i);h!==null&&(e.splice(t,3),t-=3,zf(h,{pending:!0,data:f,method:i.method,action:o},o,f))}}))}function wo(e){function t(P){return sd(P,e)}Ar!==null&&sd(Ar,e),Nr!==null&&sd(Nr,e),Mr!==null&&sd(Mr,e),bc.forEach(t),wc.forEach(t);for(var i=0;i<Tr.length;i++){var o=Tr[i];o.blockedOn===e&&(o.blockedOn=null)}for(;0<Tr.length&&(i=Tr[0],i.blockedOn===null);)Qv(i),i.blockedOn===null&&Tr.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||Zv(i);else if(S){var E=null;if(h&&h.hasAttribute("formAction")){if(f=h,S=h[Ne]||null)E=S.formAction;else if(Im(f)!==null)continue}else E=S.action;typeof E=="function"?i[o+1]=E:(i.splice(o,3),o-=3),Zv(i)}}}function Jv(){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 Hm(e){this._internalRoot=e}rd.prototype.render=Hm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(l(409));var i=t.current,o=Ga();qv(i,o,e,t,null,null)},rd.prototype.unmount=Hm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;qv(e.current,2,null,e,null,null),Fu(),t[qe]=null}};function rd(e){this._internalRoot=e}rd.prototype.unstable_scheduleHydration=function(e){if(e){var t=Qa();e={blockedOn:null,target:e,priority:t};for(var i=0;i<Tr.length&&t!==0&&t<Tr[i].priority;i++);Tr.splice(i,0,e),i===0&&Qv(e)}};var ey=a.version;if(ey!=="19.2.7")throw Error(l(527,ey,"19.2.7"));Q.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=v(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var DS={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ld=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ld.isDisabled&&ld.supportsFiber)try{Fe=ld.inject(DS),ke=ld}catch{}}return jc.createRoot=function(e,t){if(!c(e))throw Error(l(299));var i=!1,o="",f=lg,h=og,S=cg;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=$v(e,1,!1,null,null,i,o,null,f,h,S,Jv),e[qe]=t.current,xm(e),new Hm(t)},jc.hydrateRoot=function(e,t,i){if(!c(e))throw Error(l(299));var o=!1,f="",h=lg,S=og,E=cg,P=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&&(E=i.onRecoverableError),i.formState!==void 0&&(P=i.formState)),t=$v(e,1,!0,t,i??null,o,f,P,h,S,E,Jv),t.context=Uv(null),i=t.current,o=Ga(),o=vt(o),f=de(o),f.callback=null,De(i,f,o),i=o,t.current.lanes=i,bt(t,i),Zs(t),e[qe]=t.current,xm(e),new rd(t)},jc.version="19.2.7",jc}var fy;function S0(){if(fy)return $m.exports;fy=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=w0(),$m.exports}var C0=S0();const j0="https://otbyfkjxrkngvjziawki.supabase.co",k0="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",A0={getItem:()=>null,setItem:()=>{},removeItem:()=>{}},my=typeof window<"u"&&!!window.liveDesk,pt=g0(j0,k0,{auth:{autoRefreshToken:!0,persistSession:!my,storage:my?A0:void 0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}}),N0=new Set(["browserLanguage","platform","online","viewport","timezone","screen"]),M0={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])=>N0.has(a)&&r!==void 0))}};function T0(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 E0(n=M0){return n.collect()}async function R0(n,a="livedesk"){const{data:r,error:l}=await pt.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:C}=await pt.rpc("register_product_access",{p_product_key:a,p_access_type:"free"});if(C)throw C}const[d,m,p]=await Promise.all([pt.from("products").select("id, product_key, name, description, sort_order").order("sort_order"),pt.from("product_admins").select("product_id, role").eq("user_id",n),pt.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 g=d.data||[],v=(m.data||[]).map(C=>String(C.product_id)),w=(p.data||[]).map(C=>String(C.product_id)),x=c==="owner",b=x?g.map(C=>C.id):[...new Set([...v,...w])];return{products:g,access:{userId:n,globalRole:c,accessibleProductIds:b,managedProductIds:x?g.map(C=>C.id):v,canViewAllProducts:x,canViewAllPrivatePosts:x,canManageAllProducts:x,canCreateAnnouncements:x||v.length>0}}}async function D0(n=""){const{data:a,error:r}=await pt.rpc("search_support_posts",{p_query:n.trim()||null,p_limit:250});if(r)throw r;return a||[]}async function L0(n){const{data:a,error:r}=await pt.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 pt.storage.from("support-attachments").createSignedUrl(c.storage_path,3600);return{...c,signed_url:d.data?.signedUrl||void 0}}))}async function _0(){const{data:n,error:a}=await pt.from("support_notifications").select("*").order("created_at",{ascending:!1}).limit(30);if(a)throw a;return n||[]}async function z0(n){const{error:a}=await pt.rpc("mark_support_notification_read",{p_notification_id:n});if(a)throw a}async function hy(n){const{data:a,error:r}=await pt.from("support_comments").select("*").eq("post_id",n).order("created_at");if(r)throw r;return a||[]}async function I0(n){const{data:a,error:r}=await pt.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 O0(n){const{data:a,error:r}=await pt.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?E0():{}});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 H0=new Set(["image/png","image/jpeg","image/webp","text/plain","text/markdown","application/json","application/pdf"]);async function B0(n,a){if(!H0.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 pt.storage.from("support-attachments").upload(c,a,{contentType:a.type,upsert:!1});if(d.error)throw d.error;const{data:m,error:p}=await pt.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 pt.storage.from("support-attachments").remove([c]),p;const g=Array.isArray(m)?m[0]?.attachment_id:m?.attachment_id;if(!g)throw new Error("Attachment metadata was not created.");return String(g)}async function F0(n,a,r,l){const{error:c}=await pt.rpc("update_support_post",{p_post_id:n,p_title:a,p_body:r,p_visibility:l});if(c)throw c}async function P0(n,a){const{error:r}=await pt.rpc("add_support_comment",{p_post_id:n,p_body:a});if(r)throw r}async function $0(n){const{data:a,error:r}=await pt.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 U0(n,a){const{error:r}=await pt.rpc("change_support_post_status",{p_post_id:n,p_target_status:a});if(r)throw r}async function q0(n){const{error:a}=await pt.rpc("set_support_post_hidden",{p_post_id:n,p_hidden:!0});if(a)throw a}async function G0(n,a){const{error:r}=await pt.rpc("set_support_post_locked",{p_post_id:n,p_locked:a});if(r)throw r}async function V0(n,a){const{error:r}=await pt.rpc("set_support_post_pinned",{p_post_id:n,p_pinned:a});if(r)throw r}async function W0(n,a){const{error:r}=await pt.rpc("mark_support_duplicate",{p_post_id:n,p_duplicate_of_post_id:a});if(r)throw r}async function Y0(n,a){const{error:r}=await pt.rpc("accept_support_answer",{p_post_id:n,p_comment_id:a});if(r)throw r}async function K0(n,a=!0){const{error:r}=await pt.rpc("hide_support_comment",{p_comment_id:n,p_hidden:a});if(r)throw r}const jh=[{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"}],Q0=[{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"}],X0={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"]},Z0={type:"all",product:"",status:"all",visibility:"all",sort:"recent",query:""};function Gm(){if(typeof window>"u")return Z0;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 J0(n){return n==="all"?"":n==="question"?"questions":n==="issue"?"issues":n==="feature"?"features":"announcements"}function eC(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=J0(r.type),d=l.toString();return`/support${c?`/${c}`:""}${d?`?${d}`:""}`}function od(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 py(n){return n==="question"?HS:n==="issue"?BS:n==="feature"?FS:PS}function gy(n){return jh.find(a=>a.id===n)?.shortLabel||n}function Wm(n,a){return n.find(r=>r.id===a)?.name||"Product"}function Ta(n){const a=T0(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 tb({session:n,currentProductKey:a="livedesk",appVersion:r="",onSignIn:l}){const[c,d]=u.useState(()=>Gm()),[m,p]=u.useState(null),[g,v]=u.useState([]),[w,x]=u.useState([]),[b,C]=u.useState(""),[j,A]=u.useState([]),[N,k]=u.useState([]),[T,R]=u.useState([]),[U,O]=u.useState(()=>new Set),[Y,_]=u.useState(!0),[D,ne]=u.useState(""),[G,te]=u.useState(""),[B,xe]=u.useState(!1),[se,K]=u.useState(!1),[I,Q]=u.useState(""),[q,V]=u.useState(()=>Gm().query),[ce,be]=u.useState(!1),[X,$]=u.useState(!1),[ue,he]=u.useState(""),[ve,Se]=u.useState(""),[_e,re]=u.useState("free"),[Z,ze]=u.useState(""),[Le,ae]=u.useState(""),[fe,Ae]=u.useState("admin"),[Te,Be]=u.useState(""),[Ve,Je]=u.useState(""),[Et,je]=u.useState(""),[We,it]=u.useState(""),[ot,gn]=u.useState(""),[Kt,Ie]=u.useState([]),[ct,_t]=u.useState({productId:"",postType:"question",title:"",body:"",visibility:"public",includeEnvironment:!0,files:[]}),Ft=u.useCallback(H=>{const Pe={...c,...H};d(Pe),typeof window<"u"&&window.history.pushState({},"",eC(c,H))},[c]);u.useEffect(()=>{const H=()=>d(Gm());return window.addEventListener("popstate",H),()=>window.removeEventListener("popstate",H)},[]);const ge=u.useCallback(async()=>{const H=await D0(c.query);return x(H),n?.user.id&&O(await I0(n.user.id)),H},[c.query,n?.user.id]),Oe=u.useCallback(async()=>{if(!n?.user.id){p(null),v([]),x([]),C(""),R([]),_(!1);return}_(!0),te("");try{const H=await R0(n.user.id,a);p(H.access),v(H.products),await ge(),R(await _0())}catch(H){te(Ta(H))}finally{_(!1)}},[a,ge,n?.user.id]);u.useEffect(()=>{Oe()},[Oe]);const Fe=u.useMemo(()=>m?m.canViewAllProducts?g:g.filter(H=>m.accessibleProductIds.includes(H.id)):[],[m,g]),ke=u.useMemo(()=>{const H=Fe.find(Pe=>Pe.product_key===c.product);return m?.canViewAllProducts&&!c.product||c.product==="all"&&m?.canViewAllProducts?"all":H?H.product_key:Fe.some(Pe=>Pe.product_key===a)?a:Fe[0]?.product_key||""},[m?.canViewAllProducts,Fe,a,c.product]),st=ke==="all"?"":Fe.find(H=>H.product_key===ke)?.id||"",gt=u.useMemo(()=>{const H=new Map(g.map(vt=>[vt.id,vt.product_key]));return[...w.filter(vt=>c.type!=="all"&&vt.post_type!==c.type||ke!=="all"&&st&&vt.product_id!==st||c.status==="needs-response"&&!["open","needs-info"].includes(vt.status)||c.status!=="all"&&c.status!=="needs-response"&&vt.status!==c.status||c.visibility!=="all"&&vt.visibility!==c.visibility?!1:H.has(vt.product_id))].sort((vt,sn)=>c.sort==="votes"?sn.vote_count-vt.vote_count||sn.updated_at.localeCompare(vt.updated_at):c.sort==="newest"?sn.created_at.localeCompare(vt.created_at):Number(sn.is_pinned)-Number(vt.is_pinned)||sn.updated_at.localeCompare(vt.updated_at))},[w,g,c.sort,c.status,c.type,c.visibility,st,ke]),Re=gt.find(H=>H.id===b)||gt[0]||null,jn=!!(Re&&m&&(m.canViewAllProducts||m.managedProductIds.includes(Re.product_id))),Ls=!!(Re&&n?.user.id===Re.author_id)||jn;u.useEffect(()=>{if(!Re){C(""),A([]),K(!1);return}Re.id!==b&&C(Re.id)},[Re,b]),u.useEffect(()=>{let H=!0;return b?(hy(b).then(Pe=>{H&&A(Pe)}).catch(Pe=>{H&&te(Ta(Pe))}),L0(b).then(Pe=>{H&&k(Pe)}).catch(Pe=>{H&&te(Ta(Pe))}),()=>{H=!1}):(A([]),k([]),()=>{H=!1})},[b]),u.useEffect(()=>{!ct.productId&&Fe[0]&&_t(H=>({...H,productId:st||Fe[0].id}))},[Fe,ct.productId,st]),u.useEffect(()=>{V(c.query)},[c.query]),u.useEffect(()=>{!ve&&Fe[0]&&Se(Fe[0].id),!Le&&Fe[0]&&ae(Fe[0].id)},[Fe,ve,Le]);const nt=H=>{Re&&x(Pe=>Pe.map(vt=>vt.id===Re.id?{...vt,...H}:vt))},zt=async H=>{if(H.preventDefault(),!(!n||!ct.productId)){ne("create"),te("");try{const Pe=await O0({productId:ct.productId,postType:ct.postType,title:ct.title,body:ct.body,visibility:ct.postType==="announcement"?"public":ct.visibility,appVersion:r,includeEnvironment:ct.postType==="issue"&&ct.includeEnvironment});for(const sn of Kt)await B0(Pe,sn);const vt=await ge();xe(!1),Ie([]),_t(sn=>({...sn,title:"",body:"",files:[]})),C(Pe),vt.some(sn=>sn.id===Pe)||await Oe()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},zn=async H=>{if(H.preventDefault(),!!Re){ne("edit"),te("");try{await F0(Re.id,Re.title,Re.body,Re.visibility),K(!1),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},He=async H=>{if(H.preventDefault(),!(!Re||!I.trim())){ne("comment"),te("");try{await P0(Re.id,I),Q(""),A(await hy(Re.id)),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},ya=async()=>{if(!(!Re||Re.post_type!=="feature")){ne("vote"),te("");try{const H=await $0(Re.id);O(Pe=>{const vt=new Set(Pe);return H.voted?vt.add(Re.id):vt.delete(Re.id),vt}),nt({vote_count:H.totalVotes})}catch(H){te(Ta(H))}finally{ne("")}}},dt=async H=>{if(Re){ne("status"),te("");try{await U0(Re.id,H),nt({status:H}),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},Hi=async()=>{if(!(!Re||!window.confirm("Hide this Support post from the board?"))){ne("hide"),te("");try{await q0(Re.id),C(""),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},Qt=async()=>{if(Re){ne("lock"),te("");try{await G0(Re.id,!Re.is_locked),nt({is_locked:!Re.is_locked}),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},ps=async()=>{if(Re){ne("pin"),te("");try{await V0(Re.id,!Re.is_pinned),nt({is_pinned:!Re.is_pinned}),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},bt=async H=>{if(Re){ne(`accept-${H}`),te("");try{await Y0(Re.id,H),nt({accepted_comment_id:H,status:Re.post_type==="question"?"answered":Re.status}),await ge()}catch(Pe){te(Ta(Pe))}finally{ne("")}}},qn=async()=>{if(!(!Re||!We||We===Re.id)){ne("duplicate"),te("");try{await W0(Re.id,We),C(""),it(""),await ge()}catch(H){te(Ta(H))}finally{ne("")}}},_s=async H=>{if(!H.read_at)try{await z0(H.id),R(Pe=>Pe.map(vt=>vt.id===H.id?{...vt,read_at:new Date().toISOString()}:vt))}catch(Pe){te(Ta(Pe))}H.post_id&&C(H.post_id),be(!1)};return n?Y&&!m?s.jsxs("section",{className:"support-page support-loading",children:[s.jsx(Do,{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:()=>be(H=>!H),title:"Notifications",children:[s.jsx(zS,{size:16})," ",T.filter(H=>!H.read_at).length>0&&s.jsx("b",{children:T.filter(H=>!H.read_at).length})]}),ce&&s.jsxs("div",{className:"support-notification-popover",children:[s.jsx("strong",{children:"Notifications"}),T.length===0?s.jsx("span",{className:"support-muted",children:"No notifications yet."}):T.map(H=>s.jsxs("button",{type:"button",className:H.read_at?"":"unread",onClick:()=>{_s(H)},children:[s.jsx("b",{children:H.title}),s.jsx("span",{children:H.body}),s.jsx("small",{children:od(H.created_at)})]},H.id))]})]}),m?.canViewAllProducts&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>$(H=>!H),children:[s.jsx(Bt,{size:16})," Admin"]}),s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{Oe()},disabled:Y,children:[s.jsx(Do,{size:16,className:Y?"support-spin":""})," Refresh"]}),s.jsxs("button",{className:"support-primary-button",type:"button",onClick:()=>xe(!0),disabled:Fe.length===0,children:[s.jsx(Bm,{size:17})," New request"]})]})}),G&&s.jsxs("div",{className:"support-error",role:"alert",children:[s.jsx(Ya,{size:17})," ",s.jsx("span",{children:G}),s.jsx("button",{type:"button",onClick:()=>te(""),"aria-label":"Dismiss error",children:s.jsx(Ya,{size:15})})]}),B&&s.jsxs("form",{className:"support-composer",onSubmit:H=>{zt(H)},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:()=>xe(!1),"aria-label":"Close composer",children:s.jsx(Ya,{size:18})})]}),s.jsxs("div",{className:"support-form-grid",children:[s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsx("select",{value:ct.productId,onChange:H=>_t(Pe=>({...Pe,productId:H.target.value})),children:Fe.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Type"}),s.jsx("select",{value:ct.postType,onChange:H=>_t(Pe=>({...Pe,postType:H.target.value})),children:jh.filter(H=>H.id!=="announcement"||m?.canCreateAnnouncements).map(H=>s.jsx("option",{value:H.id,children:H.label},H.id))})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:"Title"}),s.jsx("input",{required:!0,minLength:3,maxLength:180,value:ct.title,onChange:H=>_t(Pe=>({...Pe,title:H.target.value})),placeholder:"A short, searchable summary"})]}),s.jsxs("label",{className:"support-form-wide",children:[s.jsx("span",{children:ct.postType==="issue"?"What happened?":ct.postType==="feature"?"Describe the desired behavior":ct.postType==="announcement"?"Announcement":"Question"}),s.jsx("textarea",{required:!0,value:ct.body,onChange:H=>_t(Pe=>({...Pe,body:H.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:ct.visibility,disabled:ct.postType==="announcement",onChange:H=>_t(Pe=>({...Pe,visibility:H.target.value})),children:[s.jsx("option",{value:"public",children:"Public"}),s.jsx("option",{value:"private",children:"Private"})]})]}),ct.postType==="issue"&&s.jsxs("label",{className:"support-checkbox",children:[s.jsx("input",{type:"checkbox",checked:ct.includeEnvironment,onChange:H=>_t(Pe=>({...Pe,includeEnvironment:H.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:H=>Ie(Array.from(H.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:Kt.length>0?`${Kt.length} attachment${Kt.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:D==="create",children:[s.jsx(Fc,{size:16})," ",D==="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:()=>Ft({type:"all"}),children:"All"}),jh.map(H=>{const Pe=py(H.id);return s.jsxs("button",{className:c.type===H.id?"active":"",type:"button",onClick:()=>Ft({type:H.id}),children:[s.jsx(Pe,{size:15})," ",H.label]},H.id)})]}),X&&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:H=>{},children:[s.jsx("strong",{children:"Grant product access"}),s.jsx("input",{type:"email",required:!0,placeholder:"User email",value:ue,onChange:H=>he(H.target.value)}),s.jsx("select",{value:ve,onChange:H=>Se(H.target.value),children:Fe.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))}),s.jsxs("select",{value:_e,onChange:H=>re(H.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:ot==="access",children:[s.jsx(Ii,{size:15})," Grant access"]})]}),s.jsxs("form",{onSubmit:H=>{},children:[s.jsx("strong",{children:"Assign product admin"}),s.jsx("input",{type:"email",required:!0,placeholder:"Admin email",value:Z,onChange:H=>ze(H.target.value)}),s.jsx("select",{value:Le,onChange:H=>ae(H.target.value),children:Fe.map(H=>s.jsx("option",{value:H.id,children:H.name},H.id))}),s.jsxs("select",{value:fe,onChange:H=>Ae(H.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:ot==="product-admin",children:[s.jsx(Bt,{size:15})," Assign admin"]})]}),s.jsxs("form",{onSubmit:H=>{},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:Te,onChange:H=>Be(H.target.value)}),s.jsx("input",{required:!0,placeholder:"Product name",value:Ve,onChange:H=>Je(H.target.value)}),s.jsx("input",{placeholder:"Description",value:Et,onChange:H=>je(H.target.value)}),s.jsxs("button",{className:"support-secondary-button",type:"submit",disabled:ot==="product",children:[s.jsx(Bm,{size:15})," Add product"]})]})]})]}),s.jsxs("form",{className:"support-search-bar",onSubmit:H=>{H.preventDefault(),Ft({query:q.trim()})},children:[s.jsxs("label",{children:[s.jsx("span",{children:"Search Support"}),s.jsx("input",{value:q,onChange:H=>V(H.target.value),placeholder:"Search titles and request details"})]}),s.jsxs("button",{className:"support-secondary-button",type:"submit",children:[s.jsx(ty,{size:15})," Search"]}),c.query&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{V(""),Ft({query:""})},"aria-label":"Clear search",children:s.jsx(Ya,{size:16})})]}),s.jsxs("div",{className:"support-filter-bar",children:[s.jsxs("div",{className:"support-filter-title",children:[s.jsx(ty,{size:16}),s.jsx("span",{children:"Filter"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Product"}),s.jsxs("select",{value:ke,onChange:H=>Ft({product:H.target.value}),disabled:!m?.canViewAllProducts&&Fe.length<=1,children:[s.jsx("option",{value:"all",children:"All products"}),Fe.map(H=>s.jsx("option",{value:H.product_key,children:H.name},H.id))]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Status"}),s.jsx("select",{value:c.status,onChange:H=>Ft({status:H.target.value}),children:Q0.map(H=>s.jsx("option",{value:H.id,children:H.label},H.id))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"Visibility"}),s.jsxs("select",{value:c.visibility,onChange:H=>Ft({visibility:H.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:H=>Ft({sort:H.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:()=>Ft({status:"needs-response"}),children:"Needs response"}),s.jsx("button",{type:"button",onClick:()=>Ft({visibility:"private"}),children:"Private requests"}),s.jsx("button",{type:"button",onClick:()=>Ft({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:[gt.length," request",gt.length===1?"":"s"]}),s.jsx("small",{children:ke==="all"?"All products":Wm(Fe,st)})]}),gt.length===0?s.jsxs("div",{className:"support-list-empty",children:[s.jsx(Lc,{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."}),Fe.length>0&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>xe(!0),children:[s.jsx(Bm,{size:16})," Create the first request"]})]}):gt.map(H=>{const Pe=py(H.post_type);return s.jsxs("button",{type:"button",className:`support-post-row ${H.id===Re?.id?"active":""}`,onClick:()=>{C(H.id),K(!1)},children:[s.jsx("span",{className:"support-post-row-icon",children:s.jsx(Pe,{size:17})}),s.jsxs("span",{className:"support-post-row-copy",children:[s.jsxs("span",{className:"support-post-row-meta",children:[s.jsx("b",{children:Wm(g,H.product_id)}),s.jsx("em",{children:gy(H.post_type)}),H.visibility==="private"&&s.jsx(Ts,{size:13})]}),s.jsx("strong",{children:H.title}),s.jsxs("small",{children:[Vm(H.status)," · ",od(H.updated_at)," · ",H.comment_count," comments"]})]}),H.post_type==="feature"&&s.jsxs("span",{className:"support-vote-count",children:[s.jsx(Ux,{size:14})," ",H.vote_count]})]},H.id)})]}),s.jsx("section",{className:"support-post-detail","aria-label":"Support post detail",children:Re?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:Wm(g,Re.product_id)}),s.jsx("span",{className:"support-type-badge",children:gy(Re.post_type)}),s.jsx("span",{className:`support-status-badge status-${Re.status}`,children:Vm(Re.status)}),Re.visibility==="private"&&s.jsxs("span",{className:"support-private-badge",children:[s.jsx(Ts,{size:13})," Private"]})]}),s.jsxs("div",{className:"support-detail-actions",children:[Ls&&s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>K(H=>!H),title:"Edit post",children:s.jsx(IS,{size:16})}),jn&&s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{ps()},disabled:D==="pin",title:Re.is_pinned?"Unpin post":"Pin post",children:s.jsx(ny,{size:16})}),s.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>{Qt()},disabled:D==="lock",title:Re.is_locked?"Unlock post":"Lock post",children:s.jsx(Ts,{size:16})}),s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{Hi()},disabled:D==="hide",title:"Hide post",children:s.jsx(ay,{size:16})})]})]})]}),se?s.jsxs("form",{className:"support-edit-form",onSubmit:H=>{zn(H)},children:[s.jsx("input",{value:Re.title,onChange:H=>nt({title:H.target.value}),minLength:3,maxLength:180,required:!0}),s.jsx("textarea",{value:Re.body,onChange:H=>nt({body:H.target.value}),rows:9,required:!0}),s.jsxs("div",{className:"support-edit-actions",children:[s.jsxs("select",{value:Re.visibility,onChange:H=>nt({visibility:H.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:D==="edit",children:[s.jsx(Ii,{size:16})," Save changes"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:Re.title}),s.jsx("div",{className:"support-detail-body",children:Re.body.split(`
|
|
10
|
+
`).map((H,Pe)=>s.jsx("p",{children:H||" "},`${Re.id}-body-${Pe}`))})]}),s.jsxs("div",{className:"support-detail-meta",children:[s.jsxs("span",{children:["Opened ",od(Re.created_at)]}),Re.app_version&&s.jsxs("span",{children:["Version ",Re.app_version]}),Re.platform&&s.jsx("span",{children:Re.platform}),Re.is_locked&&s.jsxs("span",{children:[s.jsx(Ts,{size:13})," Locked"]}),Re.is_pinned&&s.jsxs("span",{children:[s.jsx(ny,{size:13})," Pinned"]})]}),s.jsxs("div",{className:"support-detail-controls",children:[Re.post_type==="feature"&&s.jsxs("button",{className:`support-vote-button ${U.has(Re.id)?"voted":""}`,type:"button",onClick:()=>{ya()},disabled:D==="vote",children:[s.jsx(OS,{size:16})," ",U.has(Re.id)?"Voted":"Vote"," ",s.jsx("b",{children:Re.vote_count})]}),jn&&s.jsxs("label",{className:"support-status-control",children:[s.jsx("span",{children:"Change status"}),s.jsx("select",{value:Re.status,onChange:H=>{dt(H.target.value)},disabled:D==="status",children:(X0[Re.post_type]||[]).map(H=>s.jsx("option",{value:H,children:Vm(H)},H))})]}),jn&&s.jsxs(s.Fragment,{children:[s.jsxs("select",{className:"support-status-control",value:We,onChange:H=>it(H.target.value),children:[s.jsx("option",{value:"",children:"Duplicate of..."}),gt.filter(H=>H.id!==Re.id&&H.product_id===Re.product_id).map(H=>s.jsx("option",{value:H.id,children:H.title.slice(0,55)},H.id))]}),s.jsx("button",{className:"support-secondary-button",type:"button",onClick:()=>{qn()},disabled:!We||D==="duplicate",children:"Merge duplicate"})]})]}),N.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:[N.length," file",N.length===1?"":"s"]})]})}),N.map(H=>s.jsxs("a",{href:H.signed_url,target:"_blank",rel:"noreferrer",children:[s.jsx(Wh,{size:14})," ",H.file_name,s.jsxs("small",{children:[Math.ceil(H.size_bytes/1024)," KB"]})]},H.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:[j.length," comment",j.length===1?"":"s"]})]}),Re.is_locked&&s.jsxs("span",{className:"support-locked-label",children:[s.jsx(Ts,{size:14})," Locked"]})]}),j.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:j.map(H=>s.jsxs("article",{className:`support-comment ${H.is_staff_answer?"staff":""} ${Re.accepted_comment_id===H.id?"accepted":""}`,children:[s.jsxs("div",{className:"support-comment-head",children:[s.jsx("strong",{children:H.is_staff_answer?"LiveDesk Support":H.author_id===n.user.id?"You":"Support user"}),H.is_staff_answer&&s.jsxs("span",{children:[s.jsx(Bt,{size:13})," Staff answer"]}),Re.accepted_comment_id===H.id&&s.jsxs("span",{children:[s.jsx(Fn,{size:13})," Accepted"]}),s.jsx("time",{children:od(H.created_at)})]}),s.jsx("p",{children:H.body}),s.jsxs("div",{className:"support-comment-actions",children:[(n.user.id===Re.author_id||jn)&&Re.post_type==="question"&&Re.accepted_comment_id!==H.id&&s.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{bt(H.id)},disabled:D===`accept-${H.id}`,children:[s.jsx(Ii,{size:14})," Accept answer"]}),jn&&s.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{K0(H.id)},title:"Hide comment",children:s.jsx(ay,{size:14})})]})]},H.id))}),!Re.is_locked&&s.jsxs("form",{className:"support-comment-form",onSubmit:H=>{He(H)},children:[s.jsx("textarea",{value:I,onChange:H=>Q(H.target.value),placeholder:"Add a focused reply...",rows:3}),s.jsxs("button",{className:"support-primary-button",type:"submit",disabled:D==="comment"||!I.trim(),children:[s.jsx(Fc,{size:15})," Reply"]})]})]})]}):s.jsxs("div",{className:"support-detail-empty",children:[s.jsx(Lc,{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(Lc,{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 cd(n){return!!n&&typeof n=="object"}function nb(n){let a=n;return cd(a)&&"data"in a&&(a=a.data),cd(a)&&"session"in a&&(a=a.session),!cd(a)||typeof a.access_token!="string"||!a.access_token||!cd(a.user)||typeof a.user.id!="string"||!a.user.id?null:a}function vy(n){return n?.access_token?n.refresh_token?"":"refresh-token-required":"access-token-required"}const zc=5179,Cn=Hr(`http://127.0.0.1:${zc}`);function tC(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 nC(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function aC(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function sC(n){const a=tC(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 iC(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function rC(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||aC(c)?null:{host:c,port:d}}catch{return null}}function Hr(n){const a=String(n||"").trim()||`http://127.0.0.1:${zc}`,r=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const l=new URL(r);return l.port||(l.port=String(zc)),l.hash="",l.search="",l.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${zc}`}}function lC(n){const a=rC(n);return a?Hr(`http://${iC(a.host)}:${zc}`):""}function yy(n){const r=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(l=>lC(String(l||""))).filter(Boolean);return[...new Set(r)]}function Ic(n=Cn){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(nC(a.hostname))return"loopback";if(sC(a.hostname))return"local"}catch{return}}function ef(n,a=Cn){const r=new URL(n,Hr(a));return r.protocol=r.protocol==="https:"?"wss:":"ws:",r.toString()}async function Ge(n,a,r=Cn){const l=Hr(r),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},d=Ic(l);d&&(c.targetAddressSpace=d);let m;try{m=await fetch(`${l}${n}`,c)}catch(g){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."):g}let p=null;try{p=await m.json()}catch{p=null}if(!m.ok){const g=p&&typeof p=="object"&&"error"in p?String(p.error||""):"";throw new Error(`${m.status} ${g||m.statusText}`)}return p}async function ab({baseUrl:n=Cn,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 g=await Ge("/api/runtime/status",void 0,n),v=String(g.role||"").toLowerCase(),w=String(g.state||"").toLowerCase(),x=Number(g.runtimePid||0),b=r>1?x>1&&x!==r:x>1;if(v===a&&l.map(C=>C.toLowerCase()).includes(w)&&b)return g}catch(g){m=g}await new Promise(g=>setTimeout(g,300))}const p=m instanceof Error?` ${m.message}`:"";throw new Error(`LiveDesk runtime did not become ${a} with a new process.${p}`)}function oC(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 sb(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 Al(n){await navigator.clipboard.writeText(n)}function ib({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 rb={hub:"Use this computer as the LiveDesk Hub. Hub is the unified control center for Client connections, Wall, Control, file sharing, and Agents; press it after network changes to refresh secure access.","switch-to-hub":"Switch this computer from Client to Hub. LiveDesk saves the new role, restarts the same desktop runtime, and opens the Wall; this computer stops sharing as a Client.",client:"Keep this computer in Client mode so its screens, files, audio, and remote controls remain available to the active Hub.",wall:"Show live thumbnails from every connected Client. Choose a display, change tile size, or move into Control without opening another connection.",control:"Open the selected Client at full resolution and send mouse and keyboard input through the existing Hub session.","share-files":"Browse files on the Hub, send files to selected Clients, and manage shared folders and transfer progress.",agents:"Run Hub-hosted Codex tasks on connected Clients within the selected permissions, timeouts, and audit controls."},kh={en:rb,ko:{hub:"이 컴퓨터를 LiveDesk Hub로 운영합니다. Hub는 Client 연결, Wall, Control, 파일 공유와 Agents를 한곳에서 관리하는 통합 제어 공간이며, 네트워크 변경 후 누르면 보안 접속 정보도 갱신됩니다.","switch-to-hub":"이 컴퓨터를 Client에서 Hub로 전환합니다. 새 역할을 저장한 뒤 같은 데스크톱 런타임을 재시작하고 Wall을 열며, 이 컴퓨터의 Client 화면 공유는 중지됩니다.",client:"이 컴퓨터를 Client 모드로 유지합니다. 화면, 파일, 오디오와 원격 제어 기능이 활성 Hub에서 계속 사용 가능하도록 연결합니다.",wall:"연결된 모든 Client의 실시간 화면을 한곳에 표시합니다. 모니터와 타일 크기를 선택하고 새 연결 없이 Control로 이동할 수 있습니다.",control:"선택한 Client 화면을 전체 해상도로 열고 기존 Hub 세션을 통해 마우스와 키보드 입력을 전송합니다.","share-files":"Hub의 파일을 탐색하고 선택한 Client로 전송하며 공유 폴더와 전송 진행 상태를 관리합니다.",agents:"Hub에서 실행되는 Codex 작업을 연결된 Client에 전달합니다. 선택한 권한, 제한 시간과 감사 기록 범위 안에서만 실행됩니다."},ja:{hub:"このコンピューターを LiveDesk Hub として運用します。Hub は Client 接続、Wall、Control、ファイル共有、Agents を一か所で管理する統合コントロールセンターで、ネットワーク変更後に押すと安全な接続情報も更新します。","switch-to-hub":"このコンピューターを Client から Hub に切り替えます。新しい役割を保存して同じデスクトップランタイムを再起動し、Wall を開きます。Client としての共有は停止します。",client:"このコンピューターを Client モードで維持し、画面、ファイル、音声、リモート操作をアクティブ Hub から利用できるようにします。",wall:"接続中のすべての Client のライブ画面を一覧表示します。ディスプレイやタイルサイズを選び、新しい接続なしで Control に移動できます。",control:"選択した Client をフル解像度で開き、既存の Hub セッションからマウスとキーボード入力を送信します。","share-files":"Hub のファイルを参照し、選択した Client への送信、共有フォルダー、転送状況を管理します。",agents:"Hub 上の Codex タスクを接続中の Client で実行します。選択した権限、タイムアウト、監査設定が適用されます。"},zh:{hub:"将此电脑作为 LiveDesk Hub 运行。Hub 是统一控制中心,可集中管理 Client 连接、Wall、Control、文件共享和 Agents;网络变化后按下此按钮还会刷新安全连接信息。","switch-to-hub":"将此电脑从 Client 切换为 Hub。LiveDesk 保存新角色、重启同一桌面运行时并打开 Wall;此电脑将停止作为 Client 共享。",client:"让此电脑保持 Client 模式,使活动 Hub 可以继续使用它的屏幕、文件、音频和远程控制。",wall:"集中显示所有已连接 Client 的实时缩略图。可以选择显示器、调整磁贴大小,并在不新建连接的情况下进入 Control。",control:"以完整分辨率打开所选 Client,并通过现有 Hub 会话发送鼠标和键盘输入。","share-files":"浏览 Hub 文件、向所选 Client 发送文件,并管理共享文件夹和传输进度。",agents:"在已连接 Client 上运行由 Hub 托管的 Codex 任务,并遵守所选权限、超时和审计控制。"},"zh-TW":{hub:"將此電腦作為 LiveDesk Hub 運作。Hub 是統一控制中心,可集中管理 Client 連線、Wall、Control、檔案分享與 Agents;網路變更後按下此按鈕也會更新安全連線資訊。","switch-to-hub":"將此電腦從 Client 切換為 Hub。LiveDesk 會儲存新角色、重新啟動同一桌面執行階段並開啟 Wall;此電腦將停止以 Client 身分共享。",client:"讓此電腦維持 Client 模式,使作用中 Hub 可繼續使用它的畫面、檔案、音訊與遠端控制。",wall:"集中顯示所有已連線 Client 的即時縮圖。可選擇顯示器、調整圖塊大小,並在不建立新連線的情況下進入 Control。",control:"以完整解析度開啟所選 Client,並透過現有 Hub 工作階段傳送滑鼠與鍵盤輸入。","share-files":"瀏覽 Hub 檔案、傳送檔案到所選 Client,並管理共享資料夾與傳輸進度。",agents:"在已連線 Client 上執行由 Hub 託管的 Codex 工作,並遵守所選權限、逾時與稽核控制。"},es:{hub:"Usa este equipo como LiveDesk Hub. Hub es el centro de control unificado para conexiones Client, Wall, Control, archivos y Agents; púlsalo tras cambios de red para actualizar el acceso seguro.","switch-to-hub":"Cambia este equipo de Client a Hub. LiveDesk guarda el nuevo rol, reinicia el mismo entorno de escritorio y abre Wall; el equipo deja de compartirse como Client.",client:"Mantiene este equipo en modo Client para que sus pantallas, archivos, audio y control remoto sigan disponibles desde el Hub activo.",wall:"Muestra miniaturas en vivo de todos los Clients conectados. Elige pantalla y tamaño, o entra en Control sin abrir otra conexión.",control:"Abre el Client seleccionado a resolución completa y envía ratón y teclado por la sesión Hub existente.","share-files":"Explora archivos del Hub, envíalos a los Clients seleccionados y administra carpetas compartidas y transferencias.",agents:"Ejecuta tareas Codex alojadas en el Hub sobre Clients conectados, respetando permisos, límites de tiempo y auditoría."},fr:{hub:"Utilise cet ordinateur comme LiveDesk Hub. Hub est le centre de contrôle unifié des connexions Client, de Wall, Control, des fichiers et des Agents ; appuyez après un changement réseau pour actualiser l’accès sécurisé.","switch-to-hub":"Bascule cet ordinateur de Client vers Hub. LiveDesk enregistre le nouveau rôle, redémarre le même environnement de bureau et ouvre Wall ; le partage Client s’arrête.",client:"Maintient cet ordinateur en mode Client afin que ses écrans, fichiers, sons et commandes à distance restent disponibles depuis le Hub actif.",wall:"Affiche les miniatures en direct de tous les Clients connectés. Choisissez l’écran et la taille, ou passez à Control sans nouvelle connexion.",control:"Ouvre le Client sélectionné en pleine résolution et transmet souris et clavier via la session Hub existante.","share-files":"Parcourez les fichiers du Hub, envoyez-les aux Clients sélectionnés et gérez dossiers partagés et transferts.",agents:"Exécute des tâches Codex hébergées par le Hub sur les Clients connectés, selon les permissions, délais et règles d’audit."},de:{hub:"Verwendet diesen Computer als LiveDesk Hub. Hub ist die gemeinsame Steuerzentrale für Client-Verbindungen, Wall, Control, Dateien und Agents; nach Netzwerkänderungen aktualisiert ein Klick den sicheren Zugriff.","switch-to-hub":"Wechselt diesen Computer von Client zu Hub. LiveDesk speichert die neue Rolle, startet dieselbe Desktop-Laufzeit neu und öffnet Wall; die Client-Freigabe endet.",client:"Hält diesen Computer im Client-Modus, damit Bildschirme, Dateien, Audio und Fernsteuerung am aktiven Hub verfügbar bleiben.",wall:"Zeigt Live-Vorschaubilder aller verbundenen Clients. Display und Kachelgröße wählen oder ohne neue Verbindung zu Control wechseln.",control:"Öffnet den gewählten Client in voller Auflösung und sendet Maus- und Tastatureingaben über die bestehende Hub-Sitzung.","share-files":"Dateien auf dem Hub durchsuchen, an gewählte Clients senden sowie Freigaben und Übertragungen verwalten.",agents:"Führt Hub-gehostete Codex-Aufgaben auf verbundenen Clients innerhalb der gewählten Berechtigungen, Zeitlimits und Auditregeln aus."},"pt-BR":{hub:"Usa este computador como LiveDesk Hub. Hub é o centro de controle unificado para conexões Client, Wall, Control, arquivos e Agents; após mudanças de rede, pressione para atualizar o acesso seguro.","switch-to-hub":"Muda este computador de Client para Hub. O LiveDesk salva a nova função, reinicia o mesmo runtime de desktop e abre o Wall; o compartilhamento como Client é encerrado.",client:"Mantém este computador no modo Client para que telas, arquivos, áudio e controle remoto continuem disponíveis no Hub ativo.",wall:"Mostra miniaturas ao vivo de todos os Clients conectados. Escolha a tela e o tamanho ou entre em Control sem criar outra conexão.",control:"Abre o Client selecionado em resolução total e envia mouse e teclado pela sessão Hub existente.","share-files":"Navegue pelos arquivos do Hub, envie para Clients selecionados e gerencie pastas compartilhadas e transferências.",agents:"Executa tarefas Codex hospedadas no Hub em Clients conectados, respeitando permissões, limites de tempo e auditoria."},it:{hub:"Usa questo computer come LiveDesk Hub. Hub è il centro di controllo unificato per connessioni Client, Wall, Control, file e Agents; dopo modifiche di rete, premilo per aggiornare l’accesso sicuro.","switch-to-hub":"Passa questo computer da Client a Hub. LiveDesk salva il nuovo ruolo, riavvia lo stesso runtime desktop e apre Wall; la condivisione come Client termina.",client:"Mantiene questo computer in modalità Client, rendendo schermi, file, audio e controllo remoto disponibili all’Hub attivo.",wall:"Mostra le anteprime live di tutti i Client connessi. Scegli display e dimensione oppure passa a Control senza una nuova connessione.",control:"Apre il Client selezionato a piena risoluzione e invia mouse e tastiera tramite la sessione Hub esistente.","share-files":"Esplora i file dell’Hub, inviali ai Client selezionati e gestisci cartelle condivise e trasferimenti.",agents:"Esegue attività Codex ospitate dall’Hub sui Client connessi rispettando permessi, timeout e controlli di audit."},id:{hub:"Gunakan komputer ini sebagai LiveDesk Hub. Hub adalah pusat kendali terpadu untuk koneksi Client, Wall, Control, file, dan Agents; tekan setelah perubahan jaringan untuk memperbarui akses aman.","switch-to-hub":"Alihkan komputer ini dari Client menjadi Hub. LiveDesk menyimpan peran baru, memulai ulang runtime desktop yang sama, lalu membuka Wall; berbagi sebagai Client berhenti.",client:"Pertahankan komputer ini dalam mode Client agar layar, file, audio, dan kendali jarak jauh tetap tersedia bagi Hub aktif.",wall:"Tampilkan thumbnail live semua Client yang terhubung. Pilih layar dan ukuran tile atau masuk ke Control tanpa koneksi baru.",control:"Buka Client terpilih pada resolusi penuh dan kirim input mouse serta keyboard melalui sesi Hub yang ada.","share-files":"Jelajahi file Hub, kirim ke Client terpilih, serta kelola folder bersama dan progres transfer.",agents:"Jalankan tugas Codex yang di-host Hub pada Client terhubung sesuai izin, batas waktu, dan kontrol audit."},vi:{hub:"Dùng máy tính này làm LiveDesk Hub. Hub là trung tâm điều khiển hợp nhất cho kết nối Client, Wall, Control, tệp và Agents; nhấn sau khi đổi mạng để làm mới quyền truy cập an toàn.","switch-to-hub":"Chuyển máy tính này từ Client sang Hub. LiveDesk lưu vai trò mới, khởi động lại cùng môi trường desktop và mở Wall; việc chia sẻ dưới dạng Client sẽ dừng.",client:"Giữ máy tính này ở chế độ Client để màn hình, tệp, âm thanh và điều khiển từ xa luôn sẵn sàng cho Hub đang hoạt động.",wall:"Hiển thị ảnh thu nhỏ trực tiếp của mọi Client đã kết nối. Chọn màn hình, cỡ ô hoặc vào Control mà không tạo kết nối mới.",control:"Mở Client đã chọn ở độ phân giải đầy đủ và gửi chuột, bàn phím qua phiên Hub hiện có.","share-files":"Duyệt tệp trên Hub, gửi tới Client đã chọn và quản lý thư mục chia sẻ cùng tiến trình truyền.",agents:"Chạy tác vụ Codex do Hub lưu trữ trên các Client đã kết nối trong phạm vi quyền, thời gian chờ và kiểm toán đã chọn."},th:{hub:"ใช้คอมพิวเตอร์เครื่องนี้เป็น LiveDesk Hub โดย Hub คือศูนย์ควบคุมรวมสำหรับการเชื่อมต่อ Client, Wall, Control, ไฟล์ และ Agents และกดหลังเปลี่ยนเครือข่ายเพื่อรีเฟรชการเข้าถึงที่ปลอดภัย","switch-to-hub":"เปลี่ยนคอมพิวเตอร์นี้จาก Client เป็น Hub โดย LiveDesk จะบันทึกบทบาทใหม่ รีสตาร์ต desktop runtime เดิม และเปิด Wall พร้อมหยุดแชร์ในฐานะ Client",client:"ให้คอมพิวเตอร์นี้อยู่ในโหมด Client เพื่อให้ Hub ที่ใช้งานเข้าถึงหน้าจอ ไฟล์ เสียง และการควบคุมระยะไกลได้ต่อเนื่อง",wall:"แสดงภาพสดแบบย่อของ Client ที่เชื่อมต่อทั้งหมด เลือกจอและขนาด tile หรือเข้า Control ได้โดยไม่เปิดการเชื่อมต่อใหม่",control:"เปิด Client ที่เลือกแบบความละเอียดเต็ม และส่งเมาส์กับคีย์บอร์ดผ่าน session ของ Hub ที่มีอยู่","share-files":"เรียกดูไฟล์บน Hub ส่งไปยัง Client ที่เลือก และจัดการโฟลเดอร์แชร์กับความคืบหน้าการโอน",agents:"เรียกใช้งาน Codex ที่โฮสต์บน Hub กับ Client ที่เชื่อมต่อ ภายใต้สิทธิ์ timeout และการตรวจสอบที่เลือก"},hi:{hub:"इस कंप्यूटर को LiveDesk Hub के रूप में उपयोग करें। Hub, Client कनेक्शन, Wall, Control, फ़ाइल और Agents का एकीकृत नियंत्रण केंद्र है; नेटवर्क बदलने के बाद सुरक्षित पहुँच ताज़ा करने के लिए इसे दबाएँ।","switch-to-hub":"इस कंप्यूटर को Client से Hub में बदलता है। LiveDesk नई भूमिका सहेजता है, उसी desktop runtime को restart करके Wall खोलता है और Client sharing रोक देता है।",client:"इस कंप्यूटर को Client मोड में रखता है ताकि इसकी स्क्रीन, फ़ाइलें, ऑडियो और remote control सक्रिय Hub पर उपलब्ध रहें।",wall:"सभी जुड़े Clients के live thumbnail दिखाता है। स्क्रीन और tile आकार चुनें या नया connection खोले बिना Control में जाएँ।",control:"चुने हुए Client को पूर्ण resolution में खोलता है और मौजूदा Hub session से mouse तथा keyboard input भेजता है।","share-files":"Hub की फ़ाइलें देखें, चुने हुए Clients को भेजें और shared folders तथा transfer progress प्रबंधित करें।",agents:"चुनी हुई permissions, timeout और audit controls के भीतर जुड़े Clients पर Hub-hosted Codex tasks चलाता है।"},ar:{hub:"استخدم هذا الكمبيوتر بوصفه LiveDesk Hub. يمثّل Hub مركز التحكم الموحّد لاتصالات Client وWall وControl والملفات وAgents؛ اضغط عليه بعد تغييرات الشبكة لتحديث الوصول الآمن.","switch-to-hub":"يحوّل هذا الكمبيوتر من Client إلى Hub. يحفظ LiveDesk الدور الجديد ويعيد تشغيل بيئة سطح المكتب نفسها ويفتح Wall، ويتوقف الجهاز عن المشاركة كـ Client.",client:"يبقي هذا الكمبيوتر في وضع Client لتظل شاشاته وملفاته وصوته والتحكم عن بعد متاحة من Hub النشط.",wall:"يعرض صورا حية مصغرة لكل Clients المتصلين. اختر الشاشة وحجم البلاطات أو انتقل إلى Control من دون اتصال جديد.",control:"يفتح Client المحدد بالدقة الكاملة ويرسل إدخال الماوس ولوحة المفاتيح عبر جلسة Hub الحالية.","share-files":"استعرض ملفات Hub وأرسلها إلى Clients المحددين وأدر المجلدات المشتركة وتقدم النقل.",agents:"يشغّل مهام Codex المستضافة على Hub في Clients المتصلين ضمن الصلاحيات والمهل وضوابط التدقيق المحددة."},tr:{hub:"Bu bilgisayarı LiveDesk Hub olarak kullanır. Hub; Client bağlantıları, Wall, Control, dosyalar ve Agents için birleşik kontrol merkezidir; ağ değişikliklerinden sonra güvenli erişimi yenilemek için basın.","switch-to-hub":"Bu bilgisayarı Client rolünden Hub rolüne geçirir. LiveDesk yeni rolü kaydeder, aynı masaüstü runtime’ını yeniden başlatıp Wall’u açar; Client paylaşımı durur.",client:"Bu bilgisayarı Client modunda tutar; ekran, dosya, ses ve uzaktan kontrol özellikleri etkin Hub tarafından kullanılabilir kalır.",wall:"Bağlı tüm Client ekranlarının canlı küçük görüntülerini gösterir. Ekran ve kutu boyutunu seçin veya yeni bağlantı açmadan Control’e geçin.",control:"Seçili Client’ı tam çözünürlükte açar ve mevcut Hub oturumu üzerinden fare ile klavye girdisi gönderir.","share-files":"Hub dosyalarını gezin, seçili Client’lara gönderin ve paylaşılan klasörlerle aktarım ilerlemesini yönetin.",agents:"Hub üzerinde barındırılan Codex görevlerini seçili izinler, zaman aşımları ve denetim kontrolleri içinde bağlı Client’larda çalıştırır."}};function Zh(n){const a=n?[n]:typeof navigator>"u"?["en"]:navigator.languages?.length?navigator.languages:[navigator.language];for(const r of a){const l=String(r||"").trim(),c=l.toLowerCase();if(!c)continue;if(c.startsWith("zh-tw")||c.startsWith("zh-hk"))return"zh-TW";if(c.startsWith("zh"))return"zh";if(c.startsWith("pt"))return"pt-BR";const d=c.split("-")[0];if(kh[l])return l;if(kh[d])return d}return"en"}function Pd(n,a){const r=Zh(a);return kh[r]?.[n]||rb[n]}function Ah(n,a,r){return`${n}
|
|
11
|
+
${Pd(a,r)}`}const lb={eyebrow:"Change computer role",title:"Switch this computer to Hub?",description:"LiveDesk will stop sharing this computer as a Client, save the Hub role, restart the local runtime, and open Wall in this same window.",restartNotice:"Remote streams from this computer will end while LiveDesk restarts.",cancel:"Cancel",confirm:"Switch to Hub",closeLabel:"Close Hub switch confirmation"},cC={en:lb,ko:{eyebrow:"컴퓨터 역할 변경",title:"이 컴퓨터를 Hub로 전환하시겠습니까?",description:"이 컴퓨터의 Client 공유를 중지하고 Hub 역할을 저장한 뒤 로컬 런타임을 재시작하여 같은 창에서 Wall을 엽니다.",restartNotice:"LiveDesk가 재시작되는 동안 이 컴퓨터의 원격 스트림이 종료됩니다.",cancel:"취소",confirm:"Hub로 전환",closeLabel:"Hub 전환 확인 닫기"},ja:{eyebrow:"コンピューターの役割を変更",title:"このコンピューターを Hub に切り替えますか?",description:"このコンピューターの Client 共有を停止し、Hub の役割を保存してローカルランタイムを再起動し、同じウィンドウで Wall を開きます。",restartNotice:"LiveDesk の再起動中、このコンピューターのリモートストリームは終了します。",cancel:"キャンセル",confirm:"Hub に切り替える",closeLabel:"Hub 切り替え確認を閉じる"},zh:{eyebrow:"更改电脑角色",title:"将此电脑切换为 Hub?",description:"LiveDesk 将停止此电脑的 Client 共享,保存 Hub 角色,重启本地运行时,并在同一窗口中打开 Wall。",restartNotice:"LiveDesk 重启期间,此电脑的远程流将会结束。",cancel:"取消",confirm:"切换为 Hub",closeLabel:"关闭 Hub 切换确认"},"zh-TW":{eyebrow:"變更電腦角色",title:"要將此電腦切換為 Hub 嗎?",description:"LiveDesk 將停止此電腦的 Client 分享、儲存 Hub 角色、重新啟動本機執行階段,並在同一視窗中開啟 Wall。",restartNotice:"LiveDesk 重新啟動期間,此電腦的遠端串流將會結束。",cancel:"取消",confirm:"切換為 Hub",closeLabel:"關閉 Hub 切換確認"},es:{eyebrow:"Cambiar función del equipo",title:"¿Cambiar este equipo a Hub?",description:"LiveDesk dejará de compartir este equipo como Client, guardará la función Hub, reiniciará el entorno local y abrirá Wall en esta misma ventana.",restartNotice:"Los streams remotos de este equipo terminarán mientras LiveDesk se reinicia.",cancel:"Cancelar",confirm:"Cambiar a Hub",closeLabel:"Cerrar confirmación de cambio a Hub"},fr:{eyebrow:"Changer le rôle de l’ordinateur",title:"Basculer cet ordinateur vers Hub ?",description:"LiveDesk arrêtera le partage Client de cet ordinateur, enregistrera le rôle Hub, redémarrera le runtime local et ouvrira Wall dans cette même fenêtre.",restartNotice:"Les flux distants de cet ordinateur prendront fin pendant le redémarrage de LiveDesk.",cancel:"Annuler",confirm:"Basculer vers Hub",closeLabel:"Fermer la confirmation de bascule vers Hub"},de:{eyebrow:"Computerrolle ändern",title:"Diesen Computer auf Hub umstellen?",description:"LiveDesk beendet die Client-Freigabe dieses Computers, speichert die Hub-Rolle, startet die lokale Laufzeit neu und öffnet Wall im selben Fenster.",restartNotice:"Die Remote-Streams dieses Computers enden während des LiveDesk-Neustarts.",cancel:"Abbrechen",confirm:"Auf Hub umstellen",closeLabel:"Bestätigung für Hub-Wechsel schließen"},"pt-BR":{eyebrow:"Alterar função do computador",title:"Mudar este computador para Hub?",description:"O LiveDesk interromperá o compartilhamento deste computador como Client, salvará a função Hub, reiniciará o runtime local e abrirá o Wall nesta mesma janela.",restartNotice:"Os streams remotos deste computador serão encerrados enquanto o LiveDesk reinicia.",cancel:"Cancelar",confirm:"Mudar para Hub",closeLabel:"Fechar confirmação de mudança para Hub"},it:{eyebrow:"Cambia ruolo del computer",title:"Passare questo computer a Hub?",description:"LiveDesk interromperà la condivisione Client di questo computer, salverà il ruolo Hub, riavvierà il runtime locale e aprirà Wall nella stessa finestra.",restartNotice:"Gli stream remoti di questo computer termineranno durante il riavvio di LiveDesk.",cancel:"Annulla",confirm:"Passa a Hub",closeLabel:"Chiudi la conferma del passaggio a Hub"},id:{eyebrow:"Ubah peran komputer",title:"Alihkan komputer ini menjadi Hub?",description:"LiveDesk akan menghentikan berbagi komputer ini sebagai Client, menyimpan peran Hub, memulai ulang runtime lokal, lalu membuka Wall di jendela yang sama.",restartNotice:"Stream jarak jauh dari komputer ini akan berakhir saat LiveDesk dimulai ulang.",cancel:"Batal",confirm:"Alihkan ke Hub",closeLabel:"Tutup konfirmasi peralihan Hub"},vi:{eyebrow:"Đổi vai trò máy tính",title:"Chuyển máy tính này thành Hub?",description:"LiveDesk sẽ dừng chia sẻ máy tính này dưới dạng Client, lưu vai trò Hub, khởi động lại runtime cục bộ và mở Wall trong cùng cửa sổ.",restartNotice:"Các luồng từ xa của máy tính này sẽ kết thúc trong khi LiveDesk khởi động lại.",cancel:"Hủy",confirm:"Chuyển sang Hub",closeLabel:"Đóng xác nhận chuyển sang Hub"},th:{eyebrow:"เปลี่ยนบทบาทคอมพิวเตอร์",title:"เปลี่ยนคอมพิวเตอร์เครื่องนี้เป็น Hub หรือไม่",description:"LiveDesk จะหยุดแชร์คอมพิวเตอร์เครื่องนี้ในฐานะ Client บันทึกบทบาท Hub รีสตาร์ทรันไทม์ภายในเครื่อง และเปิด Wall ในหน้าต่างเดิม",restartNotice:"สตรีมระยะไกลจากคอมพิวเตอร์เครื่องนี้จะสิ้นสุดลงระหว่างที่ LiveDesk รีสตาร์ท",cancel:"ยกเลิก",confirm:"เปลี่ยนเป็น Hub",closeLabel:"ปิดการยืนยันการเปลี่ยนเป็น Hub"},hi:{eyebrow:"कंप्यूटर की भूमिका बदलें",title:"इस कंप्यूटर को Hub में बदलें?",description:"LiveDesk इस कंप्यूटर की Client साझेदारी बंद करेगा, Hub भूमिका सहेजेगा, स्थानीय रनटाइम पुनः आरंभ करेगा और इसी विंडो में Wall खोलेगा।",restartNotice:"LiveDesk के पुनः आरंभ होने के दौरान इस कंप्यूटर की रिमोट स्ट्रीम समाप्त हो जाएँगी।",cancel:"रद्द करें",confirm:"Hub में बदलें",closeLabel:"Hub परिवर्तन की पुष्टि बंद करें"},ar:{eyebrow:"تغيير دور الكمبيوتر",title:"هل تريد تحويل هذا الكمبيوتر إلى Hub؟",description:"سيوقف LiveDesk مشاركة هذا الكمبيوتر كـ Client، ويحفظ دور Hub، ويعيد تشغيل وقت التشغيل المحلي، ثم يفتح Wall في النافذة نفسها.",restartNotice:"ستنتهي التدفقات البعيدة من هذا الكمبيوتر أثناء إعادة تشغيل LiveDesk.",cancel:"إلغاء",confirm:"التحويل إلى Hub",closeLabel:"إغلاق تأكيد التحويل إلى Hub"},tr:{eyebrow:"Bilgisayar rolünü değiştir",title:"Bu bilgisayar Hub rolüne geçirilsin mi?",description:"LiveDesk bu bilgisayarın Client paylaşımını durdurur, Hub rolünü kaydeder, yerel çalışma zamanını yeniden başlatır ve Wall’u aynı pencerede açar.",restartNotice:"LiveDesk yeniden başlatılırken bu bilgisayarın uzak akışları sona erer.",cancel:"İptal",confirm:"Hub’a geçir",closeLabel:"Hub geçişi onayını kapat"}};function uC(n){const a=Zh(n);return cC[a]||lb}const dC=[{id:"docs",label:"Doc",icon:Bd},{id:"support",label:"Support",icon:Lc},{id:"pricing",label:"Pricing",icon:Ao},{id:"settings",label:"Settings",icon:qx}],xy=[0,1e3,2e3,5e3,1e4,2e4,3e4];function fC(){return typeof window>"u"?"":window.location.port==="5179"?window.location.origin:"http://127.0.0.1:5179"}async function kc(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 Nh(n){return`${Math.max(0,Math.min(100,Number(n||0))).toFixed(0)}%`}function Ym(n){return Number.isFinite(n)?`${Math.max(0,Math.min(100,Number(n))).toFixed(0)}%`:"—"}function ob(n){return Number.isFinite(n)?Nh(Number(n)):"0%"}function Tl(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 by(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 mC(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 hC(n,a){return!Number.isFinite(a)||Number(a)<=0?"Dedicated memory unavailable":Number.isFinite(n)?`${Tl(n)} / ${Tl(a)}`:`${Tl(a)} available`}function pC(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 ud({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:ob(c)}})})]})}function gC(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 vC(n){const a=n?.user.user_metadata||{},r=a.avatar_url||a.picture;return typeof r=="string"?r.trim():""}function yC({page:n,status:a}){const l={docs:{label:"DOC",title:"Using this computer",body:"This computer connects to its assigned Hub 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 Hub."})]}),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 xC({session:n,status:a,pin:r,error:l,roleChangeMessage:c,roleChangeBusy:d,onSignIn:m,onPinChange:p,onSubmitPin:g,onSwitchToHub:v}){const w=a?.connectionState==="connected",x=a?.system?.memoryTotalBytes?Number(a.system.memoryUsedBytes||0)/a.system.memoryTotalBytes*100:0,b=a?.system?.gpus||[],C=b.find(O=>Number.isFinite(O.usagePercent)||Number.isFinite(O.memoryTotalBytes))||b[0],j=Number.isFinite(C?.usagePercent)?Number(C?.usagePercent):null,A=Number.isFinite(C?.memoryTotalBytes)&&Number(C?.memoryTotalBytes)>0&&Number.isFinite(C?.memoryUsedBytes)?Number(C?.memoryUsedBytes)/Number(C?.memoryTotalBytes)*100:null,N=a?.system?.disks||[],k=a?.system?.network,T=k?.interfaces||[],R=[...new Set(T.map(O=>O.name).filter(Boolean))],U=T.map(O=>O.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(an,{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(Vx,{size:14})," Uptime ",pC(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(ud,{icon:Wx,label:"CPU",value:Nh(a?.system?.cpuUsagePercent),detail:a?.system?.cpuLogicalCores?`${a.system.cpuLogicalCores} logical cores · Current processor usage`:"Current processor usage",percent:a?.system?.cpuUsagePercent}),s.jsx(ud,{icon:$S,label:"Memory",value:Nh(x),detail:mC(a?.system?.memoryUsedBytes,a?.system?.memoryTotalBytes),percent:x}),s.jsx(ud,{icon:US,label:"GPU",value:Ym(j),detail:C?.name||(a?.system?.hardwareCollecting?"Detecting graphics hardware…":"Graphics usage unavailable"),percent:j}),s.jsx(ud,{icon:El,label:"VRAM",value:Ym(A),detail:hC(C?.memoryUsedBytes,C?.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:N.length>0?`${N.length} ${N.length===1?"drive":"drives"}`:a?.system?.hardwareCollecting?"Detecting…":"Unavailable"})]}),s.jsxs("div",{className:"client-disk-list",children:[N.map(O=>s.jsxs("article",{className:"client-disk-row",children:[s.jsxs("div",{className:"client-disk-row-head",children:[s.jsxs("span",{children:[s.jsx(Ml,{size:16}),s.jsx("strong",{children:O.mount||"Disk"}),s.jsx("small",{children:O.name||"Local disk"})]}),s.jsx("strong",{children:Ym(O.usedPercent)})]}),s.jsxs("small",{children:[Tl(O.freeBytes)," free · ",Tl(O.totalBytes)," total"]}),s.jsx("i",{"aria-hidden":"true",children:s.jsx("b",{style:{width:ob(O.usedPercent)}})})]},`${O.mount}-${O.name||""}`)),N.length===0&&s.jsxs("div",{className:"client-disk-empty",children:[s.jsx(Ml,{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(Dl,{size:18}),s.jsxs("span",{children:[s.jsx("strong",{children:R.join(", ")||"Network"}),s.jsx("small",{children:U.join(" / ")||"Checking active connection"})]})]}),s.jsxs("div",{className:"client-network-rate download",children:[s.jsx(qS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Receive"}),s.jsx("strong",{children:by(k?.receiveBytesPerSecond)})]})]}),s.jsxs("div",{className:"client-network-rate upload",children:[s.jsx(GS,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Send"}),s.jsx("strong",{children:by(k?.sendBytesPerSecond)})]})]}),s.jsxs("small",{className:"client-network-total",children:["Total ",Tl(k?.receivedBytes)," received / ",Tl(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(an,{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(No,{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(pn,{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(Rl,{size:16})," Sign in with Google"]}):s.jsxs("p",{className:"client-unified-success",children:[s.jsx(Fn,{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(Mo,{size:16}),s.jsx("input",{value:r,onChange:O=>p(O.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:g,disabled:r.length!==6,children:"Connect"})]})]}),(l||a?.lastError)&&s.jsxs("p",{className:"client-unified-error",role:"alert",children:[s.jsx(Yx,{size:15})," ",l||a?.lastError]}),c&&s.jsx("p",{className:"client-unified-success",children:c}),s.jsxs("button",{className:"client-unified-secondary full client-hub-switch-trigger",type:"button",onClick:v,disabled:d||!a?.authenticated,children:[s.jsx(El,{size:16})," ",d?"Switching to Hub…":"Switch this computer to Hub"]})]})]})]})}function bC(){const[n,a]=u.useState(null),[r,l]=u.useState(null),[c,d]=u.useState(!1),[m,p]=u.useState(""),[g,v]=u.useState(""),[w,x]=u.useState(""),[b,C]=u.useState(!1),[j,A]=u.useState(!1),[N,k]=u.useState("computer"),[T,R]=u.useState(!1),U=u.useRef(null),O=u.useRef(null),Y=u.useRef(!1),_=u.useRef(!1),D=u.useRef(!1),ne=u.useRef(0),G=u.useMemo(fC,[]),te=u.useMemo(()=>gC(r),[r]),B=u.useMemo(()=>vC(r),[r]),xe=te.slice(0,1).toUpperCase()||"L",se=u.useCallback(async()=>{if(v(""),window.liveDesk?.auth?.signInWithGoogle){const re=await window.liveDesk.auth.signInWithGoogle();return re?.ok===!1?(v(re.error||"LiveDesk could not open the system browser for Google sign-in."),!1):!0}return window.location.assign(`${G}/auth/google`),!0},[G]),K=u.useCallback(async()=>{D.current||(D.current=!0,v("Your saved Google sign-in is incomplete. LiveDesk is reopening sign-in once to repair it."),await pt.auth.signOut({scope:"local"}).catch(()=>{}),l(null),await se()||(D.current=!1))},[se]),I=u.useCallback(async re=>{const Z=vy(re);if(Z)throw new Error(Z);if(Y.current)return!1;Y.current=!0;try{const ze=await window.liveDesk?.auth?.persistSession?.(re);if(ze?.ok===!1)throw new Error(ze.error||"LiveDesk could not validate the desktop session.");for(let Le=0;Le<2;Le+=1){const ae=await kc(G,Le>0),fe=await fetch(`${G}/api/auth/session`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":ae},signal:AbortSignal.timeout(1e4),body:JSON.stringify({accessToken:re.access_token,refreshToken:re.refresh_token,expiresAt:re.expires_at,user:{id:re.user.id,email:re.user.email}})}),Ae=await fe.json().catch(()=>({}));if(fe.status===403&&Le===0){sessionStorage.removeItem("livedesk.client.csrf");continue}if(!fe.ok)throw new Error(Ae.error||`Client runtime returned HTTP ${fe.status}.`);return v(""),!0}throw new Error("Client runtime rejected the session transfer.")}finally{Y.current=!1}},[G]),Q=u.useCallback(async()=>{try{const re=await fetch(`${G}/api/client/status`,{cache:"no-store"}),Z=await re.json().catch(()=>({}));if(!re.ok)throw new Error(Z.error||`Client runtime returned HTTP ${re.status}.`);if(Z.csrfToken&&sessionStorage.setItem("livedesk.client.csrf",Z.csrfToken),String(Z.role||"").toLowerCase()==="hub")throw new Error("This computer is assigned to the Hub role.");a(Z)}catch(re){v(re instanceof Error?re.message:String(re))}},[G]);u.useEffect(()=>{Q();const re=window.setInterval(()=>{Q()},2e3);return()=>window.clearInterval(re)},[Q]);const q=u.useCallback(async()=>{const re=Date.now();if(!(!n?.authenticated||n.connectionState==="connected"||!["waiting","reconnecting"].includes(String(n.agent?.state||""))||re-ne.current<4e3)){ne.current=re;try{const Z=await fetch(`${G}/api/client/reconnect`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await kc(G)},body:JSON.stringify({onlyIfWaiting:!0,reason:"app-active"})});if(!Z.ok)throw new Error(`Client reconnect returned HTTP ${Z.status}.`);await Q()}catch(Z){v(Z instanceof Error?Z.message:String(Z))}}},[G,Q,n]);u.useEffect(()=>{const re=()=>{q()},Z=()=>{q()},ze=()=>{document.visibilityState==="visible"&&q()};return window.addEventListener("online",re),window.addEventListener("focus",Z),document.addEventListener("visibilitychange",ze),()=>{window.removeEventListener("online",re),window.removeEventListener("focus",Z),document.removeEventListener("visibilitychange",ze)}},[q]),u.useEffect(()=>{if(!c||!n||!r?.access_token||n.authenticated)return;if(vy(r)==="refresh-token-required"){K().catch(ae=>{D.current=!1,v(ae instanceof Error?ae.message:String(ae))});return}let re=!1,Z,ze=0;const Le=async()=>{if(re)return;try{const fe=await I(r);if(await Q(),fe)return}catch(fe){v(fe instanceof Error?fe.message:String(fe))}if(re)return;const ae=xy[Math.min(ze,xy.length-1)];ze+=1,Z=window.setTimeout(()=>{Le()},ae)};return Le(),()=>{re=!0,Z!==void 0&&window.clearTimeout(Z)}},[c,Q,K,r,n,I]),u.useEffect(()=>{const re=new URLSearchParams(window.location.search),Z=re.get("auth_error");if(!Z)return;v(Z),re.delete("auth_error");const ze=re.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${ze?`?${ze}`:""}${window.location.hash}`)},[]),u.useEffect(()=>{let re=!0;if(!window.liveDesk?.auth)return l(null),d(!0),Q(),()=>{re=!1};const Z=window.liveDesk?.auth?.onComplete?.(Le=>{Le.ok&&Le.session?pt.auth.setSession(Le.session).catch(ae=>v(ae instanceof Error?ae.message:String(ae))):Le.error&&v(Le.error)});(async()=>{try{const Le=window.liveDesk?.auth?.getSession?await window.liveDesk.auth.getSession():await pt.auth.getSession();if(!re)return;const ae=nb(Le);l(ae),Q()}catch(Le){re&&v(Le instanceof Error?Le.message:String(Le))}finally{re&&d(!0)}})();const{data:ze}=pt.auth.onAuthStateChange((Le,ae)=>{re&&(l(ae),d(!0),Q())});return()=>{re=!1,Z?.(),ze.subscription.unsubscribe()}},[Q]),u.useEffect(()=>{if(!c||!n||_.current||D.current||r||n.authenticated)return;const re=new URLSearchParams(window.location.search);if(!re.has("livedesk_launch"))return;_.current=!0,re.delete("livedesk_launch");const Z=re.toString();window.history.replaceState(window.history.state,"",`${window.location.pathname}${Z?`?${Z}`:""}${window.location.hash}`),se().catch(ze=>v(ze instanceof Error?ze.message:String(ze)))},[c,r,se,n]);const V=async()=>{R(!1),window.liveDesk?.auth?.persistSession?(await pt.auth.signOut(),(await window.liveDesk.auth.persistSession(null))?.runtimeCleared===!1&&v("Signed out locally. The LiveDesk runtime could not be reached to clear its session.")):await fetch(`${G}/api/auth/session`,{method:"DELETE",headers:{"X-LiveDesk-CSRF":await kc(G)}}).catch(()=>{}),l(null),await Q()};u.useEffect(()=>{if(!T)return;const re=ze=>{ze.target instanceof Element&&ze.target.closest(".account-popover, .rail-account")||R(!1)},Z=ze=>{ze.key==="Escape"&&R(!1)};return window.addEventListener("pointerdown",re),window.addEventListener("keydown",Z),()=>{window.removeEventListener("pointerdown",re),window.removeEventListener("keydown",Z)}},[T]);const ce=u.useCallback((re=!0)=>{b||(A(!1),re&&window.requestAnimationFrame(()=>O.current?.focus()))},[b]),be=u.useCallback(()=>{b||!n?.authenticated||(O.current=document.activeElement instanceof HTMLElement?document.activeElement:null,x(""),A(!0))},[b,n?.authenticated]);u.useEffect(()=>{if(!j)return;const re=window.requestAnimationFrame(()=>U.current?.focus()),Z=Le=>{Le.target instanceof Element&&Le.target.closest(".client-hub-switch-popover, .client-hub-switch-trigger")||ce(!1)},ze=Le=>{Le.key==="Escape"&&ce()};return window.addEventListener("pointerdown",Z),window.addEventListener("keydown",ze),()=>{window.cancelAnimationFrame(re),window.removeEventListener("pointerdown",Z),window.removeEventListener("keydown",ze)}},[ce,j]);const X=async()=>{v("");try{const re=await fetch(`${G}/api/client/pin`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await kc(G)},body:JSON.stringify({pin:m})}),Z=await re.json().catch(()=>({}));if(!re.ok||Z?.ok===!1)throw new Error(Z?.error||"PIN could not be accepted.");p(""),await Q()}catch(re){v(re instanceof Error?re.message:String(re))}},$=async()=>{A(!1),C(!0),x(""),v("");try{const re=await fetch(`${G}/api/runtime/switch-role`,{method:"POST",headers:{"Content-Type":"application/json","X-LiveDesk-CSRF":await kc(G)},body:JSON.stringify({role:"hub"})}),Z=await re.json().catch(()=>({}));if(!re.ok||Z?.ok===!1)throw new Error(Z?.error||`Role change failed with HTTP ${re.status}.`);x("Hub role accepted. LiveDesk is restarting this computer with the Hub Wall.");const ze=Number(n?.runtimePid||0);await ab({baseUrl:G,targetRole:"hub",previousRuntimePid:ze,allowedStates:["running"]}),window.location.reload()}catch(re){v(re instanceof Error?re.message:String(re)),C(!1)}},ue=!!(n?.authenticated||r),he=u.useMemo(()=>Zh(),[]),ve=Pd("switch-to-hub",he),Se=Pd("client",he),_e=uC(he);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(ib,{size:25})}),s.jsx("nav",{className:"rail-tools","aria-label":"Client navigation",children:s.jsxs("div",{className:"client-main-tool-slot",children:[s.jsxs("button",{className:"rail-tool client-main-tool client-hub-tool client-hub-switch-trigger accent-blue",type:"button",onClick:be,disabled:b||!n?.authenticated,"aria-busy":b,"aria-expanded":j,"aria-haspopup":"dialog","aria-controls":j?"client-hub-switch-popover":void 0,"aria-label":`Hub. ${ve}`,"data-tooltip":j?void 0:Ah("Hub","switch-to-hub",he),children:[s.jsx(El,{size:19}),s.jsx("span",{children:b?"Switching…":"Hub"})]}),s.jsxs("button",{className:`rail-tool client-main-tool accent-blue ${N==="computer"?"active":""}`,type:"button",onClick:()=>k("computer"),"aria-current":N==="computer"?"page":void 0,"aria-label":`Client. ${Se}`,"data-tooltip":Ah("Client","client",he),children:[s.jsx(an,{size:19}),s.jsx("span",{children:"Client"})]})]})}),s.jsxs("div",{className:"rail-footer",children:[dC.map(re=>{const Z=re.icon;return s.jsxs("button",{className:`rail-tool compact ${N===re.id?"active":""}`,type:"button",onClick:()=>k(re.id),title:re.label,children:[s.jsx(Z,{size:18}),s.jsx("span",{children:re.label})]},re.id)}),s.jsxs("button",{className:`rail-account ${ue?"signed-in":""}`,type:"button",onClick:()=>R(re=>!re),"aria-expanded":T,"aria-haspopup":"dialog",title:ue?"Account":"Sign in",children:[r&&B?s.jsx("img",{src:B,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{className:"avatar-fallback",children:xe}):ue?s.jsx(Bt,{size:18}):s.jsx(Rl,{size:18}),s.jsx("span",{children:ue?"Account":"Sign in"})]})]})]}),j&&s.jsxs("section",{id:"client-hub-switch-popover",className:"client-hub-switch-popover",role:"dialog","aria-modal":"false","aria-labelledby":"client-hub-switch-title","aria-describedby":"client-hub-switch-description client-hub-switch-restart",children:[s.jsxs("header",{className:"client-hub-switch-head",children:[s.jsx("span",{className:"client-hub-switch-mark","aria-hidden":"true",children:s.jsx(El,{size:19})}),s.jsx("span",{className:"client-hub-switch-eyebrow",children:_e.eyebrow}),s.jsx("button",{className:"client-hub-switch-close",type:"button",onClick:()=>ce(),"aria-label":_e.closeLabel,children:s.jsx(Ya,{size:17})})]}),s.jsx("h2",{id:"client-hub-switch-title",children:_e.title}),s.jsx("p",{id:"client-hub-switch-description",children:_e.description}),s.jsxs("p",{id:"client-hub-switch-restart",className:"client-hub-switch-notice",children:[s.jsx(Bt,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:_e.restartNotice})]}),s.jsxs("div",{className:"client-hub-switch-actions",children:[s.jsx("button",{type:"button",onClick:()=>ce(),children:_e.cancel}),s.jsxs("button",{ref:U,className:"primary",type:"button",onClick:()=>{$()},disabled:b||!n?.authenticated,children:[s.jsx(El,{size:16}),_e.confirm]})]})]}),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&&B?s.jsx("img",{src:B,alt:te,referrerPolicy:"no-referrer"}):r?s.jsx("span",{children:xe}):s.jsx(Rl,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:r?te:ue?"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":ue?"Active for this run":"Not saved"}),s.jsx("dt",{children:"Role"}),s.jsx("dd",{children:"Client"})]}),ue?s.jsxs("button",{className:"account-popover-action",onClick:()=>{V()},type:"button",children:[s.jsx(Gx,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:()=>{R(!1),se()},type:"button",children:[s.jsx(Rl,{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(pn,{size:18})}),s.jsxs("div",{children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Client workspace"})]})]})}),N==="support"?s.jsx("section",{className:"client-unified-page",children:s.jsx(tb,{session:r,currentProductKey:"livedesk",appVersion:n?.appVersion||"",onSignIn:()=>{se()}})}):N!=="computer"?s.jsx("section",{className:"client-unified-page",children:s.jsx(yC,{page:N,status:n})}):s.jsx(xC,{session:r,status:n,pin:m,error:g,roleChangeMessage:w,roleChangeBusy:b,onSignIn:()=>{se()},onPinChange:re=>p(re.replace(/\D/g,"").slice(0,6)),onSubmitPin:()=>{X()},onSwitchToHub:be})]})]})}function Lr(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(;Lr(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 dd(n,a,r,l){if(Lr(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 wC(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 cb(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,dd(n,l,r,m),c=4}else n[l.inputIndex]>=18&&(c=n[l.inputIndex]-17,l.inputIndex+=1,dd(n,l,r,c));for(;;){Lr(n,l.inputIndex,1);const m=n[l.inputIndex];l.inputIndex+=1;let p,g;if((m&192)!==0)Lr(n,l.inputIndex,1),g=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)),Lr(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;l.inputIndex+=2,g=l.outputIndex-((v>>2)+1),p=v&3}else if((m&16)!==0){d=(m&7)+2,d===2&&(d+=Km(n,l,7)),Lr(n,l.inputIndex,2);const v=n[l.inputIndex]|n[l.inputIndex+1]<<8;if(l.inputIndex+=2,g=l.outputIndex-(((m&8)<<11)+(v>>2)),p=v&3,g===l.outputIndex)break;g-=16384}else if(c===0){let v=m+3;v===3&&(v+=Km(n,l,15)),dd(n,l,r,v),c=4;continue}else c!==4?(Lr(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+1),l.inputIndex+=1,d=2):(Lr(n,l.inputIndex,1),p=m&3,g=l.outputIndex-((m>>2)+(n[l.inputIndex]<<2)+2049),l.inputIndex+=1,d=3);if(g<0||l.outputIndex+d+p>r.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");l.outputIndex=wC(r,l.outputIndex,g,d),c=p,dd(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 wy=16,Sy=8,SC=24*1024*1024,ub=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,Mh=new Uint32Array(65536);for(let n=0;n<Mh.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);Mh[n]=ub?(a|r<<8|l<<16|4278190080)>>>0:(a<<24|r<<16|l<<8|255)>>>0}function Rr(n,a){return n[a]|n[a+1]<<8}function CC(n,a){const r=Number(a);if(!Number.isSafeInteger(r)||r<wy||r>SC)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const l=n instanceof Uint8Array?n:new Uint8Array(n),c=cb(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=Rr(c,6),p=Rr(c,8),g=Rr(c,10),v=Rr(c,12);if(m<=0||p<=0||m>3840||p>2160)throw new Error(`Invalid Mode 5 frame size: ${m}x${p}.`);if(g<=0||g>256||v>8192)throw new Error(`Invalid Mode 5 tile header: ${g}/${v}.`);const w=[];let x=wy;for(let b=0;b<v;b+=1){if(x+Sy>c.length)throw new Error("Mode 5 tile header is truncated.");const C=Rr(c,x),j=Rr(c,x+2),A=Rr(c,x+4),N=Rr(c,x+6);x+=Sy;const k=A*N*2;if(A<=0||N<=0||A>g||N>g||C+A>m||j+N>p||x+k>c.length)throw new Error(`Invalid Mode 5 tile ${b}.`);w.push({x:C,y:j,width:A,height:N,pixels:c.subarray(x,x+k)}),x+=k}if(x!==c.length)throw new Error(`Mode 5 packet has ${c.length-x} trailing bytes.`);return{keyFrame:d,width:m,height:p,tileSize:g,tiles:w}}function jC(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 g=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const v of l.tiles){const w=ub&&(v.pixels.byteOffset&1)===0?new Uint16Array(v.pixels.buffer,v.pixels.byteOffset,v.pixels.byteLength>>>1):null;let x=0;for(let b=0;b<v.height;b+=1){let C=(v.y+b)*a+v.x;for(let j=0;j<v.width;j+=1){const A=x<<1,N=w?w[x]:v.pixels[A]|v.pixels[A+1]<<8;g[C]=Mh[N],x+=1,C+=1}}c=Math.min(c,v.x),d=Math.min(d,v.y),m=Math.max(m,v.x+v.width),p=Math.max(p,v.y+v.height)}return l.tiles.length>0?{x:c,y:d,width:m-c,height:p-d}:null}const Da=new WeakMap,Uc=new WeakMap,Th=new WeakMap,qc=new Set,Nl=new Set,$d=new WeakMap,Eh=new WeakMap,Rh=new WeakMap,Ud=new WeakMap,db=4,kC=2,AC=2,NC=2,MC=18,TC=40,EC=0,RC=250,fb=80,Cy=5,DC=150,LC=24,_C=180,zC=1200,IC=18,OC=.65,HC=2e3,BC=500,Jh=250,FC=globalThis.LIVEDESK_ENABLE_CANVAS_VISUAL_SAMPLING===!0;let qd=!1;function PC(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function $C(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let Ll={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:$C()};function UC(n){n.h264DecodeAcceleration&&(Ll={...Ll,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(Ll.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function mb(n,a=Ll.h264DecodeAcceleration){const r=$d.get(n);return r?.requested===a?(r.actual!=="prefer-hardware"&&Nl.delete(n),r.actual):(r&&$d.delete(n),a!=="prefer-hardware"?(Nl.delete(n),a):Nl.has(n)?"prefer-hardware":Nl.size<Ll.h264HardwareDecoderBudget?(Nl.add(n),"prefer-hardware"):"prefer-software")}function tf(n,a){return a!=="prefer-hardware"?!1:($d.set(n,{requested:a,actual:"prefer-software"}),Nl.delete(n),!0)}function qC(n,a,r,l=64){try{let c=Eh.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},Eh.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 g=p.getImageData(0,0,d,m).data;let v=2166136261;for(let b=0;b<g.length;b+=4)v^=g[b],v=Math.imul(v,16777619),v^=g[b+1],v=Math.imul(v,16777619),v^=g[b+2],v=Math.imul(v,16777619);const w=(v>>>0).toString(16).padStart(8,"0"),x=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:x}}catch{return{visualHash:"",visualChanged:!0}}}function Dh(n,a,r,l=Jh,c=64,d){if(!FC&&d)return hb(n,d);let m=Rh.get(n);m||(m={lastHash:"",initialized:!1,lastCanvasSampleAt:0},Rh.set(n,m));const p=performance.now();if(m.initialized&&l>0&&p-m.lastCanvasSampleAt<l)return{visualHash:m.lastHash,visualChanged:!1};const g=qC(n,a,r,c);return m.initialized=!0,m.lastHash=g.visualHash,m.lastCanvasSampleAt=p,g}function hb(n,a){let r=Ud.get(n);r||(r={lastHash:"",initialized:!1},Ud.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 pb(n,a){const r=Th.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 Th.set(n,d),d}return null}function GC(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 VC(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function WC(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 jy(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 YC(n,a){const r=new Uint8Array(a);let l=0,c=0;for(;l<n.length;){const d=n[l];l+=1;const m=jy(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 g=n[l]|n[l+1]<<8;if(l+=2,g<=0||g>c)throw new Error("Invalid LZ4 block: bad match offset.");const v=jy(n,l,d&15);l=v.cursor;const w=v.length+4;if(c+w>r.length)throw new Error("Invalid LZ4 block: match overrun.");let x=c-g;for(let b=0;b<w;b+=1)r[c]=r[x],c+=1,x+=1}if(c!==r.length)throw new Error("Invalid LZ4 block: incomplete output.");return r}function KC(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)),x=a*r*2,b=Math.floor(n.uncompressedByteLength||x);if(w!==2||b!==x)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 C=cb(n.payload,x),j=new Uint8ClampedArray(a*r*4);for(let A=0,N=0;A<C.length;A+=2,N+=4){const k=C[A]|C[A+1]<<8,T=k>>11&31,R=k>>5&63,U=k&31;j[N]=T<<3|T>>2,j[N+1]=R<<2|R>>4,j[N+2]=U<<3|U>>2,j[N+3]=255}return new ImageData(j,a,r)}const m=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*r*m,Math.floor(n.uncompressedByteLength||0)),g=YC(n.payload,p);if(m!==4)throw new Error(`Unsupported mode2 pixel size: ${m}`);const v=new Uint8ClampedArray(a*r*4);if(c==="rgba32"||c==="rgba")v.set(g.subarray(0,v.length));else for(let w=0,x=0;x<v.length;w+=4,x+=4)v[x]=g[w+2],v[x+1]=g[w+1],v[x+2]=g[w],v[x+3]=g[w+3];return new ImageData(v,a,r)}function ky(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=Da.get(n);if(l&&l.decoder.state!=="closed"&&l.latencyMode===a)return l;l&&Rs(n);let c;return c={decoder:new r({output:m=>{if(Da.get(n)!==c){m.close();return}const p=Number(m.timestamp||0);c.outputSerial+=1;let g=c.pendingFrames.get(p);if(g)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const j=c.pendingFrames.entries().next().value;j&&(c.pendingFrames.delete(j[0]),g=j[1],c.timestampFallbacks+=1)}const v=m.displayWidth||m.codedWidth||n.width||960,w=m.displayHeight||m.codedHeight||n.height||540,x=Number(g?.frame.durationUs||0),b=Number(m.duration||0),C=Math.max(16,Math.min(250,(x>0?x:b||83333)/1e3));for(c.targetPaintIntervalMs=C,c.decodedFrames.push({videoFrame:m,pending:g,decodedAt:performance.now(),width:v,height:w,durationMs:C}),c.lastOutputAt=performance.now();c.decodedFrames.length>tp(c);)Gd(c,c.decodedFrames.shift());gb(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>BC&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=db&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),Vd(n,c)},error:()=>{Da.get(n)===c&&(tf(n,c.hardwareAcceleration),ep(c),qc.delete(n),Da.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:mb(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},Da.set(n,c),qc.add(n),c}function ep(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 Gd(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function tp(n){return n.latencyMode==="interactive"?AC:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?kC:db}function gb(n,a=performance.now()){const r=tp(n);for(;n.decodedFrames.length>r;)Gd(n,n.decodedFrames.shift());const l=n.latencyMode==="interactive"?fb:RC;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>l;)Gd(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function vb(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const r=a.latencyMode==="interactive"?LC:DC,l=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,g]of a.pendingFrames.entries())c-g.queuedAt>HC&&a.pendingFrames.delete(p);if(Da.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{Da.get(n)===a&&_d(a)}finally{a.flushInFlight=!1;const p=performance.now()-m;if(l&&p>=_C&&a.hardwareAcceleration==="prefer-hardware"){qd=!0,tf(n,a.hardwareAcceleration),Rs(n);return}Da.get(n)===a&&a.inputSerial>d&&a.pendingFrames.size>0&&(l||performance.now()-a.lastOutputAt>=r)&&vb(n,a)}},r)}function Ay(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=pb(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"?hb(n,r.pending.frame):Dh(n,r.width,r.height,Jh,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 Vd(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(gb(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const g=a.targetPaintIntervalMs<=TC,v=a.targetPaintIntervalMs<=20;if(v&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const A=a.decodedFrames.length>=NC,N=c-a.interactiveBufferStartedAt>=MC;if(!A&&!N){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else v||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],x=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+r:c;if(!(!g||c+Cy>=b||x>=fb)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const j=a.decodedFrames.shift();if(j)try{Ay(n,a,j)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),Vd(n,a);return}const d=a.lastPaintAt>0?a.lastPaintAt+r:c+EC;if(!(c+Cy>=d||a.decodedFrames.length>=Math.max(1,tp(a)-1))){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l);return}const p=a.decodedFrames.shift();if(p)try{Ay(n,a,p)}catch{}Vd(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(l)}function yb(n,a){if(Da.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;)Gd(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,Vd(n,a),!0}function Qm(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of qc){const a=Da.get(n);if(!a||a.decoder.state==="closed"){qc.delete(n);continue}yb(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Qm),window.addEventListener("focus",Qm),window.addEventListener("pageshow",Qm));function Rs(n){Nl.delete(n),qc.delete(n),Ud.delete(n);const a=Da.get(n);if(a){Da.delete(n);try{ep(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function Ac(n){n&&($d.delete(n),Th.delete(n),Rh.delete(n),Eh.delete(n),Ud.delete(n),Uc.delete(n),Rs(n))}function _d(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),ep(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 fd(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 QC(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const r=performance.now();if(r-a.healthSampleStartedAt<zC)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<IC||c/Math.max(1,l)>=OC?!1:(qd=!0,tf(n,a.hardwareAcceleration),Rs(n),!0)}function Xm(n,a=1){if(!n)return!1;const r=Da.get(n);return r?(r.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),Rs(n),!0):!1}function XC(n){if(!n)return!1;const a=Da.get(n);return a?yb(n,a):!1}function ZC(n,a,r,l="interactive"){Rs(n);const c=performance.now(),d=CC(a.payload,a.uncompressedByteLength||0),m=String(a.streamId||"mode5");let p=Uc.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 N=3;N<A.length;N+=4)A[N]=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},Uc.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const v=Number(a.streamFrameSeq||0);if(v>0&&(p.lastStreamFrameSeq=v),!d.keyFrame&&!p.keyFrameSeen)return;d.keyFrame&&(p.keyFrameSeen=!0);const w=jC(p.rgba,p.width,p.height,d),x=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const b=pb(n,l),C=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const j=performance.now();p.outputSerial+=1,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,j-c),decodedForMs:Math.max(0,x-c),scheduledForMs:0,drawMs:Math.max(0,j-C),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:b?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:j})}const 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 Ny(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 JC(n){let a=0;for(;a<n.length;){const r=Ny(n,a);if(!r)break;const l=r.index+r.length,c=Ny(n,l),d=c?.index??n.length;if(l<d&&(n[l]&31)===7){const m=[];let p=0;for(let g=l+1;g<d;g+=1){const v=n[g];if(p>=2&&v===3){p=0;continue}m.push(v),p=v===0?p+1:0}if(m.length>=3)return`avc1.${m.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}a=c?c.index:n.length}return""}function ej(n,a,r,l,c=""){const d=Math.ceil(n/16)*Math.ceil(a/16),m=r>0?1e6/r:30,p=d*m,g=Zm.find(v=>d<=v.maxFrameSize&&p<=v.maxMacroblocksPerSecond)||Zm[Zm.length-1];return JC(l)||c||`avc1.42E0${g.code.toString(16).toUpperCase().padStart(2,"0")}`}function tj(n,a,r,l,c="smooth"){Uc.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)),g=Math.max(1,Math.floor(a.durationUs||1e6/12));let v=ky(n,c);const w=ej(m,p,g,a.payload,v.codec),x=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&l==="prefer-hardware"&&PC(),j=x==="mode4-h264-atlas"?"prefer-software":mb(n,c==="interactive"&&(qd||b)?"prefer-software":l),A=[a.streamId||"",a.commandId||"",m,p,w,d,j,c].join("|");v.onPaint=r,v.configured&&v.decoder.state!=="configured"&&(v.configured=!1,v.configKey=""),v.configured&&v.configKey!==A&&(Rs(n),v=ky(n,c),v.onPaint=r);const N={codec:w,codedWidth:m,codedHeight:p,hardwareAcceleration:j,optimizeForLatency:!0,avc:{format:d}};v.configured||fd(v,N,A,j);const k=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const T=Number(a.streamFrameSeq||0);if(T>0&&v.lastInputFrameSeq!==void 0){if(T<=v.lastInputFrameSeq){if(!k||T===v.lastInputFrameSeq)return;_d(v,v.lastInputFrameSeq-T+1),fd(v,N,A,j)}if(T>v.lastInputFrameSeq+1){if(_d(v,T-v.lastInputFrameSeq-1),!k)return;fd(v,N,A,j)}}if(T>0&&(v.lastInputFrameSeq=T),!k&&!v.keyFrameSeen)return;k&&(v.keyFrameSeen=!0);const R=Number(v.decoder.decodeQueueSize||0);if(R>8){if(v.latencyMode==="interactive"&&v.hardwareAcceleration==="prefer-hardware"){qd=!0,tf(n,v.hardwareAcceleration),Rs(n);return}if(_d(v),!k)return;fd(v,N,A,j),v.keyFrameSeen=!0}const U=v.nextChunkTimestampUs;v.nextChunkTimestampUs+=g,v.pendingFrames.set(U,{frame:a,queuedAt:performance.now(),queueSize:R}),v.inputSerial+=1,v.lastInputAt=performance.now();const O=new EncodedVideoChunk({type:k?"key":"delta",timestamp:U,duration:g,data:a.payload});try{v.decoder.decode(O)}catch(Y){throw Rs(n),Y}vb(n,v),QC(n,v)}async function Jm(n,a,r,l,c,d="smooth"){if(WC(a)){r()||ZC(n,a,l,d);return}if(VC(a)){r()||tj(n,a,l,c,d);return}if(Uc.delete(n),GC(a)){Rs(n);const x=KC(a);if(r())return;(n.width!==x.width||n.height!==x.height)&&(n.width=x.width,n.height=x.height);const b=n.getContext("2d"),C=performance.now();b?.putImageData(x,0,0);const j=performance.now(),A=Dh(n,x.width,x.height,Jh,64,a);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:x.width,height:x.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,j-C),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Ll.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:j});return}Rs(n);const m=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(m);if(r()){p.close();return}const g=a.width||p.width||960,v=a.height||p.height||540;(n.width!==g||n.height!==v)&&(n.width=g,n.height=v);const w=n.getContext("2d");if(w){const x=performance.now();w.clearRect(0,0,g,v),w.drawImage(p,0,0,g,v);const b=performance.now(),C=Dh(n,g,v);l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:g,height:v,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-x),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:Ll.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:C.visualHash,visualChanged:C.visualChanged,paintedAt:b})}p.close()}const My="livedesk_remote_host_targets",nj="livedesk_entitlements",np=new TextDecoder;function aj(n){const r=(Array.isArray(n)?n:[n||Cn]).map(l=>Hr(l||Cn));return[...new Set(r.filter(Boolean))]}function sj(){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&&pt.auth.setSession(p.session)});(window.liveDesk?.auth?.getSession?.()||pt.auth.getSession()).then(p=>{c&&(a(nb(p)),l(!1))});const{data:{subscription:m}}=pt.auth.onAuthStateChange((p,g)=>{a(g),l(!1),window.liveDesk?.auth?.persistSession?.(g)});return()=>{c=!1,d?.(),m.unsubscribe()}},[]),{session:n,loading:r}}function ij(n,a=!0){const[r,l]=u.useState(null),[c,d]=u.useState([]),[m,p]=u.useState(""),[g,v]=u.useState(""),[w,x]=u.useState(0),b=u.useRef(new Map),C=Array.isArray(n)?n.join(`
|
|
12
|
+
`):String(n||""),j=u.useMemo(()=>aj(n),[C]),A=u.useMemo(()=>j.find(T=>Ic(T)==="loopback")||j[0]||Cn,[j]),N=u.useCallback(async()=>{if(!a){l(null),d([]),v(""),p("");return}let T=null;const R=Date.now(),U=j.filter(O=>(b.current.get(O)||0)<=R);if(U.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const O of U)try{const[Y,_]=await Promise.all([Ge("/api/remote/status",void 0,O),Ge("/api/remote/devices",void 0,O)]);if(!Array.isArray(_.devices))throw new Error("Invalid Hub devices response.");b.current.delete(O),l(Y),d(_.devices),v(O),p("");return}catch(Y){T=Y,b.current.set(O,Date.now()+1e4)}throw v(""),T||new Error("No LiveDesk Hub endpoint is reachable.")},[a,j]),k=u.useCallback(()=>{b.current.clear(),N().catch(T=>{p(T instanceof Error?T.message:String(T))}),x(T=>T+1)},[N]);return u.useEffect(()=>{if(!a){l(null),d([]),v(""),p("");return}let T=!0;const R=async()=>{try{await N()}catch(O){T&&p(O instanceof Error?O.message:String(O))}};R();const U=window.setInterval(R,2500);return()=>{T=!1,window.clearInterval(U)}},[a,N,w]),{status:r,devices:c,error:m,refresh:k,hubBaseUrl:g||A,hubCandidates:j}}function rj(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:g}=await pt.from(My).select("*").eq("user_id",d).maybeSingle();if(g){c(g.message);return}r(p),c("")},[d]);return u.useEffect(()=>{m()},[m]),u.useEffect(()=>{if(!d)return;const p=pt.channel(`livedesk-remote-host-targets-${d.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:My,filter:`user_id=eq.${d}`},g=>r(g.new)).subscribe();return()=>{pt.removeChannel(p)}},[d]),{target:a,error:l,refresh:m}}function lj(n){const[a,r]=u.useState(null),[l,c]=u.useState(!1),[d,m]=u.useState(""),p=n?.user?.id||"",g=u.useCallback(async()=>{if(!p){r(null),m(""),c(!1);return}c(!0);const{data:w,error:x}=await pt.from(nj).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(x){m(x.message),c(!1);return}r(w),m(""),c(!1)},[p]);u.useEffect(()=>{g()},[g]);const v=u.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:v,loading:l,error:d,refresh:g}}const Oc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},oj=2500,cj=3e4,uj=64*1024,dj=6,fj=dj,xb=new Map;function mj(n){return xb.get(n)}const Ty={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function Ey(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const r=Date.now()-a;return r>0&&r<=cj?r:0}function Ry(n,a,r=Cn,l={}){const[c,d]=u.useState(new Map),[m,p]=u.useState("idle"),[g,v]=u.useState(""),[w,x]=u.useState(Oc),b=u.useRef(new Map),C=u.useRef(new Map),j=u.useRef(0),A=u.useRef(new Map),N=u.useRef({enabled:!1,token:"",reason:""}),k=u.useRef(new Set),[T,R]=u.useState(0),U=u.useRef(l.onFrame),O=u.useRef(l.onStreamReady),Y=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),_=u.useMemo(()=>[...n].sort().join(","),[n]),D=Number.isFinite(l.fps)?Number(l.fps):2,ne=Number.isFinite(l.maxWidth)?Number(l.maxWidth):640,G=Number.isFinite(l.maxHeight)?Number(l.maxHeight):360,te=Number.isFinite(l.quality)?Number(l.quality):45,B=String(l.frameMode||l.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",xe=l.streamPurpose==="control"?"control":"wall",se=l.forceRestart===!0,K=String(l.forceRestartToken||"").trim(),I=String(l.restartReason||"").trim();N.current={enabled:se,token:K,reason:I};const Q=u.useMemo(()=>{const ue=Object.entries(l.monitorSelections||{}).filter(([he])=>!!he).sort(([he],[ve])=>he.localeCompare(ve));return JSON.stringify(Object.fromEntries(ue))},[l.monitorSelections]);u.useEffect(()=>{U.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{O.current=l.onStreamReady},[l.onStreamReady]);const q=u.useCallback((ue,he="livedesk-frame-socket-release")=>{ue.disposed=!0;try{ue.socket.readyState===WebSocket.CONNECTING||ue.socket.readyState===WebSocket.OPEN?ue.socket.close(1e3,he):ue.socket.close()}catch{}},[]),V=u.useCallback(()=>{const ue=[...C.current.values()].map(he=>he.socket);if(ue.length===0){p("idle");return}if(ue.some(he=>he.readyState===WebSocket.OPEN)){p("open");return}if(ue.some(he=>he.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),ce=u.useCallback((ue,he,ve,Se)=>{if(he.disposed||he.socket.readyState!==WebSocket.OPEN)return!1;try{return he.socket.send(JSON.stringify({...he.payload,type:"restart-live",deviceIds:[ue],forceRestart:!0,restartReason:ve,restartToken:Se})),!0}catch{return!1}},[]),be=u.useCallback((ue,he)=>{if(!ue||ue.byteLength<5)return;const ve=Date.now(),_e=new DataView(ue).getUint32(0,!1);if(_e<=0||_e+4>ue.byteLength)return;const re=new Uint8Array(ue,4,_e),Z=JSON.parse(np.decode(re));if(Math.max(Ey(Z.receivedAt),Ey(Z.capturedAt))>oj)return;const Le=new Uint8Array(ue,4+_e),ae={deviceId:String(Z.deviceId||""),kind:Z.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(Z.frameSeq||0),streamFrameSeq:Number(Z.streamFrameSeq||0)||void 0,streamId:String(Z.streamId||""),commandId:Z.commandId?String(Z.commandId):void 0,sessionId:Z.sessionId?String(Z.sessionId):void 0,captureGeneration:Number(Z.captureGeneration||0)||void 0,streamPurpose:Z.streamPurpose?String(Z.streamPurpose):void 0,width:Number(Z.width||0),height:Number(Z.height||0),sourceWidth:Number(Z.sourceWidth||0)||void 0,sourceHeight:Number(Z.sourceHeight||0)||void 0,mimeType:String(Z.mimeType||"image/jpeg"),mode:Z.mode?String(Z.mode):void 0,frameMode:Z.frameMode?String(Z.frameMode):void 0,frameProfile:Z.frameProfile?String(Z.frameProfile):void 0,encoding:Z.encoding?String(Z.encoding):void 0,codec:Z.codec?String(Z.codec):void 0,compression:Z.compression?String(Z.compression):void 0,pixelFormat:Z.pixelFormat?String(Z.pixelFormat):void 0,bytesPerPixel:Number(Z.bytesPerPixel||0)||0,uncompressedByteLength:Number(Z.uncompressedByteLength||0)||0,h264Format:Z.h264Format?String(Z.h264Format):void 0,isKeyFrame:Z.isKeyFrame===!0,chunkType:Z.chunkType?String(Z.chunkType):void 0,timestampUs:Number(Z.timestampUs||0)||0,durationUs:Number(Z.durationUs||0)||0,sourceGapMs:Number(Z.sourceGapMs||0)||0,agentSendGapMs:Number(Z.agentSendGapMs||0)||0,agentSendDurationMs:Number(Z.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(Z.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(Z.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(Z.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(Z.agentFrameAgeMs||0)||0,droppedByAgent:Number(Z.droppedByAgent||0)||0,hubIngressDropped:Number(Z.hubIngressDropped||0)||0,hubClientDropped:Number(Z.hubClientDropped||0)||0,hardwareEncoder:Z.hardwareEncoder?String(Z.hardwareEncoder):void 0,platformProfile:Z.platformProfile?String(Z.platformProfile):void 0,monitorIndex:Number.isFinite(Number(Z.monitorIndex))?Number(Z.monitorIndex):void 0,monitorCount:Number.isFinite(Number(Z.monitorCount))?Number(Z.monitorCount):void 0,requestedFps:Number(Z.requestedFps||0)||0,effectiveFps:Number(Z.effectiveFps||0)||0,captureAverageMs:Number(Z.captureAverageMs||0)||0,captureP95Ms:Number(Z.captureP95Ms||0)||0,slowFrameCount:Number(Z.slowFrameCount||0)||0,captureHelperRestarts:Number(Z.captureHelperRestarts||0)||0,capturedAt:String(Z.capturedAt||""),receivedAt:String(Z.receivedAt||""),hubPacketAt:Z.hubPacketAt?String(Z.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(Z.hubPacketEpochMs))?Number(Z.hubPacketEpochMs):void 0,browserReceivedEpochMs:ve,byteLength:Number(Z.byteLength||Le.byteLength),contentHash:Z.contentHash?String(Z.contentHash):void 0,captureMs:Number(Z.captureMs||0)||0,captureStageMs:Number(Z.captureStageMs||0)||0,convertMs:Number(Z.convertMs||0)||0,compressMs:Number(Z.compressMs||0)||0,captureSourceSerial:Number(Z.captureSourceSerial||0)||0,captureSourceSkipped:Number(Z.captureSourceSkipped||0)||0,deltaTileSize:Number(Z.deltaTileSize||0)||0,deltaTileCount:Number(Z.deltaTileCount||0)||0,deltaVisualTileCount:Number(Z.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(Z.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(Z.deltaTotalTiles||0)||0,payload:Le};if(!ae.deviceId)return;const fe={streamId:he.lastFrameStreamId,commandId:he.lastFrameCommandId,order:he.lastFrameOrder},Ae=Number(ae.streamFrameSeq||ae.frameSeq||0),Te=!!fe.commandId&&!!ae.commandId,Be=fe.streamId===ae.streamId&&(!Te||fe.commandId===ae.commandId),Ve=fe.order;if(Be&&Ve>=Ae&&(Ve===Ae||Te))return;he.lastFrameStreamId=ae.streamId,he.lastFrameCommandId=ae.commandId||"",he.lastFrameOrder=Ae;const Je=Y.current;Je.totalFrames+=1,Je.totalBytes+=Le.byteLength,Je.sampleFrames+=1,Je.sampleBytes+=Le.byteLength;const Et=!b.current.has(ae.deviceId);b.current.set(ae.deviceId,ae),Et&&d(new Map(b.current)),U.current?.(ae)},[]);u.useEffect(()=>{const ue=window.setInterval(()=>{const he=performance.now(),ve=Y.current,Se=Math.max(1,he-ve.sampleStartedAt);x({totalFrames:ve.totalFrames,totalBytes:ve.totalBytes,framesPerSecond:ve.sampleFrames*1e3/Se,bytesPerSecond:ve.sampleBytes*1e3/Se,sampleMs:Se,lastUpdatedAt:Date.now()}),d(new Map(b.current)),ve.sampleFrames=0,ve.sampleBytes=0,ve.sampleStartedAt=he},2e3);return()=>{window.clearInterval(ue)}},[]),u.useEffect(()=>{const ue=_?_.split(",").filter(Boolean):[],he=new Set(ue),ve=performance.now();for(const[Se,_e]of C.current.entries())he.has(Se)||(q(_e,"livedesk-device-unsubscribed"),C.current.delete(Se),A.current.delete(Se),b.current.delete(Se));if(ue.length===0){for(const Se of C.current.values())q(Se,"livedesk-no-devices");C.current.clear(),A.current.clear(),b.current=new Map,d(new Map),v(""),Y.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},x(Oc),V();return}Y.current.sampleStartedAt<=0&&(Y.current.sampleStartedAt=ve,x({...Oc,lastUpdatedAt:Date.now()}));for(const Se of ue){const _e=l.monitorSelections?.[Se],re=Number.isFinite(Number(_e))?{[Se]:Number(_e)}:{},Z={type:"subscribe",deviceIds:[Se],autoStartLive:a,fps:D,maxWidth:ne,maxHeight:G,quality:te,mode:B,frameMode:B,streamPurpose:xe,monitorSelections:re},ze=JSON.stringify(Z),Le=C.current.get(Se);if(Le){const Te=Le.socket.readyState===WebSocket.CONNECTING||Le.socket.readyState===WebSocket.OPEN;if(Le.payloadKey===ze&&Te&&!Le.disposed)continue}const ae=Le&&(Le.socket.readyState===WebSocket.CONNECTING||Le.socket.readyState===WebSocket.OPEN)&&!Le.disposed?Le.handoffFrom&&!Le.handoffCompleted?Le.handoffFrom:Le:void 0;Le&&Le!==ae&&q(Le,"livedesk-subscription-superseded");const fe=new WebSocket(ef(`/api/remote/frames/ws?devices=${encodeURIComponent(Se)}`,r));fe.binaryType="arraybuffer";const Ae={socket:fe,payload:Z,payloadKey:ze,generation:j.current+1,disposed:!1,handoffFrom:ae,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};j.current=Ae.generation,C.current.set(Se,Ae),fe.addEventListener("open",()=>{if(Ae.disposed||C.current.get(Se)!==Ae){q(Ae,"livedesk-stale-frame-socket");return}v("");const Te=N.current,Be=Te.enabled&&(!Te.token||A.current.get(Se)!==Te.token);fe.send(JSON.stringify({...Ae.payload,forceRestart:Be,restartReason:Be?Te.reason:"",restartToken:Be?Te.token:""})),Be&&Te.token&&A.current.set(Se,Te.token);const Ve=Ae.handoffFrom;Ae.handoffFrom=void 0,Ae.handoffCompleted=!0,Ve&&!Ve.disposed&&q(Ve,"livedesk-subscription-replaced"),V()}),fe.addEventListener("message",Te=>{if(Ae.disposed||C.current.get(Se)!==Ae)return;if(typeof Te.data=="string"){try{const Ve=JSON.parse(Te.data);if(Ve?.type==="RemoteFrameSubscriptionError")v(String(Ve.error||"control-stream-start-failed"));else if(Ve?.type==="RemoteFrameLiveAutoStart"){const Et=(Array.isArray(Ve.skipped)?Ve.skipped:[]).find(je=>je?.deviceId===Se);if(Et)v(String(Et.reason||"control-stream-start-failed"));else if(Array.isArray(Ve.started)){const je=Ve.started.find(We=>We?.deviceId===Se);je&&(v(""),je.ready===!0&&je.streamPurpose==="control"&&je.sessionId&&je.commandId&&Number(je.captureGeneration||0)>0&&O.current?.({deviceId:Se,sessionId:String(je.sessionId),streamId:String(je.streamId||""),streamPurpose:"control",commandId:String(je.commandId),captureGeneration:Number(je.captureGeneration),monitorIndex:Number(je.monitorIndex||0)}))}}else Ve?.type==="RemoteFrameStreamReady"&&Ve.deviceId===Se&&Ve.streamPurpose==="control"&&Ve.sessionId&&Ve.commandId&&Number(Ve.captureGeneration||0)>0&&(v(""),O.current?.({deviceId:Se,sessionId:String(Ve.sessionId),streamId:String(Ve.streamId||""),streamPurpose:"control",commandId:String(Ve.commandId),captureGeneration:Number(Ve.captureGeneration),monitorIndex:Number(Ve.monitorIndex||0)}))}catch{}return}const Be=Te.data instanceof ArrayBuffer?Te.data:null;Be&&(v(""),be(Be,Ae))}),fe.addEventListener("error",()=>{Ae.disposed||C.current.get(Se)!==Ae||p("connecting")}),fe.addEventListener("close",()=>{const Te=!Ae.disposed;Ae.disposed=!0;const Be=C.current.get(Se);let Ve=!1;if(Be===Ae){const Je=Ae.handoffFrom;Ae.handoffFrom=void 0,Je&&!Je.disposed&&(Je.socket.readyState===WebSocket.CONNECTING||Je.socket.readyState===WebSocket.OPEN)?(C.current.set(Se,Je),Ve=!0):C.current.delete(Se)}if(V(),Te&&Be===Ae&&!Ve){const Je=window.setTimeout(()=>{k.current.delete(Je),R(Et=>Et+1)},750);k.current.add(Je)}})}V()},[a,q,_,D,B,be,r,G,ne,Q,l.monitorSelections,te,T,xe,V]),u.useEffect(()=>{if(!se||!K)return;const ue=_?_.split(",").filter(Boolean):[];for(const he of ue){if(A.current.get(he)===K)continue;const ve=C.current.get(he);!ve||!ce(he,ve,I,K)||A.current.set(he,K)}},[_,se,K,I,ce]),u.useEffect(()=>()=>{for(const ue of C.current.values())q(ue,"livedesk-hook-unmount");C.current.clear();for(const ue of k.current)window.clearTimeout(ue);k.current.clear()},[q]);const X=u.useCallback((ue,he="browser-stale")=>{const ve=Array.isArray(ue)&&ue.length>0?ue:_.split(",").filter(Boolean);if(ve.length===0)return!1;let Se=!1;for(const _e of ve){const re=C.current.get(_e);!re||re.socket.readyState!==WebSocket.OPEN||(Se=ce(_e,re,he,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||Se)}return Se},[_,ce]),$=u.useCallback((ue,he="browser-reconnect")=>{const ve=Array.isArray(ue)&&ue.length>0?ue:_.split(",").filter(Boolean);if(ve.length===0)return!1;let Se=!1;for(const _e of ve){const re=C.current.get(_e);re&&(q(re,`livedesk-${he}`),C.current.delete(_e),A.current.delete(_e),b.current.delete(_e),Se=!0)}return Se&&d(new Map(b.current)),R(_e=>_e+1),V(),!0},[q,_,V]);return{frames:c,state:m,error:g,stats:w,restartLive:X,reconnectLive:$}}function hj(n,a,r=Cn,l={}){const[c,d]=u.useState(null),[m,p]=u.useState(null),[g,v]=u.useState("idle"),[w,x]=u.useState(Oc),b=u.useRef(null),C=u.useRef(l.onFrame),j=u.useRef(null),A=u.useRef(0),N=u.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),k=u.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),T=u.useMemo(()=>[...new Set((l.captureDeviceIds||n).filter(Boolean))].join(","),[n,l.captureDeviceIds]),R=u.useMemo(()=>JSON.stringify(l.monitorSelections||{}),[l.monitorSelections]),U=u.useMemo(()=>({deviceIds:k.split(",").filter(Boolean),captureDeviceIds:T.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||{}}),[T,k,R,l.fps,l.height,l.monitorSelections,l.tileHeight,l.tileWidth,l.width]),O=u.useMemo(()=>JSON.stringify(U),[U]),Y=u.useRef(U);Y.current=U;const _=a&&U.deviceIds.length>0,D=u.useCallback(G=>G.readyState!==WebSocket.OPEN?!1:(G.send(JSON.stringify({type:"configure",...Y.current})),!0),[]);u.useEffect(()=>{C.current=l.onFrame},[l.onFrame]),u.useEffect(()=>{const G=window.setInterval(()=>{const te=N.current,B=performance.now(),xe=Math.max(1,B-te.sampleStartedAt);x({totalFrames:te.totalFrames,totalBytes:te.totalBytes,framesPerSecond:te.sampleFrames*1e3/xe,bytesPerSecond:te.sampleBytes*1e3/xe,sampleMs:xe,lastUpdatedAt:Date.now()});const se=j.current;se&&se.frameSeq!==A.current&&(A.current=se.frameSeq,d(se)),te.sampleFrames=0,te.sampleBytes=0,te.sampleStartedAt=B},1e3);return()=>window.clearInterval(G)},[]),u.useEffect(()=>{if(!_){b.current?.close(),b.current=null,d(null),j.current=null,A.current=0,p(null),v("idle"),x(Oc);return}let G=!1,te=0;const B=()=>{if(G)return;const xe=new WebSocket(ef("/api/remote/atlas/ws",r));xe.binaryType="arraybuffer",b.current=xe,v("connecting"),xe.addEventListener("open",()=>{N.current.sampleStartedAt=performance.now(),v("open"),D(xe)}),xe.addEventListener("message",se=>{if(typeof se.data=="string"){try{const I=JSON.parse(se.data);I?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(I.layoutVersion||0),width:Number(I.width||1920),height:Number(I.height||1080),columns:Number(I.columns||1),rows:Number(I.rows||1),tiles:Array.isArray(I.tiles)?I.tiles:[]})}catch{}return}const K=se.data instanceof ArrayBuffer?se.data:null;if(!(!K||K.byteLength<5))try{const I=Date.now(),q=new DataView(K).getUint32(0,!1);if(q<=0||q+4>K.byteLength)return;const V=JSON.parse(np.decode(new Uint8Array(K,4,q))),ce=new Uint8Array(K,4+q),be={deviceId:String(V.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(V.frameSeq||0),streamFrameSeq:Number(V.streamFrameSeq||0)||void 0,streamId:String(V.streamId||"mode4-atlas"),commandId:V.commandId?String(V.commandId):void 0,width:Number(V.width||1920),height:Number(V.height||1080),sourceWidth:Number(V.sourceWidth||V.width||1920),sourceHeight:Number(V.sourceHeight||V.height||1080),mimeType:String(V.mimeType||"video/h264"),mode:String(V.mode||"mode4-h264-atlas"),frameMode:String(V.frameMode||"mode4-h264-atlas"),frameProfile:String(V.frameProfile||"mode4-h264-atlas-v1"),encoding:String(V.encoding||"video-atlas"),codec:String(V.codec||"h264"),compression:String(V.compression||"video/h264"),h264Format:String(V.h264Format||"annexb"),isKeyFrame:V.isKeyFrame===!0,chunkType:String(V.chunkType||""),timestampUs:Number(V.timestampUs||0),durationUs:Number(V.durationUs||0),hardwareEncoder:V.hardwareEncoder?String(V.hardwareEncoder):void 0,platformProfile:V.platformProfile?String(V.platformProfile):void 0,capturedAt:String(V.capturedAt||""),receivedAt:String(V.receivedAt||""),hubPacketAt:V.hubPacketAt?String(V.hubPacketAt):void 0,hubPacketEpochMs:Number(V.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:I,byteLength:ce.byteLength,layoutVersion:Number(V.layoutVersion||0),atlasComposeMs:Number(V.atlasComposeMs||0),atlasPoolStarved:Number(V.atlasPoolStarved||0),atlasReadyTiles:Number(V.atlasReadyTiles||0),atlasTileCount:Number(V.atlasTileCount||0),atlasInputRevision:Number(V.atlasInputRevision||0),atlasSourceNewestAtEpochMs:Number(V.atlasSourceNewestAtEpochMs||0),atlasSourceOldestAtEpochMs:Number(V.atlasSourceOldestAtEpochMs||0),atlasSourceMaxAgeMs:Number(V.atlasSourceMaxAgeMs||0),payload:ce},X=N.current;X.totalFrames+=1,X.totalBytes+=ce.byteLength,X.sampleFrames+=1,X.sampleBytes+=ce.byteLength,j.current=be,A.current===0&&(A.current=be.frameSeq,d(be)),C.current?.(be)}catch{}}),xe.addEventListener("error",()=>v("error")),xe.addEventListener("close",()=>{b.current===xe&&(b.current=null),!G&&(v("closed"),te=window.setTimeout(B,1200))})};return B(),()=>{G=!0,window.clearTimeout(te),b.current?.close(),b.current=null}},[_,r,D]),u.useEffect(()=>{if(!_)return;const G=b.current;G&&D(G)},[O,_,D]);const ne=u.useCallback(()=>{const G=b.current;return G?D(G):!1},[D]);return{frame:c,layout:m,state:g,stats:w,refreshInputs:ne}}function pj(n,a=Cn){const r=u.useRef(null),l=u.useRef(0),c=u.useRef(0),d=u.useRef(new Map),[m,p]=u.useState("idle"),[g,v]=u.useState(""),[w,x]=u.useState(Ty),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"),v(""),x(Ty);return}let j=!1,A=0;const N=()=>{if(j)return;const k=new WebSocket(ef("/api/remote/input/ws",a));r.current=k,b.current.sampleStartedAt=performance.now(),p("connecting"),v(""),k.addEventListener("open",()=>{j||r.current!==k||(v(""),p("open"))}),k.addEventListener("message",T=>{if(!(j||r.current!==k||typeof T.data!="string"))try{const R=JSON.parse(T.data);if(R?.type==="RemoteInputError"){v(String(R.error||R.result?.error||"Remote input failed.")),p("error");return}if(R?.type!=="RemoteInputApplied")return;const U=Number(R.inputSeq||0),O=d.current.get(U);O!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-O),d.current.delete(U)),b.current.lastInputSeq=U,b.current.lastAgentApplyMs=Math.max(0,Number(R.agentApplyMs||0))}catch{}}),k.addEventListener("close",()=>{j||r.current!==k||(r.current=null,p("closed"),A=window.setTimeout(N,1200))}),k.addEventListener("error",()=>{!j&&r.current===k&&p("error")})};return N(),()=>{j=!0,window.clearTimeout(A);const k=r.current;r.current=null,k?.close(),d.current.clear()}},[n,a]),u.useEffect(()=>{if(!n)return;const j=window.setInterval(()=>{const A=performance.now(),N=b.current,k=Math.max(1,A-N.sampleStartedAt);x({totalSent:N.totalSent,totalDropped:N.totalDropped,sentPerSecond:N.sampleSent*1e3/k,droppedPerSecond:N.sampleDropped*1e3/k,bufferedAmount:r.current?.bufferedAmount||0,lastInputType:N.lastInputType,lastInputSeq:N.lastInputSeq,lastRoundTripMs:N.lastRoundTripMs,lastAgentApplyMs:N.lastAgentApplyMs,lastUpdatedAt:Date.now()}),N.sampleSent=0,N.sampleDropped=0,N.sampleStartedAt=A},1e3);return()=>window.clearInterval(j)},[n]);const C=u.useCallback((j,A)=>{const N=r.current;if(!N||N.readyState!==WebSocket.OPEN||!j)return!1;const k=String(A.type||"").toLowerCase(),T=k==="pointermove",U=T||k==="wheel",O=b.current;if(T&&N.bufferedAmount>uj)return O.totalDropped+=1,O.sampleDropped+=1,O.lastInputType="pointermove-drop",!1;const Y=l.current+1;l.current=Y;const _=Date.now(),D=!U||Y-c.current>=fj;for(D&&(d.current.set(Y,performance.now()),U&&(c.current=Y)),T||xb.set(j,{inputSeq:Y,inputType:k||"input",sentAt:performance.now()});d.current.size>256;){const ne=d.current.keys().next().value;if(ne===void 0)break;d.current.delete(ne)}return N.send(JSON.stringify({type:"input",requestId:U?"":crypto.randomUUID(),fireAndForget:U,deviceId:j,input:{...A,inputSeq:Y,requestAck:D,issuedAtEpochMs:_,issuedAt:new Date(_).toISOString()}})),O.totalSent+=1,O.sampleSent+=1,O.lastInputType=k||"input",!0},[]);return{state:m,sendInput:C,stats:w,error:g}}function gj(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const md={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},vj=.08,yj=.25,xj=.02,Dy=300,bj=4,hd=1500,eh=5e3,wj=2e3,Sj=1e4,pd=[0,1e3,3e3];function Ly(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function Cj(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,g=Math.floor(r.byteLength/p),v=Math.floor(g/l),w=n.createBuffer(l,v,c),x=new DataView(r);for(let b=0;b<l;b+=1){const C=w.getChannelData(b);for(let j=0;j<v;j+=1){const N=(j*l+b)*p;C[j]=m?Math.max(-1,Math.min(1,x.getInt16(N,!0)/32768)):Math.max(-1,Math.min(1,x.getFloat32(N,!0)))}}return w}function jj(n,a,r=Cn){const l=u.useRef(null),c=u.useRef(0),[d,m]=u.useState("idle"),[p,g]=u.useState(null),[v,w]=u.useState(md),[x,b]=u.useState("");return u.useEffect(()=>{if(!a||!n){m("idle"),g(null),w(md),b("");return}m("connecting"),g(null),w(md),b("");const C=window.AudioContext||window.webkitAudioContext;if(!C){m("unsupported"),w(md),b("Audio playback is not supported in this browser.");return}const j=new C;l.current=j,c.current=j.currentTime;const A=new WebSocket(ef("/api/remote/audio/ws?devices="+encodeURIComponent(n),r));A.binaryType="arraybuffer";const N=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(j.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let T=!1,R=0,U=!1,O=0,Y=0;const _=(I=!0)=>{for(const Q of N)try{Q.stop()}catch{}N.clear(),I&&(c.current=j.currentTime+vj)},D=()=>{k.audioContextState=String(j.state),!T&&(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.")))},ne=async()=>{if(T||String(j.state)==="closed")return!1;try{if(String(j.state)!=="running"&&await j.resume(),k.audioContextState=String(j.state),!T&&!U&&k.audioContextState==="running"){const I=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=hd,Q=k.lastCaptureStatusAt>0&&performance.now()-k.lastCaptureStatusAt<=eh&&k.captureAlive&&k.helperAlive;m(I?"playing":Q?"silent":"open")}return k.audioContextState==="running"}catch(I){return T||(m("suspended"),b(I instanceof Error?"Audio playback is suspended: "+I.message:"Audio playback is suspended.")),!1}},G=async()=>{if(T||U||A.readyState!==WebSocket.OPEN)return;if(O>=pd.length){m("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const I=O;O+=1,U=!0,k.stalledCount+=1,k.automaticRestarts+=1,m("reconnecting");try{const Q=await Ge("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},r);if(Q.ok===!1)throw new Error(Q.error||"Remote audio stop failed.");if(T)return;const q=await Ge("/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(q.ok===!1)throw new Error(q.error||"Remote audio start failed.");const V=performance.now();R=V,k.lastPacketAt=V,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,Y=V+(pd[I+1]??3e3),b(""),T||m("open")}catch(Q){T||(Y=performance.now()+(pd[I+1]??3e3),m("error"),b(Q instanceof Error?"Remote audio restart failed: "+Q.message:"Remote audio restart failed."))}finally{U=!1}},te=()=>{k.drops+=1},B=window.setInterval(()=>{if(T)return;const I=performance.now(),Q=k.lastPacketAt>0?Math.max(0,I-k.lastPacketAt):R>0?Math.max(0,I-R):0,q=k.lastAcceptedAt>0?Math.max(0,I-k.lastAcceptedAt):0,V=k.lastCaptureStatusAt>0?Math.max(0,I-k.lastCaptureStatusAt):0,ce=A.readyState===WebSocket.OPEN,be=k.lastCaptureStatusAt>0,X=be&&V<=eh,$=be&&(!k.captureAlive||!k.helperAlive)&&V>wj,ue=be&&V>eh,he=!be&&R>0&&I-R>Sj,ve=R>0&&(k.lastAcceptedAt<=0?I-R>hd:q>hd);ce&&R>0&&($||ue||he)?O>=pd.length&&!U?(m("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!U&&I>=Y?G():U||m("stalled"):ce&&ve&&!U&&k.audioContextState!=="suspended"&&k.audioContextState!=="interrupted"&&m(X?"silent":"open"),w({queuedMs:Math.max(0,(c.current-j.currentTime)*1e3),browserAgeMs:k.browserAgeMs,captureAgeMs:k.captureAgeMs,captureStatusAgeMs:V,silentForMs:k.silentForMs,captureAlive:k.captureAlive,helperAlive:k.helperAlive,captureRestartCount:k.captureRestartCount,localProcessingAgeMs:k.localProcessingAgeMs,lastPacketAgeMs:Q,lastAcceptedAgeMs:q,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),xe=()=>{D(),(String(j.state)==="suspended"||String(j.state)==="interrupted")&&ne()},se=()=>{document.visibilityState==="visible"&&ne()},K=()=>{ne()};return j.addEventListener("statechange",xe),document.addEventListener("visibilitychange",se),window.addEventListener("pageshow",K),window.addEventListener("pointerdown",K),window.addEventListener("keydown",K),m("connecting"),b(""),D(),A.addEventListener("open",()=>{T||(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]})),ne())}),A.addEventListener("message",I=>{if(typeof I.data=="string")return;const Q=I.data instanceof ArrayBuffer?I.data:null;if(!Q||Q.byteLength<5)return;const q=performance.now();k.lastPacketAt=q,(async()=>{try{const ce=new DataView(Q).getUint32(0,!1);if(ce<=0||ce+4>Q.byteLength){te();return}const be=new Uint8Array(Q,4,ce),X=JSON.parse(np.decode(be)),$=Q.slice(4+ce),ue=String(X.frameKind||X.kind||"").toLowerCase();if(X.type==="remote.audio.status"||ue==="audio-status"){if(k.lastCaptureStatusAt=q,k.captureAlive=X.captureAlive===!0,k.helperAlive=X.helperAlive===!0,k.captureRestartCount=Math.max(0,Number(X.restartCount||0)||0),k.lastPcmAtEpochMs=Math.max(0,Number(X.lastPcmAtEpochMs||0)||0),k.silentForMs=Math.max(0,Number(X.silentForMs||0)||0),k.captureAgeMs=k.lastPcmAtEpochMs>0?Math.max(0,Date.now()-k.lastPcmAtEpochMs):k.silentForMs,k.captureAlive&&k.helperAlive){if(O=0,Y=0,!U){b("");const ve=String(j.state)==="running",Se=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=hd;m(ve?Se?"playing":"silent":"suspended")}}else U||m("stalled");return}const he={deviceId:String(X.deviceId||""),frameSeq:Number(X.frameSeq||0),streamId:String(X.streamId||""),mimeType:String(X.mimeType||"audio/webm;codecs=opus"),sampleRate:Number(X.sampleRate||48e3),channels:Number(X.channels||2),capturedAt:String(X.capturedAt||""),receivedAt:String(X.receivedAt||""),byteLength:Number(X.byteLength||$.byteLength),payload:$};if(!he.deviceId||T)return;if(performance.now()-q>Dy){te();return}if(k.pendingDecodes>=bj){te();return}k.pendingDecodes+=1;try{const ve=gj(he.mimeType)?Cj(j,he,$):await j.decodeAudioData($.slice(0));if(k.localProcessingAgeMs=Math.max(0,performance.now()-q),T)return;if(k.localProcessingAgeMs>Dy){te();return}if(he.frameSeq>0&&he.frameSeq<=k.lastFrameSeq){te();return}if(k.activeStreamId&&he.streamId!==k.activeStreamId&&he.frameSeq<=k.lastFrameSeq){te();return}he.streamId&&he.streamId!==k.activeStreamId&&(k.activeStreamId=he.streamId,k.lastFrameSeq=0,_());const Se=j.currentTime;Math.max(0,c.current-Se)>yj&&(_(),k.resyncs+=1);const re=j.createBufferSource();re.buffer=ve,re.connect(j.destination),N.add(re),re.onended=()=>{N.delete(re),re.onended=null};const Z=Math.max(j.currentTime+xj,c.current);re.start(Z),c.current=Z+ve.duration,k.browserAgeMs=Ly(he.receivedAt),k.captureAgeMs=Ly(he.capturedAt),k.lastAcceptedAt=performance.now(),k.framesReceived+=1,k.lastFrameSeq=he.frameSeq,O=0,Y=0,g(he),ne();const ze=String(j.state)==="running";ze&&b(""),m(ze?"playing":"suspended")}finally{k.pendingDecodes=Math.max(0,k.pendingDecodes-1)}}catch(V){T||(m("error"),b(V instanceof Error?V.message:String(V)))}})()}),A.addEventListener("error",()=>{T||(m("error"),b("Remote audio WebSocket error."))}),A.addEventListener("close",()=>{T||m("closed")}),()=>{T=!0,window.clearInterval(B),j.removeEventListener("statechange",xe),document.removeEventListener("visibilitychange",se),window.removeEventListener("pageshow",K),window.removeEventListener("pointerdown",K),window.removeEventListener("keydown",K),_(!1),A.close(),j.close().catch(()=>{}),l.current===j&&(l.current=null)}},[n,a,r]),{state:d,lastFrame:p,stats:v,error:x}}const kj=3;function _y(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,kj);return c<=d?0:c>=l-d?1:c/l}function Aj(n,a,r){return{normalizedX:_y(n,r.left,r.width),normalizedY:_y(a,r.top,r.height)}}const ei=Object.freeze({smallDirectDeviceLimit:4,interactiveDirectFps:30,controlWallReuseMaxFps:30,scalableAtlasInputFps:8,atlasOutputFps:20,maxDirectFramesPerSecond:96,directDecodeAcceleration:"prefer-software",directLatencyMode:"interactive",configuredLatencyMode:"smooth"});function Nj(n,a){const r=Math.max(0,Math.floor(Number(a)||0));return n===!0&&r>0&&r<=ei.smallDirectDeviceLimit}function Nc({mode4Enabled:n,directMode4WallEnabled:a,isMac:r}){return!n||a||r?"direct":"atlas"}function Mj({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(ei.interactiveDirectFps,c);const d=Math.max(1,Math.floor(Number(l)||1));return Math.max(1,Math.min(c,Math.floor(ei.maxDirectFramesPerSecond/d)))}function Tj(n,a){return n?{acceleration:ei.directDecodeAcceleration,latencyMode:ei.directLatencyMode}:{acceleration:a,latencyMode:ei.configuredLatencyMode}}const Lh={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}}},Ej=[{id:"connection",label:"Connection",icon:Dl},{id:"security",label:"Security",icon:Bt},{id:"control",label:"Control",icon:an},{id:"wall",label:"Wall",icon:Pc},{id:"files-audio",label:"Files & Audio",icon:ko},{id:"agent",label:"Agent",icon:Es},{id:"advanced",label:"Advanced",icon:Fd}];function wl(n,a){return n?.settings?.[a]||Lh.settings[a]}function ht({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 Tt({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 Li({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 Rj({hubUrl:n="",runtimeRole:a="hub",runtimeDeviceId:r="",sessionAccessToken:l="",initialTab:c="connection",pin:d,wall:m,control:p,agent:g,advancedExtras:v,captureGallery:w}){const[x,b]=u.useState(c),[C,j]=u.useState(null),[A,N]=u.useState("loading"),[k,T]=u.useState(""),[R,U]=u.useState("idle"),[O,Y]=u.useState("");u.useEffect(()=>{let ve=!0;return N("loading"),Ge("/api/settings",void 0,n).then(Se=>{ve&&(j({revision:Number(Se.revision||0),updatedAt:Se.updatedAt,settings:Se.settings}),N("saved"))}).catch(Se=>{ve&&(T(Se instanceof Error?Se.message:String(Se)),j(Lh),N("failed"))}),()=>{ve=!1}},[n]);const _=async(ve,Se,_e)=>{const re=C||Lh,Z=re,ze={...re,settings:{...re.settings,[ve]:{...wl(re,ve),[Se]:_e}}};j(ze),N("saving"),T("");try{const Le=await Ge("/api/settings",{method:"PATCH",body:JSON.stringify({revision:re.revision,[ve]:{[Se]:_e}})},n);j({revision:Le.revision,updatedAt:Le.updatedAt,settings:Le.settings}),N("saved")}catch(Le){j(Z),N("failed"),T(Le instanceof Error?Le.message:String(Le))}},D=(ve,Se)=>_e=>{_(ve,Se,_e)},ne=async()=>{if(a!=="hub"||!r||!l){U("failed"),Y("Sign in to this Hub before changing its runtime role.");return}U("changing"),Y("");try{const ve=await Ge("/api/runtime/status",void 0,n);await Ge("/api/runtime/role",{method:"POST",headers:{Authorization:`Bearer ${l}`},body:JSON.stringify({role:"client"})},n),U("accepted"),await ab({baseUrl:n,targetRole:"client",previousRuntimePid:Number(ve.runtimePid||0),allowedStates:["running","waiting-auth"]}),oC(5179)}catch(ve){U("failed"),Y(ve instanceof Error?ve.message:String(ve))}},G=wl(C,"security"),te=wl(C,"connection"),B=wl(C,"control"),xe=wl(C,"wall"),se=wl(C,"filesAudio"),K=wl(C,"agent"),I=u.useMemo(()=>G.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:G.requireEncryptedConnections&&G.requireNewDeviceApproval&&G.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."},[G]),Q=`settings-panel-${x}`,q=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(Dl,{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(Kx,{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(Mo,{size:20})]}),s.jsx(ht,{icon:Mo,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:s.jsx(Tt,{checked:!!te.usePinToAddDevices,onChange:D("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),s.jsx(ht,{icon:Bt,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:s.jsx(Tt,{checked:!!te.approveNewDevices,onChange:D("connection","approveNewDevices"),label:"Approve new devices"})}),s.jsx(ht,{icon:pn,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:s.jsx(Tt,{checked:!!te.showConnectionNotifications,onChange:D("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(Fd,{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."}):O?s.jsx("p",{className:"settings-help runtime-role-error",role:"alert",children:O}):null,s.jsx("button",{className:"settings-reset",onClick:()=>{ne()},disabled:R==="changing"||a!=="hub",type:"button",children:R==="changing"?"Switching role…":"Switch this computer to Client"})]})]}),V=s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[s.jsxs("section",{className:`security-status-card ${I.tone}`,children:[s.jsxs("div",{children:[s.jsx("span",{children:"Security status"}),s.jsx("strong",{children:I.label}),s.jsx("small",{children:I.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(Ts,{size:20})]}),s.jsx(ht,{icon:Bt,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:s.jsx(Li,{value:String(G.accessMode),onChange:D("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(ht,{icon:Dl,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:s.jsx(Tt,{checked:!!G.requireEncryptedConnections,onChange:D("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),s.jsx(ht,{icon:Dl,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:s.jsx(Tt,{checked:!!G.allowInternetConnections,onChange:D("security","allowInternetConnections"),label:"Allow internet connections"})}),s.jsx(ht,{icon:an,title:"Allow LAN connections",description:"Permit connections from the local network.",children:s.jsx(Tt,{checked:!!G.allowLanConnections,onChange:D("security","allowLanConnections"),label:"Allow LAN connections"})}),s.jsx(ht,{icon:Bt,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:s.jsx(Tt,{checked:!!G.requireNewDeviceApproval,onChange:D("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(pn,{size:20})]}),s.jsx(ht,{icon:an,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:s.jsx(Tt,{checked:!!G.visibleControlIndicator,onChange:D("security","visibleControlIndicator"),label:"Show Control indicator"})}),s.jsx(ht,{icon:Ts,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:s.jsx(Tt,{checked:!!G.lockOnControlEnd,onChange:D("security","lockOnControlEnd"),label:"Lock after Control ends"})}),s.jsx(ht,{icon:pn,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:s.jsx(Tt,{checked:!!G.disconnectIdleControlSessions,onChange:D("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),s.jsx(ht,{icon:pn,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!G.disconnectIdleControlSessions,children:s.jsx(Li,{value:Number(G.idleControlMinutes),onChange:ve=>D("security","idleControlMinutes")(Number(ve)),disabled:!G.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),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:"Remote use"}),s.jsx("h3",{children:"What can a connected user do?"})]}),s.jsx(an,{size:20})]}),s.jsx(ht,{icon:an,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:s.jsx(Tt,{checked:!!B.allowKeyboardMouse,onChange:D("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),s.jsx(ht,{icon:VS,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:s.jsx(Tt,{checked:!!B.allowSystemShortcuts,onChange:D("control","allowSystemShortcuts"),label:"System shortcuts"})}),s.jsx(ht,{icon:Mo,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:s.jsx(Tt,{checked:!!B.allowClipboardText,onChange:D("control","allowClipboardText"),label:"Clipboard text sharing"})}),s.jsx(ht,{icon:pn,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!B.allowKeyboardMouse,children:s.jsx(Tt,{checked:!!B.allowRemoteRestart,onChange:D("control","allowRemoteRestart"),disabled:!B.allowKeyboardMouse,label:"Remote restart"})}),s.jsx(ht,{icon:an,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:s.jsx(Tt,{checked:!!B.allowSwitchingMonitors,onChange:D("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(Fn,{size:20})]}),s.jsx(ht,{icon:an,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:s.jsx(Tt,{checked:!!B.openControlOnDoubleClick,onChange:D("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),s.jsx(ht,{icon:pn,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:s.jsx(Tt,{checked:!!B.startRemoteAudioWithControl,onChange:D("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),s.jsx(ht,{icon:an,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:s.jsx(Tt,{checked:!!B.fitRemoteScreen,onChange:D("control","fitRemoteScreen"),label:"Fit remote screen"})}),s.jsx(ht,{icon:pn,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:s.jsx(Tt,{checked:!!B.keepControlReadyBetweenPages,onChange:D("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),be=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(Pc,{size:20})]}),s.jsx(ht,{icon:Es,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:s.jsx(Li,{value:String(xe.performanceMode),onChange:D("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(pn,{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(([ve,Se,_e])=>s.jsx(ht,{icon:an,title:Se,description:_e,children:s.jsx(Tt,{checked:!!xe[ve],onChange:D("wall",ve),label:Se})},ve))]})]}),X=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(ko,{size:20})]}),s.jsx(ht,{icon:ko,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:s.jsx(Tt,{checked:!!se.allowFileTransfer,onChange:D("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),s.jsx(ht,{icon:Pc,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!se.allowFileTransfer,children:s.jsx(Tt,{checked:!!se.allowFolderSync,onChange:D("filesAudio","allowFolderSync"),disabled:!se.allowFileTransfer,label:"Allow folder sync"})}),s.jsx(ht,{icon:Bt,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:s.jsx(Tt,{checked:!!se.askBeforeReceivingFiles,onChange:D("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),s.jsx(ht,{icon:ko,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:s.jsx(Tt,{checked:!!se.allowOverwrite,onChange:D("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(pn,{size:20})]}),s.jsx(ht,{icon:pn,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:s.jsx(Tt,{checked:!!se.allowRemoteAudio,onChange:D("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),s.jsx(ht,{icon:pn,title:"Start audio muted",description:"New audio sessions begin silent.",children:s.jsx(Tt,{checked:!!se.startAudioMuted,onChange:D("filesAudio","startAudioMuted"),label:"Start audio muted"})}),s.jsx(ht,{icon:pn,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:s.jsx(Tt,{checked:!!se.automaticallyRecoverAudio,onChange:D("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(an,{size:20})]}),s.jsx(ht,{icon:pn,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:s.jsx(Tt,{checked:!!se.rollingBufferEnabled,onChange:D("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),s.jsx(ht,{icon:pn,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:s.jsx(Li,{value:String(se.recordingQuality),onChange:D("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),s.jsx(ht,{icon:pn,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:s.jsx(Li,{value:Number(se.timelapseIntervalSeconds),onChange:ve=>D("filesAudio","timelapseIntervalSeconds")(Number(ve)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),s.jsx(ht,{icon:an,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:s.jsx(Tt,{checked:!!se.includeRemoteCursor,onChange:D("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),s.jsx(ht,{icon:ko,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:s.jsx(Li,{value:String(se.captureSaveLocation),onChange:D("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(se.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),s.jsx(ht,{icon:ko,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:s.jsx(Li,{value:String(se.captureAutoDelete),onChange:D("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),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:"Agent safety"}),s.jsx("h3",{children:"AI workstation operations"})]}),s.jsx(Es,{size:20})]}),s.jsx(ht,{icon:Es,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:s.jsx(Tt,{checked:!!K.enabled,onChange:D("agent","enabled"),label:"Enable AI Agent"})}),s.jsx(ht,{icon:Bt,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:s.jsx(Li,{value:String(K.defaultPermissionMode),onChange:D("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),s.jsx(ht,{icon:Bt,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!K.enabled,children:s.jsx(Tt,{checked:!!K.askBeforeDestructive,onChange:D("agent","askBeforeDestructive"),disabled:!K.enabled,label:"Ask before destructive operations"})}),s.jsx(ht,{icon:pn,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:s.jsx(Tt,{checked:!!K.keepAuditHistory,onChange:D("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),s.jsx(ht,{icon:pn,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:s.jsx(Li,{value:Number(K.timeoutMinutes),onChange:ve=>D("agent","timeoutMinutes")(Number(ve)),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(([ve,Se])=>s.jsx(ht,{icon:Bt,title:Se,description:ve.includes("allowCommand")||ve.includes("Installation")||ve.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:s.jsx(Tt,{checked:!!K[ve],onChange:D("agent",ve),label:Se})},ve))]}),s.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),he=x==="connection"?q:x==="security"?V:x==="control"?ce:x==="wall"?be:x==="files-audio"?X:x==="agent"?s.jsxs(s.Fragment,{children:[$,g]}):s.jsxs("div",{className:"settings-tab-content product-settings-content",children:[v,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(Fd,{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:Ej.map(({id:ve,label:Se,icon:_e})=>s.jsxs("button",{className:x===ve?"active":"",id:`settings-tab-${ve}`,role:"tab","aria-selected":x===ve,"aria-controls":`settings-panel-${ve}`,tabIndex:x===ve?0:-1,onClick:()=>b(ve),type:"button",children:[s.jsx(_e,{size:16}),Se]},ve))}),k&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:k}),s.jsx("section",{className:"settings-page-panel",id:Q,role:"tabpanel","aria-labelledby":`settings-tab-${x}`,tabIndex:0,children:he})]})}function Dj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function Lj({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}function _j({children:n}){return s.jsx("div",{className:"settings-tab-content",children:n})}const bb={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 zy(n){return{...bb,...n||{}}}function zj({hubUrl:n}){const[a,r]=u.useState(bb),[l,c]=u.useState(null),[d,m]=u.useState(""),[p,g]=u.useState(""),[v,w]=u.useState(""),[x,b]=u.useState("");u.useEffect(()=>{let D=!0;return Ge("/api/settings/agent",void 0,n).then(ne=>{D&&(c(ne.settings),r(zy(ne.settings)))}).catch(ne=>{D&&b(ne instanceof Error?ne.message:String(ne))}),()=>{D=!1}},[n]);const C=(D,ne)=>r(G=>({...G,[D]:ne})),j=D=>{c(D),r(zy(D))},A=async()=>{g("save"),b(""),w("");try{const D={...a};d.trim()&&(D.apiKey=d.trim());const ne=await Ge("/api/settings/agent",{method:"PUT",body:JSON.stringify(D)},n);j(ne.settings),m(""),w("Agent settings saved.")}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},N=async()=>{g("reset"),b("");try{const D=await Ge("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);j(D.settings),w("Codex defaults restored.")}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},k=async()=>{g("test"),b(""),w("");try{const D=await Ge("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),ne=await Ge("/api/settings/agent",void 0,n);j(ne.settings),w(`Codex connection verified with ${D.connection?.modelName||"the configured model"}${D.connection?.latencyMs?` in ${D.connection.latencyMs} ms.`:"."}`)}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},T=async()=>{g("clear-key"),b("");try{const D=await Ge("/api/settings/agent/api-key",{method:"DELETE"},n);j(D.settings),m(""),w("The optional OpenCode Go key was removed.")}catch(D){b(D instanceof Error?D.message:String(D))}finally{g("")}},R=l?.codexInstallation==="installed"&&l.codexAuth==="signed-in",U=l?.securityStatus,O=U?.state||"unavailable",Y=O==="verified"?"Verified":O==="configured"?"Configured":"Unavailable",_=[["Codex home",U?.isolatedCodexHome],["Environment variables",U?.restrictedEnvironment],["LiveDesk MCP only",U?.livedeskMcpOnly],["Selected-device scope",U?.selectedDeviceScopeEnforced],["Fail-closed execution",U?.failClosed]];return s.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[s.jsx("section",{className:"settings-section-card agent-enable-card",children:s.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,onChange:D=>C("enabled",D.target.checked)}),s.jsx("span",{children:"Enable Agent AI"})]})}),x&&s.jsx("div",{className:"agent-settings-alert error",role:"alert",children:x}),v&&s.jsx("div",{className:"agent-settings-alert success",role:"status",children:v}),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(Mo,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Agent provider"}),s.jsxs("select",{value:a.provider,onChange:D=>C("provider",D.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(WS,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),s.jsxs("p",{className:"settings-help",children:[s.jsx(YS,{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(KS,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Model"}),s.jsx("input",{value:a.codexModelId,onChange:D=>C("codexModelId",D.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:D=>C("codexReasoningEffort",D.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:D=>C("codexTaskTimeoutMs",Number(D.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:D=>C("codexMaxToolCalls",Number(D.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:D=>C("codexResumeSessions",D.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:D=>C("codexShowDetailedEvents",D.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(Mo,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{value:a.baseUrl,onChange:D=>C("baseUrl",D.target.value)})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"API key"}),s.jsx("input",{type:"password",value:d,onChange:D=>m(D.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:()=>{T()},disabled:p!==""||!l?.hasApiKey,type:"button",children:[s.jsx(Yh,{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(Fn,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:D=>C("deterministicParserFirst",D.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:D=>C("generateSummary",D.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:D=>C("fallbackSummary",D.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:D=>C("includeRawDeviceDetails",D.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(D=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Yx,{size:15}),s.jsx("span",{children:D}),s.jsx("strong",{children:"Blocked"})]},D)),_.map(([D])=>s.jsxs("div",{className:"agent-safety-row",children:[s.jsx(Bt,{size:15}),s.jsx("span",{children:D}),s.jsx("strong",{className:O==="unavailable"?"agent-safety-failed":O==="configured"?"agent-safety-configured":"agent-safety-verified",children:Y})]},D)),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:()=>{N()},disabled:p!=="",type:"button",children:[s.jsx(_c,{size:15})," Reset defaults"]}),s.jsxs("button",{className:"text-button primary",onClick:()=>{A()},disabled:p!=="",type:"button",children:[s.jsx(Kx,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function ti(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 ap(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function Lo(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 Ij(n,a="data-id"){const r=Lo(n,a);return r?r.getAttribute(a):null}function Gc(n,a="data-id"){const r=Lo(n,a);return r?nf(r,a):null}function nf(n,a="data-id"){const r=n.getAttribute(a);return r?Oj(r):null}function Pn(n){return typeof n=="string"?":"+n:n}function Oj(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function Hj(){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 La=Hj();function sp(n){Object.assign(La,n)}function Iy(n,a,r){function l(c){const d=Lo(c);if(!d)return;const m=nf(d);if(typeof a=="function")return a(m,c);let p,g=c.target;for(;g!=d;){if(p=g.dataset?g.dataset.action:null,p&&a[p]){a[p](m,c);return}g=g.parentNode}a[r]&&a[r](m,c)}La.addEvent(n,r,l)}function _o(n,a){Iy(n,a,"click"),a.dblclick&&Iy(n,a.dblclick,"dblclick")}function Bj(n,a){for(let r=n.length-1;r>=0;r--)if(n[r]===a){n.splice(r,1);break}}function Fj(n,a,r){for(let l=0;l<Oi.length;l++){if(l===r)continue;const c=Oi[l],d=c.props.parent?.();if(d&&n.contains(d)&&c.node.contains(a))return!0}return!1}var wb=new Date,Wd=!1,gd=[],Oi=[],Oy=n=>{const a=n.target;if(Wd||!a.isConnected){Wd=!1;return}for(let r=Oi.length-1;r>=0;r--){const{node:l,date:c,props:d}=Oi[r];if(!(c>wb)&&!l.contains(a)&&l!==a&&(Fj(l,a,r)||(d.callback&&d.callback(n),d.modal||n.defaultPrevented)))break}},Pj=n=>{wb=new Date,Wd=!0;for(let a=Oi.length-1;a>=0;a--){const{node:r}=Oi[a];if(!r.contains(n.target)&&r!==n.target){Wd=!1;break}}};function ni(n,a){gd.length||(gd=[La.addGlobalEvent("click",Oy,n),La.addGlobalEvent("contextmenu",Oy,n),La.addGlobalEvent("mousedown",Pj,n)]),typeof a!="object"&&(a={callback:a});const r={node:n,date:new Date,props:a};return Oi.push(r),{destroy(){Bj(Oi,r),Oi.length||(gd.forEach(l=>l()),gd=[])}}}var vd=n=>n.indexOf("bottom")!==-1,yd=n=>n.indexOf("left")!==-1,xd=n=>n.indexOf("right")!==-1,th=n=>n.indexOf("top")!==-1,Hy=n=>n.indexOf("fit")!==-1,Mc=n=>n.indexOf("overlap")!==-1,$j=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),Uj=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function qj(n,a){let r=0;const l=La.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 Ln,ia,Tc,Qn;function Sb(n,a,r="bottom",l=0,c=0){if(!n)return null;Ln=l,ia=c,Tc="auto";let d=0,m=0,p=r;const g=Cb(n),v=Mc(r)?La.getTopNode(n):g;if(!g)return null;const w=g.getBoundingClientRect(),x=n.getBoundingClientRect(),b=v.getBoundingClientRect(),C=window.getComputedStyle(v),j={left:0,top:0,bottom:0,right:0};for(const U in j){const O=`border-${U}-width`;j[U]=parseFloat(C.getPropertyValue(O))}if(a){const U=qj(a,g);d=Math.max(U+1,20)}if(a){if(Qn=a.getBoundingClientRect(),Hy(r)&&(Tc=Qn.width+"px"),r!=="point")if($j(r))Hy(r)?Ln=0:(Ln=b.width/2,m=1),ia=(b.height-x.height)/2;else{const U=Mc(r)?0:1;Ln=xd(r)?Qn.right+U:Qn.left-U,ia=vd(r)?Qn.bottom+1:Qn.top;const O=Uj(r);O&&(xd(r)||yd(r)?O==="center"?ia-=(x.height-Qn.height)/2:O==="end"&&(ia-=x.height-Qn.height):(vd(r)||th(r))&&(O==="center"?Ln-=(x.width-Qn.width)/2:O==="end"&&(Ln-=x.width-Qn.width),Mc(r)||(Ln+=1)))}}else Qn={left:l,right:l,top:c,bottom:c};const A=(yd(r)||xd(r))&&(vd(r)||th(r));yd(r)&&(m=2);const N=Ln-x.width-b.left;a&&yd(r)&&!A&&N<0&&(Ln=Qn.right,m=0,p=p.replace("left","right"));const k=Ln+x.width*(1-m/2)-b.right;if(k>0)if(!xd(r))Ln=b.right-j.right-x.width;else{const U=Qn.left-b.x-x.width;a&&!A&&U>=0?(Ln=Qn.left-x.width,p=p.replace("right","left")):Ln-=k+j.right}m&&(Ln=Math.round(Ln-x.width*m/2));const T=N<0||k>0||!A;th(r)&&(ia=Qn.top-x.height,a&&ia<b.y&&T&&(ia=Qn.bottom,p=p.replace("top","bottom")));const R=ia+x.height-b.bottom;return R>0&&(a&&vd(r)&&T?(ia-=x.height+Qn.height+1,p=p.replace("bottom","top")):ia-=R+j.bottom),Ln-=w.left+j.left,ia-=w.top+j.top,Ln=(Mc(r)?Ln:Math.max(Ln,0))+v.scrollLeft,ia=(Mc(r)?ia:Math.max(ia,0))+v.scrollTop,Tc=Tc||"auto",{at:p,x:Ln,y:ia,z:d,width:Tc}}function Cb(n){const a=La.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 Gj(n){const a=[];let r=n;const l=La.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 By=new Date().valueOf();function ip(){return By+=1,By}function la(n){return n<10?"0"+n:n.toString()}function Vj(n){const a=la(n);return a.length==2?"0"+a:a}function jb(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 Fy=["",""];function Wj(n,a,r){switch(n){case"%d":return la(a.getDate());case"%m":return la(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return la(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 la((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return la(a.getHours());case"%i":return la(a.getMinutes());case"%a":return((a.getHours()>11?r.pm:r.am)||Fy)[0];case"%A":return((a.getHours()>11?r.pm:r.am)||Fy)[1];case"%s":return la(a.getSeconds());case"%S":return Vj(a.getMilliseconds());case"%W":return la(nh(a));case"%w":{const l=r.weekStart??1;if(l===1)return la(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)),la(nh(m))}case"%c":{let l=a.getFullYear()+"";return l+="-"+la(a.getMonth()+1),l+="-"+la(a.getDate()),l+="T",l+=la(a.getHours()),l+=":"+la(a.getMinutes()),l+=":"+la(a.getSeconds()),l}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var Yj=/%[a-zA-Z]/g;function To(n,a){return typeof n=="function"?n:function(r){return r?(r.getMonth||(r=new Date(r)),n.replace(Yj,l=>Wj(l,r,a))):""}}function Py(n){return n&&typeof n=="object"&&!Array.isArray(n)}function _h(n,a){for(const r in a){const l=a[r];Py(n[r])&&Py(l)?n[r]=_h({...n[r]},a[r]):n[r]=a[r]}return n}function Wc(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),Wc(l)}}}var Kj=eb();const Qj="en-US",Xj={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},Zj={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},Jj={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},kb={core:Zj,calendar:Xj,formats:Jj,lang:Qj},rp=u.createContext(""),Ab=u.createContext({}),Ds=u.createContext(null),Nb=u.createContext(null),Un=Object.freeze(Object.defineProperty({__proto__:null,fieldId:Nb,helpers:Ab,i18n:Ds,theme:rp},Symbol.toStringTag,{value:"Module"}));function Mb(n){const a=u.useContext(Nb),[r]=u.useState(()=>n||a||ip());return r}function Hc({type:n="",css:a="",icon:r="",disabled:l=!1,title:c="",tooltip:d,text:m="",children:p,onClick:g}){const v=u.useMemo(()=>{let x=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+x},[n,a]),w=x=>{g&&g(x)};return s.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${v} ${r&&!p?"wx-icon":""}`,disabled:l,onClick:w,"data-tooltip-text":d,children:[r&&s.jsx("i",{className:"wx-2ZWgb4 "+r}),p||m||" "]})}function ek({id:n,label:a="",inputValue:r="",value:l=!1,onChange:c,disabled:d=!1,css:m=""}){const p=Mb(n),[g,v]=ti(l),w=({target:x})=>{const b=x.checked;v(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:g,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 lp({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(rp);return u.useEffect(()=>{m(a||tk(c.current)||La.getTopNode(c.current))},[c.current]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:c,style:{display:"none"}}),c.current&&d?Kj.createPortal(s.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:r}),d):null]})}function tk(n){const a=La.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function nk({left:n=0,top:a=0,at:r="bottom",parent:l=null,width:c="auto",css:d="",onCancel:m,children:p,trackScroll:g=!1}){const[v,w]=u.useState(0),[x,b]=u.useState(0),[C,j]=u.useState("auto"),[A,N]=u.useState(!1),k=u.useRef(null),T=u.useRef(null),R=u.useRef(m);u.useEffect(()=>{R.current=m},[m]);function U(Y){return l&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(_,D)=>(D=D*l.offsetWidth/100+"px",c.replace(_,D))):c&&c!=="auto"?c:Y}const O=u.useCallback(()=>{if(!k.current)return;const Y=Sb(k.current,l,r,n,a);Y&&(w(Y.x),b(Y.y),j(U(Y.width)))},[k,l,r,n,a,c]);return u.useLayoutEffect(()=>{const Y=D=>{R.current&&D.target!==T.current&&k.current&&!k.current.contains(D.target)&&R.current(D)};let _;return requestAnimationFrame(()=>{O(),N(!0),g&&k.current&&(T.current=Cb(k.current),T.current&&T.current.addEventListener("scroll",Y,!0)),l&&(_=new ResizeObserver(O),_.observe(l))}),()=>{g&&T.current&&T.current.removeEventListener("scroll",Y,!0),_?.disconnect()}},[]),u.useLayoutEffect(()=>{O()},[l,r,n,a]),u.useEffect(()=>{const Y=_=>{R.current&&R.current(_)};if(k.current)return ni(k.current,{callback:Y,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:x+"px",left:v+"px",width:C},children:p})}function ak({position:n="bottom",align:a="start",autoFit:r=!0,onCancel:l=null,width:c="100%",css:d="",children:m}){const p=u.useRef(null),[g,v]=u.useState(n),[w,x]=u.useState(a),b=u.useRef(l);return u.useEffect(()=>{b.current=l},[l]),u.useEffect(()=>{if(r){const C=p.current;if(C){const j=C.getBoundingClientRect(),A=document.body.getBoundingClientRect();j.right>=A.right&&x("end"),j.bottom>=A.bottom&&v("top")}}},[]),u.useEffect(()=>{if(p.current){const C=j=>{b.current&&b.current(j)};return ni(p.current,C).destroy}},[]),s.jsx("div",{ref:p,className:["wx-dropdown",`wx-${g}-${w}`,d||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:m})}function op({position:n="bottom",align:a="start",autoFit:r=!0,inline:l=!1,onCancel:c,width:d="100%",children:m,...p}){const[g,v]=u.useState(void 0),w=u.useRef(null),x=u.useMemo(()=>`${n}-${a}`,[n,a]);return u.useLayoutEffect(()=>{w.current&&v(w.current.parentNode)},[]),s.jsxs(s.Fragment,{children:[g&&(l?s.jsx(ak,{onCancel:c,position:n,align:a,autoFit:r,width:d,...p,children:m}):s.jsx(lp,{children:s.jsx(nk,{parent:g,at:x,onCancel:c,width:d,...p,children:m})})),s.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function af(){return Wc(kb)}function sk(){let n=null,a=!1,r=!1,l,c,d,m;const p=(x,b,C,j,A)=>{l=x,c=b,d=C,m=j,r=A},g=x=>{n=x,a=n!==null,d(n)},v=(x,b)=>{if(!r&&x!==null&&l){const C=l.querySelectorAll(".wx-list > .wx-item")[x];C&&(C.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(x,b)=>{const C=x===null?null:Math.max(0,Math.min(n+x,c.length-1));C!==n&&(g(C),l?v(C,b):requestAnimationFrame(()=>v(C,b)))};return{move:x=>{const b=Gc(x),C=c.findIndex(j=>j.id===b);C!==n&&g(C)},keydown:(x,b)=>{switch(x.code){case"Enter":a?m():g(0);break;case"Space":a||g(0);break;case"Escape":d(n=null);break;case"Tab":d(n=null);break;case"ArrowDown":w(a?1:b||0,x);break;case"ArrowUp":w(a?-1:b||0,x);break}},init:p,navigate:w}}const $y=10,ik=u.memo(function({data:n,checkboxes:a,itemTemplate:r,value:l}){return s.jsxs(s.Fragment,{children:[a&&s.jsx(ek,{id:n.id,css:"wx-list-checkbox",value:l&&l.includes(n.id)}),r?ap(r,{option:n}):n.label]})});function Uy({visibleItems:n,visibleRange:a,navIndex:r,checkboxes:l,itemTemplate:c,value:d,measureRefCallback:m}){return n.map((p,g)=>{const v=a.start+g;return s.jsx("div",{ref:g===0?m:void 0,className:`wx-233fr7 wx-item ${v===r?"wx-focus":""}`,"data-id":p.id,children:s.jsx(ik,{data:p,checkboxes:l,itemTemplate:c,value:d})},p.id)})}function sf({items:n=[],children:a,onSelect:r,onReady:l,virtualized:c=!1,checkboxes:d,multiselect:m,value:p,...g}){const v=u.useRef(),w=u.useRef(!1),x=u.useRef(sk()),[b,C]=u.useState(null),j=u.useRef(b),[A,N]=u.useState(0),[k,T]=u.useState(24),R=u.useRef(!1),U=(u.useContext(Ds)||af()).getGroup("core"),O=u.useRef(n);u.useEffect(()=>{O.current=n},[n]);const Y=u.useRef(p);u.useEffect(()=>{Y.current=p},[p]);const _=u.useRef(0);u.useEffect(()=>{_.current=k},[k]);const D=u.useCallback(X=>{X&&X.stopPropagation();const $=O.current,ue=Y.current,he=j.current;let ve;const Se=$[he]?.id;m?ue&&ue.includes(Se)?ve=ue.filter(_e=>_e!==Se):ve=[...ue||[],Se]:ve=Se,r&&r({id:ve})},[m,r]),ne=u.useRef(D);u.useEffect(()=>{ne.current=D},[D]);const G=u.useCallback(X=>{if(v.current){let $=X*_.current-v.current.clientHeight+_.current;N($),v.current.scrollTop=$}},[_.current]),te=u.useCallback(X=>{v.current=X,c&&(X&&!w.current&&j.current!==null&&requestAnimationFrame(()=>{v.current&&(G(j.current),w.current=!0)}),X||(w.current=!1))},[G]),B=u.useCallback(X=>{if(!X||R.current)return;const $=X.getBoundingClientRect().height;$&&(T($),_.current=$,R.current=!0)},[]);u.useEffect(()=>{x.current.init(v.current,n,X=>{C(X),j.current=X},X=>ne.current(X),c)},[n,v.current,c]),u.useEffect(()=>{const X=(ue,he)=>{x.current.navigate(ue,he),G(j.current)},$=(ue,he)=>{const ve=j.current,Se=O.current;if(ve!==0&&ve!==Se.length-1&&(ue.key==="ArrowDown"||ue.key==="ArrowUp")&&ue.preventDefault(),x.current.keydown(ue,he),v.current){const _e=v.current.scrollTop<=j.current*_.current,re=v.current.scrollTop+v.current.clientHeight>=j.current*_.current+_.current;_e?re||G(j.current):(v.current.scrollTop=j.current*_.current,N(v.current.scrollTop))}};l&&l({navigate:c?X:x.current.navigate,keydown:c?$:x.current.keydown,move:x.current.move})},[]);const xe=u.useRef(0),se=u.useRef(n);se.current!==n&&(se.current=n,xe.current+=1);const K=u.useCallback(()=>{x.current.navigate(null)},[x]),I=u.useCallback(X=>{c&&N(X.target.scrollTop)},[c]),Q=u.useMemo(()=>Math.ceil((v.current?.clientHeight||0)/k),[k,A]),q=u.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const X=Math.floor(A/k),$=X+Q;return{start:Math.max(0,X-$y),end:Math.min(n.length,$+$y)}},[c,n,A,k,Q]),V=u.useMemo(()=>{if(!c)return n;const{start:X,end:$}=q;return n.slice(X,$).map(ue=>({...ue}))},[c,n,q]),ce=q.start*k,be=n.length*k;return u.useEffect(()=>{c&&N(0)},[n,c]),u.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:s.jsx(op,{onCancel:K,...g,children:s.jsx("div",{className:"wx-233fr7 wx-list",ref:te,onClick:D,onMouseMove:x.current.move,onScroll:I,children:n.length?c?s.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${be}px`},children:s.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${ce}px)`},children:s.jsx(Uy,{visibleRange:q,visibleItems:V,navIndex:b,measureRefCallback:B,checkboxes:d,itemTemplate:a,value:p})})}):s.jsx(Uy,{visibleRange:q,visibleItems:V,navIndex:b,measureRefCallback:B,checkboxes:d,itemTemplate:a,value:p}):s.jsx("div",{className:"wx-233fr7 wx-no-data",children:U("No data")})})},xe.current)}function cp({value:n="",id:a,readonly:r=!1,focus:l=!1,select:c=!1,type:d="text",placeholder:m="",disabled:p=!1,error:g=!1,title:v="",tooltip:w,css:x="",icon:b="",clear:C=!1,onChange:j}){const A=Mb(a),[N,k]=ti(n),T=u.useRef(null),R=u.useMemo(()=>b&&x.indexOf("wx-icon-left")===-1?"wx-icon-right "+x:x,[b,x]),U=u.useMemo(()=>b&&x.indexOf("wx-icon-left")!==-1,[b,x]);u.useEffect(()=>{const ne=setTimeout(()=>{l&&T.current&&T.current.focus(),c&&T.current&&T.current.select()},1);return()=>clearTimeout(ne)},[l,c]);const O=u.useCallback(ne=>{const G=ne.target.value;k(G),j&&j({value:G,input:!0})},[j]),Y=u.useCallback(ne=>j&&j({value:ne.target.value}),[j]);function _(ne){ne.stopPropagation(),k(""),j&&j({value:""})}let D=d;return d!=="password"&&d!=="number"&&(D="text"),u.useEffect(()=>{const ne=Y,G=T.current;return G.addEventListener("change",ne),()=>{G&&G.removeEventListener("change",ne)}},[Y]),s.jsxs("div",{className:`wx-hQ64J4 wx-text ${R} ${g?"wx-error":""} ${p?"wx-disabled":""} ${C?"wx-clear":""}`,"data-tooltip-text":w,children:[s.jsx("input",{className:"wx-hQ64J4 wx-input",ref:T,id:A,readOnly:r,disabled:p,placeholder:m,type:D,title:v,value:N,onInput:O}),C&&!p&&N?s.jsxs(s.Fragment,{children:[s.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:_}),U&&s.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?s.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function rk({date:n,type:a,part:r,onShift:l}){const{calendar:c,formats:d}=u.useContext(Ds).getRaw(),m=n.getFullYear(),p=u.useMemo(()=>{switch(a){case"month":return To(d.monthYearFormat,c)(n);case"year":return To(d.yearFormat,c)(n);case"duodecade":{const{start:v,end:w}=jb(m),x=To(d.yearFormat,c);return`${x(new Date(v,0,1))} - ${x(new Date(w,11,31))}`}default:return""}},[n,a,m,c,d]);function g(){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:g,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 up({onClick:n,children:a}){return s.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function lk({value:n,current:a,part:r="",markers:l=null,css:c="",onCancel:d,onChange:m}){const p=(u.useContext(Ds)||af()).getRaw().calendar,g=(p.weekStart||7)%7,v=p.dayShort.slice(g).concat(p.dayShort.slice(0,g)),w=(O,Y,_)=>new Date(O.getFullYear(),O.getMonth()+(Y||0),O.getDate()+(_||0));let x=r!=="normal";function b(O){const Y=O.getDay();return Y===0||Y===6}function C(){const O=w(a,0,1-a.getDate());return O.setDate(O.getDate()-(O.getDay()-(g-7))%7),O}function j(){const O=w(a,1,-a.getDate());return O.setDate(O.getDate()+(6-O.getDay()+g)%7),O}const A=u.useRef(0);function N(O,Y){Y.timeStamp!==A.current&&(A.current=Y.timeStamp,Y.stopPropagation(),m&&m(new Date(O)),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]),T=u.useMemo(()=>{const O=C(),Y=j(),_=a.getMonth();let D=[];for(let ne=O;ne<=Y;ne.setDate(ne.getDate()+1)){const G={day:ne.getDate(),in:ne.getMonth()===_,date:ne.valueOf()};let te="";if(te+=G.in?"":" wx-inactive",te+=k.indexOf(G.date)>-1?" wx-selected":"",x){const B=G.date==k[0],xe=G.date==k[1];B&&!xe?te+=" wx-left":xe&&!B&&(te+=" wx-right"),G.date>k[0]&&G.date<k[1]&&(te+=" wx-inrange")}if(te+=b(ne)?" wx-weekend":"",l){const B=l(ne);B&&(te+=" "+B)}D.push({...G,css:te})}return D},[a,k,x,l]),R=u.useRef(null);let U=u.useRef({});return U.current.click=N,u.useEffect(()=>{_o(R.current,U.current)},[]),s.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[s.jsx("div",{className:"wx-398RBS wx-weekdays",children:v.map(O=>s.jsx("div",{className:"wx-398RBS wx-weekday",children:O},O))}),s.jsx("div",{className:"wx-398RBS wx-days",ref:R,children:T.map(O=>s.jsx("div",{className:`wx-398RBS wx-day ${O.css} ${O.in?"":"wx-out"}`,"data-id":O.date,children:O.day},O.date))})]})}function ok({value:n,current:a,part:r,onCancel:l,onChange:c,onShift:d}){const m=u.useRef(new Date),[p,g]=ti(n||m.current),[v,w]=ti(a||m.current),x=u.useContext(Ds).getRaw().calendar,b=x.monthShort||[],C=u.useMemo(()=>v.getMonth(),[v]),j=u.useCallback((k,T)=>{if(k!=null){T.stopPropagation();const R=new Date(v);R.setMonth(k),w(R),d&&d({current:R})}r==="normal"&&g(new Date(v)),l&&l()},[v,r,d,l]),A=u.useCallback(()=>{const k=new Date(Tb(p,r)||v);k.setMonth(v.getMonth()),k.setFullYear(v.getFullYear()),c&&c(k)},[p,v,r,c]),N=u.useCallback(k=>{const T=k.target.closest("[data-id]");if(T){const R=parseInt(T.getAttribute("data-id"),10);j(R,k)}},[j]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-34U8T8 wx-months",onClick:N,children:b.map((k,T)=>s.jsx("div",{className:"wx-34U8T8 wx-month"+(C===T?" wx-current":""),"data-id":T,children:k},T))}),s.jsx("div",{className:"wx-34U8T8 wx-buttons",children:s.jsx(up,{onClick:A,children:x.done})})]})}const ah="wx-1XEF33",ck=({value:n,current:a,onCancel:r,onChange:l,onShift:c,part:d})=>{const m=u.useContext(Ds).getRaw().calendar,[p,g]=ti(a),[v,w]=ti(n),x=u.useMemo(()=>p.getFullYear(),[p]),b=u.useMemo(()=>{const{start:k,end:T}=jb(x),R=[];for(let U=k;U<=T;++U)R.push(U);return R},[x]),C={click:j};function j(k,T){if(k){T.stopPropagation();const R=new Date(p);R.setFullYear(k),g(R),c&&c({current:R})}d==="normal"&&w(new Date(p)),r&&r()}function A(){const k=new Date(Tb(v,d)||p);k.setFullYear(p.getFullYear()),l&&l(k)}const N=u.useRef(null);return u.useEffect(()=>{N.current&&_o(N.current,C)},[]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:ah+" wx-years",ref:N,children:b.map((k,T)=>s.jsx("div",{className:ah+` wx-year ${x==k?"wx-current":""} ${T===0?"wx-prev-decade":""} ${T===11?"wx-next-decade":""}`,"data-id":k,children:k},T))}),s.jsx("div",{className:ah+" wx-buttons",children:s.jsx(up,{onClick:A,children:m.done})})]})},qy={month:{component:lk,next:dk,prev:uk},year:{component:ok,next:mk,prev:fk},duodecade:{component:ck,next:pk,prev:hk}};function uk(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function dk(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function fk(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function mk(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function hk(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function pk(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Tb(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 gk=["clear","today"];function vk(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function yk({value:n,current:a,onCurrentChange:r,part:l="normal",markers:c=null,buttons:d,css:m="",onShift:p,onChange:g}){const v=u.useContext(Ds).getGroup("calendar"),[w,x]=u.useState("month"),b=Array.isArray(d)?d:d?gk:[],C=(T,R)=>{T.preventDefault(),g&&g({value:R})},j=()=>{w==="duodecade"?x("year"):w==="year"&&x("month")},A=T=>{const{diff:R,current:U}=T;if(R===0){w==="month"?x("year"):w==="year"&&x("duodecade");return}if(R){const O=qy[w];r(R>0?O.next(a):O.prev(a))}else U&&r(U);p&&p()},N=T=>{x("month"),g&&g({select:!0,value:T})},k=u.useMemo(()=>qy[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(rk,{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:j,onChange:N,onShift:A}),w==="month"&&b.length>0&&s.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(T=>s.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:s.jsx(up,{onClick:R=>C(R,vk(T)),children:v(T)})},T))})]})]})})}function dp(n){let{words:a=null,optional:r=!1,children:l}=n,c=u.useContext(Ds);const d=u.useMemo(()=>{let m=c;return(!m||!m.extend)&&(m=Wc(kb)),a!==null&&(m=m.extend(a,r)),m},[a,r,c]);return s.jsx(Ds.Provider,{value:d,children:l})}function Gy(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 xk=["clear","today"];function Eb({value:n,current:a,markers:r=null,buttons:l=xk,css:c="",onChange:d}){const[m,p]=ti(n),[g,v]=ti(a);u.useEffect(()=>{Gy(g,m,v,!1)},[m,g]);const w=u.useCallback(b=>{const C=b.value;C?(p(new Date(C)),Gy(g,new Date(C),v,!0)):p(null),d&&d({value:C?new Date(C):null})},[d,g]),x=u.useCallback(b=>{v(b)},[v]);return g?s.jsx(dp,{children:s.jsx(yk,{value:m,current:g,markers:r,buttons:l,css:c,onChange:w,onCurrentChange:x})}):null}function bk(n){return n||(n={}),n.width||(n.width="unset"),n}const wk=["clear","today"];function Sk({value:n,id:a,disabled:r=!1,error:l=!1,placeholder:c="",format:d="",buttons:m=wk,css:p="",title:g="",tooltip:v,editable:w=!1,clear:x=!1,onChange:b,dropdown:C={}}){const{calendar:j,formats:A}=(u.useContext(Ds)||af()).getRaw(),N=d||A?.dateFormat;let k=typeof N=="function"?N:To(N,j);const[T,R]=u.useState(n),[U,O]=u.useState(!1);u.useEffect(()=>{R(n)},[n]);function Y(){O(!1)}function _(G){const te=G===T||G&&T&&G.valueOf()===T.valueOf()||!G&&!T;R(G),te||b&&b({value:G}),setTimeout(Y,1)}const D=u.useMemo(()=>T?k(T):"",[T,k]);function ne({value:G,input:te}){if(!w&&!x||te)return;let B=typeof w=="function"?w(G):G?new Date(G):null;B=isNaN(B)?T||null:B||null,_(B)}return u.useEffect(()=>{const G=Y;return window.addEventListener("scroll",G),()=>window.removeEventListener("scroll",G)},[]),s.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>O(!0),children:[s.jsx(cp,{css:`wx-date-input ${p}`,title:g,tooltip:v,value:D,id:a,readonly:!w,disabled:r,error:l,placeholder:c,onInput:Y,onChange:ne,icon:"wxi-calendar",clear:x}),U&&!r&&s.jsx(op,{onCancel:Y,...bk(C),children:s.jsx(Eb,{buttons:m,value:T,onChange:G=>_(G.value)})})]})}function Ck({value:n="",options:a=[],textOptions:r=null,placeholder:l="",disabled:c=!1,error:d=!1,title:m="",tooltip:p,textField:g="label",clear:v=!1,css:w="",children:x,onChange:b,dropdown:C={}}){const j=u.useRef(null),A=u.useRef(null);let[N,k]=ti(n);function T(_){j.current=_.navigate,A.current=_.keydown}const R=u.useMemo(()=>N||N===0?(r||a).find(_=>_.id===N):null,[N,r,a]),U=u.useCallback(({id:_})=>{(_||_===0)&&(k(_),j.current(null),b&&b({value:_}))},[k,b]),O=u.useCallback(_=>{_.stopPropagation(),k(""),b&&b({value:""})},[k,b]),Y=u.useCallback(()=>a.findIndex(_=>_.id===N),[a,N]);return s.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${d?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${x?"":"wx-2YgblL wx-nowrap"}`,title:m,onClick:()=>j.current(Y()),onKeyDown:_=>A.current(_,Y()),tabIndex:0,"data-tooltip-text":p,children:[s.jsx("div",{className:"wx-2YgblL wx-label",children:R?x?x(R):R[g]:l?s.jsx("span",{className:"wx-2YgblL wx-placeholder",children:l}):" "}),v&&!c&&N?s.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:O}):s.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&s.jsx(sf,{items:a,onReady:T,onSelect:U,...C,children:({option:_})=>x?x(_):_[g]})]})}const jk=({options:n=[],value:a="",css:r="",children:l,onChange:c})=>{const[d,m]=u.useState(a),p=g=>{m(g),c&&c({value:g})};return u.useEffect(()=>{m(a)},[a]),s.jsx("div",{className:`wx-0hMO7P wx-segmented ${r}`,children:n.map(g=>s.jsx("button",{className:`wx-0hMO7P wx-segment ${g.css} ${g.id===d?"wx-selected":""}`,title:g.title,onClick:()=>p(g.id),"data-tooltip-text":g.tooltip,children:l?ap(l,{option:g}):s.jsxs(s.Fragment,{children:[g.icon&&s.jsx("i",{className:`wx-0hMO7P wx-icon ${g.icon} ${g.label?"":"wx-only"}`}),g.label&&s.jsx("span",{className:"wx-0hMO7P wx-label",children:g.label})]})},g.id))})};function kk({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 Ak({data:n=[]}){return s.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>s.jsx(kk,{notice:a},a.id))})}function zh({title:n="",buttons:a=["cancel","ok"],header:r,children:l,footer:c,css:d="",onConfirm:m,onCancel:p}){const g=(u.useContext(Ds)||af()).getGroup("core"),v=u.useRef(null);u.useEffect(()=>{v.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const C=b.target.tagName;if(C==="TEXTAREA"||C==="BUTTON")return;m&&m({event:b});break}case"Escape":p&&p({event:b});break}}function x(b,C){const j={event:b,button:C};C==="cancel"?p&&p(j):m&&m(j)}return s.jsx("div",{className:`wx-1FxkZa wx-modal ${d}`,ref:v,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(Hc,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:C=>x(C,b),children:g(b)})},b))})]})})}function Nk({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((g,v)=>{p.resolve=w=>{l(null),g(w)},p.reject=w=>{l(null),v(w)}})},showNotice:m=>{m={...m},m.id=m.id||ip(),m.remove=()=>d(p=>p.filter(g=>g.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(zh,{title:r.title,buttons:r.buttons,onConfirm:r.resolve,onCancel:r.reject,children:r.message}),s.jsx(Ak,{data:c})]})}const Mk=u.forwardRef(Nk);function Tk(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(Ab.Provider,{value:l,children:s.jsx(Mk,{ref:r,children:a})})}const Ek=({value:n=!1,type:a="",icon:r="",disabled:l=!1,iconActive:c="",onClick:d,title:m="",tooltip:p,css:g="",text:v="",textActive:w="",children:x,active:b,onChange:C})=>{const[j,A]=ti(n),N=u.useMemo(()=>(j?"pressed":"")+(a?" "+a:""),[j,a]),k=u.useCallback(T=>{let R=!j;d&&d(T),T.defaultPrevented||(A(R),C&&C({value:R}))},[j,d,C]);return j&&b?s.jsx(Hc,{title:m,tooltip:p,text:j&&w||v,css:g,type:N,icon:j&&c||r,onClick:k,disabled:l,children:ap(b,{value:j})}):x?s.jsx(Hc,{title:m,tooltip:p,text:j&&w||v,css:g,type:N,icon:j&&c||r,onClick:k,disabled:l,children:x}):s.jsx(Hc,{title:m,tooltip:p,text:j&&w||v,css:g,type:N,icon:j&&c||r,onClick:k,disabled:l})};function Rk(){return s.jsx(s.Fragment,{})}function Vy(n){const{fonts:a=!0,children:r}=n;return s.jsx(rp.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(Rk,{}),s.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}sp(La);const fp={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 Rb=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 Dk=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]:Wy(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=bd(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=bd(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),g=c?d:this._pool.get(d.parent);g.data||(g.data=[]);const v=bd(p,l.id);Lk(p,v);const w=c?g.data.length:bd(g,d.id)+(a==="after"?1:0);if(Wy(g,w,l),p.id===g.id&&v===w)return null;l.parent=g.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&&Db(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 Db(n,a){n.forEach(r=>{a.push(r),r.open===!0&&Db(r.data,a)})}function Lk(n,a){const r=[...n.data];r.splice(a,1),n.data=r}function Wy(n,a,r){const l=[...n.data];l.splice(a,0,r),n.data=l}function bd(n,a){return n?.data.findIndex(r=>r.id===a)}var Lb=2,_k=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 g=r[p],v=l[p],w=a[p];if(g&&(v===w&&typeof w!="object"||w instanceof Date&&v instanceof Date&&v.getTime()===w.getTime()))continue;const x=c+(c?".":"")+p;g?(g.__parse(w,x,d,m)&&(l[p]=w),m&Lb?d[x]=g.__trigger:g.__trigger()):(w&&w.__reactive?r[p]=this._wrapNested(w,w,x,d):r[p]=this._wrapWritable(w),l[p]=w),d[x]=d[x]||null}}_wrapNested(a,r,l,c){const d=this._wrapWritable(a);return this._wrapProperties(a,d,r,l,c,0),d.__parse=(m,p,g,v)=>(this._wrapProperties(m,d,r,p,g,v),!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 Yy(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var zk=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(g=>p[g]=!0),this._sources.set(m,p)})}),this._routes.forEach(d=>{d.length=Math.max(...d.in.map(m=>_b(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,Lb);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(g=>{r.indexOf(g)==-1&&r.push(g)})}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 _b(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>_b(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(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 So=1024;function Vc(n){return n<So?`${n} B`:n<So**2?`${(n/So).toFixed(1)} KB`:n<So**3?`${(n/So**2).toFixed(1)} MB`:`${(n/So**3).toFixed(1)} GB`}function Ky(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(Qy(a)),d=l.sort(Qy(a));return[...c,...d]}function Ok(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 Hk(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 Qy({key:n,order:a}){const r=a==="asc"?Ok:Hk;return(l,c)=>r(l[n],c[n])}function mp(n,a){const r=n==="/"?1:n.split("/").length;return r>=a.length?null:a[r].id}function Bk(n){return n.length>1?n[n.length-2].id:null}let Fk=class extends Dk{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:g,lazy:v}=c,w={id:d,date:m,type:p??"file"};v&&(w.lazy=v),g&&(w.size=g),r.push(w);const x=this.serialize(d);x.length&&r.push(...x)}),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,g=r+(r==="/"?"":"/")+p;for(;this.byId(g+m);){const v=".new";g+=v,p+=v}return{...a,id:g+m,name:p+m,parent:r,ext:d.toLocaleLowerCase()}}},Pk=class extends _k{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:g}=this.getState(),v=[];v[d]={_crumbs:p.getParents(g[d].path)},this.setState({panels:v},m)}}),r.push({in:["data",`panels.${d}.path`,`panels.${d}._sorts`,"search"],out:[`panels.${d}._files`],exec:m=>{const{data:p,panels:g,search:v}=this.getState();let w;v?w=p.findFiles(v,g[d].path):w=p.byId(g[d].path)?.data||[];const{path:x,_sorts:b}=g[d];w=Ky(w,b[x]);const C=[];C[d]={_files:w},this.setState({panels:C},m)}}),r.push({in:["data",`panels.${d}.selected`,`panels.${d}._sorts`],out:[`panels.${d}._selected`],exec:m=>{const{data:p,panels:g}=this.getState(),v=[];g[d].selected.forEach(j=>{const A=p.byId(j);A&&v.push(A)});const{path:w,_sorts:x}=g[d],b=Ky(v,x[w]),C=[];C[d]={_selected:b},this.setState({panels:C},m)}});this._router=new zk(super.setState.bind(this),r,{data:d=>new Fk(d)});const l=this.in=new Ik;l.on("select-file",({id:d,toggle:m,range:p,panel:g,type:v})=>{const{panels:w,activePanel:x}=this.getState();typeof g>"u"&&(g=x),d||(m=p=!1);let b=[...w[g].selected];if(m){const j=b.indexOf(d);j===-1?b.push(d):b.splice(j,1)}else if(p&&w[g]._lastSelected){const j=w[g]._files;let A=j.findIndex(T=>T.id==w[g]._lastSelected),N=j.findIndex(T=>T.id==d);N<A&&([A,N]=[N,A]);const k=j.slice(A,N+1).map(T=>T.id);b=[...new Set([...b,...k])]}else b=d?[d]:[];const C=[];C[g]={selected:b,_lastSelected:d,_selectNavigation:v==="navigation"},this.setState({panels:C})}),l.on("set-path",({id:d,panel:m,selected:p})=>{const{data:g,activePanel:v}=this.getState(),w=g.byId(d);if(w){const x=[];typeof m>"u"&&(m=v),x[m]={path:d},this.setState({panels:x}),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:g}=this.getState(),v=g.byId(d);v&&(v.lazy||(v.data=[]),v.lazy=!1,g.parse(m,d,p==="search"),this.setState({data:g}))}),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:g,panels:v}=this.getState(),w=g.byId(m);if(w.name!==p){w.name=p;const x=g.normalizeFile(w,w.parent);d.newId=x.id,x.data=null,g.add(x);let b={[m]:x.id};w.data?.forEach(j=>b={...g.moveFiles([j.id],x.id),...b});const C=v.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));g.remove(m),this._updatePanels(C,b),this.setState({data:g,panels:C})}}),l.on("create-file",d=>{const{file:m,parent:p}=d,{data:g}=this.getState(),v=g.normalizeFile(m,p);v.type=m.type||"file",d.newId=v.id,g.add(v),this.setState({data:g}),l.exec("select-file",{id:v.id})}),l.on("delete-files",({ids:d})=>{const{data:m,panels:p}=this.getState(),g=p.map(v=>({selected:v.selected,_crumbs:v._crumbs,_lastSelected:v._lastSelected,_sorts:v._sorts}));d.forEach(v=>m.remove(v)),this._updatePanels(g,{}),this.setState({data:m,panels:g})}),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:g,panels:v,activePanel:w}=this.getState(),x=g.copyFiles(m,p);d.newIds=m.map(b=>x[b]),this.setState({data:g}),v[w].path==p&&(l.exec("select-file",{}),m.forEach(b=>{l.exec("select-file",{id:x[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:g,panels:v,activePanel:w}=this.getState(),x=g.moveFiles(m,p);if(x){d.newIds=m.map(C=>x[C]);const b=v.map(C=>({selected:C.selected,_crumbs:C._crumbs,_lastSelected:C._lastSelected,_sorts:C._sorts}));this._updatePanels(b,x,!0),this.setState({data:g,panels:b}),v[w].path==p&&(l.exec("select-file",{}),m.forEach(C=>{l.exec("select-file",{id:x[C],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 g={mode:d,search:"",panels:p};c=null,this.setState(g)}),l.on("set-active-panel",({panel:d})=>{this.setState({activePanel:d})}),l.on("sort-files",({key:d,order:m,panel:p,path:g})=>{const{activePanel:v,panels:w}=this.getState();p=p??v,g=g??w[p].path;const x=[];x[p]={_sorts:{...w[p]._sorts,[g]:{key:d,order:m}}},this.setState({panels:x})}),this.initOnce()}initOnce(){const a=[];for(let l=0;l<2;l++)a[l]=Yy({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[l]});const r={panels:Yy(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(v=>{c.byId(v)?m.push(v):!l&&r[v]&&m.push(r[v])}),d.selected=m,c.byId(d._lastSelected)||(d._lastSelected=l?null:r[d._lastSelected]||null);const p={};Object.keys(d._sorts).forEach(v=>{c.byId(v)?p[v]=d._sorts[v]:r[v]&&!l&&(p[r[v]]=d._sorts[v])}),d._sorts=p;const g=d._crumbs[d._crumbs.length-1];g?.id!=="/"&&(r[g.id]?d.path=r[g.id]:c.byId(g.id)||(d.path="/"))})}_isPlacedIntoSelf(a,r){return a.some(l=>l===r||this.getState().data.getParents(r).some(c=>c.id===l))}};function $k(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 Uk(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 qk(n,a="data-id"){const r=Uk(n,a);return r?r.getAttribute(a):null}new Date().valueOf();function Gk(n,a){const{api:r}=a;function l(d,m){const p=a.getPanel(),g=p.selected,v=m.ctrlKey||m.metaKey,w=m.shiftKey;let x;const b=g?.[0]?r.getFile(g[0]):null;g?.length?g.length>1?x=a.menuOptions("multiselect"):x=a.menuOptions(b.type,b):x=a.menuOptions("body");const C=`${v?"ctrl+":""}${w?"shift+":""}${d}`,j=x?x.find(N=>N.hotkey?.toLowerCase()===C):!1,A=a.performAction;if(j)switch(C){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:j.handler?.({context:b})}switch(d){case"enter":{if(v||w)break;const{_crumbs:N,_selectNavigation:k}=p;if(k){const T=Bk(N);if(T){const R=mp(T,N);r.exec("set-path",{id:T,selected:[R]})}}else if(g.length===1){const T=r.getFile(g[0]);T&&r.exec(T.type==="folder"?"set-path":"open-file",{id:T.id})}break}case"arrowup":case"arrowleft":{const{_files:N,_selected:k,path:T,_selectNavigation:R}=p;let U;if(k.length){const O=k.at(0).id,Y=N.findIndex(_=>_.id===O);if(Y!==-1){const _=Y-1;N[_]?U=N[_].id:T!=="/"&&!(v||w)&&r.exec("select-file",{type:"navigation"})}}else{if(R)break;if(T!=="/"){r.exec("select-file",{type:"navigation"});break}U=N.at(0)?.id}U&&r.exec("select-file",{id:U,toggle:v,range:w});break}case"arrowdown":case"arrowright":{const{_files:N,_selected:k,path:T,_selectNavigation:R}=p;let U;if(k.length){const O=k.at(-1).id,Y=N.findIndex(_=>_.id===O);if(Y!==-1){const _=Y+1;N[_]&&(U=N[_].id)}}else{if(T!=="/"&&!R){r.exec("select-file",{type:"navigation"});break}U=N.at(0)?.id}U&&r.exec("select-file",{id:U,toggle:v,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:+qk(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function Vk(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 Wk(n,a="data-id"){const r=n.getAttribute(a);return r?Yk(r):null}function Yk(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function Kk(){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 Qk=Kk();new Date().valueOf();function zb(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 Xk(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 lt(n,a){const r=n.getState(),l=n.getReactiveState();return Xk(l[a],r[a],a)}function Zk(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 hs(n,a){const r=n.getState(),l=n.getReactiveState();return Zk(l[a],r[a])}function Ib(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 Ob(n){let a=n,r=[];return{subscribe:p=>{r.push(p),p(a)},unsubscribe:p=>{r=r.filter(g=>g!==p)},set:p=>{a=p,r.forEach(g=>g(a))},update:p=>{a=p(a),r.forEach(g=>g(a))}}}function Xy(n,a,r){function l(c){const d=Vk(c);if(!d)return;const m=Wk(d);if(typeof a=="function")return a(m,c);let p,g=c.target;for(;g!=d;){if(p=g.dataset?g.dataset.action:null,p&&a[p]){a[p](m,c);return}g=g.parentNode}a[r]&&a[r](m,c)}return Qk.addEvent(n,r,l)}function Jk(n,a){const r=[Xy(n,a,"click")];return a.dblclick&&r.push(Xy(n,a.dblclick,"dblclick")),()=>{r.forEach(l=>l())}}function Hb(n,a){return n.map((r,l)=>{const c=a(r,l);return r.data&&r.data.length&&(c.data=Hb(r.data,a)),c}).filter(Boolean)}function Bb(n,a){const r=[];return n.forEach(l=>{if(l.data){const c=Bb(l.data,a);c.length&&r.push({...l,data:c})}else a(l)&&r.push(l)}),r}function e1(n){return Hb(n,(a,r)=>{const l={...a,id:a.id||ip()};return l.type&&(l.comp=l.type),l.comp==="separator"&&n[r-1]?.comp==="separator"?null:l})}const Fb={};function t1(n){return Fb[n]||n}function n1(n,a){Fb[n]=a}function a1({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?t1(r.comp):null,[r]);return s.jsxs("div",{ref:l,className:`wx-cDCz9rZQ wx-option ${r.css||""} ${r.disabled?"wx-disabled":""}`,"data-id":Pn(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 hp({options:n,left:a=0,top:r=0,at:l="bottom",parent:c=null,mount:d=null,context:m=null,css:p="",onClick:g,onCancel:v}){const[w,x]=u.useState(-1e4),[b,C]=u.useState(-1e4),[j,A]=u.useState(20),[N,k]=u.useState(),T=u.useRef(null),[R,U]=u.useState(!1),[O,Y]=u.useState(null),_=u.useCallback(()=>{const se=Sb(T.current,c,l,a,r);se&&(x(se.x),C(se.y),k(se.width));let K=se?.z??20;const I=c?Gj(c):[];let Q=0;for(const q of I){const V=parseInt(getComputedStyle(q).zIndex,10);V>Q&&(Q=V)}Q>=K&&(K=Q+1),A(K)},[c,l,a,r]);u.useEffect(()=>{d&&d(_)},[]);const D=u.useCallback(()=>{U(!1)},[]),ne=u.useCallback((se,K)=>{U(se),Y(K)},[]),G=u.useMemo(()=>e1(n),[n]);u.useEffect(()=>{_()},[c,_]);const te=u.useRef(g),B=u.useRef(v),xe=u.useRef(c);return u.useEffect(()=>{te.current=g},[g]),u.useEffect(()=>{B.current=v},[v]),u.useEffect(()=>{xe.current=c},[c]),u.useEffect(()=>{if(!T.current)return;function se(K){B.current?B.current(K):te.current&&te.current({action:null,option:null})}return ni(T.current,{callback:se,modal:!0,parent:()=>xe.current}).destroy},[]),s.jsx("div",{ref:T,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:N,zIndex:j},onMouseLeave:D,children:G.map(se=>s.jsxs(u.Fragment,{children:[se.comp==="separator"?s.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):s.jsx(a1,{option:se,onShow:ne,onClick:K=>{if(!se.data&&!K.defaultPrevented){const I={context:m,action:se,option:se,event:K};se.handler&&se.handler(I),g&&g(I),K.stopPropagation()}}}),se.data&&R===se.id?s.jsx(hp,{css:p,options:se.data,at:"right-overlap",parent:O,context:m,onClick:g,onCancel:v}):null]},se.id))})}const Pb=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:g,onClick:v}=n,[w,x]=u.useState(null),[b,C]=u.useState(null),[j,A]=u.useState(0),[N,k]=u.useState(0),T=u.useRef(null),R=u.useMemo(()=>`data-${d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[d]),U=u.useMemo(()=>w!==null&&m?Bb(r,D=>m(D,w)):r,[w,m,r]);function O(D){C(null),v&&v(D)}function Y(D){if(T.current===D){T.current=null;return}C(null),v&&v({action:null,option:null})}const _=u.useCallback((D,ne)=>{if(!D){C(null);return}if(D.defaultPrevented)return;const G=D.target;if(G&&G.dataset&&G.dataset.menuIgnore)return;if(b&&b===G){C(null),D.preventDefault();return}A(D.clientX+1),k(D.clientY+1);let te=typeof ne<"u"?ne:Gc(G,R);c&&(te=c(te,D),!te)||(x(te),C(G),T.current=D.nativeEvent||D,D.preventDefault())},[b,R,c]);return u.useImperativeHandle(a,()=>({show:_}),[_]),s.jsxs(s.Fragment,{children:[g?s.jsx("span",{onClick:_,"data-menu-ignore":"true",children:typeof g=="function"?g():g}):null,b?s.jsx(lp,{children:s.jsx(hp,{css:p,at:l,top:N,left:j,parent:b,context:w,onClick:O,onCancel:Y,options:U},b)}):null]})}),s1=u.forwardRef(function(n,a){const{options:r,at:l="bottom",css:c="",children:d,onClick:m}=n,[p,g]=u.useState(null),v=u.useRef(null);function w(j){g(null),m&&m(j)}function x(j){if(v.current===j){v.current=null;return}g(null),m&&m({action:null,option:null})}const b=u.useCallback(j=>{g(j.target),v.current=j.nativeEvent||j,j.preventDefault()},[]);u.useImperativeHandle(a,()=>({show:b}),[b]);function C(j){let A=j.target;for(;!A.dataset.menuIgnore;)g(A),A=A.parentNode}return s.jsxs(s.Fragment,{children:[s.jsx("span",{onClick:C,"data-menu-ignore":"true",children:d}),p?s.jsx(lp,{children:s.jsx(hp,{css:c,at:l,parent:p,options:r,onClick:w,onCancel:x})}):null]})}),i1=u.forwardRef(function(n,a){const{options:r,at:l="bottom",resolver:c=null,dataKey:d="contextId",filter:m=null,css:p="",children:g,onClick:v}=n,w=u.useRef(null),x=u.useCallback((b,C)=>{w.current.show(b,C)},[]);return u.useImperativeHandle(a,()=>({show:x}),[x]),s.jsxs(s.Fragment,{children:[g?s.jsx("span",{onContextMenu:x,"data-menu-ignore":"true",children:g}):null,s.jsx(Pb,{css:p,at:l,options:r,resolver:c,dataKey:d,filter:m,ref:w,onClick:v})]})}),r1={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 l1=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 $b(n){const[a,r]=u.useState([]),[l,c]=u.useState(Promise.resolve(null)),[d,m]=u.useState(null),[p,g]=u.useState(!1),v=u.useRef();return v.current||(v.current=new l1(r,c,m,g,n)),v.current.files=a,v.current.ready=l,v.current.signal=d,v.current.drag=p,v.current}function o1(n,a){{if(n){const r=n.getGroup(a);if(r)return r}return Wc(r1).getGroup(a)}}const c1=()=>Math.random().toString(36).substr(2,9),u1=({data:n,accept:a="",multiple:r=!0,folder:l=!1,uploadURL:c="",apiOnly:d=!1,disabled:m=!1,children:p,onChange:g,onUpload:v})=>{const w=u.useRef(null),x=u.useRef(null),[b,C]=u.useState({}),j=$b(),A=n||j,N=u.useContext(Un.i18n),k=o1(N,"uploader");u.useEffect(()=>{w.current&&l&&(w.current.webkitdirectory=!0)},[l]),u.useEffect(()=>{if(!d&&x.current&&!m)return A.droparea(x.current)},[d,m,x]);const T=G=>{const te=new FormData;return te.append("upload",G.file),fetch(c,{method:"POST",body:te}).then(B=>B.json()).then(B=>({id:G.id,...B}),()=>({id:G.id,status:"error"})).catch(B=>(console.log(B),{id:G.id,status:"error"}))},R=(G,te)=>{const B=A.updateFile(G,te),xe={...B,status:A.getState()};B&&B.uploaded&&B.uploaded(xe),v&&v(xe),B.temp&&A.deleteFile(B.id)},U=G=>{if(!G)return;const te=typeof c=="function"?c(G):T(G);A.setReady(te.then(B=>{B.status=B.status||"server",R(G.id,B)}).catch(B=>{R(G.id,{status:"error",error:B})}))},O=(G,te)=>{const B={...te||b,id:c1(),status:"client",name:G.name,file:G};B.selected&&B.selected(B),g&&g(B),A.addFile(B,r),U(B),w.current&&(w.current.value="")},Y=(G,te,B)=>{G.isFile?G.file(xe=>{O(xe,B)}):G.isDirectory&&G.createReader().readEntries(xe=>{xe.forEach(se=>{Y(se,te+se.name+"/",B)})})},_=G=>{Array.from(G.target.files).forEach(te=>O(te))},D=(G,te)=>{Array.from(G.dataTransfer.items).forEach(B=>{const xe=B.webkitGetAsEntry();xe&&Y(xe,"",te)})},ne=()=>{w.current&&w.current.click()};return u.useEffect(()=>{if(A.signal){const[G,te,B]=A.signal;C(te),G==="click"?ne():G==="drop"&&D(B,te),A.setSignal(null)}},[A.signal]),d?s.jsxs(s.Fragment,{children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:_,accept:a,multiple:r,disabled:m}),p]}):s.jsxs("div",{className:`wx-at1A8tb8 wx-label ${A.drag?"wx-active":""} ${m?"wx-disabled":""}`,ref:x,children:[s.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:_,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:ne,children:k("select files")})]})})]})};new Date().valueOf();function d1(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(!rf(l,c))return!1}return!0}function rf(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(!rf(n[r],a[r]))return!1;return!0}else return d1(n,a);return n===a}function Ih(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(Ih);const a={};for(const r in n)a[r]=Ih(n[r]);return a}var Ub=2,f1=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],g=r[m],v=n[m];if(p&&(g===v&&typeof v!="object"||v instanceof Date&&g instanceof Date&&g.getTime()===v.getTime()))continue;const w=l+(l?".":"")+m;p?(p.__parse(v,w,c,d)&&(r[m]=v),d&Ub?c[w]=p.__trigger:p.__trigger()):(v&&v.__reactive?a[m]=this._wrapNested(v,v,w,c):a[m]=this._wrapWritable(v),r[m]=v),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,g)=>(this._wrapProperties(d,c,a,m,p,g),!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}}}},m1=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=>qb(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,Ub);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 qb(n,a,r){const l=a.get(n);if(!l)return r;const c=Object.keys(l).map(d=>qb(d,a,r+1));return Math.max(...c)}var h1=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(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 p1(n){return a=>a[n]}function g1(n){return(a,r)=>a[n]=r}function Or(n,a){return(a.getter||p1(a.id))(n)}function sh(n,a,r){return(a.setter||g1(a.id))(n,r)}function v1(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 Ir(n,a){let r=Or(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 y1(n,a){const r=/\n|"|;|,/;let l="";const c=a.rows||`
|
|
13
|
+
`,d=a.cols||" ",m=n._columns,p=n.flatData;a.header!==!1&&m[0].header&&(l=Zy("header",m,l,d,c));for(let g=0;g<p.length;g++){const v=[];for(let w=0;w<m.length;w++){let x=Ir(p[g],m[w]);r.test(x)&&(x='"'+x.replace(/"/g,'""')+'"'),v.push(x)}l+=(l?c:"")+v.join(d)}return a.footer!==!1&&m[0].footer&&(l=Zy("footer",m,l,d,c)),l}function Zy(n,a,r,l,c){const d=/\n|"|;|,/;for(let m=0;m<a[0][n].length;m++){const p=[];for(let g=0;g<a.length;g++){let v=(a[g][n][m].text||"")+"";d.test(v)&&(v='"'+v.replace(/"/g,'""')+'"'),p.push(v)}r+=(r?c:"")+p.join(l)}return r}const x1="portrait",b1=100,w1="a4",S1={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function C1(n,a){const r=[];let l=[],c=0;const d=n.filter(p=>!p.hidden),m=j1(a);return d.forEach((p,g)=>{c+p.width<=m?(c+=p.width,l.push(p)):(l.length&&r.push(l),l=[p],c=p.width),g===d.length-1&&l.length&&r.push(l)}),r}function Jy(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 g={...m[p]};if(l[p][d]!==null){if(!d&&!g.rowspan&&!g.colspan){let v=1,w=n[d+v][a][p],x=g.width;for(;!w.rowspan&&!w.colspan;)v++,w=n[d+v][a][p],x+=w.width;g.colspan=v,g.width=x,g.height=r[p]}if(l[p].push(g),!g.collapsed&&g.colspan>1){let v=g.colspan-1;if(g.colspan+d>n.length){const w=g.colspan-(g.colspan+d-n.length);g.colspan=w,g.width=n.slice(d,d+v+1).reduce((x,b)=>x+b.width,0),w>1&&(v=w-1)}for(let w=0;w<v;w++)l[p].push(null)}if(g.rowspan>1){const v=g.rowspan;for(let w=1;w<v;w++)l[p+w]||(l[p+w]=[]),l[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<l.length;p++){const g=l[p],v=g[d];if(v&&v.collapsed){if(g[d]=null,!p)break}else{const w=v||g.findLast(x=>x?.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 j1(n){const{mode:a,ppi:r,paper:l}=n,{width:c,height:d}=S1[l];return k1(a==="portrait"?c:d,r)}function k1(n,a){return n*a}function A1(n={}){const{mode:a,ppi:r,paper:l}=n;return{mode:a||x1,ppi:r||b1,paper:l||w1}}function Gb(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 N1(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 ex=["resize-column","hide-column","update-cell"],M1=["delete-row","update-row","update-cell"],T1=["move-item"],E1=["resize-column","move-item"];class R1{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=Or(c,d);return rf(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(E1.includes(r)){(l.inProgress&&!this.progress[r]||typeof l.inProgress!="boolean")&&(T1.includes(r)&&this.setPrev("flatData"),ex.includes(r)&&this.setPrev("columns")),this.progress[r]=l.inProgress;return}M1.includes(r)&&this.setPrev("data"),ex.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]=Ih(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 Vb(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function D1(n,a){return-Vb(n,a)}function L1(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"?Vb:D1;return function(l,c){return r(Or(l,a),Or(c,a))}}function _1(n,a){if(!n||!n.length)return;const r=n.map(l=>{const c=a.find(d=>d.id==l.key);return L1(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 wd=28,z1=20;function I1(){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 Yd(n,a,r,l,c){const d=document.createElement("div"),m=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let g,v;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 x=d.getBoundingClientRect(),b=Math.ceil(x.width)+(l&&l.length?l[w]:0),C=Math.ceil(x.height);g=Math.max(g||0,b),v=Math.max(v||0,C)}return d.remove(),{width:g,height:v}}function tx(n,a,r,l,c){const d=[];for(let m=0;m<n.length;m++){const p=n[m][a],g=p.length;for(let v=0;v<g;v++){const{text:w,vertical:x,collapsed:b,rowspan:C,css:j}=p[v];if(!w){d[v]=Math.max(d[v]||0,l);continue}let A=0;if(x&&!b){let N=`wx-measure-cell-${a}`;if(N+=j?` ${j}`:"",A=Yd(w,N,c).width,(C>1||!p[v+1])&&r>v+1){const k=C||r-v,T=d.slice(v,v+k).reduce((R,U)=>R+U,0);if(T<A){const R=Math.ceil((A-T)/k);for(let U=v;U<v+k;U++)d[U]=(d[U]||l)+R}continue}}d[v]=Math.max(d[v]||l,A)}}return d}function O1(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],g=Ir(p,n);g&&(l.push(g),n.treetoggle?c.push(a[m].$level*wd+(a[m].$count?wd:0)+(n.draggable?wd:0)):n.draggable&&c.push(wd))}return Yd(l,d,r,c).width}function H1(n,a){const r="wx-measure-cell-header",l=n.sort?z1:0;let c=n.header;if(typeof c=="string")return Yd(c,r,a).width+l;let d;Array.isArray(c)||(c=[c]);for(let m=0;m<c.length;m++){const p=c[m],g=typeof p=="string"?p:p.text,v=r+(typeof p=="string"?"":` ${p.css}`);let w=Yd(g,v,a).width;m===c.length-1&&(w+=l),d=Math.max(d||0,w)}return d}const B1={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&&P1(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 Wb(n){return B1[n]}function F1(n,a){const r=[];for(const l in n){const c=a.find(g=>g.id==l),{config:d,type:m}=c.header.find(g=>g.filter).filter,p=n[l];r.push(g=>{const v=Or(g,c);return d?.handler?d.handler(v,p):Wb(m)(v,p)})}return l=>{for(let c=0;c<r.length;c++)if(!r[c](l))return!1;return!0}}function P1(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let $1=class extends f1{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 m1(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:d,sizes:m,_skin:p}=this.getState(),g=this.copyColumns(d),v=g.reduce((b,C)=>Math.max(C.header.length,b),0),w=g.reduce((b,C)=>Math.max(C.footer.length,b),0);g.forEach(this.setCollapsibleColumns);const x=this.normalizeSizes(g,m,v,w,p);for(let b=0;b<g.length;b++)this.normalizeColumns(g,b,"header",v,x),this.normalizeColumns(g,b,"footer",w,x);this.setState({_columns:g,_sizes:x},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:d,tree:m,dynamic:p,_filterIds:g}=this.getState(),v=g&&new Set(g),w=m?this.flattenRows(d,[],g):v?d.filter(b=>v.has(b.id)):d,x=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:x},c)}}],{sizes:c=>({...r,...c})});const l=this.in=new h1;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),g=d?this.getColumn(d):this.getNextEditor(p);if(g?.editor){let v=g.editor;if(typeof v=="function"&&(v=v(p,g)),!v)return;m={column:g.id,id:c,value:Or(p,g)??"",renderedValue:Ir(p,g),type:v.type||v},typeof v=="object"&&v.config&&(m.config=v.config,v.config.options&&(m.options=v.config.options)),g.options&&!m.options&&(m.options=g.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=Ir(p,m),this.setState({editor:d})}}),l.on("add-row",c=>{const d=this.getState();let{data:m}=d;const{select:p,_filterIds:g}=d,{row:v,before:w,after:x,select:b}=c;if(c.id=v.id=c.id||v.id||Sd(),w||x){const j=w||x,A=m.findIndex(N=>N.id===j);m=[...m],m.splice(A+(x?1:0),0,c.row)}else m=[...m,c.row];const C={data:m};g&&(C._filterIds=[...g,c.id]),this.setState(C),!(typeof b=="boolean"&&!b)&&(b||p)&&l.exec("select-row",{id:v.id,show:!0})}),l.on("delete-row",c=>{const{data:d,selectedRows:m,focusCell:p,editor:g}=this.getState(),{id:v}=c,w={data:d.filter(x=>x.id!==v)};this.isSelected(v)&&(w.selectedRows=m.filter(x=>x!==v)),g?.id===v&&(w.editor=null),this.setState(w),p?.row===v&&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:g,column:v,value:w}=c,x=this.getColumn(v);if(p){const b={...this._branches[g]};sh(b,x,w);const C=this.updateTreeRow(b);b.$parent===0&&(m=C)}else{const b=m.findIndex(j=>j.id===g),C={...m[b]};sh(C,x,w),m[b]=C}this.setState({data:m})}),l.on("update-row",c=>{let{data:d}=this.getState();const{id:m,row:p}=c,g=d.findIndex(v=>v.id===m);d=[...d],d[g]={...d[g],...p},this.setState({data:d})}),l.on("select-row",({id:c,toggle:d,range:m,mode:p,show:g,column:v})=>{const w=this.getState(),{focusCell:x}=w;let{selectedRows:b}=w;if(b.length||(m=d=!1),m){const{data:C}=this.getState();let j=C.findIndex(N=>N.id===b[b.length-1]),A=C.findIndex(N=>N.id===c);j>A&&([j,A]=[A,j]),C.slice(j,A+1).forEach(N=>{this.isSelected(N.id)||b.push(N.id)})}else if(d&&this.isSelected(c)){if(p===!0)return;b=b.filter(C=>C!==c)}else if(d){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),x?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),g&&this.in.exec("scroll",{row:c,column:v})}),this.in.on("focus-cell",c=>{const{row:d,column:m,eventSource:p}=c,{_columns:g,split:v}=this.getState();d&&m?(this.setState({focusCell:{row:d,column:m}}),p!=="click"&&((!v.left||g.findIndex(w=>w.id===c.column)>=v.left)&&(!v.right||g.findIndex(w=>w.id===c.column)<g.length-v.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:g}=c;if(g===!1)return;let v=c.width||0;const w=[...this.getState().columns],x=this.getColumn(d);if(m){if(m==="data"||m===!0){const{flatData:b,_skin:C}=this.getState();let j=b.length;p&&(j=Math.min(p,j));const A=b.slice(0,j);v=O1(x,A,C)}if(m==="header"||m===!0){const{_skin:b}=this.getState();v=Math.max(H1(x,b),v)}}x.width=Math.max(17,v),delete x.flexgrow,this.setState({columns:w})}),l.on("hide-column",c=>{const{id:d,mode:m}=c,p=[...this.getState().columns],g=this.getColumn(d),v=p.reduce((w,x)=>w+(x.hidden?0:1),0);!m||v>1?(g.hidden=!g.hidden,this.setState({columns:p})):c.skipUndo=!0}),l.on("sort-rows",c=>{const{key:d,add:m,sort:p}=c,g=this.getState(),{columns:v,data:w,tree:x}=g;if(p){const T=[...w];T.sort(p),this.setState({data:T});return}const{order:b="asc"}=c;let C=g.sortMarks;const j=Object.keys(C),A=j.length;!m||!A||A===1&&C[d]?C={[d]:{order:b}}:(A===1&&(C[j[0]]={...C[j[0]],index:0}),C={...C,[d]:{order:b,index:typeof m=="number"?m:C[d]?.index??A}});const N=Object.keys(C).sort((T,R)=>C[T].index-C[R].index).map(T=>({key:T,order:C[T].order}));this.setState({sortMarks:C});const k=_1(N,v);if(k){const T=[...w];x?this.sortTree(T,k):T.sort(k),this.setState({data:T})}}),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 g=this.getState(),{data:v,tree:w,_columns:x}=g;let b=g.filterValues;const C={};m&&(b={...b,[m]:d},C.filterValues=b);const j=p??F1(b,x);let A=[];w?A=this.filterTree(v,j,A):v.forEach(N=>{j(N)&&A.push(N.id)}),C._filterIds=A,this.setState(C)}),l.on("collapse-column",c=>{const{id:d,row:m,mode:p}=c,g=[...this.getState().columns],v=this.getColumn(d).header,w=Array.isArray(v)?v[m]:v;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:g}))}),l.on("move-item",c=>{const{id:d,inProgress:m}=c;let{target:p,mode:g="after"}=c;const{data:v,flatData:w,tree:x}=this.getState(),b=w.findIndex(A=>A.id===d);let C;if(g==="up"||g==="down"){if(g==="up"){if(b===0)return;C=b-1,g="before"}else if(g==="down"){if(b===w.length-1)return;C=b+1,g="after"}p=w[C]&&w[C].id}else C=w.findIndex(A=>A.id===p);if(b===-1||C===-1||m===!1)return;let j;x||(j=this.moveItem(d,p,v,g)),this.setState({data:x?this.normalizeTreeRows(j):j})}),l.on("copy-row",c=>{const{id:d,target:m,mode:p="after"}=c,g=this.getState(),{flatData:v,_filterIds:w}=g;let{data:x}=g;const b=this.getRow(d);if(!b)return;const C={...b,id:Sd()};c.id=C.id;const j=v.findIndex(N=>N.id===m);if(j===-1)return;x.splice(j+(p==="after"?1:0),0,C),x=[...x];const A={data:x};w&&(A._filterIds=[...w,C.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",g=`${c.fileName||"data"}.${p}`;if(p==="csv"){const v=y1(this.getState(),c.csv||{});c.download!==!1?v1(new Blob(["\uFEFF"+v],{type:"text/csv"}),g):c.result=v,d(!0)}else m()})),l.on("hotkey",({key:c,event:d,isInput:m})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:g,select:v}=this.getState();if(d.preventDefault(),m)return;const w=g?g.column:this._getFirstVisibleColumn()?.id,x=g?this.getPrevRow(g.row)?.id:p[p.length-1]?.id;w&&x&&(this.in.exec("focus-cell",{row:x,column:w,eventSource:"key"}),v&&this.in.exec("select-row",{id:x}));break}case"arrowdown":{const{flatData:p,focusCell:g,select:v}=this.getState();if(d.preventDefault(),m)return;const w=g?g.column:this._getFirstVisibleColumn()?.id,x=g?this.getNextRow(g.row)?.id:p[0]?.id;w&&x&&(this.in.exec("focus-cell",{row:x,column:w,eventSource:"key"}),v&&this.in.exec("select-row",{id:x}));break}case"arrowright":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const g=this.getNextColumn(p.column,!0)?.id;g&&this.in.exec("focus-cell",{row:p.row,column:g,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(m)return;if(d.preventDefault(),p){const g=this.getPrevColumn(p.column,!0)?.id;g&&this.in.exec("focus-cell",{row:p.row,column:g,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:g,select:v}=this.getState();if(p){d.preventDefault();const w=p.column;let x=p.id,b=this.getNextEditor(this.getRow(x),this.getColumn(w));if(!b){const C=this.getNextRow(x);C&&(x=C.id,b=this.getNextEditor(C))}b&&(this.in.exec("open-editor",{id:x,column:b.id}),this.in.exec("focus-cell",{row:x,column:b.id,eventSource:"key"}),v&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}else g&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:g,select:v}=this.getState();if(p){d.preventDefault();const w=p.column;let x=p.id,b=this.getPrevEditor(this.getRow(x),this.getColumn(w));if(!b){const C=this.getPrevRow(x);C&&(x=C.id,b=this.getPrevEditor(C))}b&&(this.in.exec("open-editor",{id:x,column:b.id}),this.in.exec("focus-cell",{row:x,column:b.id,eventSource:"key"}),v&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}else g&&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:g}=this.getState();!p&&g&&this.in.exec("open-editor",{id:g.row,column:g.column});break}case"enter":{const{focusCell:p,tree:g}=this.getState();if(!m&&g&&p&&this.getColumn(p.column).treetoggle){const v=this.getRow(p.row);if(!v.data)return;this.in.exec(v.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:g}=this.getState();if(!p&&g){d.preventDefault();const v=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:g.row,column:v,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:g,flatData:v,select:w}=this.getState();if(!p&&g){d.preventDefault();const x=v[0]?.id,b=this._getFirstVisibleColumn()?.id;x&&b&&(this.in.exec("focus-cell",{row:x,column:b,eventSource:"key"}),w&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}break}case"end":{const{editor:p,focusCell:g}=this.getState();if(!p&&g){d.preventDefault();const v=this._getLastVisibleColumn()?.id,w=g.row;this.in.exec("focus-cell",{row:w,column:v,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:g,flatData:v,select:w}=this.getState();if(!p&&g){d.preventDefault();const x=v.at(-1).id,b=this._getLastVisibleColumn()?.id;x&&b&&(this.in.exec("focus-cell",{row:x,column:b,eventSource:"key"}),w&&!this.isSelected(x)&&this.in.exec("select-row",{id:x}))}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:g,dynamic:v,_rowHeightFromData:w}=this.getState();let x=-1,b=-1,C=0,j=0;if(c.column){x=0;const A=d.findIndex(N=>N.id===c.column);C=d[A].width;for(let N=m.left??0;N<A;N++){const k=d[N];k.hidden||(x+=k.width)}}if(c.row&&!v){const A=g.findIndex(N=>N.id===c.row);A>=0&&(w?(b=g.slice(0,A).reduce((N,k)=>N+(k.rowHeight||p.rowHeight),0),j=g[A].rowHeight):b=p.rowHeight*A)}this.setState({scroll:{top:b,left:x,width:C,height:j||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=A1(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=I1()),a.columns&&a.columns.forEach(r=>{r.options&&(r.optionsMap=new Map(r.options.map(l=>[l.id,l.label])))}),rf(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 R1(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 g=d>0?a[d-1]:null;return g?.data&&g.open?a[d-1]={...g,data:[...g.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 g=c.length-d;c=c.slice(0,d+1),c[d].rowspan=g}const p=m.colspan;if(p){const g=c[d+1];let v=1;g&&g.colspan&&!g.collapsed&&(v=g.colspan);for(let w=v;w<p;w++){const x=l[r+w];x&&(x.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],g=d[`${l}RowHeights`];for(let v=0;v<c;v++){const w=p[v];w.id=m.id,v===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-v):c-v);for(let x=1;x<w.rowspan;x++){p.splice(v+x,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[r+b][l].splice(v+x,0,{})}if(w.rowspan){const x=(w.rowspan===c?g:g.slice(v,w.rowspan+v)).reduce((b,C)=>b+C,0);w.height=x,v+w.rowspan!=c&&w.height--}if(w.colspan){let x=m.width,b=m.flexgrow||0;const C=w.colspan;for(let j=1;j<C;j++){const A=a[r+j];A&&(A.hidden?w.colspan-=1:A.flexgrow?b+=A.flexgrow:x+=A.width||d.columnWidth),b?w.flexgrow=b:w.width=x}}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=Sd());return a}normalizeTreeRows(a,r,l){return!r&&!l&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=Sd()),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(v=>v.id==c),{config:m,type:p}=d.header.find(v=>v.filter).filter,g=a[c];l.push(v=>{const w=Or(v,d);return m?.handler?m.handler(w,g):Wb(p)(w,g)})}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 g={};m.forEach(v=>{const w=Ir(p,v);String(w).toLowerCase().includes(a)&&(g[v.id]=!0)}),Object.keys(g).length&&(l[p.id]=g)}),l}normalizeSizes(a,r,l,c,d){const m=tx(a,"header",l,r.headerHeight,d),p=tx(a,"footer",c,r.footerHeight,d),g=m.reduce((w,x)=>w+x,0),v=p.reduce((w,x)=>w+x,0);return{...r,headerRowHeights:m,footerRowHeights:p,headerHeight:g,footerHeight:v}}},U1=new Date().valueOf();function Sd(){return"temp://"+U1++}function q1(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 G1=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)}}},Eo=[],V1={subscribe:n=>{W1();const a=new G1;return Eo.push(a),n(a),()=>{const r=Eo.findIndex(l=>l===a);r>=0&&Eo.splice(r,1)}}},nx=!1;function W1(){nx||(nx=!0,document.addEventListener("keydown",n=>{if(Eo.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=Eo.length-1;c>=0;c--){const d=Eo[c],m=d.store.get(l)||d.store.get(r);m&&d.node.contains(n.target)&&m(n,{key:l,evKey:r})}}}))}const Y1={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 K1(n,{keys:a,exec:r}){if(!a)return;function l(m){const p=m.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||q1(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]=g=>{const v=l(g);r({key:m,event:g,isInput:v})}))}const d=V1.subscribe(m=>{m.configure(c,n)});return{destroy:()=>{d()}}}function Q1(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,g=a.getHeight(),v=a.getWidth(),w=a.getScrollMargin();if(d>=0){const x=n.scrollTop;d<x?n.scrollTop=d:d+m>x+g&&(n.scrollTop=d-g+m)}if(c>=0){const x=n.scrollLeft;c<x?n.scrollLeft=c:c+p>x+v-w&&(n.scrollLeft=c-v+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 Ka=u.createContext(null);function X1(n,a){const r=new ResizeObserver(l=>{requestAnimationFrame(()=>a(l[0].contentRect))});return r.observe(n.parentNode),{destroy(){r.disconnect()}}}const ax=5,Z1=700;function zd(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 Oh(n,a){const r=zd(a);return{x:n.clientX-r.x,y:n.clientY-r.y}}function J1(n,a){const r=a.current;let l=null,c,d,m=!1,p=!1;const g=document.createElement("DIV");g.className="wx-drag-zone",g.setAttribute("tabindex",-1);function v(){clearTimeout(c),c=null}function w(_){const D=Lo(_);D&&(l={container:g,sourceNode:_.target,from:nf(D),pos:Oh(_,n)},d=l.pos,x(_))}function x(_){if(!l)return;const D=l.pos=Oh(_,n);if(!m){if(!p&&!_?.target?.getAttribute("draggable-data")&&Math.abs(d.x-D.x)<ax&&Math.abs(d.y-D.y)<ax)return;if(O(_)===!1)return Y()}if(p){const ne=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,G=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;l.targetNode=document.elementFromPoint(_.pageX-ne,_.pageY-G)}else l.targetNode=_.target;r.move&&r.move(_,l),g.style.left=-(l.offset?l.offset.x:0)+"px",g.style.top=l.pos.y+(l.offset?l.offset.y:0)+"px"}function b(_){g.parentNode&&g.parentNode.removeChild(g),g.innerHTML="",m&&r.end&&r.end(_,l),l=d=null,Y()}function C(_){r.getReorder&&!r.getReorder()||_.button===0&&(U(_),window.addEventListener("mousemove",j),window.addEventListener("mouseup",A),w(_))}function j(_){x(_)}function A(_){b(_)}function N(_){if(r.getReorder&&!r.getReorder())return;c=setTimeout(()=>{p=!0,w(_.touches[0])},Z1),U(_);function D(){c&&v(),_.target.removeEventListener("touchmove",k),_.target.removeEventListener("touchend",D),b(_)}_.target.addEventListener("touchmove",k),_.target.addEventListener("touchend",D),n.addEventListener("contextmenu",T)}function k(_){m?(_.preventDefault(),x(_.touches[0])):c&&v()}function T(_){if(m||c)return _.preventDefault(),!1}function R(_){_.preventDefault()}function U(_){if(!r.getDraggableInfo)return;const{hasDraggable:D}=r.getDraggableInfo();(!D||_.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function O(_){if(m=!0,r.start){if(r.start(_,l)===!1)return!1;n.appendChild(g),document.body.style.cursor="move"}}function Y(_){m=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",A),_&&(n.removeEventListener("mousedown",C),n.removeEventListener("touchstart",N),n.removeEventListener("dragstart",R))}return n.addEventListener("mousedown",C),n.addEventListener("touchstart",N),n.addEventListener("dragstart",R),{destroy(){Y(!0)}}}const eA=.004;function tA(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function nA(n,a,r,l){const{node:c,left:d,top:m,bottom:p,sense:g,xScroll:v,yScroll:w}=l,x=Oh(n,c);r.scrollState||(r.scrollState=tA());let b=0,C=0;x.x<d+g?b=-1:x.x>a.width-g&&(b=1),x.y<m+Math.round(g/2)?C=-1:x.y>a.height-p-Math.round(g/2)&&(C=1),(r.scrollState.dirX!==b||r.scrollState.dirY!==C)&&(Yb(r),r.scrollState.dirX=b,r.scrollState.dirY=C),(v&&r.scrollState.dirX!==0||w&&r.scrollState.dirY!==0)&&aA(r,l,{x:r.scrollState.dirX,y:r.scrollState.dirY})}function aA(n,a,r){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(sA,15,n,a,r)},250))}function Yb(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function sA(n,a,r){const{x:l,y:c}=r;n.scrollSpeedFactor+=eA,l!==0&&rA(n,a,l),c!==0&&iA(n,a,c)}function iA(n,a,r){const l=a.node.scrollTop;Kb(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollTop",a)}function rA(n,a,r){const l=a.node.scrollLeft;Kb(l+Math.round(a.sense/3)*n.scrollSpeedFactor*r,"scrollLeft",a)}function Kb(n,a,r){r.node[a]=n}function lf(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 Qb(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 lA(n){const{row:a,column:r,cellStyle:l=null,columnStyle:c=null,children:d,focusable:m}=n,p=u.useContext(Ka),g=lt(p,"focusCell"),v=lt(p,"search"),w=lt(p,"reorder"),x=u.useMemo(()=>v?.rows[a.id]&&v.rows[a.id][r.id],[v,a.id,r.id]),b=u.useMemo(()=>lf(r.width,r.flexgrow,r.fixed,r.left,r.right),[r.width,r.flexgrow,r.fixed,r.left,r.right]);function C(O,Y){let _="wx-cell";return _+=r.fixed?" "+(r.fixed===-1?"wx-shadow":"wx-fixed"):"",_+=O?" "+O(r):"",_+=Y?" "+Y(a,r):"",_+=r.treetoggle?" wx-tree-cell":"",_}const j=u.useMemo(()=>C(c,l),[c,l,r,a]),A=u.useMemo(()=>typeof r.draggable=="function"?r.draggable(a,r)!==!1:r.draggable,[r,a]),N=u.useRef(null);u.useEffect(()=>{N.current&&m&&g?.row===a.id&&g?.column===r.id&&N.current.focus()},[g,m,a.id,r.id]);const k=u.useCallback(()=>{m&&!g&&p.exec("focus-cell",{row:a.id,column:r.id,eventSource:"focus"})},[p,m,g,a.id,r.id]);function T(O){const Y=new RegExp(`(${v.value.trim()})`,"gi");return String(O).split(Y).map(_=>({text:_,highlight:Y.test(_)}))}const R=u.useMemo(()=>{const O=r.fixed&&r.fixed.left===-1||r.fixed.right===-1,Y=r.fixed&&r.fixed.right;return[j,O?"wx-shadow":"",Y?"wx-fixed-right":""].filter(Boolean).join(" ")},[j,r]),U=r.cell;return s.jsxs("div",{className:"wx-TSCaXsGV "+R,ref:N,onFocus:k,style:b,"data-row-id":Pn(a.id),"data-col-id":Pn(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,U?s.jsx(U,{api:p,row:a,column:r,onAction:({action:O,data:Y})=>p.exec(O,Y)}):d?d():x?s.jsx("span",{children:T(Ir(a,r)).map(({highlight:O,text:Y},_)=>O?s.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:Y},_):s.jsx("span",{children:Y},_))}):Ir(a,r)]})}function sx(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 oA({filter:n,column:a,action:r,filterValue:l}){function c({value:d}){r({value:d,key:a.id})}return s.jsx(cp,{...n.config??{},value:l,onChange:c})}function cA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Ka),d=lt(c,"flatData"),m=u.useMemo(()=>n?.config?.options||a?.options||g(),[n,a,d]),p=u.useMemo(()=>n?.config?.template,[n]);function g(){const x=[];return d.forEach(b=>{const C=Or(b,a);x.includes(C)||x.push(C)}),x.map(b=>({id:b,label:b}))}function v({value:x}){r({value:x,key:a.id})}function w(x){x.key!=="Tab"&&x.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:w,children:s.jsx(Ck,{placeholder:"",clear:!0,...n?.config??{},options:m,value:l,onChange:v,children:x=>p?p(x):x.label})})}function uA({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(Sk,{placeholder:"",clear:!0,...n?.config??{},value:l,onChange:c})})}function Xb(n){const{value:a,options:r=[],placeholder:l="",clear:c=!1,text:d=null,template:m=null,cell:p=null,dropdown:g={},autoOpen:v=!1,onChange:w,onAction:x}=n,[b,C]=zb(a||[]),j=u.useMemo(()=>(b||[]).map(G=>r.find(te=>te.id===G)).filter(Boolean),[b,r]),A=u.useRef(null),N=u.useRef(null),[k,T]=u.useState(null),R=()=>{const G=b||[];if(!G.length)return 0;const te=r.find(B=>G.includes(B.id));return te?r.indexOf(te):0};function U(G){N.current=G.navigate,T(()=>G.keydown),v&&G.navigate(R())}u.useEffect(()=>{v&&(A.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function O({id:G}){C(G),w&&w({value:G})}function Y(G){G.stopPropagation(),C([]),w&&w({value:[]})}function _(){N.current?.(R())}function D(){N.current?.(null)}function ne(G){k?.(G,R())}return s.jsxs("div",{ref:A,className:"wx-multiselect wx-aadNNOwy",onClick:_,onKeyDown:ne,tabIndex:0,children:[s.jsx("div",{className:"wx-label wx-aadNNOwy",children:m?m(j):p?s.jsx(p,{data:j,onAction:x}):d?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:d}):j.length?s.jsx("span",{className:"wx-text wx-aadNNOwy",children:j.map(G=>G.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:Y}):s.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),s.jsx(sf,{items:r,onReady:U,onSelect:O,multiselect:!0,checkboxes:!0,value:b||[],onCancel:D,...g,children:({option:G})=>s.jsx("div",{className:"wx-option wx-aadNNOwy",children:m?m(G):p?s.jsx(p,{data:G,onAction:x}):G.label})})]})}function dA({filter:n,column:a,action:r,filterValue:l}){const c=u.useContext(Un.i18n)?.getGroup("grid")||Wc(fp).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(x=>a.optionsMap.get(x)).join(", "):w+" "+c("selected"):""},[l,a,c]);function g({value:w}){r({value:w,key:a.id})}function v(w){w.key!=="Tab"&&w.preventDefault()}return s.jsx("div",{style:{width:"100%"},onKeyDown:v,children:s.jsx(Xb,{placeholder:"",...d,options:m,value:l||[],text:p,onChange:g})})}const fA={text:oA,richselect:cA,datepicker:uA,multiselect:dA};function mA({filter:n,column:a}){const r=u.useContext(Ka),l=lt(r,"filterValues");function c(m){r.exec("filter-rows",m)}const d=u.useMemo(()=>fA[n.type],[n.type]);return s.jsx(d,{filter:n,column:a,action:c,filterValue:l[a.id]})}function hA(n){const{cell:a,column:r,row:l,lastRow:c,sortRow:d,columnStyle:m,bodyHeight:p,hasSplit:g}=n,v=u.useContext(Ka),w=lt(v,"sortMarks"),x=u.useMemo(()=>w?w[r.id]:void 0,[w,r.id]),b=u.useRef(),C=u.useCallback(se=>{b.current=a.flexgrow?se.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),j=u.useCallback((se,K)=>{v.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+se),inProgress:K})},[v,a.id]),A=u.useCallback(se=>j(se,!0),[j]),N=u.useCallback(se=>j(se,!1),[j]),k=u.useCallback(se=>{if(!r.sort||a.filter)return;let K=x?.order;K&&(K=K==="asc"?"desc":"asc"),v.exec("sort-rows",{key:a.id,add:se.ctrlKey||se.metaKey,order:K})},[v,a.id,a.filter,r.sort,x?.order]),T=u.useCallback(se=>{se&&se.stopPropagation(),v.exec("collapse-column",{id:a.id,row:l})},[v,a.id,l]),R=u.useCallback(se=>{se.key==="Enter"&&T()},[T]),U=u.useCallback(se=>{se.key==="Enter"&&!a.filter&&k(se)},[k,a.filter]),O=u.useMemo(()=>a.collapsed&&r.collapsed,[a.collapsed,r.collapsed]),Y=u.useMemo(()=>O&&!g&&a.collapsible!=="header",[O,g,a.collapsible]),_=u.useMemo(()=>Y?{top:-p/2,position:"absolute"}:{},[Y,p]),D=u.useMemo(()=>lf(a.width,a.flexgrow,r.fixed,r.left,a.right??r.right,a.height+(O&&Y?p:0)),[a.width,a.flexgrow,r.fixed,r.left,a.right,r.right,a.height,O,Y,p]),ne=u.useMemo(()=>Qb(r,a,m),[r,a,m]),G=u.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([se])=>se!=="cell")),[a]),te=`wx-cell ${ne} ${a.css||""} wx-collapsed`,B=["wx-cell",ne,a.css||"",a.filter?"wx-filter":"",r.fixed&&r.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),xe=u.useRef(null);return u.useEffect(()=>{const se=xe.current;if(!se)return;const K=sx(se,{down:C,move:A,up:N});return()=>{typeof K=="function"&&K()}},[C,A,N,sx]),O?s.jsx("div",{className:"wx-RsQD74qC "+te,style:D,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:T,"data-header-id":Pn(r.id),children:s.jsx("div",{className:"wx-RsQD74qC wx-text",style:_,children:a.text||""})}):s.jsxs("div",{className:"wx-RsQD74qC "+B,style:D,onClick:k,"data-header-id":Pn(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":!x?.order||a.filter?"none":x?.order==="asc"?"ascending":"descending",onKeyDown:U,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:T,children:s.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const se=a.cell;return s.jsx(se,{api:v,cell:G(),column:r,row:l,onAction:({action:K,data:I})=>v.exec(K,I)})})():a.filter?s.jsx(mA,{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:xe,onClick:se=>se.stopPropagation(),children:s.jsx("div",{})}):null,d?s.jsx("div",{className:"wx-RsQD74qC wx-sort",children:x?s.jsxs(s.Fragment,{children:[typeof x.index<"u"?s.jsx("div",{className:"wx-RsQD74qC wx-order",children:x.index+1}):null,s.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${x.order==="asc"?"up":"down"}`})]}):null}):null]})}function pA({cell:n,column:a,row:r,columnStyle:l}){const c=u.useContext(Ka),d=u.useMemo(()=>lf(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(()=>Qb(a,n,l),[a,n,l]),p=u.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([v])=>v!=="cell")),[n]),g=`wx-6Sdi3Dfd wx-cell ${m||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return s.jsx("div",{className:g,style:d,children:!a?.collapsed&&!n?.collapsed?n?.cell?Kh.createElement(n.cell,{api:c,cell:p(),column:a,row:r,onAction:({action:v,data:w})=>c.exec(v,w)}):s.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function ix({deltaLeft:n,contentWidth:a,columns:r,type:l="header",columnStyle:c,bodyHeight:d}){const m=u.useContext(Ka),p=lt(m,"_sizes"),g=lt(m,"split"),v=u.useMemo(()=>p?.[`${l}RowHeights`],[p,l]),w=u.useMemo(()=>{let A=[];if(r&&r.length){const N=r[0][l].length;for(let k=0;k<N;k++){let T=0;A.push([]),r.forEach((R,U)=>{const O={...R[l][k]};T||A[k].push(O),O.colspan>1?T=O.colspan-1:T&&T--})}}return A},[r,l]),x=u.useMemo(()=>g?.left||g?.right,[g]);function b(A){return r.find(N=>N.id===A)}function C(A,N){let k=N;return A.rowspan&&(k+=A.rowspan-1),k===w.length-1}function j(A,N,k){if(!k.sort)return!1;for(let T=w.length-1;T>=0;T--){const R=k.header[T];if(!R.filter&&!R._hidden)return N===T}return C(A,N)}return s.jsx("div",{className:`wx-sAsPVaUK wx-${l}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((A,N)=>s.jsx("div",{className:l==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${v?.[N]}px`,display:"flex"},role:"row",children:A.map(k=>{const T=b(k.id);return l==="header"?s.jsx(hA,{cell:k,columnStyle:c,column:T,row:N,lastRow:C(k,N),bodyHeight:d,sortRow:j(k,N,T),hasSplit:x},k.id):s.jsx(pA,{cell:k,columnStyle:c,column:b(k.id),row:N},k.id)})},N))})}function gA({overlay:n}){const a=u.useContext(Ka);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 vA(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=ni(p.current,()=>r(!0));return()=>w.destroy()},[r]);function g(){p.current&&(d(p.current.value),l(p.current.value))}function v({key:w}){w==="Enter"&&r()}return s.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:g,onKeyDown:v,ref:p,type:m,value:c})}function yA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d,m]=u.useState(n?.value),[p,g]=u.useState(n?.renderedValue),[v,w]=u.useState(n?.options||[]),x=u.useMemo(()=>n?.config?.template,[n]),b=u.useMemo(()=>n?.config?.cell,[n]),C=u.useMemo(()=>n?.config?.dropdown||{},[n]),j=u.useMemo(()=>({trackScroll:!0,...C}),[C]),A=u.useMemo(()=>(v||[]).findIndex(_=>_.id===d),[v,d]),N=u.useRef(null),k=u.useRef(null),T=u.useCallback(_=>{N.current=_.navigate,k.current=_.keydown,N.current(A)},[A,N]),R=u.useCallback(_=>{const D=_?.target?.value??"";g(D);const ne=D?(n?.options||[]).filter(G=>(G.label||"").toLowerCase().includes(D.toLowerCase())):n?.options||[];w(ne),ne.length?N.current(-1/0):N.current(null)},[n]),U=u.useRef(null);u.useEffect(()=>{U.current&&U.current.focus()},[]);const O=u.useRef(r);u.useEffect(()=>{O.current=r},[r]),u.useEffect(()=>{if(!U.current)return;const _=ni(U.current,()=>O.current(!0));return()=>_.destroy()},[]),u.useEffect(()=>{m(n?.value),g(n?.renderedValue),w(n?.options||[])},[n]);const Y=u.useCallback(({id:_})=>{l(_),r()},[l,r]);return s.jsxs(s.Fragment,{children:[s.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:U,value:p??"",onChange:R,onKeyDown:_=>k.current?k.current(_,A):void 0}),s.jsx(sf,{items:v,onReady:T,onSelect:Y,...j,onCancel:c,children:({option:_})=>x?x(_):b?s.jsx(b,{data:_,onAction:a}):_.label})]})}function xA({editor:n,onAction:a,onSave:r,onApply:l,onCancel:c}){const[d]=u.useState(()=>n.value||new Date),{template:m,cell:p,dropdown:g={}}=n?.config||{},v=u.useMemo(()=>({trackScroll:!0,width:"auto",...g}),[g]);function w({value:j}){l(j),r()}const x=u.useRef(null),[b,C]=u.useState(null);return u.useEffect(()=>{x.current&&x.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!b)return;const j=ni(b,()=>r(!0));return()=>j.destroy()},[b,r]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:x,tabIndex:0,onClick:c,onKeyDown:j=>j.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(op,{...v,onCancel:c,children:s.jsx("div",{ref:C,className:"wx-lNWNYUb6",children:s.jsx(Eb,{value:d,onChange:w,buttons:n.config?.buttons})})})]})}function bA(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,g=u.useMemo(()=>({trackScroll:!0,...p}),[p]),[v]=u.useState(a.options.find(R=>R.id===a.value)),[w]=u.useState(a.value),[x]=u.useState(a.options),b=u.useMemo(()=>x.findIndex(R=>R.id===w),[x,w]);function C({id:R}){c(R),l()}let j;const[A,N]=u.useState();function k(R){j=R.navigate,N(()=>R.keydown),j(b)}const T=u.useRef(null);return u.useEffect(()=>{T.current&&T.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),u.useEffect(()=>{if(!T.current)return;const R=ni(T.current,()=>l(!0));return()=>R.destroy()},[l]),s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:T,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:d,onKeyDown:R=>{A(R,b),R.preventDefault()},children:m.template?m.template(v):m.cell?(()=>{const R=m.cell;return s.jsx(R,{data:v,onAction:r})})():s.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),s.jsx(sf,{items:x,onReady:k,onSelect:C,...g,onCancel:d,children:({option:R})=>m.template?m.template(R):m.cell?(()=>{const U=m.cell;return s.jsx(U,{data:R,onAction:r})})():R.label})]})}function wA(n){const{editor:a,onAction:r,onSave:l,onApply:c}=n,d=a?.config||{},m=a?.options??[],p=a?.value||[],g=a?.renderedValue,v=u.useMemo(()=>({trackScroll:!0,...d.dropdown||{}}),[d]);function w({value:b}){c(b)}const x=u.useRef(null);return u.useEffect(()=>{if(!x.current)return;const b=ni(x.current,()=>l(!0));return()=>b.destroy()},[l]),s.jsx("div",{ref:x,className:"wx-value wx-aacZ4gNU",onClick:()=>l(!0),children:s.jsx(Xb,{value:p,options:m,text:g,template:d.template,cell:d.cell,clear:d.clear,dropdown:v,autoOpen:!0,onChange:w,onAction:r})})}const SA={text:vA,combo:yA,datepicker:xA,richselect:bA,multiselect:wA};function CA({column:n,row:a}){const r=u.useContext(Ka),l=lt(r,"editor"),c=u.useCallback((j,A)=>{r.exec("close-editor",{ignore:j}),A&&r.exec("focus-cell",{...A,eventSource:"click"})},[r]),d=u.useCallback(j=>{const A=j?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(j=>{r.exec("editor",{value:j})},[r]),g=u.useCallback(j=>{j.key==="Enter"&&l&&(n.editor.type==="multiselect"?p(l.value):m())},[l,n.editor,m,p]),v=u.useMemo(()=>lf(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=u.useMemo(()=>{let j=n.editor;if(typeof j=="function"&&(j=j(a,n)),!j)return null;let A=typeof j=="string"?j:j.type;return SA[A]},[n,a]),x=u.useRef(null);u.useEffect(()=>{x.current&&typeof v=="string"&&x.current.setAttribute("style",v)},[v]);const b=typeof a.$parent<"u"?"gridcell":"cell",C=typeof a.$parent<"u"?!n.editor:void 0;return s.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:x,style:typeof v=="object"&&v!==null?v:void 0,role:b,"aria-readonly":C,tabIndex:-1,onClick:j=>j.stopPropagation(),onDoubleClick:j=>j.stopPropagation(),onKeyDown:g,children:w?s.jsx(w,{editor:l,onSave:d,onApply:p,onCancel:m,onAction:({action:j,data:A})=>r.exec(j,A)}):null})}function rx(n){const{columns:a,type:r,columnStyle:l}=n,c=u.useContext(Ka),{filterValues:d,_columns:m,_sizes:p}=c.getState();function g(v){return l?" "+l(v):""}return s.jsx(s.Fragment,{children:a.map((v,w)=>s.jsx("tr",{children:v.map(x=>{const b=m.find(A=>A.id===x.id),C=`wx-print-cell-${r}${g(b)}${x.filter?" wx-print-cell-filter":""}${x.vertical?" wx-vertical":""}`,j=x.cell;return s.jsx("th",{style:Ib(Gb(x,p.columnWidth)),className:"wx-Gy81xq2u "+C,rowSpan:x.rowspan,colSpan:x.colspan,children:j?s.jsx(j,{api:c,cell:Object.fromEntries(Object.entries(x).filter(([A])=>A!=="cell")),column:b,row:w}):x.filter?s.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:N1(d,m,x)}):s.jsx("div",{className:"wx-Gy81xq2u wx-text",children:x.text??""})},x.id)})},w))})}function jA(n){const{columns:a,rowStyle:r,columnStyle:l,cellStyle:c,header:d,footer:m,reorder:p}=n,g=u.useContext(Ka),{flatData:v,_sizes:w}=g.getState(),x=d&&Jy(a,"header",w.headerRowHeights),b=m&&Jy(a,"footer",w.footerRowHeights);function C(A,N){let k="";return k+=l?" "+l(N):"",k+=c?" "+c(A,N):"",k}function j(A,N){return typeof N.draggable=="function"?N.draggable(A,N)!==!1:N.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(rx,{columns:x,type:"header",columnStyle:l})}):null,s.jsx("tbody",{children:v.map((A,N)=>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 ${C(A,k)}`,style:Ib(Gb(k,w.columnWidth)),children:[p&&k.draggable?s.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:j(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 T=k.cell;return s.jsx(T,{api:g,row:A,column:k})})():s.jsx("span",{children:Ir(A,k)})]},k.id))},N))}),m?s.jsx("tfoot",{children:s.jsx(rx,{columns:b,type:"footer",columnStyle:l})}):null]})}function kA(n){const{config:a,...r}=n,l=u.useContext(Ka),{_skin:c,_columns:d}=l.getState(),m=u.useMemo(()=>C1(d,a),[]),p=u.useRef(null);return u.useEffect(()=>{const g=document.body;g.classList.add("wx-print");const v=p.current;if(!v)return;const w=v.cloneNode(!0);g.appendChild(w);const x=`@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(x)),window.print(),b.remove(),g.classList.remove("wx-print"),w.remove()},[]),s.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:m.map((g,v)=>s.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:s.jsx(jA,{columns:g,...r})},v))})}function AA(n){const{header:a,footer:r,overlay:l,multiselect:c,onreorder:d,rowStyle:m,columnStyle:p,cellStyle:g,autoRowHeight:v,resize:w,clientWidth:x,clientHeight:b,responsiveLevel:C,hotkeys:j}=n,A=u.useContext(Ka),N=lt(A,"dynamic"),k=lt(A,"_columns"),T=lt(A,"flatData"),R=lt(A,"split"),U=lt(A,"_sizes"),[O,Y]=hs(A,"selectedRows"),_=lt(A,"select"),D=lt(A,"editor"),ne=lt(A,"scrollLeft"),G=lt(A,"scrollTop"),te=lt(A,"tree"),B=lt(A,"focusCell"),xe=lt(A,"_print"),se=lt(A,"undo"),K=lt(A,"reorder"),I=lt(A,"_rowHeightFromData"),[Q,q]=u.useState(0);u.useEffect(()=>{q(ps())},[]);const[V,ce]=u.useState(0),be=u.useMemo(()=>(k||[]).some(ee=>!ee.hidden&&ee.flexgrow),[k]),X=u.useMemo(()=>U?.rowHeight||0,[U]),$=u.useRef(null),[ue,he]=u.useState(null),[ve,Se]=u.useState(null),_e=u.useMemo(()=>{let ee=[],Ne=0;return R&&R.left&&(ee=(k||[]).slice(0,R.left).filter(qe=>!qe.hidden).map(qe=>({...qe})),ee.forEach(qe=>{qe.fixed={left:1,leftSize:R.left},qe.left=Ne,Ne+=qe.width}),ee.length&&(ee[ee.length-1].fixed.left=-1)),{columns:ee,width:Ne}},[R,k]),re=u.useMemo(()=>{let ee=[],Ne=0;if(R&&R.right){ee=(k||[]).slice(R.right*-1).filter(qe=>!qe.hidden).map(qe=>({...qe}));for(let qe=ee.length-1;qe>=0;qe--){const rt=ee[qe];rt.fixed={right:1},rt.right=Ne,Ne+=rt.width}ee.length&&(ee[0].fixed={right:-1})}return{columns:ee,width:Ne}},[R,k]),Z=u.useMemo(()=>{const ee=(k||[]).slice(R?.left||0,(k||[]).length-(R?.right??0)).filter(Ne=>!Ne.hidden);return ee.forEach(Ne=>{Ne.fixed=0}),ee},[k,R]),ze=u.useMemo(()=>(k||[]).reduce((ee,Ne)=>(Ne.hidden||(ee+=Ne.width),ee),0),[k]),Le=1;function ae(ee,Ne,qe){let rt=Ne,Nt=ee;if(Z.length){let Mt=Z.length;for(let Qe=ee;Qe>=0;Qe--)Z[Qe][qe].forEach(ut=>{ut.colspan>1&&Qe>ee-ut.colspan&&Qe<Mt&&(Mt=Qe)});if(Mt!==Z.length&&Mt<ee){for(let Qe=Mt;Qe<ee;Qe++)rt-=Z[Qe].width;Nt=Mt}}return{index:Nt,delta:rt}}const fe=u.useMemo(()=>{let ee,Ne,qe;const rt=ne||0,Nt=(ne||0)+(x||0);let Mt=0,Qe=0,ut=0,kn=0;Z.forEach((cn,vn)=>{rt>ut&&(Mt=vn,kn=ut),ut=ut+cn.width,Nt>ut&&(Qe=vn+Le)});const Wt={header:0,footer:0};for(let cn=Qe;cn>=Mt;cn--)["header","footer"].forEach(vn=>{Z[cn]&&Z[cn][vn].forEach(Fr=>{const zs=Fr.colspan;if(zs&&zs>1){const Pr=zs-(Qe-cn+1);Pr>0&&(Wt[vn]=Math.max(Wt[vn],Pr))}})});const An=ae(Mt,kn,"header"),St=ae(Mt,kn,"footer"),rn=An.delta,Pt=An.index,xa=St.delta,ca=St.index;return be&&ze>(x||0)?ee=Ne=qe=[..._e.columns,...Z,...re.columns]:(ee=[..._e.columns,...Z.slice(Mt,Qe+1),...re.columns],Ne=[..._e.columns,...Z.slice(Pt,Qe+Wt.header+1),...re.columns],qe=[..._e.columns,...Z.slice(ca,Qe+Wt.footer+1),...re.columns]),{data:ee||[],header:Ne||[],footer:qe||[],d:kn,df:xa,dh:rn}},[Z,_e,re,ne,x,be,ze]),Ae=u.useMemo(()=>a&&U?.headerHeight||0,[a,U]),Te=u.useMemo(()=>r&&U?.footerHeight||0,[r,U]),Be=u.useMemo(()=>x&&b?ze>=x:!1,[x,b,ze]),[Ve,Je]=u.useState(!1),Et=u.useMemo(()=>(b||0)-Ae-Te-(Be?Q:0),[b,Ae,Te,Be,Q]),je=u.useMemo(()=>Math.ceil((Et||0)/(X||1))+1,[Et,X]),We=u.useRef([]),[it,ot]=u.useState(0),[gn,Kt]=u.useState(void 0),Ie=u.useMemo(()=>{let ee=0,Ne=0;const qe=2,rt=G||0;if(v){let Qe=rt;for(;Qe>0;)Qe-=We.current[ee]||X,ee++;Ne=rt-Qe;for(let ut=Math.max(0,ee-qe-1);ut<ee;ut++)Ne-=We.current[ee-ut]||X;ee=Math.max(0,ee-qe)}else{if(I){let Qe=0,ut=0;for(let St=0;St<(T||[]).length;St++){const rn=T[St].rowHeight||X;if(ut+rn>rt){Qe=St;break}ut+=rn}ee=Math.max(0,Qe-qe);for(let St=0;St<ee;St++)Ne+=T[St].rowHeight||X;let kn=0,Wt=0;for(let St=Qe+1;St<(T||[]).length;St++){const rn=T[St].rowHeight||X;if(kn++,Wt+rn>Et)break;Wt+=rn}const An=Math.min(N?N.rowCount:(T||[]).length,Qe+kn+qe);return{d:Ne,start:ee,end:An}}ee=Math.floor(rt/(X||1)),ee=Math.max(0,ee-qe),Ne=ee*(X||0)}const Nt=N?N.rowCount:(T||[]).length,Mt=Math.min(Nt,ee+(je||0)+qe);return{d:Ne,start:ee,end:Mt}},[v,I,G,X,N,T,je,Et]),ct=u.useMemo(()=>{const ee=N?N.rowCount:(T||[]).length;if(v)return it+Ie.d+(ee-(gn||0))*(X||0);if(!I)return ee*(X||0);let Ne=0;for(let qe=0;qe<ee;qe++)Ne+=T[qe]?.rowHeight||X;return Ne},[N,T,X,v,I,it,Ie.d,gn]),_t=u.useRef({});_t.current={clientWidth:x,clientHeight:b,fullHeight:ct,headerHeight:Ae,footerHeight:Te,fullWidth:ze,SCROLLSIZE:Q};const Ft=u.useCallback(()=>{const ee=_t.current;Je(ee.clientWidth&&ee.clientHeight?ee.fullHeight+ee.headerHeight+ee.footerHeight>=ee.clientHeight-(ee.fullWidth>=ee.clientWidth?ee.SCROLLSIZE:0):!1)},[]);u.useEffect(()=>{const ee=requestAnimationFrame(Ft);return()=>window.cancelAnimationFrame(ee)},[V,Ft]),u.useEffect(()=>{Ft()},[b,Ft]);const ge=u.useMemo(()=>be&&ze<=(x||0)?(x||0)-0-(Ve?Q:0):ze,[be,ze,x,Ve,Q,Be]),Oe=u.useMemo(()=>be&&ze<=(x||0)?x||0:ge<(x||0)?ze+(Ve?Q:0):-1,[be,ze,x,ge,Ve,Q]),Fe=u.useRef({});u.useEffect(()=>{if(N&&(Fe.current.start!==Ie.start||Fe.current.end!==Ie.end)){const{start:ee,end:Ne}=Ie;Fe.current={start:ee,end:Ne},A&&A.exec&&A.exec("request-data",{row:{start:ee,end:Ne}})}},[N,Ie,A]);const ke=u.useMemo(()=>N?T||[]:(T||[]).slice(Ie.start,Ie.end),[N,T,Ie]),st=u.useMemo(()=>(O||[]).filter(ee=>(ke||[]).some(Ne=>Ne.id===ee)),[Y,ke]),gt=u.useMemo(()=>Ie.start,[Ie.start]),Re=u.useRef({top:G,left:ne});Re.current={top:G,left:ne};const jn=u.useCallback(ee=>{const Ne=ee.target.scrollTop,qe=ee.target.scrollLeft,rt=Re.current;(Ne!==rt.top||qe!==rt.left)&&A.exec("scroll-to",{top:Ne,left:qe})},[A]),Ls=u.useCallback(ee=>{ee.shiftKey&&ee.preventDefault(),$.current&&$.current.focus&&$.current.focus()},[]),nt=u.useCallback(()=>!!(k||[]).find(ee=>!!ee.draggable),[k]),zt=u.useRef(null),zn=u.useRef(null),He=u.useRef({dblclick:(ee,Ne)=>{const qe={id:ee,column:Gc(Ne,"data-col-id")};A.exec("open-editor",qe)},click:(ee,Ne)=>{if(Ne.target.closest("input")||zt.current)return;const qe=Gc(Ne,"data-col-id");if(B?.id!==ee&&A.exec("focus-cell",{row:ee,column:qe,eventSource:"click"}),_===!1)return;const rt=c&&(Ne.ctrlKey||Ne.metaKey),Nt=c&&Ne.shiftKey;(rt||O.length>1||!O.includes(ee))&&A.exec("select-row",{id:ee,toggle:rt,range:Nt})},"toggle-row":ee=>{const Ne=A.getRow(ee);A.exec(Ne.open!==!1?"close-row":"open-row",{id:ee})},"ignore-click":()=>!1}),ya=u.useMemo(()=>({top:Ae,bottom:Te,left:_e.width,xScroll:Be,yScroll:Ve,sense:v&&ve?ve.offsetHeight:Math.max(U?.rowHeight||0,40),node:$.current&&$.current.firstElementChild}),[Ae,Te,_e.width,Be,Ve,v,ve,U]);function dt(ee,Ne){const{container:qe,sourceNode:rt,from:Nt}=Ne;if(nt()&&!rt.getAttribute("draggable-data"))return!1;he(Nt),te&&A.getRow(Nt).open&&A.exec("close-row",{id:Nt,nested:!0});const Mt=Lo(rt),Qe=Mt.cloneNode(!0);Qe.classList.remove("wx-selected"),Qe.querySelectorAll("[tabindex]").forEach(An=>An.setAttribute("tabindex","-1")),qe.appendChild(Qe),Se(Qe);const ut=(ne||0)-fe.d,kn=Ve?Q:0;qe.style.width=Math.min((x||0)-kn,be&&ze<=(x||0)?ge:ge-kn)+ut+"px";const Wt=zd(Mt);Ne.offset={x:ut,y:-Math.round(Wt.height/2)},zn.current||(zn.current=ee.clientY)}function Hi(ee,Ne){const{from:qe}=Ne,rt=Ne.pos,Nt=zd($.current);rt.x=Nt.x;const Mt=ya.top;if(rt.y<Mt)rt.y=Mt;else{const Qe=Nt.height-(Be&&Q>0?Q:Math.round(ya.sense/2))-ya.bottom;rt.y>Qe&&(rt.y=Qe)}if($.current.contains(Ne.targetNode)){const Qe=Lo(Ne.targetNode),ut=Qe&&nf(Qe);if(ut&&ut!==qe){Ne.to=ut;const kn=v?ve?.offsetHeight:U?.rowHeight;if(ve&&((G||0)===0||rt.y>Mt+kn-1)){const Wt=Qe.getBoundingClientRect(),An=zd(ve).y,St=Wt.y,rn=An>St?-1:1,Pt=rn===1?"after":"before",xa=A.getState().flatData,ca=Math.abs(xa.findIndex(vn=>vn.id===qe)-xa.findIndex(vn=>vn.id===ut)),cn=ca!==1?Pt==="before"?"after":"before":Pt;if(ca===1&&(rn===-1&&ee.clientY>zn.current||rn===1&&ee.clientY<zn.current))return;zn.current=ee.clientY,A.exec("move-item",{id:qe,target:ut,mode:cn,inProgress:!0})}}d&&d({event:ee,context:Ne})}nA(ee,Nt,Ne,ya)}function Qt(ee,Ne){const{from:qe,to:rt}=Ne;A.exec("move-item",{id:qe,target:rt,inProgress:!1}),zt.current=setTimeout(()=>{zt.current=0},1),he(null),Se(null),zn.current=null,Yb(Ne)}function ps(){const ee=document.createElement("div");ee.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(ee);const Ne=ee.offsetWidth-ee.clientWidth;return document.body.removeChild(ee),Ne}const bt=u.useMemo(()=>Oe>0?{width:`${Oe}px`}:void 0,[Oe]),qn=u.useRef(null);function _s(){Promise.resolve().then(()=>{let ee=0,Ne=gt;const qe=qn.current;qe&&(Array.from(qe.children).forEach((rt,Nt)=>{We.current[gt+Nt]=rt.offsetHeight,ee+=rt.offsetHeight,Ne++}),ot(ee),Kt(Ne))})}u.useEffect(()=>{ke&&v&&_s()},[ke,v,gt]);let[H,Pe]=u.useState();u.useEffect(()=>{if(B&&(!_||!st.length||st.includes(B.row)))Pe({...B});else if(ke.length&&fe.data.length){if(!H||st.length&&!st.includes(H.row)||ke.findIndex(ee=>ee.id===H.row)===-1||fe.data.findIndex(ee=>ee.id===H.column&&!ee.collapsed)===-1){const ee=st[0]||ke[0].id,Ne=fe.data.findIndex(qe=>!qe.collapsed);Pe(Ne!==-1?{row:ee,column:fe.data[Ne].id}:null)}}else Pe(null)},[B]);const vt=u.useRef(null);u.useEffect(()=>{const ee=$.current;if(!ee)return;const Ne=X1(ee,w);return()=>{typeof Ne=="function"&&Ne()}},[w]);const sn=u.useRef({});Object.assign(sn.current,{start:dt,move:Hi,end:Qt,getReorder:()=>K,getDraggableInfo:()=>({hasDraggable:nt()})}),u.useEffect(()=>{const ee=$.current;return ee?J1(ee,sn).destroy:void 0},[K,$.current]),u.useEffect(()=>{const ee=$.current;return ee?K1(ee,{keys:j!==!1&&{...Y1,"ctrl+z":se,"ctrl+y":se,...j},exec:Ne=>A.exec("hotkey",Ne)}).destroy:void 0},[A,se,j]);const Qa=u.useRef({scroll:A.getReactiveState().scroll,scrollLeft:A.getReactiveState().scrollLeft,scrollTop:A.getReactiveState().scrollTop});Qa.current.getWidth=()=>(x||0)-(Ve?Q:0),Qa.current.getHeight=()=>Et,Qa.current.getScrollMargin=()=>_e.width+re.width,u.useEffect(()=>{Q1(vt.current,Qa.current)},[]);const Br=u.useRef(null);u.useEffect(()=>{const ee=Br.current;if(!ee)return;const Ne=[];Ne.push(ni(ee,()=>B&&A.exec("focus-cell",{eventSource:"click"})).destroy),Ne.push(Jk(ee,He.current)),ce(ee.clientHeight);const qe=new ResizeObserver(()=>{ce(ee.clientHeight)});return qe.observe(ee),Ne.push(()=>qe.disconnect()),()=>Ne.forEach(rt=>rt())},[]);const Xa=`wx-grid ${C?`wx-responsive-${C}`:""}`;return u.useEffect(()=>{B&&(ke.some(ee=>ee.id===B.row)&&fe.data.some(ee=>ee.id===B.column&&!ee.collapsed)||A.exec("focus-cell",{eventSource:"destroy"}))},[B,ke,fe.data,A]),s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"wx-4VuBwK2D "+Xa,style:{"--header-height":`${Ae}px`,"--footer-height":`${Te}px`,"--split-left-width":`${_e.width}px`,"--split-right-width":`${re.width}px`},children:s.jsx("div",{ref:$,className:"wx-4VuBwK2D wx-table-box",style:bt,role:te?"treegrid":"grid","aria-colcount":fe.data.length,"aria-rowcount":ke.length,"aria-multiselectable":te&&c?!0:void 0,tabIndex:-1,children:s.jsxs("div",{ref:vt,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:Be?"scroll":"hidden",overflowY:Ve?"scroll":"hidden"},onScroll:jn,children:[a?s.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:s.jsx(ix,{contentWidth:ge,deltaLeft:fe.dh,columns:fe.header,columnStyle:p,bodyHeight:Et-+r})}):null,s.jsxs("div",{ref:Br,className:"wx-4VuBwK2D wx-body",style:{width:`${ge}px`,height:`${ct}px`},onMouseDown:ee=>Ls(ee),children:[l?s.jsx(gA,{overlay:l}):null,s.jsx("div",{ref:qn,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${Ie.d}px`,paddingLeft:`${fe.d}px`},children:ke.map((ee,Ne)=>{const qe=O.indexOf(ee.id)!==-1,rt=ue===ee.id,Nt="wx-row"+(v?" wx-autoheight":"")+(m?" "+m(ee):"")+(qe?" wx-selected":"")+(rt?" wx-inactive":""),Mt=v?{minHeight:`${ee.rowHeight||X}px`}:{height:`${ee.rowHeight||X}px`};return s.jsx("div",{className:"wx-4VuBwK2D "+Nt,"data-id":Pn(ee.id),"data-context-id":Pn(ee.id),style:Mt,role:"row","aria-rowindex":Ne,"aria-expanded":ee.open,"aria-level":te?ee.$level+1:void 0,"aria-selected":te?qe:void 0,tabIndex:-1,children:fe.data.map(Qe=>Qe.collapsed?s.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},Qe.id):D?.id===ee.id&&D.column===Qe.id?s.jsx(CA,{row:ee,column:Qe},Qe.id):s.jsx(lA,{row:ee,column:Qe,columnStyle:p,cellStyle:g,reorder:K,focusable:H?.row===ee.id&&H?.column===Qe.id},Qe.id))},ee.id)})})]}),r&&(T||[]).length?s.jsx(ix,{type:"footer",contentWidth:ge,deltaLeft:fe.df,columns:fe.footer,columnStyle:p}):null]})})}),xe?s.jsx(kA,{config:xe,rowStyle:m,columnStyle:p,cellStyle:g,header:a,footer:r,reorder:K}):null]})}const NA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),MA=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:g=!0,footer:v=!1,dynamic:w=null,overlay:x=null,reorder:b=!1,onReorder:C=null,autoRowHeight:j=!1,sizes:A,split:N,tree:k=!1,autoConfig:T=!1,init:R=null,responsive:U=null,sortMarks:O,undo:Y=!1,hotkeys:_=null,filterValues:D,...ne},G){const te=u.useRef();te.current=ne;const B=u.useMemo(()=>new $1(Ob),[]),xe=u.useMemo(()=>B.in,[B]),se=u.useRef(null);se.current===null&&(se.current=new Rb((re,Z)=>{const ze="on"+NA(re);te.current&&te.current[ze]&&te.current[ze](Z)}),xe.setNext(se.current));const K=u.useMemo(()=>({getState:B.getState.bind(B),getReactiveState:B.getReactive.bind(B),getStores:()=>({data:B}),exec:xe.exec,setNext:re=>(se.current=se.current.setNext(re),se.current),intercept:xe.intercept.bind(xe),on:xe.on.bind(xe),detach:xe.detach.bind(xe),getRow:B.getRow.bind(B),getColumn:B.getColumn.bind(B)}),[B,xe]),[I,Q]=u.useState(0),[q,V]=u.useState(0),[ce,be]=u.useState(null),[X,$]=u.useState(null),ue=u.useMemo(()=>{if(T&&!a.length&&n.length){const re=n[0],Z=[];for(let ze in re)if(ze!=="id"&&ze[0]!=="$"){let Le={id:ze,header:ze[0].toUpperCase()+ze.slice(1)};typeof T=="object"&&(Le={...Le,...T}),Z.push(Le)}return Z}return(X&&X.columns)??a},[T,a,n,X]),he=u.useMemo(()=>(X&&X.sizes)??A,[X,A]),ve=u.useCallback(re=>{if(Q(re.width),V(re.height),U){const Z=Object.keys(U).map(Number).sort((ze,Le)=>ze-Le).find(ze=>re.width<=ze)??null;Z!==ce&&($(U[Z]),be(Z))}},[U,ce]),Se=u.useContext(Un.theme),_e=u.useRef(0);return u.useEffect(()=>{if(!_e.current)R&&R(K);else{const re=B.getState();B.init({data:n,columns:ue,split:N||re.split,sizes:he||re.sizes,selectedRows:d||re.selectedRows,dynamic:w,tree:k,sortMarks:O||re.sortMarks,filterValues:D||re.filterValues,undo:Y,reorder:b,_skin:Se,_select:m})}_e.current++},[B,n,ue,N,he,d,w,k,O,D,Y,b,Se,m,R,K]),_e.current===0&&B.init({data:n,columns:ue,split:N||{left:0},sizes:he||{},selectedRows:d||[],dynamic:w,tree:k,sortMarks:O||{},filterValues:D||{},undo:Y,reorder:b,_skin:Se,select:m}),u.useImperativeHandle(G,()=>({...K}),[K]),s.jsx(Ka.Provider,{value:K,children:s.jsx(dp,{words:fp,optional:!0,children:s.jsx(AA,{header:g,footer:v,overlay:x,rowStyle:r,columnStyle:l,cellStyle:c,onReorder:C,multiselect:p,autoRowHeight:j,clientWidth:I,clientHeight:q,responsiveLevel:ce,resize:ve,hotkeys:_})})})});sp(La);const $n=u.createContext(null),pp=u.createContext(null),gp=u.createContext(null);function TA({children:n}){const a=u.useContext(Un.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=u.useContext($n),[c]=hs(l,"panels"),d=lt(l,"activePanel"),m=c[d].path,[p,g]=u.useState(null),[v,w]=u.useState(null),[x,b]=u.useState(""),[C,j]=u.useState(""),[A,N]=u.useState(!1);function k(){const O=x.trim();if(!O){N(!0);return}p.add?l.exec("create-file",{file:{...p.item,name:O},parent:m}):C!==O&&l.exec("rename-file",{id:p.item.id,name:O}),T()}function T(){g(null),N(null),j(""),b("")}function R(){l.exec("delete-files",{ids:v.selected}),w(null)}const U=u.useMemo(()=>({showPrompt(O){const Y=O.item.name||(O.item.type==="folder"?r("New folder"):`${r("New file")}.txt`);j(Y),b(Y),g({...O})},showConfirm(O){w({...O})}}),[r]);return s.jsxs(pp.Provider,{value:U,children:[s.jsx(Tk,{children:n}),p?s.jsx(zh,{title:r(`Enter ${p.item.type} name`),onConfirm:k,onCancel:T,children:s.jsx(cp,{error:A,select:!0,focus:!0,value:x,onChange:({value:O})=>b(O)})}):null,v?s.jsx(zh,{title:r("Are you sure you want to delete these items:"),onConfirm:R,onCancel:()=>w(null),children:v.selected?s.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:v.selected.map((O,Y)=>s.jsx("li",{children:O},Y))}):null}):null]})}let lx={"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 EA(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 RA({item:n}){const a=u.useContext($n),r=u.useContext(Un.i18n).getGroup("filemanager"),l=u.useContext($n).templates,[c]=hs(a,"panels"),d=lt(a,"activePanel"),m=lt(a,"mode"),p=c[d].selected,g=u.useMemo(()=>l.preview(n,214,163),[l,n]),v=u.useMemo(()=>l.icon(n,"big"),[l,n]),[w,x]=u.useMemo(()=>EA(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":Pn("/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":Pn(n.id),children:[g?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:g})}):v?s.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:s.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:v})}):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:x})]})]}),s.jsx("div",{"data-action-id":Pn(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:x})]})}),s.jsx("div",{"data-action-id":Pn(n.id),className:"wx-GAOa4kDV wx-more",children:s.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function Zb(){const n=u.useContext($n),a=u.useContext(Un.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),[l]=hs(n,"panels"),c=lt(n,"activePanel"),d=lt(n,"mode"),m=l[c]._files,p=l[c].selected,g=l[c].path,v=l[c]._crumbs,w=l[c]._selectNavigation,x=u.useCallback((T,R)=>{const U=R&&(R.ctrlKey||R.metaKey),O=R&&R.shiftKey;if(T==="/wx-filemanager-parent-link"){if(p.length&&(U||O))return;n.exec("select-file",{type:"navigation"});return}let Y=T==="body"&&R?null:T;const _=R.target.className.indexOf("wx-more")!==-1||R.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:Y,toggle:U&&!_,range:O&&!_,panel:c})},1)},[n,p,c]),b=u.useCallback(()=>{v.length>1&&n.exec("set-path",{id:v[v.length-2].id,panel:c,selected:[v[v.length-1].id]})},[n,v,c]),C=u.useCallback(T=>{if(T==="/wx-filemanager-parent-link")return b();d==="search"&&n.exec("filter-files",{text:""});const R=m.find(U=>U.id===T);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]),j=u.useCallback((T,R)=>{(!p?.length||!p.filter(U=>U?.id===T).length>0)&&x(T,R)},[p,x]),A=u.useMemo(()=>g!=="/"?[{id:"/wx-filemanager-parent-link",name:r("Back to parent folder"),navigation:w},...m]:m,[g,r,w,m]),N=u.useRef(null),k=u.useRef();return u.useEffect(()=>{N.current&&(k.current?(k.current.click=x,k.current._dblclick=C,k.current.context=j):(k.current={click:x,dblclick:T=>k.current._dblclick(T),_dblclick:C,context:j},_o(N.current,k.current)))},[x,C,j]),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"+(g!=="/"&&d!=="search"?" wx-has-back-link":"")),"data-id":Pn("body"),ref:N,children:A.map(T=>s.jsx(RA,{item:T},T.id))})}function _l({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 DA(){const n=u.useContext(Un.i18n).getGroup("filemanager"),a=u.useContext($n),r=lt(a,"activePanel"),[l]=hs(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(_l,{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(Zb,{})]})}function ih({narrowMode:n,extraInfo:a}){const r=u.useContext($n),{preview:l,icon:c}=r.templates,d=u.useContext(Un.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>To("%D, %d %F %Y, %H:%i",d.getRaw().calendar),[d]),[g,v]=hs(r,"panels"),w=lt(r,"activePanel"),x=lt(r,"preview"),b=lt(r,"search"),C=u.useMemo(()=>{const _=g&&w!=null&&g[w]?._selected?.length||0;return b&&!_},[b,v,w]),j=u.useMemo(()=>{const _=g&&w!=null?g[w]:null;return _?C?_._files:_._selected:[]},[C,v,w]),A=u.useCallback((_,D)=>(_?`${_} ${m(_>1?"folders":"folder")} `:"")+(D?`${D} ${m(D>1?"files":"file")}`:""),[m]),N=u.useCallback(()=>{r.exec("show-preview",{mode:!x})},[r,x]),k=u.useCallback(_=>_.type==="folder"?m("Folder"):_.ext||m("Unknown file"),[m]),T=u.useMemo(()=>{let _,D,ne,G,te,B,xe,se;if(j.length===1&&!C){D=j[0],_=D.name;const K=l(D,400,500);K?(ne=K,G=""):(G=c(D,"big"),ne=""),te=D.type!=="folder"}else{if(D=te=null,_="",j.length){let K=0,I=0,Q=0,q=[],V;j.forEach(be=>{typeof be.size>"u"&&(V=!0,K=void 0),V||(K+=be.size),q.push(k(be)),be.type==="folder"?I++:Q++});const ce=new Set(q);B=ce.size>1?m("multiple"):[...ce][0],xe=A(I,Q),se=K,C||(_=m("Multiple files"))}G=c({type:C?"search":j.length?"multiple":"none"},"big"),ne=""}return{name:_,item:D,previewSrc:ne,iconSrc:G,showDownloadIcon:te,type:B,totalCount:xe,totalSize:se}},[j,C,l,c,m,k,A]),R=u.useCallback(()=>{r.exec("download-file",{id:j[0].id})},[r,j]),U=u.useCallback(async _=>{if(!a||!_)return null;try{return await a(_)}catch(D){return console.log(D),null}},[a]),[O,Y]=u.useState(null);return u.useEffect(()=>{let _=!1;return Y(null),Promise.resolve(U(T.item)).then(D=>{_||Y(D)}).catch(()=>{_||Y(null)}),()=>{_=!0}},[U,T.item]),s.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:j&&j.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:T.name}),s.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[T.showDownloadIcon?s.jsx(_l,{name:"download",onClick:R}):null,n?s.jsx(_l,{name:"close",onClick:N}):null]})]}),T.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:T.previewSrc,alt:m("A miniature file preview")})}):T.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:T.iconSrc,alt:m("A miniature file preview")})}):s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:T.item?s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${T.item.type}`}):s.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${C?"search":"file-multiple-outline"}`})})]}),s.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[s.jsx("div",{className:"wx-O0BTtRrH wx-title",children:m(C?"Found":"Information")}),s.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[T.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(T.item)}),typeof T.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:Vc(T.item.size)})]}):null,s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Date")}),s.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(T.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:T.totalCount}),s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:T.type}),typeof T.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:Vc(T.totalSize)})]}):null]}),O?Object.entries(O).map(([_,D])=>s.jsxs(Kh.Fragment,{children:[s.jsx("span",{className:"wx-O0BTtRrH wx-name",children:_}),s.jsx("span",{className:"wx-O0BTtRrH wx-value",children:D})]},_)):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:T.name}),s.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?s.jsx(_l,{name:"close",onClick:N}):null})]}),s.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:s.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[T.previewSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:s.jsx("img",{src:T.previewSrc,alt:m("A miniature file preview")})}):T.iconSrc?s.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:s.jsx("img",{src:T.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-${C?"search":"message-question-outline"}`})}),s.jsx("span",{className:"wx-O0BTtRrH wx-text",children:C?"":m("Select file or folder to view details")})]})})]})})}function Jb({panel:n}){const a=u.useContext($n),r=u.useContext(Un.i18n),l=u.useMemo(()=>r.getGroup("filemanager"),[r]),[c,d]=hs(a,"panels"),m=u.useMemo(()=>c[n]._files,[d,n]),p=u.useMemo(()=>c[n]._crumbs||[],[d,n]);function g(j){const A=mp(j,p);a.exec("set-path",{id:j,panel:n,...A&&{selected:[A]}})}const[v,w]=u.useState(null);u.useEffect(()=>{m&&w(null)},[m]);function x(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=u.useRef(null),C=u.useRef();return u.useEffect(()=>{C.current?C.current.click=g:(C.current={click:g},_o(b.current,C.current))},[g]),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(_l,{name:"refresh",spin:!!v,onClick:x})}),p.map((j,A)=>s.jsxs(Kh.Fragment,{children:[A?s.jsx(_l,{name:"angle-right"}):null,s.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":Pn(j.id),"data-menu-ignore":"true",children:j.id=="/"?l(j.name):j.name})]},A))]})}function LA({row:n}){const a=u.useContext(Un.i18n),[r]=u.useState(()=>a.getGroup("filemanager")),l=u.useContext($n).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 ew({children:n}){const a=u.useContext($n),r=lt(a,"activePanel"),l=u.useContext(gp),c=u.useRef(null);let d=u.useRef({});return d.current.drop=()=>{const m=c.current,p=Ij(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 Hh({panel:n,active:a=!1,onClick:r,onContextMenu:l}){const c=u.useContext($n),d=u.useContext(Un.i18n),m=u.useMemo(()=>d.getGroup("filemanager"),[d]),p=u.useMemo(()=>To("%d %M %Y",d.getRaw().calendar),[d]),[g]=hs(c,"panels"),v=g[n].selected,w=g[n].path,x=g[n]._crumbs,b=g[n]._sorts,C=g[n]._selectNavigation,j=g[n]._files,A=u.useMemo(()=>[{id:"name",header:m("Name"),flexgrow:3,sort:!0,resize:!0,cell:LA},{id:"size",header:m("Size"),width:100,sort:!0,resize:!0,template:B=>typeof B=="number"?Vc(B):""},{id:"date",header:m("Date"),width:120,sort:!0,resize:!0,template:B=>B?p(B):""}],[m,p]),N=u.useRef(null),k=u.useRef(null),T=u.useMemo(()=>C?["/wx-filemanager-parent-link"]:[...v],[C,v]);function R(B,xe){if(xe&&xe.target&&xe.target.className&&xe.target.className.indexOf("wx-grip")!==-1)return;const se=xe&&(xe.ctrlKey||xe.metaKey),K=xe&&xe.shiftKey;if(B==="/wx-filemanager-parent-link"){if(v.length&&(se||K))return;c.exec("select-file",{type:"navigation"});return}let I=B==="body"&&xe?null:B;!N.current&&!k.current?c.exec("select-file",{id:I,toggle:se,range:K,panel:n}):(N.current=null,k.current=null)}function U(){x.length>1&&c.exec("set-path",{id:x[x.length-2].id,panel:n,selected:[x[x.length-1].id]})}function O(B){if(B==="/wx-filemanager-parent-link")return U();const xe=j.find(se=>se.id===B);xe&&(xe.type==="folder"?c.exec("set-path",{id:xe.id,panel:n}):c.exec("open-file",{id:xe.id}))}function Y(B){const xe=B.key,se=b[w];let K=se?"asc":"desc";se&&se.key===xe&&(K=se.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:xe,order:K,panel:n,path:w})}function _(B){B.intercept("sort-rows",xe=>(N.current=!0,Y(xe),!1)),B.intercept("select-row",()=>!1),B.on("resize-column",()=>k.current=!0),B.intercept("hotkey",()=>!1)}const D=u.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:m("Back to parent folder")},...j]:j,[w,j,m]),ne=u.useMemo(()=>{if(D&&b&&b[w]){const{key:B,order:xe}=b[w];return{[B]:{order:xe}}}},[D,b,w]),G=u.useRef(null),te=u.useRef();return u.useEffect(()=>{te.current?(te.current.click=R,te.current._dblclick=O):(te.current={click:R,dblclick:B=>te.current._dblclick(B),_dblclick:O},_o(G.current,te.current))},[R,O]),s.jsxs("div",{onClick:r,onContextMenu:l,className:"wx-SSaVhET7 wx-wrapper",children:[s.jsx(Jb,{panel:n}),s.jsx("div",{"data-id":Pn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:G,children:s.jsx(ew,{children:s.jsx(MA,{init:_,data:D,columns:A,selectedRows:T,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:ne})})})]})}function _A(){const n=u.useContext($n),a=lt(n,"activePanel");function r(l){n.exec("set-active-panel",{panel:l})}return s.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":Pn("body"),children:[s.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:s.jsx(Hh,{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(Hh,{panel:1,active:a==1,onClick:()=>r(1),onContextMenu:()=>r(1)})})]})}function tw({folderIcon:n=!1,folder:a={}}){const r=u.useContext($n),[l,c]=hs(r,"panels"),d=lt(r,"activePanel"),m=u.useMemo(()=>l[d].path,[c,d]),p=u.useContext(Un.i18n),g=u.useMemo(()=>p.getGroup("filemanager"),[p]),v=u.useMemo(()=>!!a.data?.find(C=>C.type==="folder"),[a]),w=u.useMemo(()=>a.id=="/"?g(a.name):a.name,[a,g]),x=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":Pn(a.id),className:`wx-NYfhvGIt wx-folder${m===a.id?" wx-selected":""}`,style:{paddingLeft:`${x}px`},children:[v?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&&v?s.jsx(s.Fragment,{children:a.data.map(C=>C.type==="folder"?s.jsx(tw,{folder:C},C.id):null)}):null]})}function zA(){const n=u.useContext($n),[a,r]=hs(n,"data"),[l,c]=hs(n,"panels"),d=lt(n,"activePanel"),m=u.useMemo(()=>l[d]._crumbs,[c,d]),p=u.useCallback(C=>{n.exec("open-tree-folder",{id:C,mode:!a.byId(C).open})},[n,r]),g=u.useCallback(C=>{const j=mp(C,m);n.exec("set-path",{id:C,panel:d,...j&&{selected:[j]}})},[n,m,d]),[v,w]=u.useState([]);u.useEffect(()=>{w(a.byId(0).data)},[r]);const x=u.useRef(null),b=u.useRef();return u.useEffect(()=>{b.current?(b.current.click=g,b.current.toggle=p):(b.current={click:g,toggle:p},_o(x.current,b.current))},[g,p]),s.jsx("ul",{ref:x,className:"wx-LyHJ6R6A",children:v.map(C=>C.type==="folder"?s.jsx(tw,{folder:C},C.id):null)})}function IA(){const n=u.useContext($n),a=u.useContext(Un.i18n),r=u.useMemo(()=>a.getGroup("filemanager"),[a]),l=lt(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:[Vc(c)," ",r("of")," ",Vc(d)," ",r("used")]})]}):null}function OA({option:n}){const a=u.useContext(Un.i18n).getGroup("filemanager"),r=u.useContext(gp),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 HA({readonly:n,menuOptions:a}){const r=u.useContext(Un.i18n).getGroup("filemanager"),{showPrompt:l}=u.useContext(pp);u.useEffect(()=>{n1("upload",OA)},[]);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(s1,{options:d,at:"bottom-fit",onClick:c,children:s.jsx(Hc,{type:"primary block",children:r("Add New")})})}),s.jsx("div",{className:"wx-FlucfALM wx-tree",children:s.jsx(zA,{})}),s.jsx(IA,{})]})}function BA({value:n="",onSearch:a}){const[r,l]=zb(n),c=u.useContext(Un.i18n).getGroup("filemanager"),d=u.useRef(null),m=u.useMemo(()=>r!==""?"wxi-close":"wxi-search",[r]);function p(v){const w=v.target.value;l(w),a&&a({value:w})}function g(){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:g}),s.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:d,value:r,onInput:p,placeholder:c("Search")})]})}function FA({narrowMode:n=!1,onShowTree:a}){const r=u.useContext($n),l=u.useContext(Un.i18n).getGroup("filemanager"),c=lt(r,"mode"),d=lt(r,"preview"),m=lt(r,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function g({value:x}){r.exec("set-mode",{mode:x})}function v(x){x.preventDefault(),r.exec("show-preview",{mode:!d})}function w(x){r.exec("filter-files",{text:x.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":Pn("toggle-tree"),children:s.jsx(_l,{onClick:()=>a&&a(),name:"subtask"})}):s.jsx("div",{className:"wx-5PZQQztG wx-name",children:l("Files")}),s.jsx(BA,{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(Ek,{onClick:v,value:d,children:s.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),s.jsx("div",{className:"wx-5PZQQztG wx-modes",children:s.jsx(jk,{value:c,options:p,onChange:g})})]})]})}function PA(){const n=u.useContext($n),a=lt(n,"activePanel");return s.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[s.jsx(Jb,{panel:a}),s.jsx(ew,{children:s.jsx(Zb,{})})]})}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,g]=u.useState(void 0),[v,w]=u.useState(!1),x=$b(),b=u.useContext($n),{showPrompt:C,showConfirm:j}=u.useContext(pp),A=u.useContext(Un.i18n),N=u.useMemo(()=>A.getGroup("filemanager"),[A]),k=lt(b,"mode"),T=lt(b,"preview"),R=lt(b,"activePanel"),[U,O]=hs(b,"panels"),Y=u.useMemo(()=>(U&&R!=null?U[R]:null)?.selected??[],[O,R]),_=u.useMemo(()=>(U&&R!=null?U[R]:null)?.path,[O,R]),[D,ne]=u.useState([]);u.useEffect(()=>{const ce=l.current;if(!ce)return;const be=new ResizeObserver(X=>{const $=X[0]?.borderBoxSize?.[0]?.inlineSize;typeof $=="number"&&g($<768)});return be.observe(ce),()=>{be.disconnect()}},[]);const G=u.useCallback(()=>{w(ce=>!ce)},[]),te=u.useCallback(ce=>{p&&Gc(ce)!=="toggle-tree"&&w(!1)},[p]);u.useEffect(()=>{const ce=c.current;if(ce)return ni(ce,te).destroy},[te]),u.useEffect(()=>{const ce=c.current;if(!ce)return;const be=new ResizeObserver(()=>{ce&&m(ce.clientWidth)});return be.observe(ce),ce&&m(ce.clientWidth),()=>{be.disconnect()}},[]);const B=u.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),xe=u.useCallback(ce=>{let be=p?[B]:[];return ce==="file"&&(be=[...be,...a().filter(X=>X.id==="download")]),be},[p,B,a]),se=u.useRef(null),K=u.useCallback((ce,be,X)=>{const $=X?[be.id]:Y;switch(ce){case"download":b.exec("download-file",{id:be.id});break;case"copy":case"move":se.current={action:ce,ids:$};break;case"paste":se.current&&b.exec(se.current.action==="copy"?"copy-files":"move-files",{ids:se.current.ids,target:be?.type==="folder"?be.id:_});break;case"rename":C({item:be});break;case"delete":j({selected:$});break;case"preview":b.exec("show-preview",{mode:!T});break}},[b,Y,_,C,j,T]),I=u.useCallback(()=>U?.[R],[U,R]);u.useEffect(()=>{const ce=l.current;if(!ce)return;const be=Gk(ce,{api:b,menuOptions:n?xe:a,performAction:K,getPanel:I});return()=>{typeof be=="function"?be():be&&typeof be.destroy=="function"&&be.destroy()}},[b,n,xe,a,K,I]);const Q=u.useCallback((ce,be)=>{const X=ce?b.getFile(ce):null,$=be.target.closest(".tree-item.folder");let ue;if(n)ue=xe(X?.type);else{switch(ce){case"body":ue=a(ce);break;default:if(X)if(!$&&Y.length>1)ue=p?[B,...a("multiselect")]:a("multiselect");else if(ce==="/")ue=a("folder",X).filter(he=>he.id==="paste");else{const he=a(X.type,X);he&&(ue=p?[B,...he]:he)}}k==="search"&&(ue=ue?.filter(he=>he.id!=="paste"))}if(X?.id&&(!Y.length||!Y.some(he=>he===X.id))&&!$&&b.exec("select-file",{id:X.id}),ue?.length)return ue.forEach(he=>{$&&(he.hotkey=""),he.text&&(he.text=N(he.text)),he.hotkey&&(he.subtext=he.hotkey)}),ne(ue),X||{}},[b,n,xe,a,Y,p,B,k,N]),q=u.useCallback(ce=>{const{action:be,context:X}=ce;be&&K(be.id,X,!be.hotkey)},[K]);async function V(ce){await Promise.resolve();const{name:be,size:X}=ce.file;b.exec("create-file",{file:{name:be,size:X,date:new Date,file:ce.file},parent:_})}return s.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:l,"data-menu-ignore":"false",children:p&&T?s.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:s.jsx(ih,{narrowMode:p,extraInfo:r})}):s.jsxs(s.Fragment,{children:[s.jsx(FA,{narrowMode:p,onShowTree:G}),s.jsx(i1,{dataKey:"id",at:"point",options:D,resolver:Q,onClick:q,children:s.jsxs(Pb,{dataKey:"actionId",options:D,resolver:Q,onClick:q,children:[s.jsx(u1,{data:x,apiOnly:!0,uploadURL:V}),s.jsx(gp.Provider,{value:x,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":"",v?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:s.jsx(HA,{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${T?"":"-fit"}`,"data-id":Pn("body"),children:k==="table"?s.jsx(Hh,{panel:R}):s.jsx(PA,{})}),T?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${T?"":"-fit"}`,children:k==="panels"?s.jsx(_A,{}):s.jsx(DA,{})}),T?s.jsx("div",{className:"wx-RJbNonjJ wx-info",children:s.jsx(ih,{extraInfo:r})}):null]})})})]})})]})})}const UA=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function qA(n,a){const{type:r,ext:l}=n;if(r==="folder")return!1;let c;return r&&r!=="file"&&lx[r]?c=r:l?c=lx[l]?l:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const GA=u.forwardRef(function(n,a){const{data:r=[],mode:l="cards",drive:c=null,preview:d=!1,panels:m=null,activePanel:p=0,readonly:g=!1,menuOptions:v=$k,extraInfo:w=null,init:x=null,icons:b=qA,previews:C=null,...j}=n,A=u.useRef();A.current=j;const N=u.useMemo(()=>new Pk(Ob),[]),k=u.useMemo(()=>N.in,[N]),T=u.useRef(null);T.current===null&&(T.current=new Rb((O,Y)=>{const _="on"+UA(O);A.current&&A.current[_]&&A.current[_](Y)}),k.setNext(T.current));const R=u.useMemo(()=>({getState:N.getState.bind(N),getReactiveState:N.getReactive.bind(N),getStores:()=>({data:N}),exec:k.exec,setNext:O=>(T.current=T.current.setNext(O),T.current),intercept:k.intercept.bind(k),on:k.on.bind(k),detach:k.detach.bind(k),getFile:N.getFile.bind(N),serialize:N.serialize.bind(N),templates:{preview:C||(()=>null),icon:b==="simple"?(()=>null):b}}),[N,k]),U=u.useRef(0);return u.useEffect(()=>{if(!U.current)x&&x(R);else{const O=N.getState();N.init({data:r,mode:l,drive:c,preview:d,panels:m||O.panels||[],activePanel:p})}U.current++},[N,r,l,c,d,m,p,x,R]),U.current===0&&N.init({data:r,mode:l,drive:c,preview:d,panels:m||[],activePanel:p}),u.useImperativeHandle(a,()=>({...R}),[R]),s.jsx($n.Provider,{value:R,children:s.jsx(dp,{words:fp,optional:!0,children:s.jsx(TA,{children:s.jsx($A,{readonly:g,menuOptions:v,extraInfo:w})})})})});function VA({fonts:n=!0,children:a}){return a?s.jsx(Vy,{fonts:n,children:a}):s.jsx(Vy,{fonts:n})}sp(La);function vp(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function Yc(n,a,r){const l=vp(n,r);if(!Array.isArray(l[a]))throw new Error(`Invalid Hub ${r} response: ${a} must be an array.`);return l[a]}function WA(n,a,r){const l=vp(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 YA(n,a=!1){return Yc(await Ge(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function rh(n,a){const r=await Ge(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:WA(r,"folder","filesystem entries"),entries:Yc(r,"entries","filesystem entries")}}async function KA(n,a){return Ge("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function QA(n,a,r,l){return Ge("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:r})},l)}async function XA(n,a=!1){const r=await Ge(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:Yc(r,"jobs","file transfer jobs")}}async function ZA(n,a){return Ge(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function JA(n,a){return Ge(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function ox(n){return Yc(await Ge("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function eN(n,a){return Ge("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function tN(n,a,r){return Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},r)}async function nN(n,a){return Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function aN(n,a,r,l){const c=await Ge(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:r})},l),d=vp(c,"shared folder sync");return{ok:d.ok===!0,jobs:Yc(c,"jobs","shared folder sync"),files:Number(d.files||0),totalBytes:Number(d.totalBytes||0)}}function sN(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 cx(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 Id(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function iN(n){const a=n.filter(r=>Id(r)==="local");return a.find(r=>/\bC:/i.test(`${r.name} ${r.displayPath||""}`))||a[0]||n[0]||null}function rN({hubUrl:n,roots:a,loading:r,error:l,onRefreshRoots:c,onImportFiles:d,onImportFolder:m,onSelectionChange:p,onShareItem:g,onAddSyncFolder:v,onNotice:w}){const x=u.useRef(null),b=u.useRef("/"),C=u.useRef(0),j=u.useRef([]),A=u.useRef(new Map),[N,k]=u.useState(null),[T,R]=u.useState([]),[U,O]=u.useState([]),[Y,_]=u.useState(0),[D,ne]=u.useState(null),[G,te]=u.useState(!1),[B,xe]=u.useState(""),[se,K]=u.useState(new Set),I=a.find(ae=>ae.id===N)||null,Q=T[T.length-1]||null,q=I?Q?.svarPath||`/${I.name}`:null,V=q;u.useEffect(()=>{j.current=T,b.current=V||"/"},[V,T]);const ce=u.useMemo(()=>(A.current.clear(),!I||!V||T.length===0?[]:(T.forEach(ae=>A.current.set(ae.svarPath,ae.hubId)),[...T.map((ae,fe)=>({id:ae.svarPath,parent:fe===0?"/":T[fe-1].svarPath,type:"folder",name:ae.name,date:ae.modifiedAt?new Date(ae.modifiedAt):void 0,lazy:!1})),...U.map(ae=>{const fe=`${V}/${ae.name}`;return A.current.set(fe,ae.id),{id:fe,parent:V,name:ae.name,type:ae.type==="file"?"file":"folder",...ae.type==="file"?{size:ae.size}:{},date:ae.modifiedAt?new Date(ae.modifiedAt):void 0,lazy:ae.type!=="file"&&ae.hasChildren===!0,displayPath:ae.displayPath,locked:ae.locked,driveType:ae.driveType,totalBytes:ae.totalBytes,freeBytes:ae.freeBytes}})])),[I,U,V,T]),be=ae=>A.current.get(String(ae))||String(ae),X=ae=>sN({...ae,id:be(String(ae.id)),parent:be(String(ae.parent))}),$=async(ae,fe)=>{const Ae=ae[ae.length-1];if(!Ae)return;const Te=++C.current;te(!0),xe("");try{const Be=await rh(Ae.hubId,n);if(Te!==C.current)return;if(!Array.isArray(Be.entries))throw new Error("Invalid Hub filesystem entries response.");const Ve={...Ae,displayPath:Be.folder.displayPath||Ae.displayPath,modifiedAt:Be.folder.modifiedAt||Ae.modifiedAt},Je=[...ae.slice(0,-1),Ve];j.current=Je,R(Je),O(Be.entries),_(Et=>Et+1)}catch(Be){if(Te!==C.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:Ae.hubId,error:Be}),xe(Be instanceof Error?`${fe}: ${Be.message}`:`${fe}: Unable to read this folder.`)}finally{Te===C.current&&te(!1)}},ue=async ae=>{const fe={svarPath:`/${ae.name}`,hubId:ae.id,name:ae.name,displayPath:ae.displayPath,modifiedAt:ae.modifiedAt},Ae=++C.current;k(ae.id),j.current=[fe],R([fe]),b.current=fe.svarPath,O([]),xe(""),te(!0),ne(ae.id),K(Te=>{const Be=new Set(Te);return Be.delete(ae.id),Be});try{const Te=await rh(ae.id,n);if(Ae!==C.current)return;if(!Array.isArray(Te.entries))throw new Error("Invalid Hub filesystem entries response.");const Be={...fe,displayPath:Te.folder.displayPath||fe.displayPath,modifiedAt:Te.folder.modifiedAt||fe.modifiedAt};j.current=[Be],R([Be]),O(Te.entries),_(Ve=>Ve+1)}catch(Te){if(Ae!==C.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:ae.id,error:Te}),K(Be=>new Set(Be).add(ae.id)),xe(Te instanceof Error?`${ae.name}: ${Te.message}`:`${ae.name}: Unable to read this drive.`),w(Te instanceof Error?`${ae.name}: ${Te.message}`:`${ae.name}: Unable to read this drive.`)}finally{Ae===C.current&&(ne(null),te(!1))}},he=ae=>{const fe=j.current;ae<0||ae>=fe.length||ae===fe.length-1||$(fe.slice(0,ae+1),fe[ae].name)},ve=(ae,fe)=>{if(ae.type!=="folder")return;const Ae=j.current,Te=Ae.findIndex(Ve=>Ve.svarPath===fe);if(Te<0)return;const Be={svarPath:`${fe}/${ae.name}`,hubId:ae.id,name:ae.name,displayPath:ae.displayPath,modifiedAt:ae.modifiedAt};$([...Ae.slice(0,Te+1),Be],ae.name)},Se=()=>he(j.current.length-2),_e=ae=>{if(ae.key!=="Enter"&&ae.code!=="Enter"&&ae.code!=="NumpadEnter"||ae.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const Ae=x.current;if(!Ae)return;const Te=Ae.getState().panels?.flatMap(Ve=>Ve.selected||[])||[];if(Te.length!==1)return;const Be=Ae.getFile(String(Te[0]));Be?.type==="folder"&&(ae.preventDefault(),ae.stopPropagation(),ve(X(Be),String(Be.parent||b.current)))};u.useEffect(()=>{const ae=a.find(fe=>fe.id===N)||iN(a);if(K(fe=>new Set([...fe].filter(Ae=>a.some(Te=>Te.id===Ae)))),!ae){k(null),j.current=[],R([]),O([]);return}ue(ae)},[a]);const re=ae=>{x.current=ae,ae.on("request-data",async({id:fe})=>{const Ae=String(fe),Te=be(Ae);try{const Be=await rh(Te,n);if(!Array.isArray(Be.entries))throw new Error("Invalid Hub filesystem entries response.");const Ve=Be.entries.map(Je=>{const Et=`${Ae}/${Je.name}`;return A.current.set(Et,Je.id),{id:Et,parent:Ae,name:Je.name,type:Je.type==="file"?"file":"folder",...Je.type==="file"?{size:Je.size}:{},date:Je.modifiedAt?new Date(Je.modifiedAt):void 0,lazy:Je.type!=="file"&&Je.hasChildren===!0,displayPath:Je.displayPath,locked:Je.locked,driveType:Je.driveType,totalBytes:Je.totalBytes,freeBytes:Je.freeBytes}});await ae.exec("provide-data",{id:Ae,data:Ve})}catch(Be){console.error("[LiveDesk FS] nested getEntries failed",{id:Te,error:Be}),w(Be instanceof Error?Be.message:"Unable to read this folder.")}}),ae.intercept("set-path",({id:fe})=>{const Ae=String(fe),Te=j.current.findIndex(Ve=>Ve.svarPath===Ae);if(Te>=0)return he(Te),!1;const Be=ae.getFile(Ae);if(Be?.type==="folder")return ve(X(Be),String(Be.parent||b.current)),!1}),ae.intercept("open-file",()=>!1),ae.on("select-file",()=>{window.setTimeout(()=>{const Te=(ae.getState().panels?.flatMap(Be=>Be.selected||[])||[]).map(Be=>ae.getFile(Be)).filter(Boolean).map(Be=>X(Be));p(Te.map(Be=>Be.id),Te)},0)})},Z=(ae,fe)=>{const Ae=fe?X(fe):null,Te=()=>{const Be=Ae?.type==="file"?String(fe?.parent||b.current):String(fe?.id||b.current);x.current?.exec("request-data",{id:Be})};return ae==="body"?[{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Te},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w("Select a file or folder to view its properties.")}]:ae==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(x.current?.getState().panels?.flatMap(Ve=>Ve.selected||[])||[]).forEach(Ve=>{const Je=x.current?.getFile(Ve);Je&&g(X(Je))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Te}]:Ae?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>g(Ae)},...Ae.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>v(Ae)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{Al(Ae.displayPath||Ae.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:Te},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${Ae.name}
|
|
14
|
+
${Ae.displayPath||""}`)}]:[]},ze=async()=>{try{await c()}catch(ae){w(ae instanceof Error?ae.message:"Unable to refresh Hub drives.")}},Le=[{id:"local",label:"Local drives",icon:Ml,roots:a.filter(ae=>Id(ae)==="local")},{id:"removable",label:"Removable drives",icon:QS,roots:a.filter(ae=>Id(ae)==="removable")},{id:"network",label:"Network drives",icon:Qh,roots:a.filter(ae=>Id(ae)==="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(Ml,{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(Qx,{size:16})}),s.jsx("button",{className:"icon-button",onClick:m,title:"Import folder from this browser",type:"button",children:s.jsx(XS,{size:16})}),s.jsx("button",{className:"icon-button",onClick:()=>{ze()},title:"Refresh drives",type:"button",children:s.jsx(Do,{size:16})})]})]}),r?s.jsxs("div",{className:"hub-file-explorer-state",children:[s.jsx(Ml,{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(Ts,{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(Ml,{size:15}),s.jsx("strong",{children:"This PC"})]}),Le.map(ae=>ae.roots.length>0&&s.jsxs("section",{className:"hub-drive-group",children:[s.jsxs("h3",{children:[s.jsx(ae.icon,{size:13}),ae.label]}),s.jsx("div",{className:"hub-drive-list",children:ae.roots.map(fe=>{const Ae=ae.icon,Te=se.has(fe.id)||fe.locked===!0;return s.jsxs("button",{className:`hub-drive-item ${N===fe.id?"active":""} ${Te?"unavailable":""}`,onClick:()=>{ue(fe)},"aria-pressed":N===fe.id,type:"button",children:[s.jsx("span",{className:"hub-drive-item-icon",children:s.jsx(Ae,{size:16})}),s.jsxs("span",{className:"hub-drive-item-copy",children:[s.jsx("strong",{children:fe.name}),s.jsx("small",{children:fe.displayPath||fe.name}),s.jsxs("em",{children:[cx(fe.freeBytes||0)," free / ",cx(fe.totalBytes||0)]})]}),D===fe.id?s.jsx(Js,{className:"hub-drive-item-status spin",size:15}):Te?s.jsx(sy,{className:"hub-drive-item-status",size:15}):null]},fe.id)})})]},ae.id)),a.length===0&&s.jsxs("div",{className:"hub-drive-sidebar-empty",children:[s.jsx(Ts,{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:T.map((ae,fe)=>s.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[fe>0&&s.jsx(Xh,{size:13,"aria-hidden":"true"}),s.jsx("button",{className:`hub-file-explorer-breadcrumb ${fe===T.length-1?"current":""}`,onClick:()=>he(fe),"aria-current":fe===T.length-1?"location":void 0,type:"button",children:ae.name})]},ae.svarPath))}),s.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[G&&s.jsx(Js,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),s.jsx("button",{className:"icon-button",onClick:Se,disabled:T.length<=1||G,title:"Back to parent folder",type:"button",children:s.jsx(Ux,{size:16})})]})]}),B&&s.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[s.jsx(sy,{size:15}),s.jsx("span",{children:B})]}),s.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:_e,children:s.jsx(VA,{fonts:!1,children:s.jsx(GA,{data:ce,panels:q?[{path:q,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:re,icons:"simple",menuOptions:Z},`${I?.id||"no-root"}:${Y}`)})})]})]})]})}class lN 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(Jd,{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(Do,{size:15})," Retry"]})]}):this.props.children}}function oN(n){return n.deviceName||n.hostname||n.deviceId}function cN({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($c,{size:14})," All connected"]}),s.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>l("selected"),type:"button",children:[s.jsx(an,{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(an,{size:20,"aria-hidden":"true"}),s.jsxs("span",{children:[s.jsx("strong",{children:oN(m)}),s.jsxs("small",{children:["Slot ",m.slotNumber?String(m.slotNumber).padStart(3,"0"):"-"," / ",m.platform||"unknown OS"]})]}),s.jsx(Fn,{size:17,"aria-hidden":"true"})]},m.deviceId)})})]})}function uN(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 dN({folders:n,loading:a,busy:r,canSync:l,onSyncAll:c,onSync:d,onToggleAuto:m,onRemove:p,onAdd:g}){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(Rd,{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:g,type:"button",children:[s.jsx(Rd,{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(v=>s.jsxs("article",{className:`file-share-sync-row state-${v.status}`,children:[s.jsx("div",{className:"file-share-sync-icon",children:s.jsx(Rd,{size:19})}),s.jsxs("div",{className:"file-share-sync-info",children:[s.jsx("strong",{children:v.name}),s.jsx("span",{children:v.displayPath}),s.jsxs("small",{children:[v.fileCount," files / ",uN(v.totalBytes)," · ",v.lastSyncedAt?`Last sync ${sb(v.lastSyncedAt)} ago`:v.message||"Not synced yet"]})]}),s.jsxs("label",{className:"file-share-auto-sync",children:[s.jsx("input",{type:"checkbox",checked:v.autoSync,onChange:()=>m(v)}),s.jsx("span",{children:"Auto"})]}),s.jsxs("button",{className:"text-button compact",onClick:()=>d(v),disabled:r||!l||v.status==="syncing",type:"button",children:[s.jsx(Do,{size:14})," Sync now"]}),s.jsx("button",{className:"icon-button",onClick:()=>p(v),title:"Remove sync folder",type:"button",children:s.jsx(Yh,{size:15})})]},v.id))})]})}function fN(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(Fc,{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(cN,{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(No,{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(Fc,{size:17})," Share selected"]}),s.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[s.jsx(No,{size:16})," Add selected folder to Sync"]})]}):s.jsx(dN,{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 mN(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 ux(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 dx(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 fx(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function hN({hubUrl:n,devices:a,localFeatureAccess:r,upgradeNotice:l,remoteDirectory:c,onRemoteDirectoryChange:d,targetMode:m,selectedTargetIds:p,onTargetModeChange:g,onTargetToggle:v,filePickerRef:w,folderPickerRef:x,onBrowserFileImport:b,onBrowserFolderImport:C,onNotice:j,onTransferChange:A}){const N=Array.isArray(a)?a:[],[k,T]=u.useState([]),[R,U]=u.useState(!0),[O,Y]=u.useState(""),[_,D]=u.useState([]),[ne,G]=u.useState([]),[te,B]=u.useState(null),[xe,se]=u.useState(!1),[K,I]=u.useState([]),[Q,q]=u.useState(!0),[V,ce]=u.useState(!1),[be,X]=u.useState("send"),[$,ue]=u.useState([]),he=u.useRef(new Set),ve=u.useMemo(()=>m==="all"?N.map(je=>je.deviceId):p.filter(je=>N.some(We=>We.deviceId===je)),[N,p,m]),Se=$.find(je=>!fx(je.state)),_e=ne.length===1&&ne[0].type==="folder"?ne[0]:null,re=ne.length===0?"Select files or folders from the Hub explorer.":xe?"Calculating selection size...":te?`${te.files} files, ${te.folders} folders · ${mN(te.totalBytes)}`:`${ne.length} item${ne.length===1?"":"s"} selected`,Z=je=>{A({id:je.jobId,state:je.state,progress:ux(je),message:dx(je)})},ze=u.useCallback(async()=>{const je=await YA(n,!0);return T(je),Y(""),je},[n]),Le=async()=>{try{const We=(await XA(n,!0)).jobs||[],it=await Promise.all([...he.current].map(async Kt=>{try{return await ZA(Kt,n)}catch{return null}})),ot=[...We,...it.filter(Boolean)],gn=[...new Map(ot.map(Kt=>[Kt.jobId,Kt])).values()];ue(gn),gn.forEach(Z),gn.filter(Kt=>fx(Kt.state)).forEach(Kt=>he.current.delete(Kt.jobId))}catch{}};u.useEffect(()=>{let je=!0;U(!0),Y(""),Promise.all([ze(),ox(n).then(it=>{je&&I(it)})]).catch(it=>{je&&(Y(it instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),j(it instanceof Error?it.message:"Hub file system is unavailable."))}).finally(()=>{je&&(U(!1),q(!1))}),Le();const We=window.setInterval(()=>{Le()},800);return()=>{je=!1,window.clearInterval(We)}},[n,ze]),u.useEffect(()=>{if(_.length===0){B(null);return}let je=!1;return se(!0),KA(_,n).then(We=>{je||B(We)}).catch(We=>{je||j(We instanceof Error?We.message:"Unable to calculate selected size.")}).finally(()=>{je||se(!1)}),()=>{je=!0}},[n,_.join("|")]);const ae=(je,We)=>{D(je),G(We)},fe=je=>{je.forEach(We=>he.current.add(We.jobId)),ue(We=>[...new Map([...We,...je].map(it=>[it.jobId,it])).values()]),je.forEach(Z)},Ae=async()=>{if(!r){j(l);return}if(_.length===0){j("Select files or folders from the Hub explorer.");return}if(ve.length===0){j("Choose at least one connected workstation.");return}if(Se){j("A Hub transfer is already running.");return}try{const je=await QA(_,ve,c.trim(),n);he.current.add(je.jobId),j("Hub transfer queued."),await Le()}catch(je){j(je instanceof Error?je.message:"Unable to start Hub transfer.")}},Te=async je=>{const We=je||_e;if(!We||We.type!=="folder"){j("Select one folder to add it to Sync.");return}try{const it=await eN(We.id,n);I(ot=>[...ot.filter(gn=>gn.id!==it.folder.id),it.folder]),X("sync"),j(`${We.name} is ready for Hub sync.`)}catch(it){j(it instanceof Error?it.message:"Unable to add the Hub folder to Sync.")}},Be=async je=>{if(ve.length===0){j("Choose at least one connected workstation.");return}ce(!0),I(We=>We.map(it=>it.id===je.id?{...it,status:"syncing"}:it));try{const We=await aN(je.id,ve,c.trim(),n);fe(We.jobs||[]),j(We.jobs?.length?"Hub sync queued.":"No changed files to sync.");const it=await ox(n);I(it)}catch(We){j(We instanceof Error?We.message:"Unable to sync the Hub folder."),I(it=>it.map(ot=>ot.id===je.id?{...ot,status:"error",message:"Sync failed"}:ot))}finally{ce(!1)}},Ve=async()=>{ce(!0);try{for(const je of K)await Be(je)}finally{ce(!1)}},Je=async je=>{try{const We=await tN(je.id,{autoSync:!je.autoSync},n);I(it=>it.map(ot=>ot.id===je.id?We.folder:ot))}catch(We){j(We instanceof Error?We.message:"Unable to update auto sync.")}},Et=async je=>{try{await nN(je.id,n),I(We=>We.filter(it=>it.id!==je.id))}catch(We){j(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:je=>{je.currentTarget.files&&b(je.currentTarget.files),je.currentTarget.value=""}}),s.jsx("input",{ref:x,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:je=>{je.currentTarget.files&&C(je.currentTarget.files),je.currentTarget.value=""}}),s.jsx("div",{className:"file-share-workspace",children:s.jsxs(lN,{onRetry:()=>window.location.reload(),children:[s.jsx(rN,{hubUrl:n,roots:k,loading:R,error:O,onRefreshRoots:ze,onImportFiles:()=>w.current?.click(),onImportFolder:()=>x.current?.click(),onSelectionChange:ae,onShareItem:je=>{D([je.id]),G([je]),X("send")},onAddSyncFolder:je=>{D([je.id]),G([je]),Te(je)},onNotice:j}),s.jsx(fN,{devices:N,targetMode:m,selectedTargetIds:p,onTargetModeChange:g,onTargetToggle:v,remoteDirectory:c,onRemoteDirectoryChange:d,selectedEntries:ne,selectedSummary:re,canShare:r&&!Se&&_.length>0&&ve.length>0&&!xe,onShare:()=>{Ae()},canAddSync:!!_e,onAddSync:()=>{Te()},tab:be,onTabChange:X,folders:K,foldersLoading:Q,syncBusy:V,onSyncAll:()=>{Ve()},onSync:je=>{Be(je)},onToggleAuto:je=>{Je(je)},onRemove:je=>{Et(je)},onAddFolder:()=>{Te()}})]})}),Se&&s.jsx("footer",{className:"file-share-workspace-footer",children:s.jsxs("span",{children:[dx(Se)," · ",ux(Se),"% ",s.jsx("button",{className:"icon-button",onClick:()=>{JA(Se.jobId,n).then(je=>{ue(We=>We.map(it=>it.jobId===je.jobId?je:it)),Z(je)})},title:"Cancel transfer",type:"button",children:s.jsx(Ya,{size:14})})]})})]})}const pN=u.forwardRef(function({value:a,onChange:r,onSubmit:l,onOpenSuggestedTasks:c,suggestedOpen:d=!1,suggestedTaskCount:m,disabled:p=!1,placeholder:g="Ask LiveDesk to work across your machines..."},v){return s.jsxs("form",{className:"agents-composer",onSubmit:w=>{w.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(ZS,{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:w=>r(w.target.value.slice(0,4e3)),placeholder:g,"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(Js,{className:"spin",size:16}):s.jsx(Fc,{size:16}),p?"Running":"Run"]})]})}),gN=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function Kd(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function Qd(n){return n.connected!==!0?!1:n.synthetic===!0?!0:!n.channels||n.channels.control===!0}function vN(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function yN(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 xN(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Va(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function Cd(n){const a=Va(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 bN(n){const a=Va(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function wN(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function Xd(n,a){if(a.error)return a.error;const r=xN(a.data),l=wN(a.result||"");if(!r)return l||a.stage||a.status;if(n==="system.health"){const c=typeof r.machine=="string"?r.machine:"",d=Cd(r.freeMemoryBytes),m=Cd(r.totalMemoryBytes),p=Va(r.totalMemoryBytes)&&Va(r.freeMemoryBytes)!==null?`${Math.round(Va(r.freeMemoryBytes)/Va(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=Cd(r.freeBytes),m=Va(r.totalBytes)&&Va(r.freeBytes)!==null?`${Math.round(Va(r.freeBytes)/Va(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=bN(r.usageRatio),m=Va(r.temperatureC)!==null?`${Math.round(Va(r.temperatureC))}°C`:"",p=Cd(r.freeMemoryBytes);return[c,d&&`GPU ${d}`,m,p&&`${p} free`].filter(Boolean).join(" · ")||l||a.status}if(n==="process.list"){const c=Va(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 mx(n,a){const r=Xd(n,a);return a.status==="failed"||a.status==="cancelled"||/\b(?:warning|failed|error|offline|not running|low|timeout|timed out)\b/i.test(`${a.result||""} ${r}`)}function SN({state:n,operation:a}){const r=n.status==="completed"?Ii:n.status==="failed"||n.status==="cancelled"?Ya:n.status==="running"?Js:Xx,l=n.status==="running"?n.stage||"Working":n.status==="completed"?a?Xd(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return 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 CN({operation:n,states:a,status:r,onCancel:l,onRetry:c,busy:d=!1}){const m=["running","queued"].includes(r),[p,g]=u.useState(!1),[v,w]=u.useState("all"),x=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=>mx(n,R)),C=b.filter(R=>R.status==="completed").length,j=x.failed>0,A=b.length>0,N=a.filter(R=>v==="issues"?mx(n,R):v==="running"?R.status==="running"||R.status==="queued":v==="completed"?R.status==="completed":v==="failed"?R.status==="failed":!0),k=A&&!m||r==="completed-with-failures"?"Completed with issues":r[0]?.toUpperCase()+r.slice(1),T=a.filter(R=>R.status==="completed").map(R=>Xd(n,R)).filter(Boolean).filter((R,U,O)=>O.indexOf(R)===U).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:yN(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:[x.total," targets"]}),s.jsxs("span",{className:"summary-completed",children:[x.completed," completed"]}),x.running>0&&s.jsxs("span",{className:"summary-running",children:[x.running," running"]}),x.queued>0&&s.jsxs("span",{children:[x.queued," queued"]}),j&&s.jsxs("span",{className:"summary-failed",children:[x.failed," failed"]}),C>0&&s.jsxs("span",{className:"summary-cancelled",children:[C," warning"]}),x.cancelled>0&&s.jsxs("span",{className:"summary-cancelled",children:[x.cancelled," cancelled"]})]}),T.length>0&&s.jsxs("div",{className:"agent-task-result-preview",title:T.join(" · "),children:[s.jsx("span",{children:"Result"}),T.join(" · ")]}),s.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((R,U)=>{const O=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}: ${Xd(n,R)}`,"aria-label":`${U+1}. ${R.deviceName}: ${R.status}`,children:[s.jsx("b",{children:String(U+1).padStart(2,"0")}),s.jsx("span",{children:O})]},R.deviceId)})}),a.length>0&&s.jsx("div",{className:"agent-task-details-toggle",children:s.jsxs("button",{type:"button",onClick:()=>g(R=>!R),"aria-expanded":p,children:[p?s.jsx(JS,{size:14}):s.jsx(Zx,{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:v===R?"active":"",onClick:()=>w(R),role:"tab","aria-selected":v===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:N.length>0?N.map(R=>s.jsx(SN,{operation:n,state:R},R.deviceId)):s.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(m||j)&&s.jsxs("div",{className:"agent-task-actions",children:[m&&l&&s.jsxs("button",{onClick:l,disabled:d,type:"button",children:[s.jsx(e0,{size:14})," Cancel"]}),!m&&j&&c&&s.jsxs("button",{onClick:c,disabled:d,type:"button",children:[s.jsx(_c,{size:14})," Retry failed"]})]})]})}function jN(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function kN({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:jN(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(Ya,{size:14})," Reject"]}),s.jsxs("button",{disabled:a,onClick:()=>r("once"),type:"button",children:[s.jsx(Ii,{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(Jd,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function AN(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 NN({items:n,onCancel:a,onRetry:r,busyBatchId:l,approvals:c,onApprove:d,onReject:m,busyApprovalId:p,progress:g,emptyTitle:v="Ask LiveDesk to work across your machines.",emptyBody:w="Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."}){const x=u.useRef(null),b=u.useRef(!0),C=u.useRef(""),j=n[n.length-1];return u.useLayoutEffect(()=>{const A=x.current;A&&(j?.type==="user"&&j.id!==C.current&&(b.current=!0),C.current=j?.id||"",b.current&&(A.scrollTop=A.scrollHeight))},[c,n,j?.id,j?.type,g?.message,g?.stage]),s.jsxs("section",{className:"agents-conversation","aria-live":"polite",ref:x,onScroll:A=>{const N=A.currentTarget;b.current=N.scrollHeight-N.scrollTop-N.clientHeight<72},children:[c.filter(A=>A.status==="pending").map(A=>s.jsx(kN,{approval:A,busy:p===A.approvalId,onApprove:N=>d(A,N),onReject:()=>m(A)},A.approvalId)),n.length===0&&s.jsxs("div",{className:"agents-empty-conversation",children:[s.jsx("strong",{children:v}),s.jsx("span",{children:w})]}),n.map(A=>{if(A.type==="task"){const N=A;return s.jsx(CN,{operation:N.operation,states:N.states,status:N.status,onCancel:()=>a(N.batchId,N.agentRunId),onRetry:()=>r(N.batchId),busy:l===N.batchId},N.id)}return s.jsxs("article",{className:`agents-message ${A.type}`,children:[s.jsx("span",{children:A.type==="user"?"You":"LiveDesk Agent"}),s.jsx("p",{children:A.text})]},A.id)}),g&&s.jsxs("article",{className:"agents-message agent agents-progress-message",role:"status",children:[s.jsxs("span",{children:[s.jsx(Js,{"aria-hidden":"true",size:15}),AN(g.stage)]}),s.jsx("p",{children:g.message})]})]})}const hx=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],Sn=["windows","macos","linux"],_r={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:Sn},"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:Sn},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:Sn},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:Sn},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:Sn},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:Sn},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:Sn},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:Sn},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:Sn},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:Sn},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Sn}};new Set(Object.keys(_r));const MN={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","문제해결","복구","장애"]},px=["low","medium","high","critical"];function TN(n){return n.reduce((a,r)=>{const l=_r[r].risk;return px.indexOf(l)>px.indexOf(a)?l:a},"low")}function EN(n){return Sn.filter(a=>n.every(r=>_r[r].supportedPlatforms.includes(a)))}function Ue(n,a,r,l,c,d,m={}){const p=m.description||l,g=c.flatMap(w=>w.split(".")),v=[...new Set([...MN[a],...d,...g])];return{id:n,category:a,title:r,prompt:l,description:p,requiredOperations:c,risk:m.risk||TN(c),targetSupport:m.targetSupport||"single-or-multiple",supportedPlatforms:m.supportedPlatforms||EN(c),keywords:v,recommended:m.recommended??!1,enabled:!0}}const nw=[Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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}),Ue("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","높은 사용량"]),Ue("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),Ue("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),Ue("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"]),Ue("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","디스크"]),Ue("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),Ue("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","경고"]),Ue("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"]),Ue("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","실행 중"]),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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","서비스 상태"]),Ue("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"}),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"]),Ue("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"]),Ue("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"}),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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","구성"]),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"]}),Ue("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"]}),Ue("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"]}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"]),Ue("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"}),Ue("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),Ue("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),Ue("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),Ue("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"]),Ue("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"]),Ue("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"]),Ue("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),Ue("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"]),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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"}),Ue("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 RN(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 DN(n,a,r){const l=RN(a,r),c=n.requiredOperations.map(d=>l[_r[d].permissionCategory]);if(c.includes("deny")){const d=n.requiredOperations.find(m=>l[_r[m].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${_r[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=>_r[d].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function LN(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 _N(n,a,r){const l=new Set(r);return n.filter(c=>c.connected&&(a==="all"||a==="auto"||l.has(c.deviceId)))}function zN(n,a){const r=LN(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=>_r[c].readOnly):a.requiredOperations.every(c=>l.includes(c))}function aw(n,a,r,l,c,d){const m=DN(n,c,d),p=_N(a,r,l),g=p.map(C=>C.deviceId),v={...m,available:!1,availableDeviceIds:[],unsupportedDeviceIds:g,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...v,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...v,reason:"This task supports one workstation at a time."};if(m.state==="blocked")return v;const w=p.filter(C=>zN(C,n)),x=w.map(C=>C.deviceId),b=g.filter(C=>!x.includes(C));return w.length===0?{...v,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...v,available:!0,availableDeviceIds:x,unsupportedDeviceIds:b}}function IN(n,a,r,l,c,d){return n.filter(m=>m.enabled&&aw(m,a,r,l,c,d).available).length}const oh="livedesk.agentPromptRecent",ch="livedesk.agentPromptFavorites",ON={Recommended:Es,"Health & capacity":pn,"Processes & services":i0,"AI workloads":Wx,"Files & configuration":s0,"Software & automation":Fd,"Network & connectivity":Qh,"Power & maintenance":Bt,"Troubleshooting & recovery":a0};function gx(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 jd(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 HN(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 BN(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 FN(n){return`permission-${n}`}function PN(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 UN({devices:n,targetMode:a,selectedIds:r,permissionMode:l,customCategories:c,onSelectPrompt:d,onClose:m}){const[p,g]=u.useState(""),[v,w]=u.useState("all"),[x,b]=u.useState(()=>gx(oh)),[C,j]=u.useState(()=>gx(ch)),[A,N]=u.useState(0),[k,T]=u.useState(""),R=u.useRef(null),U=u.useRef(null),O=u.useMemo(()=>nw.filter(K=>K.enabled),[]),Y=u.useMemo(()=>new Map(O.map(K=>[K.id,aw(K,n,a,r,l,c)])),[c,n,l,r,a,O]),_=u.useMemo(()=>[...Y.values()].filter(K=>K.available).length,[Y]),D=u.useMemo(()=>n.filter(K=>K.connected&&(a==="all"||a==="auto"||r.includes(K.deviceId))).length,[n,r,a]),ne=u.useMemo(()=>{const K=O.filter(I=>BN(I,Y.get(I.id),p));return v==="recent"?x.map(I=>K.find(Q=>Q.id===I)).filter(I=>!!I):v==="favorites"?C.map(I=>K.find(Q=>Q.id===I)).filter(I=>!!I):v==="all"?K:K.filter(I=>{const Q=Y.get(I.id);return v==="read-only"?Q.state==="read-only":v==="auto"?Q.state==="auto":v==="approval"?Q.state==="approval":v==="full-access"?Q.state==="full-access":v==="available"?Q.available:v==="unavailable"?!Q.available:I.category===v})},[Y,C,v,x,p,O]),G=u.useMemo(()=>v!=="all"?[{category:uh(v),templates:ne}]:hx.map(K=>({category:K,templates:ne.filter(I=>I.category===K)})).filter(K=>K.templates.length>0),[v,ne]);u.useEffect(()=>{N(K=>Math.min(K,Math.max(0,ne.length-1)))},[ne.length]),u.useEffect(()=>{jd(oh,x)},[x]),u.useEffect(()=>{jd(ch,C)},[C]),u.useEffect(()=>{U.current?.focus();const K=Q=>{Q.target instanceof Node&&!R.current?.contains(Q.target)&&m()},I=Q=>{Q.key==="Escape"&&(Q.preventDefault(),m())};return document.addEventListener("pointerdown",K),document.addEventListener("keydown",I),()=>{document.removeEventListener("pointerdown",K),document.removeEventListener("keydown",I)}},[m]);const te=K=>{const I=Y.get(K.id);if(!I.available){T(I.reason||"This task is not available for the current targets and permission policy.");return}const Q=[K.id,...x.filter(q=>q!==K.id)].slice(0,10);b(Q),jd(oh,Q),d(K.prompt),m()},B=K=>{j(I=>{const Q=I.includes(K)?I.filter(q=>q!==K):[K,...I];return jd(ch,Q),Q})},xe=K=>{K.key==="ArrowDown"?(K.preventDefault(),N(I=>Math.min(I+1,Math.max(0,ne.length-1)))):K.key==="ArrowUp"?(K.preventDefault(),N(I=>Math.max(I-1,0))):K.key==="Enter"&&ne[A]&&(K.preventDefault(),te(ne[A]))};let se=-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(Es,{size:15})," Suggested tasks"]}),s.jsxs("small",{children:[_," available · ",O.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(Ya,{size:16})})]}),s.jsxs("label",{className:"agents-suggested-search",children:[s.jsx(t0,{size:15,"aria-hidden":"true"}),s.jsx("input",{ref:U,value:p,onChange:K=>g(K.target.value),onKeyDown:xe,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",...hx].map(K=>{const I=K==="recent"?Vx:K==="favorites"?Ch:K==="all"?Es:K==="available"?Fn:K==="unavailable"?n0:K==="read-only"||K==="auto"||K==="approval"||K==="full-access"?Bt:ON[K];return s.jsxs("button",{className:v===K?"active":"",type:"button",title:uh(K),"aria-label":uh(K),"aria-pressed":v===K,onClick:()=>{w(K),N(0),T("")},children:[s.jsx(I,{size:12})," ",HN(K)]},K)})}),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:[G.map(K=>s.jsxs("div",{className:"agents-suggested-group",children:[s.jsx("strong",{children:K.category}),K.templates.map(I=>{se+=1;const Q=se===A,q=C.includes(I.id),V=Y.get(I.id),ce=V.availableDeviceIds.length+V.unsupportedDeviceIds.length||D,be=V.available?`Available on ${V.availableDeviceIds.length} of ${ce} target${ce===1?"":"s"}`:`Unavailable: ${V.reason||"not supported by the current targets"}`;return s.jsxs("div",{className:`agents-suggested-item ${Q?"active":""} ${V.available?"":"unavailable"}`,children:[s.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Q,"aria-disabled":!V.available,onClick:()=>te(I),children:[s.jsx("span",{children:I.title}),s.jsx("small",{className:"agents-suggested-description",children:I.description}),s.jsxs("span",{className:"agents-suggested-meta",children:[s.jsx("em",{children:I.category}),s.jsx("em",{className:FN(V.state),children:V.label}),s.jsx("em",{className:`risk-${I.risk}`,children:PN(I.risk)}),s.jsx("em",{children:I.supportedPlatforms.map($N).join(" · ")}),s.jsx("em",{className:V.available?"availability-ok":"availability-unavailable",children:be}),V.available&&V.unsupportedDeviceIds.length>0&&s.jsxs("em",{className:"availability-warning",children:["Unsupported on ",V.unsupportedDeviceIds.length]})]})]}),s.jsx("button",{className:`agents-suggested-favorite ${q?"favorite":""}`,type:"button","aria-label":q?`Remove ${I.title} from favorites`:`Add ${I.title} to favorites`,"aria-pressed":q,onClick:()=>B(I.id),children:s.jsx(Ch,{size:14,fill:q?"currentColor":"none"})})]},I.id)})]},K.category)),ne.length===0&&s.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function qN({devices:n,mode:a,selectedIds:r,onModeChange:l,onToggle:c,permissionMode:d,onPermissionModeChange:m}){const p=n.filter(Qd),g=r.filter(v=>p.some(w=>w.deviceId===v)).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($c,{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(Ii,{size:14})," Selected ",g]}),s.jsxs("button",{className:a==="auto"?"active":"",onClick:()=>l("auto"),type:"button",children:[s.jsx(Es,{size:14})," Auto"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Saved workstation groups are coming next.",children:[s.jsx($c,{size:14})," Group ",s.jsx("small",{children:"Soon"})]})]}),s.jsxs("label",{className:`agents-permission-picker permission-${d}`,children:[s.jsx(Jd,{size:14}),s.jsx("span",{children:"Permission"}),s.jsxs("select",{value:d,onChange:v=>m(v.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(Zx,{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(v=>{const w=Qd(v),x=a==="all"||a==="auto"?w:r.includes(v.deviceId);return s.jsxs("label",{className:`agents-target-option ${x?"selected":""} ${w?"":"offline"}`,children:[s.jsx("input",{type:"checkbox",checked:x,disabled:!w||a!=="selected",onChange:()=>c(v.deviceId)}),s.jsx("span",{className:"agents-target-icon",children:s.jsx(an,{size:15})}),s.jsxs("span",{children:[s.jsx("strong",{children:Kd(v)}),s.jsx("small",{children:w?"Ready":v.connected?"Agent reconnecting":"Offline"})]}),x&&s.jsx(Ii,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},v.deviceId)})})]})}async function GN(n,a){return Ge("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function VN(n,a){return Ge("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function WN(n,a){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function YN(n,a){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function KN(n){return Ge("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function QN(n,a,r,l){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/approve`,{method:"POST",body:JSON.stringify({scope:l})},n)}async function XN(n,a,r,l="User rejected this action."){return Ge(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(r)}/reject`,{method:"POST",body:JSON.stringify({reason:l})},n)}async function ZN(n,a,r){return Ge(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:r})},n)}async function JN(n,a){return Ge("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function eM(n,a){return Ge("/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 tM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function nM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function aM(n,a){return Ge(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function Sl(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function kd(n,a){const r=new Map(a.map(l=>[l.deviceId,Kd(l)]));return n.results.map(l=>({deviceId:l.deviceId,deviceName:l.deviceName||r.get(l.deviceId)||l.deviceId,status:vN(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 sM(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 iM(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 g=p.result||"";return!/not running|no process/i.test(g)&&/running|online|found/i.test(g)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return l.length>0?`${m}
|
|
15
15
|
${l.map(p=>`${p.deviceName}는 ${p.error||"응답하지 않았습니다."}`).join(`
|
|
16
|
-
`)}`:m}return l.length>0?`${r.length}대 완료, ${l.length}대 실패했습니다.`:`${r.length}대 작업이 완료되었습니다.`}const
|
|
16
|
+
`)}`:m}return l.length>0?`${r.length}대 완료, ${l.length}대 실패했습니다.`:`${r.length}대 작업이 완료되었습니다.`}const rM={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 lM(n){return n==="safe-auto"?"Safe Auto":n==="full-access"?"Full Access":n==="custom"?"Custom":"Ask"}function oM(n){return n.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase())}function cM(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 vx({hubUrl:n,devices:a,launchRequest:r,variant:l="page",selectedDeviceIds:c=[]}){const d=l==="dock",[m,p]=u.useState(d?c.length>0?"selected":"auto":"all"),[g,v]=u.useState(c),[w,x]=u.useState("auto"),[b,C]=u.useState(""),[j,A]=u.useState([]),[N,k]=u.useState(""),[T,R]=u.useState(""),[U,O]=u.useState(""),[Y,_]=u.useState("safe-auto"),[D]=u.useState("custom-default"),[ne,G]=u.useState(rM),[te,B]=u.useState([]),[xe,se]=u.useState(""),[K,I]=u.useState(!1),[Q,q]=u.useState(null),[V,ce]=u.useState(!1),[be,X]=u.useState(""),[$,ue]=u.useState(!1),[he,ve]=u.useState(null),Se=u.useRef(null),_e=u.useRef(new Set),re=u.useRef(new Set),Z=u.useRef(new Set),ze=u.useMemo(()=>a.filter(Qd).map(ge=>ge.deviceId),[a]),Le=u.useMemo(()=>IN(nw,a,m,g,Y,ne),[ne,a,Y,g,m]);u.useEffect(()=>{d&&v(c)},[d,c]),u.useEffect(()=>{r?.deviceId&&(p("selected"),v([r.deviceId]),C(r.instruction),ue(!1),window.requestAnimationFrame(()=>{Se.current?.focus(),Se.current?.setSelectionRange(r.instruction.length,r.instruction.length)}))},[r]);const ae=u.useCallback(ge=>{const Oe=kd(ge,a);if(A(Fe=>Fe.map(ke=>ke.type==="task"&&ke.batchId===ge.batchId?{...ke,states:sM(ke.states,Oe),status:ge.status}:ke)),!["running","queued"].includes(ge.status)&&!_e.current.has(ge.batchId)){_e.current.add(ge.batchId);const Fe=Sl("agent-summary");A(ke=>[...ke,{type:"agent",id:Fe,text:iM(ge,Oe)}]),ge.operation&&JN(n,{instruction:ge.instructionPreview,operation:ge.operation,total:Oe.length,completed:Oe.filter(ke=>ke.status==="completed").length,failed:Oe.filter(ke=>ke.status==="failed").length,results:Oe.map(ke=>({deviceName:ke.deviceName,status:ke.status,result:ke.result,error:ke.error}))}).then(ke=>{!ke.ok||!ke.summary||A(st=>st.map(gt=>gt.type==="agent"&>.id===Fe?{...gt,text:ke.summary}:gt))}).catch(()=>{}),k(ke=>ke===ge.batchId?"":ke)}},[a,n]),fe=u.useCallback(async ge=>{const Oe=await tM(n,ge);return ae(Oe),Oe},[n,ae]),Ae=u.useCallback((ge,Oe)=>{Z.current.has(ge.batchId)||(Z.current.add(ge.batchId),A(Fe=>[...Fe,{type:"task",id:Sl("task"),batchId:ge.batchId,agentRunId:Oe,operation:ge.operation||"diagnostics.collect",instruction:ge.instructionPreview,states:kd(ge,a),status:ge.status}])),ae(ge)},[a,ae]),Te=u.useCallback(async ge=>{const Oe=await WN(n,ge);for(const ke of Oe.taskBatches||[])Ae(ke,ge);B(Oe.approvals||[]);const Fe=["running","queued","waiting-approval"].includes(Oe.status);if(ve(Fe?{runId:ge,stage:Oe.stage||Oe.status,message:Oe.progressMessage||(Oe.status==="waiting-approval"?"Review the requested action to continue.":"Codex is preparing the answer.")}:ke=>ke?.runId===ge?null:ke),!Fe&&!re.current.has(ge)){re.current.add(ge);const ke=[Oe.error,Oe.errorMessage].filter(Boolean).join(" — "),st=Oe.finalResponse?.trim()||(Oe.status==="cancelled"?"Codex 작업을 취소했습니다.":ke?`Codex 작업이 완료되지 않았습니다: ${ke}`:"Codex 작업이 완료되었습니다.");A(gt=>[...gt,{type:Oe.status==="failed"?"error":"agent",id:Sl("agent-run-result"),text:st}])}return Oe},[Ae,n]);u.useEffect(()=>{if(!N)return;let ge=!0;const Oe=async()=>{try{const ke=await fe(N);ge&&!["running","queued"].includes(ke.status)&&k("")}catch(ke){ge&&X(ke instanceof Error?ke.message:String(ke))}};Oe();const Fe=window.setInterval(()=>{Oe()},800);return()=>{ge=!1,window.clearInterval(Fe)}},[N,fe]),u.useEffect(()=>{if(!T)return;let ge=!0;const Oe=async()=>{try{const ke=await Te(T);ge&&!["running","queued","waiting-approval"].includes(ke.status)&&(R(""),ce(!1))}catch(ke){ge&&X(ke instanceof Error?ke.message:String(ke))}};Oe();const Fe=window.setInterval(()=>{Oe()},800);return()=>{ge=!1,window.clearInterval(Fe)}},[T,Te]);const Be=async(ge="",Oe,Fe=!1)=>{const ke=(ge||b).trim();if(!ke||N||T)return;let st=null;const gt=Oe||(m==="all"||m==="auto"?ze:g.filter(nt=>ze.includes(nt)));if(gt.length===0){X("Select at least one connected workstation.");return}if(Y==="full-access"&&!V&&!Fe){q({instruction:ke,targetIds:gt});return}if(A(nt=>[...nt,{type:"user",id:Sl("user"),text:ke}]),C(""),ue(!1),X(""),gt.length===0){A(nt=>[...nt,{type:"error",id:Sl("no-targets"),text:"연결된 대상 장비를 하나 이상 선택해 주세요."}]);return}const jn=w==="ask"?`Read-only request. Inspect and answer without changing workstation state.
|
|
17
17
|
|
|
18
18
|
${ke}`:w==="plan"?`Plan only. Produce a safe execution plan, but do not change workstation state.
|
|
19
19
|
|
|
@@ -21,5 +21,5 @@ ${ke}`:w==="execute"?`Execute this request within the configured LiveDesk approv
|
|
|
21
21
|
|
|
22
22
|
${ke}`:ke,Ls=m==="auto"?`Auto target selection is enabled. Inspect the allowed workstations and use only the most suitable target or targets for this request.
|
|
23
23
|
|
|
24
|
-
${jn}`:jn;if(!at){try{if(Y==="custom"){const zt=await XN(n,D,ne);if(!zt.ok)throw new Error(zt.error||"Custom Agent policy could not be saved.")}const nt=await GN(n,{instruction:Ls,deviceIds:gt,permissionMode:Y,customPolicyId:D});if(!nt.ok||!nt.runId)throw new Error(nt.error||"Codex Agent run could not be started.");B(nt.approvals||[]),ve({runId:nt.runId,stage:nt.stage||nt.status||"queued",message:nt.progressMessage||"Codex request queued on the Hub."}),R(nt.runId);return}catch(nt){try{const zt=await qN(n,Ls);zt.ok&&zt.plan&&(at={operation:zt.plan.operation,query:zt.plan.targetQuery})}catch{A(zt=>[...zt,{type:"error",id:wl("unsupported"),text:oM(nt)}])}}if(!at)return}try{const nt=await JN(n,{instruction:Ls,deviceIds:gt,operation:at.operation,targetQuery:at.query});if(!nt.ok||!nt.batch||!nt.batchId)throw new Error(nt.error||"작업을 만들지 못했습니다.");const zt={type:"task",id:wl("task"),batchId:nt.batchId,operation:at.operation,instruction:ke,states:jd(nt.batch,a),status:nt.batch.status};Z.current.add(nt.batchId),A(zn=>[...zn,zt]),k(nt.batchId)}catch(nt){X(nt instanceof Error?nt.message:String(nt))}},Ve=async(ge,Oe)=>{se(ge.approvalId);try{const Fe=await KN(n,ge.runId,ge.approvalId,Oe);if(!Fe.ok)throw new Error(Fe.error||"Agent approval could not be applied.");await Te(ge.runId)}catch(Fe){X(Fe instanceof Error?Fe.message:String(Fe))}finally{se("")}},Je=async ge=>{se(ge.approvalId);try{const Oe=await QN(n,ge.runId,ge.approvalId);if(!Oe.ok)throw new Error(Oe.error||"Agent approval could not be rejected.");await Te(ge.runId)}catch(Oe){X(Oe instanceof Error?Oe.message:String(Oe))}finally{se("")}},Et=async(ge,Oe)=>{O(ge);try{if(Oe){const ke=await WN(n,Oe);for(const at of ke.taskBatches||[])ae(at);R(at=>at===Oe?"":at),ve(at=>at?.runId===Oe?null:at);return}const Fe=await tM(n,ge);ae(Fe),k(ke=>ke===ge?"":ke)}catch(Fe){X(Fe instanceof Error?Fe.message:String(Fe))}finally{O("")}},je=async()=>{if(!(K||!N&&!T)){I(!0);try{const ge=await YN(n);if(!ge.ok)throw new Error(ge.error||"모든 Agent 작업을 취소하지 못했습니다.");k(""),R(""),ve(null),B([]),A(Oe=>Oe.map(Fe=>Fe.type==="task"&&["queued","running"].includes(Fe.status)?{...Fe,status:"cancelled",states:Fe.states.map(ke=>["queued","running"].includes(ke.status)?{...ke,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:ke)}:Fe))}catch(ge){X(ge instanceof Error?ge.message:String(ge))}finally{I(!1)}}},We=async ge=>{O(ge);try{const Oe=await nM(n,ge);if(!Oe.ok||!Oe.batch||!Oe.batchId)throw new Error(Oe.error||"재시도하지 못했습니다.");_e.current.delete(Oe.batchId),A(Fe=>Fe.map(ke=>ke.type==="task"&&ke.batchId===ge?{...ke,batchId:Oe.batchId,states:jd(Oe.batch,a),status:Oe.batch.status}:ke)),k(Oe.batchId)}catch(Oe){X(Oe instanceof Error?Oe.message:String(Oe))}finally{O("")}},it=ge=>{C(ge),ue(!1),window.requestAnimationFrame(()=>Se.current?.focus())},ot=u.useMemo(()=>a.filter(Kd),[a]),gn=u.useMemo(()=>ot.filter(ge=>g.includes(ge.deviceId)),[ot,g]),Kt=m==="auto"?`Auto · ${ot.length} available`:m==="all"?`All ${ot.length} computers`:gn.length===1?Yd(gn[0]):`${gn.length} selected`,Ie=m==="auto"?"LiveDesk chooses the best computer for each task.":m==="all"?"The Agent may coordinate every connected computer.":gn.length>0?gn.map(Yd).join(" · "):"Select one or more computers on the Wall.",ct=m==="selected"&&gn.length===1?["Diagnose this computer","Analyze recent errors","Summarize running applications","Check disk and GPU capacity"]:m==="all"?["Compare all computer health","Find the busiest computer","Check disk capacity everywhere","Divide a task across computers"]:["Use the fastest computer","Find an idle computer","Choose the best GPU","Check all computer health"],_t=m==="selected"?gn.length>0?"What should this computer do?":"Choose a computer or use Auto.":m==="all"?"Use all your computers together.":"What should LiveDesk handle?",Ft=m==="auto"?"LiveDesk can inspect the available computers and choose the best target.":"Describe the outcome. LiveDesk will plan, request approval when needed, and show progress per computer.";return s.jsxs("section",{className:`agents-page ${d?"agents-dock-console":""}`,children:[d&&s.jsxs("header",{className:"agent-console-header",children:[s.jsxs("div",{className:"agent-console-title",children:[s.jsx("span",{className:"agent-console-mark",children:s.jsx(Es,{size:16})}),s.jsxs("div",{children:[s.jsx("small",{children:"Live agent"}),s.jsx("strong",{children:"Agent Console"})]}),s.jsx("i",{children:"Ready"})]}),s.jsxs("section",{className:"agent-console-target","aria-label":"Agent target scope",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Target"}),s.jsx("strong",{children:Kt}),s.jsx("small",{children:Ie})]}),s.jsxs("div",{className:"agent-console-target-modes",children:[s.jsxs("button",{className:m==="selected"?"active":"",onClick:()=>p("selected"),type:"button",children:[s.jsx(Ii,{size:12})," Selected"]}),s.jsxs("button",{className:m==="all"?"active":"",onClick:()=>p("all"),type:"button",children:[s.jsx(Pc,{size:12})," All"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Saved workstation groups are coming next.",children:[s.jsx(Pc,{size:12})," Group"]}),s.jsxs("button",{className:m==="auto"?"active":"",onClick:()=>p("auto"),type:"button",children:[s.jsx(Es,{size:12})," Auto"]})]})]}),s.jsx("div",{className:"agent-console-interaction-modes","aria-label":"Agent interaction mode",children:["auto","ask","plan","execute"].map(ge=>s.jsxs("button",{className:w===ge?"active":"",onClick:()=>x(ge),type:"button",children:[ge==="auto"?s.jsx(Es,{size:12}):ge==="execute"?s.jsx(an,{size:12}):null,ge[0].toUpperCase()+ge.slice(1)]},ge))})]}),s.jsxs("div",{className:"agents-workspace",children:[(N||T)&&s.jsxs("div",{className:"agents-page-status",children:[s.jsxs("span",{children:[ze.length," workstations · ",rM(Y)]}),s.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{je()},disabled:K,children:K?"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(Zd,{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:()=>q(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"danger",onClick:()=>{const ge=Q;q(null),ce(!0),Be(ge.instruction,ge.targetIds,!0)},children:"Run with Full Access"})]})]})}),be&&s.jsx("div",{className:"agents-error",role:"alert",children:be}),s.jsx(AN,{items:j,onCancel:Et,onRetry:We,busyBatchId:U,approvals:te,onApprove:Ve,onReject:Je,busyApprovalId:xe,progress:he,emptyTitle:d?_t:void 0,emptyBody:d?Ft:void 0}),d&&j.length===0&&!he&&s.jsx("div",{className:"agent-console-suggestions","aria-label":"Suggested Agent commands",children:ct.map(ge=>s.jsx("button",{type:"button",onClick:()=>it(ge),children:ge},ge))}),s.jsxs("div",{className:"agents-composer-shell",children:[$&&s.jsx($N,{devices:a,targetMode:m,selectedIds:g,permissionMode:Y,customCategories:ne,onSelectPrompt:it,onClose:()=>ue(!1)}),s.jsx(hN,{ref:Se,value:b,onChange:C,onSubmit:()=>{Be()},onOpenSuggestedTasks:()=>ue(ge=>!ge),suggestedOpen:$,suggestedTaskCount:De,disabled:!!N||!!T,placeholder:d?"Tell LiveDesk what outcome you want...":void 0})]})]}),!d&&s.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[s.jsx(UN,{devices:a,mode:m,selectedIds:g,onModeChange:p,onToggle:ge=>v(Oe=>Oe.includes(ge)?Oe.filter(Fe=>Fe!==ge):[...Oe,ge]),permissionMode:Y,onPermissionModeChange:ge=>{_(ge),ge!=="full-access"&&ce(!1)}}),Y==="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:pN.map(ge=>s.jsxs("label",{children:[s.jsx("span",{children:lM(ge)}),s.jsxs("select",{value:ne[ge],onChange:Oe=>G(Fe=>({...Fe,[ge]:Oe.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"})]})]},ge))})]})]})]})}function aw(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function sw(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function iw(n,a,r){const l=encodeURIComponent(JSON.stringify({kind:a.kind,fileName:a.fileName,mimeType:n.type||"application/octet-stream",durationMs:a.durationMs,target:aw(a.target)})),c=await fetch(`${Or(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 sw(c));return await c.json()}async function cM(n,a){return await Ge("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:aw(n.target)})},a)}async function uM(n,a,r,l){const c=await fetch(`${Or(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 sw(c));return await c.json()}async function dM(n,a,r){return await Ge(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},r)}async function vx(n,a){await Ge(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function fM(n){return await Ge("/api/captures",void 0,n)}function yx(n,a){return`${Or(a)}/api/captures/${encodeURIComponent(n)}/content`}async function mM(n,a){return await Ge(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function hM({hubUrl:n,onToast:a}){const[r,l]=u.useState([]),[c,d]=u.useState(!0),m=u.useCallback(async()=>{d(!0);try{l((await fM(n)).captures||[])}catch(g){a(g instanceof Error?g.message:String(g))}finally{d(!1)}},[n,a]);u.useEffect(()=>{m()},[m]);const p=async g=>{const v=yx(g.id,n);if(navigator.share)try{await navigator.share({title:g.fileName,url:v});return}catch{}window.open(v,"_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(Ro,{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(g=>{const v=yx(g.id,n);return s.jsxs("article",{className:"capture-gallery-card",children:[g.mimeType.startsWith("image/")?s.jsx("img",{src:v,alt:g.target.label}):s.jsx("video",{src:v,controls:!0,preload:"metadata"}),s.jsxs("div",{className:"capture-gallery-card-body",children:[s.jsx("strong",{children:g.fileName}),s.jsxs("small",{children:[g.target.label," · ",new Date(g.createdAt).toLocaleString()," · ",Math.ceil(g.sizeBytes/1024)," KB"]}),s.jsxs("div",{children:[s.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),type:"button",children:s.jsx(i0,{size:15})}),s.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${v}?download=1`,download:g.fileName,children:s.jsx(Vh,{size:15})}),s.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(g)},type:"button",children:s.jsx(r0,{size:15})}),s.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${g.fileName}?`)&&mM(g.id,n).then(()=>m()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:s.jsx(Wh,{size:15})})]})]})]},g.id)})})]})}function kd(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 xx({controller:n,compact:a=!1,onFirstRollingUse:r,onError:l}){const{state:c,settings:d,videoSupported:m}=n,p=async x=>{try{await x()}catch(b){l?.(b instanceof Error?b.message:String(b))}},g=async()=>{if(d.rollingEnabled){n.setRollingEnabled(!1);return}(r?await r():window.confirm(`Keep the most recent 30 seconds in memory temporarily?
|
|
25
|
-
Nothing is saved until you press Save Last 30s.`))&&n.setRollingEnabled(!0)},v=c.recording?`Stop recording · ${kd(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${kd(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(l0,{size:17})}),s.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":v,title:v,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(sy,{size:14,fill:"currentColor"}),s.jsx("span",{children:kd(c.recordingStartedAt)})]}):s.jsx(Qx,{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 g(),type:"button",children:[s.jsx(o0,{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(sy,{size:14,fill:"currentColor"}),s.jsx("span",{children:kd(c.timelapseStartedAt)})]}):s.jsx(c0,{size:17})})]})}async function pM(n,a={}){const r=n.filter(x=>x.canvas&&x.canvas.width>0&&x.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),g=Math.floor(c/m),v=document.createElement("canvas");v.width=Math.max(320,p*d),v.height=Math.max(180,g*m);const w=v.getContext("2d",{alpha:!1});if(!w)return v;w.fillStyle="#0b1220",w.fillRect(0,0,v.width,v.height),w.font="600 14px system-ui, sans-serif",w.textBaseline="bottom";for(let x=0;x<r.length;x+=1){const b=r[x],C=x%d,j=Math.floor(x/d),A=C*p,N=j*g,k=b.canvas,T=Math.min(p/k.width,g/k.height),R=Math.max(1,Math.floor(k.width*T)),U=Math.max(1,Math.floor(k.height*T)),O=A+Math.floor((p-R)/2),Y=N+Math.floor((g-U)/2);w.drawImage(k,O,Y,R,U),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(A,N+g-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,A+9,N+g-9))}return v}function gM(n){return n?.signature||"none"}function vM(n){return n?.label||"No capture target"}function bx(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function yM(){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 xM(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"Wall"}function bM(n){return`LiveDesk_${n.type==="wall"||n.type==="selection"?"Wall":`${xM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${yM()}.png`}async function wM(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 iw(l,{kind:"screenshot",fileName:bM(a),target:a},r);try{await navigator.clipboard.write([new ClipboardItem({"image/png":l})])}catch{}return c.capture}function rw(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function SM(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 lw(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=rw();if(!a)throw new Error("This browser does not support WebM recording.");const r=n.kind||"recording",l=await cM({kind:r,fileName:SM(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,g=!1,v=null,w=Promise.resolve();return d.ondataavailable=x=>{if(!x.data||x.data.size===0)return;const b=p++;w=w.then(()=>uM(l.sessionId,b,x.data,n.hubUrl).then(()=>{})).catch(C=>{v=v||(C instanceof Error?C:new Error(String(C))),n.onError?.(v)})},d.onerror=()=>{v=new Error("Video recording stopped unexpectedly."),n.onError?.(v)},d.start(1e3),{requestFrame:()=>{c.getVideoTracks()[0]?.requestFrame?.()},stop:async()=>{if(!g){if(g=!0,await new Promise(x=>{d.addEventListener("stop",()=>x(),{once:!0}),d.stop()}),c.getTracks().forEach(x=>x.stop()),await w,v)throw await vx(l.sessionId,n.hubUrl).catch(()=>{}),v;await dM(l.sessionId,Math.max(0,performance.now()-m),n.hubUrl)}},cancel:async()=>{g||(g=!0,d.stop(),c.getTracks().forEach(x=>x.stop()),await vx(l.sessionId,n.hubUrl).catch(()=>{}))}}}class CM{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=rw();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 iw(l,{kind:"last-30s",fileName:d,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},r)}}async function jM(n,a,r,l,c){const d=await lw({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 ow="livedesk.captureSettings";function kM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(ow)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function AM(n){const[a,r]=u.useState(kM),[l,c]=u.useState(0),[d,m]=u.useState(0),[p,g]=u.useState(0),[v,w]=u.useState(!1),x=u.useRef(void 0),b=u.useRef(!1),C=u.useRef(""),j=u.useRef(null),A=u.useRef(null),N=u.useRef(null),k=u.useRef(null),T=u.useRef(new CM),R=n.sourceRegistry.resolveCurrentTarget(),U=gM(R),O=vM(R),Y=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;u.useEffect(()=>{if(localStorage.setItem(ow,JSON.stringify(a)),!b.current)return;const q=JSON.stringify(a);q!==C.current&&(C.current=q,Ge("/api/settings",{method:"PATCH",body:JSON.stringify({revision:x.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(V=>{x.current=Number(V.revision||x.current||0)}).catch(()=>{}))},[n.hubUrl,a]),u.useEffect(()=>{let q=!0;return Ge("/api/settings",void 0,n.hubUrl).then(V=>{if(!q)return;const ce=V.settings?.filesAudio||{},be=typeof ce.rollingBufferEnabled=="boolean"?ce.rollingBufferEnabled:a.rollingEnabled,X=ce.recordingQuality==="high"?"high":"standard",$=[5,10,30,60].includes(Number(ce.timelapseIntervalSeconds))?Number(ce.timelapseIntervalSeconds):a.timelapseIntervalSeconds,ue=typeof ce.includeRemoteCursor=="boolean"?ce.includeRemoteCursor:a.includeRemoteCursor,he={rollingEnabled:be,recordingQuality:X,timelapseIntervalSeconds:$,includeRemoteCursor:ue};x.current=Number(V.revision||0),C.current=JSON.stringify(he),b.current=!0,r(he)}).catch(()=>{b.current=!0}),()=>{q=!1}},[n.hubUrl]);const _=u.useCallback(async q=>{if(q.sourceCanvas&&q.sourceCanvas.width>0&&q.sourceCanvas.height>0)return{target:bx(q),canvas:q.sourceCanvas,cleanup:()=>{}};const V=await n.sourceRegistry.composeWall(q.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let ce=!1;const be=window.setInterval(async()=>{if(ce)return;const X=await n.sourceRegistry.composeWall(q.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!X||ce||((V.width!==X.width||V.height!==X.height)&&(V.width=X.width,V.height=X.height),V.getContext("2d")?.drawImage(X,0,0))},100);return{target:bx(q),canvas:V,cleanup:()=>{ce=!0,window.clearInterval(be)}}},[n.sourceRegistry]);u.useEffect(()=>{const q=T.current;if(!a.rollingEnabled||!R||!Y){q.stop(),g(0);return}let V=!1,ce=null;return(async()=>{try{if(ce=await _(R),V)return;await q.start(ce.canvas,ce.target);const X=window.setInterval(()=>g(Math.round(q.seconds)),500),$=()=>{window.clearInterval(X),ce?.cleanup()};q.__cleanup=$}catch(X){V||n.onToast(X instanceof Error?X.message:String(X))}})(),()=>{V=!0,q.stop(),q.__cleanup?.(),q.__cleanup=void 0,g(0)}},[_,n.onToast,a.rollingEnabled,U,Y]);const D=u.useCallback(q=>r(V=>({...V,rollingEnabled:q})),[]),ne=u.useCallback(q=>r(V=>({...V,recordingQuality:q})),[]),G=u.useCallback(q=>r(V=>({...V,timelapseIntervalSeconds:q})),[]),te=u.useCallback(async()=>{const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let V=null;try{V=await _(q),await wM(V.canvas,V.target,n.hubUrl),n.onToast("Screenshot saved")}finally{V?.cleanup(),w(!1)}},[_,n.hubUrl,n.onToast,n.sourceRegistry]),B=u.useCallback(async()=>{if(N.current)throw new Error("Stop the timelapse before recording.");const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");const V=await _(q),ce=await lw({canvas:V.canvas,target:V.target,fps:q.type==="control"?30:15,hubUrl:n.hubUrl,onError:be=>n.onToast(be.message)});A.current=V.cleanup,j.current=ce,c(Date.now()),n.onToast("Recording started")},[_,n.hubUrl,n.onToast,n.sourceRegistry]),xe=u.useCallback(async()=>{const q=j.current;if(q){w(!0);try{await q.stop(),n.onToast("Recording saved")}finally{j.current=null,A.current?.(),A.current=null,c(0),w(!1)}}},[n.onToast]),se=u.useCallback(async()=>{if(j.current||N.current)throw new Error("Last 30s is unavailable during a recording.");const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await T.current.save(q,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),K=u.useCallback(async()=>{if(j.current)throw new Error("Stop the recording before starting a timelapse.");const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");const V=await _(q),ce=await jM(V.canvas,V.target,a.timelapseIntervalSeconds,n.hubUrl,be=>n.onToast(be.message));k.current=V.cleanup,N.current=ce,m(Date.now()),n.onToast("Timelapse started")},[_,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),I=u.useCallback(async()=>{const q=N.current;if(q){w(!0);try{await q.stop(),n.onToast("Timelapse saved")}finally{N.current=null,k.current?.(),k.current=null,m(0),w(!1)}}},[n.onToast]);return u.useEffect(()=>{const q=V=>{!j.current&&!N.current||(V.preventDefault(),V.returnValue="")};return window.addEventListener("beforeunload",q),()=>window.removeEventListener("beforeunload",q)},[]),u.useEffect(()=>()=>{T.current.stop(),j.current?.cancel(),N.current?.cancel(),A.current?.(),k.current?.()},[]),{state:u.useMemo(()=>({recording:!!j.current,recordingStartedAt:l,timelapse:!!N.current,timelapseStartedAt:d,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:v,targetLabel:O}),[p,v,l,a.rollingEnabled,O,d]),settings:a,videoSupported:Y,targetKey:U,setRollingEnabled:D,setRecordingQuality:ne,setTimelapseInterval:G,takeScreenshot:te,startRecording:B,stopRecording:xe,saveLast30Seconds:se,startTimelapse:K,stopTimelapse:I}}const NM=120,MM=999,Tc=5,Ec=30,TM=Number.POSITIVE_INFINITY,cw="livedesk.remoteDirectory",Hh="livedesk.localHubAccessEnabled",uw="livedesk.streamSettings",Bh=16,dw="livedesk.controlStreamSettings",Fh=6,fw="livedesk.wallMonitorSelections",mw=1,uh=512*1024,Ph="".trim(),hw="".trim(),wx="livedesk-adsense-script",dh=!!Ph&&!!hw,EM=1e3/60,fh=1500,RM=650,DM=1800,LM=650,_M=2500,Sx=1500,Cx=15e3,zM=6e4,jx=240,IM=1024,OM=480,HM=270,kx="Connected LiveDesk clients are updating in batches. Hub will restart after every target reconnects on the requested versions.",Ad="LiveDesk is replacing the Hub and verifying the requested version.",Nd=5*6e4,BM=5e3;function FM(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 Sl={free:{name:"Free",price:"$0",limit:Tc,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:Ec,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:TM,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},pw={"mode1-jpeg":5,"mode3-h264-hw":30,"mode4-h264-atlas":20};function Ax(n,a){const r=m=>{const g=String(m||"").trim().replace(/^v/i,"").match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/);if(!g)return null;const v=g[4]?g[4].split(".").map(w=>/^\d+$/.test(w)?w.length>1&&w.startsWith("0")?Number.NaN:Number(w):w):[];return v.some(w=>typeof w=="number"&&!Number.isFinite(w))?null:{core:[Number(g[1]),Number(g[2]),Number(g[3])],prerelease:v}},l=r(n),c=r(a);if(!l||!c)return!1;for(let m=0;m<3;m+=1){if(l.core[m]>c.core[m])return!0;if(l.core[m]<c.core[m])return!1}if(l.prerelease.length===0||c.prerelease.length===0)return l.prerelease.length===0;const d=Math.max(l.prerelease.length,c.prerelease.length);for(let m=0;m<d;m+=1){const p=l.prerelease[m],g=c.prerelease[m];if(p===void 0||g===void 0)return g===void 0;if(p!==g){if(typeof p=="number"&&typeof g=="number")return p>g;if(typeof p=="number")return!1;if(typeof g=="number"||p>g)return!0;if(p<g)return!1}}return!0}function Ms(n,a){return`${n}:${a}`}const ga={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:pw["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},Ra={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function mh(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 gw(n,a){n.push(a),n.length>jx&&n.splice(0,n.length-jx)}function Nx(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 Mx(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),gw(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 Tx(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 Ex(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function PM(n){return Number.isFinite(n)?String(n):"30+"}const Id=[{id:"mode4-h264-atlas",label:"Mode 4",detail:"Hub H.264 Atlas"},{id:"mode3-h264-hw",label:"Mode 3",detail:"H.264 hardware"}],$h=[{id:"prefer-software",label:"Software low latency"},{id:"prefer-hardware",label:"Hardware decode"},{id:"no-preference",label:"Browser auto"}],$M=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"}],Od=[{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}],hh=Od.filter(n=>n.width>=1280),ph=[{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}],vp=[1,2,5,8,12,20,30],UM=[20,30,60],Rx=[45,60,75,90],Dx={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},oa={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:ei.maxDirectFramesPerSecond,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},Lx=2200,qM=8e3,GM=3500,VM=7e3,WM=2,YM=2600,KM=4200,QM=750,XM=2,_x=4200;function zx(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function Hc(n,a){const r=n.capabilities?.[a];return typeof r=="boolean"?r:/^(1|true|yes|on)$/i.test(String(r||"").trim())}function fs(n){return n.deviceName||n.hostname||n.deviceId}function ZM(){return"npx -y --prefer-online livedesk@latest client"}function JM(){return"npx -y --prefer-online livedesk@latest"}function eT(){try{return localStorage.getItem(cw)||""}catch{return""}}function tT(){try{return localStorage.getItem(Hh)==="1"}catch{return!1}}function So(n){try{n?localStorage.setItem(Hh,"1"):localStorage.removeItem(Hh)}catch{}}function ms(n,a,r,l){const c=Number(n);return Number.isFinite(c)?Math.max(a,Math.min(r,Math.round(c))):l}function Uh(n){const a=String(n||"").trim();return Id.some(r=>r.id===a)?a:ga.frameMode}function Xd(n){const a=String(n||"").trim();return $h.some(r=>r.id===a)?a:ga.h264DecodeAcceleration}function qh(n){return n==="mode3-h264-hw"?n:Ra.frameMode}function vw(n){return pw[n]||12}function yw(n){return n==="mode3-h264-hw"?30:n==="mode4-h264-atlas"?20:30}function Gh(n,a){return ms(n,1,yw(a),vw(a))}function _l(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function pa(n){const a=_l(n.status),r=_l(a.screens),l=_l(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 _r(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function nT(n){const a=_l(n.status),l=[_l(a.screens).displays,a.displays,a.monitors];for(const c of l)if(!(!Array.isArray(c)||c.length===0))return c.map(d=>_l(d));return[]}function xw(n,a){const r=nT(n),l=r.find(g=>Number(g.index)===a)||r[a]||r[0]||{},c=_r(l.width),d=_r(l.height),m=[l.name,l.displayName,l.deviceName,l.id].find(g=>typeof g=="string"&&g.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 aT(n){const a=pa(n);return Array.from({length:a},(r,l)=>xw(n,l))}function sT(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 bw(n,a){const r=xw(n,a);if(r.width>0&&r.height>0)return{width:r.width,height:r.height};const l=_l(n.status),c=_r(l.screenWidth||l.width),d=_r(l.screenHeight||l.height);return c>0&&d>0?{width:c,height:d}:null}function ww(n){if(!n)return null;const a=_r(n.sourceWidth)||_r(n.width),r=_r(n.sourceHeight)||_r(n.height);return a>0&&r>0?{width:a,height:r}:null}function iT(n,a,r){const d=((typeof a?.monitorIndex=="number"?Ea(a.monitorIndex,Math.max(1,a.monitorCount||1)):r)===r?ww(a):null)||bw(n,r);return d?Math.max(.25,Math.min(4,d.width/d.height)):16/9}const Md=16/9;function Ea(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 rT(){try{const n=localStorage.getItem(fw);if(!n)return{};const a=JSON.parse(n),r=a&&typeof a=="object"&&!Array.isArray(a)?a.selections:void 0;if(Number(a?.version)!==mw||!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 lT(n){try{localStorage.setItem(fw,JSON.stringify({version:mw,selections:n}))}catch{}}function oT(){try{const n=JSON.parse(localStorage.getItem(uw)||"{}"),a=Number(n.version);if(![Bh,15,14,13,12,11].includes(a))return ga;const r=Uh(n.frameMode),l=ms(n.maxWidth,320,3840,ga.maxWidth),c=ms(n.maxHeight,180,2160,ga.maxHeight);return{frameMode:r,h264DecodeAcceleration:Xd(n.h264DecodeAcceleration),fps:a<Bh&&r==="mode3-h264-hw"?ga.fps:Gh(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:ms(n.quality,20,95,ga.quality),autoStartLive:typeof n.autoStartLive=="boolean"?n.autoStartLive:ga.autoStartLive,showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:ga.showScreenStatus,visibleOnlyLive:typeof n.visibleOnlyLive=="boolean"?n.visibleOnlyLive:ga.visibleOnlyLive,adaptiveLoadShedding:typeof n.adaptiveLoadShedding=="boolean"?n.adaptiveLoadShedding:ga.adaptiveLoadShedding,adaptiveSizeByWall:typeof n.adaptiveSizeByWall=="boolean"?n.adaptiveSizeByWall:ga.adaptiveSizeByWall}}catch{return ga}}function cT(n){try{localStorage.setItem(uw,JSON.stringify({...n,version:Bh}))}catch{}}function uT(){try{const n=JSON.parse(localStorage.getItem(dw)||"{}"),a=Number(n.version);if(![Fh,5,4,3,2,1].includes(a))return Ra;const r=ms(n.fps,20,60,Ra.fps),l=a<Fh;return{frameMode:l?Ra.frameMode:qh(n.frameMode),h264DecodeAcceleration:l?Ra.h264DecodeAcceleration:Xd(n.h264DecodeAcceleration),fps:l?Ra.fps:r,maxWidth:ms(n.maxWidth,1280,3840,Ra.maxWidth),maxHeight:ms(n.maxHeight,720,2160,Ra.maxHeight),quality:ms(n.quality,20,95,Ra.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:Ra.showScreenStatus}}catch{return Ra}}function dT(n){try{localStorage.setItem(dw,JSON.stringify({...n,version:Fh}))}catch{}}function gh(n,a){return n.length!==a.length?!1:n.every((r,l)=>r===a[l])}function vh(n){return[...new Set(n.filter(Boolean))].sort()}function fT(n){return oa.fallbackVisibleCounts[n]||oa.fallbackVisibleCounts.large}function mT(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=Dx[a]||Dx.large;return{maxWidth:Math.min(n.maxWidth,l.maxWidth),maxHeight:Math.min(n.maxHeight,l.maxHeight)}}function hT(n,a=oa.minFps){const r=[...vp].sort((c,d)=>c-d),l=Math.max(a,Math.floor(n/2));return[...r].reverse().find(c=>c<n&&c>=a)||l}function pT(n,a){return[...vp].sort((l,c)=>l-c).find(l=>l>n&&l<=a)||a}function Rc(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 Ix(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`${Ix(r)} / ${Ix(n)}`}function gT(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 Ox(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 vT(n){return n===1?"middle":n===2?"right":"left"}function Hx(n,...a){for(const r of a){const l=n?.[r];if(typeof l=="string"&&l.trim())return l.trim()}return""}function Bx(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=MM?a:0}const yT={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function xT(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=yT[c.id]||c.label;return c.value&&c.value!=="-"?`${d} ${c.value}`:d}function lf(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 hn(n,...a){for(const r of a){const l=lf(n,r),c=Number(l);if(Number.isFinite(c))return c}}function Wa(n,...a){for(const r of a){const l=lf(n,r);if(typeof l=="string"&&l.trim())return l.trim();if(typeof l=="number"&&Number.isFinite(l))return String(l)}return""}function bT(n,...a){for(const r of a){const l=lf(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 _i(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function xh(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return _i((n-Math.max(0,a))/n)}function Co(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 Cl(n,a=.92,r=.78){return n===void 0?"unknown":n>=a?"critical":n>=r?"warn":"good"}function wT(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 Td(n,a,r){const l=lf(n,`tools.${a}`),c=Wa(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),d=bT(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),m=Wa(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=Wa(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let g="unknown";return c==="busy"?g="busy":["online","running","ready","active"].includes(c)||d===!0?g="online":(["offline","stopped","missing","not-found"].includes(c)||d===!1||l===!1)&&(g="offline"),{id:a,label:r,status:g,detail:g==="offline"?"offline":m||(p?`:${p}`:g==="unknown"?"not reported":g)}}function ST(n){const a=n.status||{},r=hn(a,"cpu.cores","cpuCores","processorCount"),l=hn(a,"loadavg.0","cpu.load1"),c=_i(hn(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=hn(a,"memory.totalBytes","totalMem"),m=hn(a,"memory.freeBytes","freeMem"),p=_i(hn(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??xh(d,m),g=hn(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),v=hn(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=_i(hn(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??xh(g,v),x=hn(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=_i(hn(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),C=Wa(a,"gpu.name","gpu.model","accelerators.gpu.name"),j=hn(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),A=hn(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),N=_i(hn(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??xh(j,A),k=hn(a,"gpu.temperatureC","thermal.gpuC"),T=_i(hn(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),R=Wa(a,"npu.name","npu.model","accelerators.npu.name"),U=hn(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),O=hn(a,"network.rxMbps","network.receiveMbps","network.downMbps"),Y=hn(a,"network.txMbps","network.transmitMbps","network.upMbps"),_=hn(a,"network.latencyMs","network.rttMs"),D=_i(hn(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),ne=Wa(a,"network.link","network.interface","network.name"),G=x===void 0?void 0:_i((x-35)/60),te=Wa(a,"workload.role","role","lane")||(Hc(n,"aiAssist")?"Agent worker":Hc(n,"taskDispatch")?"Task worker":"Local machine"),B=Wa(n.latestTask,"status")||Wa(a,"workload.status")||"idle",xe=Wa(n.latestTask,"title","instructionPreview")||Wa(a,"workload.title"),se=Wa(n.latestTask,"resultSummary","error","instructionPreview")||Wa(a,"workload.summary"),K=[Td(a,"ollama","Ollama"),Td(a,"lmStudio","LM Studio"),Td(a,"comfyui","ComfyUI"),Td(a,"stableDiffusion","Stable Diffusion")],I=K.some(X=>X.status!=="unknown"),Q=Date.parse(n.lastSeenAt||n.connectedAt||""),q=Number.isFinite(Q)?Date.now()-Q:0;let V="online";n.connected?q>5*6e4?V="stale":(x??0)>=86||(k??0)>=88||(c??0)>=.94||(b??0)>=.96||(N??0)>=.96||(T??0)>=.96||(p??0)>=.94||(w??0)>=.94||(_??0)>=200||B==="failed"?V="critical":(x??0)>=78||(k??0)>=80||(c??0)>=.82||(b??0)>=.86||(N??0)>=.88||(T??0)>=.86||(p??0)>=.82||(w??0)>=.86||(_??0)>=80?V="warn":(["queued","running","targeted"].includes(B)||K.some(X=>X.status==="busy"))&&(V="busy"):V="offline";const ce=K.filter(X=>X.status==="online"||X.status==="busy").length,be=[{id:"cpu",label:"CPU",value:Co(c),detail:r?`${r} cores`:l!==void 0?`load ${l.toFixed(1)}`:"not reported",ratio:c,state:Cl(c,.92,.78)},{id:"memory",label:"RAM",value:Co(p),detail:yh(d,m),ratio:p,state:Cl(p,.92,.78)},{id:"disk",label:"DISK",value:Co(w),detail:yh(g,v),ratio:w,state:Cl(w,.92,.82)},{id:"gpu",label:"GPU",value:Co(b),detail:C||(j&&A!==void 0?`${Rc(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":Cl(b,.96,.86)},{id:"vram",label:"VRAM",value:Co(N),detail:yh(j,A),ratio:N,state:Cl(N,.96,.88)},{id:"npu",label:"NPU",value:T!==void 0?Co(T):U!==void 0?`${Math.round(U)} TOPS`:"-",detail:R||(U!==void 0?"neural engine":"not reported"),ratio:T,state:Cl(T,.96,.86)},{id:"temp",label:"TEMP",value:x===void 0?"-":`${Math.round(x)}C`,detail:ce>0?`${ce} local tools`:`uptime ${wT(hn(a,"uptimeSec"))}`,ratio:G,state:x===void 0?"unknown":x>=86?"critical":x>=78?"warn":"good"},{id:"network",label:"NET",value:bh(O)||(_!==void 0?`${Math.round(_)}ms`:ne||"-"),detail:bh(Y)?`${bh(Y)} up`:ne||"not reported",ratio:D,state:_!==void 0&&_>=200?"critical":_!==void 0&&_>=80?"warn":Cl(D,.9,.75)}];return{state:V,label:xT(V,be,B),role:te,taskLabel:xe||(B==="idle"?"idle":B),taskStatus:B,taskSummary:se,tools:I?K:K.map(X=>({...X,detail:"not reported"})),metrics:be}}const CT=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],jT=[{id:"sync-server",label:"Hub",icon:Tl,accent:"blue",tooltip:"hub"},{id:"wall",label:"Wall",icon:Fc,accent:"blue",tooltip:"wall"},{id:"control",label:"Control",icon:Rd,accent:"red",tooltip:"control"},{id:"share-files",label:"Share Files",icon:Ed,accent:"green",tooltip:"share-files"},{id:"agents",label:"Agents",icon:Dd,accent:"violet",tooltip:"agents"}],kT=[{id:"doc",label:"Doc",icon:Hd,accent:"amber"},{id:"support",label:"Support",icon:Dc,accent:"violet"},{id:"pricing",label:"Pricing",icon:ko,accent:"green"}];function AT(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 on(n){return AT(n).replaceAll("Sync Server","Hub").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 jl(n){return n.map(a=>on(a))}function ra(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:on(n.title),intro:on(n.intro),sections:[{title:on(n.managerTitle),body:on(n.managerBody),points:jl(n.managerPoints)},{title:on(n.clientTitle),body:on(n.clientBody),points:jl(n.clientPoints)},{title:on(n.syncTitle),body:on(n.syncBody),points:jl(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:on(n.agentTitle),body:on(n.agentBody),points:jl(n.agentPoints)}]:[],{title:on(n.platformTitle),body:on(n.platformBody),points:jl(n.platformPoints)}],sync:{title:on(n.syncTitle),body:on(n.syncBody),points:jl(n.syncPoints)},firewall:{title:on(n.firewallTitle),body:on(n.firewallBody),points:jl(n.firewallPoints)},commands:{title:on(n.commandsTitle),body:on(n.commandsBody),manager:on(n.managerCommandLabel),primary:on(n.clientCommandLabel),slot:on(n.slotCommandLabel),manual:on(n.manualCommandLabel)}}}const Eo={ko:ra({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:ra({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:ra({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":ra({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":ra({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:ra({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:ra({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:ra({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":ra({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:ra({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:ra({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:ra({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:ra({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:ra({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:ra({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:ra({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ı"})},NT=Object.entries(Eo).map(([n,a])=>({id:n,label:a.languageName}));function MT(){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(Eo[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(Eo[l])return l}return"en"}function Fx({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(an,{size:24}),s.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function TT(n){if(!n)return!1;const a=String(n.platform||"").trim().toLowerCase();return zi(a)&&n.capabilities?.screenRecordingPermission===!1}function zi(n){const a=String(n||"").trim().toLowerCase();return a==="macos"||a==="darwin"||a==="mac"||a==="macosx"}function Px(n){if(!n)return!1;const a=String(n.capabilities?.liveCaptureConcurrency||"").trim().toLowerCase();return a==="exclusive"?!0:a==="parallel"?!1:zi(n.platform)}function wh({device:n,frame:a,selected:r,controlEnabled:l,showStatus:c,monitorIndex:d,monitorCount:m,onSelect:p,onFocusDevice:g,onOpenControl:v,onCycleMonitor:w,onCanvasReady:x,sendInput:b,updateIndicator:C,presentationReady:j,showPresentationSpinner:A=!1}){const N=u.useRef(null),k=u.useRef(null),T=u.useRef(0),R=u.useRef(null),U=ST(n),O=["cpu","gpu","memory","vram"].map($=>U.metrics.find(ue=>ue.id===$)).filter($=>!!$),Y=Ea(d,m),_=m>1,D=j??!!a,ne=TT(n)&&!D,G=A&&n.connected&&!D&&!ne,te=iT(n,a,Y),B=te>=Md?100:te/Md*100,xe=te>=Md?Md/te*100:100,se={"--screen-aspect":te.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,B)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,xe)).toFixed(3)}%`},K=u.useCallback($=>{N.current=$,x(n.deviceId,$)},[n.deviceId,x]),I=$=>{const ue=$.currentTarget.getBoundingClientRect();return kj($.clientX,$.clientY,ue)},Q=$=>({shiftKey:$.shiftKey,ctrlKey:$.ctrlKey,altKey:$.altKey,metaKey:$.metaKey}),q=u.useCallback(()=>{R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)},[]),V=u.useCallback(()=>{const $=k.current;if(!$)return;k.current=null;const ue=Number($.input.normalizedX),he=Number($.input.normalizedY);if(!Number.isFinite(ue)||!Number.isFinite(he))return;b(n.deviceId,{...$.input,normalizedX:ue,normalizedY:he})&&(T.current=performance.now())},[n.deviceId,b]),ce=u.useCallback(()=>{R.current===null&&(R.current=window.requestAnimationFrame(()=>{R.current=null,V()}))},[V]);u.useEffect(()=>()=>{q(),k.current=null},[q]);const be=($,ue)=>{if(!l)return;const he={type:ue,monitorIndex:Y,...I($),button:vT($.button),...Q($)};if(ue==="pointermove"){const ve=performance.now();k.current={input:he},ve-T.current>=EM&&(q(),V()),ce();return}k.current&&(q(),V()),b(n.deviceId,he)},X=u.useCallback($=>{const ue=document.activeElement;ue instanceof HTMLElement&&$.contains(ue)&&ue.classList.contains("monitor-cycle-button")&&ue.blur()},[]);return s.jsx("article",{className:`device-tile ${r?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:se,children:s.jsxs("div",{className:`tile-screen ${D?"has-frame":"is-empty"}`,role:"button",tabIndex:l?-1:0,"aria-pressed":r,onClick:$=>{$.target instanceof Element&&$.target.closest(".monitor-cycle")||l||p()},onKeyDown:$=>{$.target instanceof Element&&$.target.closest(".monitor-cycle")||l||($.key==="Enter"||$.key===" ")&&($.preventDefault(),p())},onDoubleClick:$=>{$.target instanceof Element&&$.target.closest(".monitor-cycle")||($.preventDefault(),v())},onPointerLeave:$=>X($.currentTarget),children:[s.jsx("span",{className:`screen-content ${D?"has-frame":"is-empty"}`,children:s.jsx("canvas",{ref:K,className:`remote-canvas ${D?"has-frame":"is-empty"}`,tabIndex:l?0:-1,onPointerDown:$=>{l&&($.preventDefault(),$.stopPropagation(),g(),$.currentTarget.focus(),$.currentTarget.setPointerCapture($.pointerId),be($,"pointerdown"))},onPointerMove:$=>{l&&$.preventDefault(),be($,"pointermove")},onPointerLeave:$=>{l&&(be($,"pointermove"),q(),V())},onPointerUp:$=>{l&&($.preventDefault(),$.stopPropagation(),be($,"pointerup"),$.currentTarget.hasPointerCapture($.pointerId)&&$.currentTarget.releasePointerCapture($.pointerId))},onPointerCancel:$=>{$.currentTarget.hasPointerCapture($.pointerId)&&$.currentTarget.releasePointerCapture($.pointerId)},onWheel:$=>{l&&($.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:Y,...I($),deltaX:$.deltaX,deltaY:$.deltaY,...Q($)}))},onKeyDown:$=>{l&&($.preventDefault(),$.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:Y,key:$.key,code:$.code,keyCode:$.keyCode||$.which||0,location:$.location,text:$.key.length===1?$.key:"",repeat:$.repeat,...Q($)}))},onKeyUp:$=>{l&&($.preventDefault(),$.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:Y,key:$.key,code:$.code,keyCode:$.keyCode||$.which||0,location:$.location,text:$.key.length===1?$.key:"",repeat:!1,...Q($)}))},onContextMenu:$=>l&&$.preventDefault()})}),!D&&s.jsx("span",{className:"empty-screen",children:s.jsx(an,{size:26})}),G&&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"})]}),ne&&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."})]}),C&&s.jsxs("span",{className:`wall-update-status state-${C.state}`,role:"status","aria-live":"polite",title:C.error||C.label,children:[C.state==="updated"?s.jsx(Fn,{size:20,"aria-hidden":"true"}):C.state==="failed"?s.jsx(Ya,{size:22,"aria-hidden":"true"}):C.state==="offline"?s.jsx(Rl,{size:22,"aria-hidden":"true"}):s.jsx("span",{className:"wall-update-spinner","aria-hidden":"true"}),s.jsx("strong",{children:C.label}),C.error?s.jsx("small",{children:C.error}):null]}),c&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`tile-health-pill state-${U.state}`,children:U.label}),s.jsx("span",{className:"tile-metrics","aria-label":`${fs(n)} status`,children:O.map($=>s.jsxs("span",{className:`tile-metric state-${$.state}`,children:[s.jsx("b",{children:$.label}),s.jsx("em",{children:$.value}),$.ratio!==void 0&&s.jsx("i",{style:{width:`${Math.round($.ratio*100)}%`}})]},$.id))})]}),_&&s.jsxs("span",{className:"monitor-cycle","aria-label":`${fs(n)} display ${Y+1} of ${m}`,onPointerDown:$=>$.stopPropagation(),onClick:$=>$.stopPropagation(),onDoubleClick:$=>$.stopPropagation(),children:[s.jsx("button",{className:"monitor-cycle-button previous",onClick:$=>{$.preventDefault(),$.stopPropagation(),w(-1),$.currentTarget.blur()},title:"Previous display",type:"button",children:s.jsx(Zx,{size:18})}),s.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",Y+1,"/",m]}),s.jsx("button",{className:"monitor-cycle-button next",onClick:$=>{$.preventDefault(),$.stopPropagation(),w(1),$.currentTarget.blur()},title:"Next display",type:"button",children:s.jsx(Qh,{size:18})})]}),r&&s.jsx("span",{className:"device-selection-check","aria-hidden":"true",children:s.jsx(Ii,{size:23,strokeWidth:3.5})})]})})}function ET({visible:n}){return u.useEffect(()=>{if(!n||!dh)return;if(!document.getElementById(wx)){const r=document.createElement("script");r.id=wx,r.async=!0,r.crossOrigin="anonymous",r.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(Ph)}`,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 ${dh?"adsense-ready":"house-ad"}`,"aria-label":"Advertisement",children:[s.jsx("span",{className:"ad-label",children:"Advertisement"}),dh?s.jsx("ins",{className:"adsbygoogle livedesk-ad-unit",style:{display:"block"},"data-ad-client":Ph,"data-ad-slot":hw,"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 RT(){const{session:n,loading:a}=aj(),{target:r,error:l,refresh:c}=ij(n),d=u.useMemo(()=>{if(!r?.active)return null;const y=r.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(y)&&y<=Date.now()?null:r},[r]),m=u.useMemo(()=>vy(d),[d]),p=u.useMemo(()=>m.length>0?[...new Set([...m,Cn])]:[Cn],[m]),[g,v]=u.useState(tT),w=u.useMemo(()=>p.some(y=>!!zc(y)),[p]),x=!w||g,{status:b,devices:C,error:j,refresh:A,hubBaseUrl:N}=sj(p,x),{entitlement:k,licensed:T,loading:R,error:U,refresh:O}=rj(n),[Y,_]=u.useState([]),[D,ne]=u.useState(""),[G,te]=u.useState(""),[B,xe]=u.useState(""),[se,K]=u.useState(""),[I,Q]=u.useState(""),[q,V]=u.useState("idle"),[ce,be]=u.useState(!1),[X,$]=u.useState(null),[ue,he]=u.useState(""),ve=u.useRef("");ve.current=se;const[Se,_e]=u.useState(!1),[re,Z]=u.useState(!1),ze=u.useRef(""),De=u.useRef(new Map),ae=u.useRef(0),[fe,Ae]=u.useState(""),[Te,Be]=u.useState(""),[Ve,Je]=u.useState(null);u.useEffect(()=>{fe==="auth"&&n?.access_token&&Ae("")},[fe,n?.access_token]);const[Et,je]=u.useState(""),[We,it]=u.useState(null),ot=u.useRef(null),gn=u.useRef(0),Kt=u.useCallback((y,M,L)=>{const F=String(y||"").trim();if(je(F),ot.current!==null&&(window.clearTimeout(ot.current),ot.current=null),!F){it(null);return}const z=++gn.current;if(it({id:z,message:F,tone:M}),!L)return;const pe=window.setTimeout(()=>{it(de=>de?.id===z?null:de),ot.current===pe&&(ot.current=null)},5e3);ot.current=pe},[]),Ie=u.useCallback((y,M="info")=>{Kt(y,M,!0)},[Kt]),ct=u.useCallback(y=>{Kt(y,"progress",!1)},[Kt]);u.useEffect(()=>()=>{ot.current!==null&&window.clearTimeout(ot.current)},[]);const[_t,Ft]=u.useState(()=>typeof window<"u"&&window.location.pathname.startsWith("/support")?"support":"wall");u.useEffect(()=>{const y=()=>{Ft(window.location.pathname.startsWith("/support")?"support":M=>M==="support"?"wall":M)};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[]);const[ge,Oe]=u.useState("large"),[Fe,ke]=u.useState(MT),[at,gt]=u.useState(!1),[Ee,jn]=u.useState(!1),[Ls,nt]=u.useState(!1),[zt,zn]=u.useState(eT),[He,va]=u.useState(oT),[dt,Hi]=u.useState(uT),[Qt,ps]=u.useState(rT),[bt,qn]=u.useState(null),[_s,H]=u.useState([]),[Pe,vt]=u.useState(He.fps),[sn,Qa]=u.useState(""),[Hr,Xa]=u.useState(0),[ee,Ne]=u.useState(0),[qe,rt]=u.useState(()=>new Set),Nt=u.useRef(new Map),Mt=u.useRef(new Map),Qe=u.useRef(new Map),ut=u.useRef(new Map),kn=u.useRef(new Map),Wt=u.useRef(new Set),An=u.useRef(new Map),St=u.useRef(""),rn=u.useRef(""),Pt=u.useRef(null),ya=u.useRef(null),ca=u.useRef(new Map),cn=u.useRef(null),vn=u.useRef(0),Br=u.useRef(new Map),[zs,Fr]=u.useState({}),_o=u.useRef(new Map),[Bi,zl]=u.useState({}),[Za,Zt]=u.useState(!1),Il=u.useRef(null),Ja=u.useRef(null),Xn=u.useRef(0),Is=u.useRef(""),Os=u.useRef(new Map),Pr=u.useRef(new Map),Gn=u.useRef(performance.now()),ai=u.useRef(new Map),si=u.useRef(new Map),Hs=u.useRef(new Map),Bs=u.useRef(new Map),Fi=u.useRef(0),$r=u.useRef(0),gs=u.useRef(0),Ol=u.useRef(0),Hl=u.useRef(0),zo=u.useRef(new Map),es=u.useRef(new Map),[ii,Fs]=u.useState(null),[Bl,_a]=u.useState(!1),[Yc,Io]=u.useState([]),[za,Pi]=u.useState("all"),[ri,Ur]=u.useState([]),[of,Fl]=u.useState(!1),[Ps,Oo]=u.useState(!0),$i=u.useRef(null),vs=u.useRef(null),Ho=u.useRef(null),Pl=u.useRef(null),Kc=u.useRef(!1),Ui=u.useRef(!1),qi=u.useRef(!1),Gi=u.useRef(0),ln=u.useRef(0),ts=_t==="settings",qr=_t==="pricing",Vi=_t==="doc",Qc=_t==="support",li=_t==="share-files",Gr=_t==="agents",Wi=!ts&&!qr&&!Vi&&!Qc&&!li&&!Gr,st=_t==="control",ft=He.frameMode==="mode4-h264-atlas",xa=I||dt.frameMode,Yi=xa!=="mode3-h264-hw"?Math.min(30,dt.fps):dt.fps,$s=xa!=="mode3-h264-hw"?{maxWidth:Math.min(1920,dt.maxWidth),maxHeight:Math.min(1080,dt.maxHeight)}:{maxWidth:dt.maxWidth,maxHeight:dt.maxHeight};u.useEffect(()=>{if(b?.started){if(!n?.access_token){Ge("/api/remote/license",{method:"DELETE"},N).catch(()=>{});return}Ge("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${n.access_token}`}},N).catch(y=>{console.warn("[LiveDesk] Hub license sync failed",y)})}},[k?.updated_at,N,n?.access_token,b?.started]),u.useEffect(()=>{!n?.access_token||!b?.started||b.runtimeRole!=="hub"||!b.deviceId||(async()=>{try{const{data:y,error:M}=await pt.rpc("register_livedesk_device",{p_device_id:b.deviceId,p_device_name:b.deviceName||b.deviceId,p_role:"hub",p_assigned_hub_id:null,p_platform:navigator.platform||navigator.userAgent,p_os_version:navigator.userAgent,p_app_version:b.managerVersion||b.managerPackage||""}),L=Array.isArray(y)?y[0]:y;(M||L?.ok===!1)&&console.warn("[LiveDesk] Hub device role registration failed",M||L?.reason||"unknown-error")}catch(y){console.warn("[LiveDesk] Hub device role registration failed",y)}})()},[n?.access_token,b?.deviceId,b?.deviceName,b?.managerPackage,b?.managerVersion,b?.runtimeRole,b?.started]),u.useEffect(()=>{!n?.access_token||!n.refresh_token||!b?.started||b.runtimeRole!=="hub"||qi.current||(qi.current=!0,Ge("/api/auth/session",{method:"POST",body:JSON.stringify({accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:n.expires_at,user:{id:n.user.id,email:n.user.email}})},N||Cn).then(y=>{y.hostTarget?.ok===!1&&console.warn("[LiveDesk] Hub host target publish is waiting for a valid Hub role:",y.hostTarget.error||"unknown-error"),A()}).catch(y=>{console.warn("[LiveDesk] Hub session sync failed:",y)}).finally(()=>{qi.current=!1}))},[N,A,n?.access_token,n?.expires_at,n?.refresh_token,n?.user?.email,n?.user?.id,b?.runtimeRole,b?.started]);const et=u.useMemo(()=>C.filter(y=>y.connected),[C]),Xc=za==="all"?et.length:ri.filter(y=>et.some(M=>M.deviceId===y)).length,cf=u.useMemo(()=>et.reduce((y,M)=>Math.max(y,Bx(M.slotNumber)),0),[et]),$l=Math.max(NM,et.length,cf),Vr=u.useMemo(()=>{const y=Array($l).fill(null),M=[];for(const L of et){const F=Bx(L.slotNumber);F>0&&F<=$l&&!y[F-1]?y[F-1]=L:M.push(L)}for(const L of M){const F=y.findIndex(z=>!z);F<0?y.push(L):y[F]=L}return y},[et]),Bo=u.useMemo(()=>et.map(y=>y.deviceId),[et]),oi=u.useMemo(()=>new Set(Y),[Y]),ba=u.useMemo(()=>et.filter(y=>oi.has(y.deviceId)),[et,oi]),Ki=u.useMemo(()=>C.find(y=>y.deviceId===D)||ba[0]||null,[C,D,ba]),Vn=u.useMemo(()=>C.find(y=>y.deviceId===G)||null,[G,C]),Us=Vn?Ea(Qt[Vn.deviceId],pa(Vn)):0,Le=st?Vn:Ki,Zc=u.useMemo(()=>new Set(ri),[ri]),uf=u.useMemo(()=>za==="all"?et.map(y=>y.deviceId):et.filter(y=>Zc.has(y.deviceId)).map(y=>y.deviceId),[et,Zc,za]),df=Le?Hc(Le,"control"):!1,Ul=zi(Le?.platform)&&(Le?.capabilities?.controlPermission===!1||Le?.capabilities?.accessibilityPermission===!1),Wr=Le?Hc(Le,"audio")||Hc(Le,"remoteAudio"):!1,Jc=Array.isArray(Le?.capabilities?.agentTools)?Le.capabilities.agentTools.map(String):[],eu=Jc.includes("system.power"),tu=Jc.includes("command.run"),Yt=T?k?.plan==="pro"?"pro":"ltd":"free",nu=Sl[Yt],ql=nu.limit,Qi=u.useMemo(()=>{if(!Number.isFinite(ql))return new Set(et.map(M=>M.deviceId));const y=Le?[Le,...et.filter(M=>M.deviceId!==Le.deviceId)]:et;return new Set(y.slice(0,ql).map(M=>M.deviceId))},[ql,et,Le]),ff=!Le||Qi.has(Le.deviceId),Fo=Yt==="free",It=ff,Yr=Yt==="ltd"?`Plus includes up to ${Ec} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${Tc} workstations. Upgrade to Plus for ${Ec} devices and no ads.`,au=Yt==="free",ns=It&&!!Le&&df,Po=It&&!!Le&&Wr,Kr=u.useMemo(()=>Vr.filter(y=>!!y?.connected).slice(0,fT(ge)).map(y=>y.deviceId),[Vr,ge]),Qr=u.useMemo(()=>ft?Bo:He.visibleOnlyLive?_s.length>0?_s:Kr:Bo,[Kr,ft,_s,He.visibleOnlyLive,Bo]),In=u.useMemo(()=>vh(Qr.filter(y=>Qi.has(y))),[Qi,Qr]),qs=u.useMemo(()=>In.filter(y=>y!==sn),[In,sn]),Gl=u.useMemo(()=>new Map(et.map(y=>[y.deviceId,y.platform])),[et]),as=Aj(ft,In.length),ua=u.useMemo(()=>ft?qs.filter(y=>Ac({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(Gl.get(y))})==="atlas"):[],[as,ft,Gl,qs]),Zn=u.useMemo(()=>qs.filter(y=>Ac({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(Gl.get(y))})==="direct"),[as,ft,Gl,qs]);u.useEffect(()=>{const y=new Set(In);rt(M=>{let L=!1;const F=new Set;for(const z of M)y.has(z)?F.add(z):L=!0;return L?F:M})},[In]);const Xr=u.useMemo(()=>{const y=z=>et.find(pe=>pe.deviceId===z)||null,M=z=>Ea(Qt[z],y(z)?pa(y(z)):0),L=(z,pe=M(z))=>z===B&&(q==="connecting"||q==="active"||q==="warm")?ut.current.get(z)||Mt.current.get(z)||null:ft?ca.current.get(z)||Nt.current.get(z)||null:Nt.current.get(z)||null,F=(z,pe=M(z))=>{const de=y(z);return`${de?fs(de):z} · Monitor ${pe+1}`};return{resolveCurrentTarget(){if(st&&Vn){const $e=Us;return{type:"control",deviceIds:[Vn.deviceId],monitorIndex:$e,label:`${fs(Vn)} · Monitor ${$e+1}`,sourceCanvas:L(Vn.deviceId,$e),signature:`control:${Vn.deviceId}:${$e}:${dt.frameMode}`}}const z=ba.map($e=>$e.deviceId).filter($e=>qs.includes($e)),pe=Ki&&qs.includes(Ki.deviceId)?Ki.deviceId:"",de=z.length>0?z:pe?[pe]:qs,Re=z.length===0&&!pe;if(de.length===0)return null;if(de.length===1){const $e=de[0],Xe=M($e);return{type:Re?"wall":z.length>1?"selection":"device",deviceIds:de,monitorIndex:Xe,label:Re?"Wall":F($e,Xe),sourceCanvas:Re?null:L($e,Xe),signature:`${Re?"wall":"device"}:${$e}:${Xe}:${ft?"atlas":"direct"}`}}return{type:z.length>1?"selection":"wall",deviceIds:de,label:z.length>1?`${de.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${z.length>1?"selection":"wall"}:${de.join(",")}:${ge}`}},getDeviceCanvas:L,composeWall(z,pe={}){return pM(z.map(de=>{const Re=M(de);return{deviceId:de,label:F(de,Re),canvas:L(de,Re)}}),pe)}}},[et,Vn,B,q,dt.frameMode,Nt,ft,Qt,Us,ba,st,qs,Ki,ge]),Xi=AM({hubUrl:N,sourceRegistry:Xr,onToast:Ie}),Zi=u.useMemo(()=>It&&B&&Qi.has(B)&&(q==="connecting"||q==="active"||q==="warm")?[B]:[],[B,q,It,Qi]),Vl=u.useMemo(()=>vh([...In,...Zi]),[Zi,In]),On=u.useMemo(()=>mT(He,ge),[He,ge]),ci=Nj({mode4Enabled:ft,directMode4WallEnabled:as,adaptiveFps:Pe,directDeviceCount:Zn.length}),Ia=u.useCallback((y,M,L)=>{if(y.width<=0||y.height<=0)return!1;const F=L?Math.min(1,L.maxWidth/y.width,L.maxHeight/y.height):1,z=Math.max(1,Math.round(y.width*F)),pe=Math.max(1,Math.round(y.height*F));(M.width!==z||M.height!==pe)&&(M.width=z,M.height=pe);const de=M.getContext("2d",{alpha:!1});return de?(de.imageSmoothingEnabled=!0,de.imageSmoothingQuality="high",de.drawImage(y,0,0,y.width,y.height,0,0,M.width,M.height),!0):!1},[]),Gs=u.useCallback(y=>{y&&rt(M=>{if(M.has(y))return M;const L=new Set(M);return L.add(y),L})},[]),Zr=u.useCallback(y=>{y&&rt(M=>{if(!M.has(y))return M;const L=new Set(M);return L.delete(y),L})},[]),Jr=u.useCallback((y,M)=>{if(!M||M.width<=0||M.height<=0)return!1;const L=document.createElement("canvas");return L.width=M.width,L.height=M.height,Ia(M,L)?(Qe.current.set(y,L),Gs(y),!0):!1},[Gs,Ia]),ss=u.useCallback((y,M=!1)=>{if(!Wt.current.has(y))return!1;const L=performance.now(),F=An.current.get(y)||0,z=Math.max(1,Math.min(ei.controlWallReuseMaxFps,Yi)),pe=Yi>z?Math.max(0,1e3/z-2):0;if(!M&&L-F<pe)return!1;const de=ut.current.get(y)||Mt.current.get(y),Re=Nt.current.get(y)||ca.current.get(y);return!de||!Re||!Ia(de,Re,On)?!1:(An.current.set(y,L),Gs(y),!0)},[Yi,On,Gs,Ia]);u.useEffect(()=>{St.current=sn},[sn]);const su=u.useCallback((y,M)=>{const L=Nt.current.get(y);if(L&&L!==M&&(Jr(y,L),kc(L)),M){Nt.current.set(y,M),Qe.current.delete(y),ss(y,!0);return}Nt.current.delete(y),Qe.current.has(y)||Zr(y)},[Zr,ss,Jr]),mf=u.useCallback((y,M)=>{const L=Mt.current.get(y);if(L&&L!==M&&kc(L),M){Mt.current.set(y,M);const F=ut.current.get(y)||Qe.current.get(y)||Nt.current.get(y)||ca.current.get(y);F&&Ia(F,M)&&y===G&&Zt(!0);return}Mt.current.delete(y)},[G,Ia]),Wl=u.useCallback((y,M,L)=>{const F=performance.now(),z=Ms(y,L.deviceId);let pe=L;if(y==="control"&&L.visualChanged){const Re=fj(L.deviceId),$e=zo.current.get(L.deviceId)||0,Xe=Re?F-Re.sentAt:Number.POSITIVE_INFINITY;Re&&Re.inputSeq>$e&&Xe<=Sx&&(pe={...L,inputFeedbackSeq:Re.inputSeq,inputFeedbackMs:Math.max(0,Xe),inputFeedbackAt:F},zo.current.set(L.deviceId,Re.inputSeq))}Pr.current.set(z,F);const de=Br.current.get(z)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:F,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};y==="control"&&pe.inputFeedbackMs===void 0&&de.lastInfo?.inputFeedbackMs!==void 0&&de.lastInfo.inputFeedbackAt!==void 0&&F-de.lastInfo.inputFeedbackAt<=Sx&&(pe={...pe,inputFeedbackSeq:de.lastInfo.inputFeedbackSeq,inputFeedbackMs:de.lastInfo.inputFeedbackMs,inputFeedbackAt:de.lastInfo.inputFeedbackAt}),de.totalFrames+=1,de.sampleFrames+=1,Mx(de,F,pe.frameSeq),pe.visualChanged&&(de.totalChangedFrames+=1,de.sampleChangedFrames+=1),de.lastInfo=pe,Br.current.set(z,de)},[]),Yl=u.useCallback((y,M)=>{Wl("wall",y,M),y.kind==="live"&&Gs(y.deviceId);const L=ce&&B===y.deviceId;St.current!==y.deviceId&&!L&&(Wt.current.delete(y.deviceId),An.current.delete(y.deviceId))},[B,ce,Gs,Wl]),iu=u.useCallback((y,M)=>{Wl("control",y,M),he(pe=>pe&&"");const L=ut.current.get(y.deviceId),F=Mt.current.get(y.deviceId);L&&L.width>0&&L.height>0&&(F&&Ia(L,F),kn.current.set(y.deviceId,{...y,payload:new Uint8Array(0),byteLength:0}),Qe.current.delete(y.deviceId),Wt.current.add(y.deviceId),y.deviceId===B&&(be(!0),V(pe=>pe==="connecting"?"active":pe)),ss(y.deviceId));const z=Il.current;!z||!FM(z,y)||Zt(!0)},[B,Ia,ss,Wl]);u.useEffect(()=>{const y=window.setInterval(()=>{const M=performance.now(),L={};for(const[F,z]of Br.current.entries()){const pe=Math.max(1,M-z.sampleStartedAt);L[F]={totalFrames:z.totalFrames,totalChangedFrames:z.totalChangedFrames,framesPerSecond:z.sampleFrames*1e3/pe,changedFramesPerSecond:z.sampleChangedFrames*1e3/pe,averageIntervalMs:z.intervalCount>0?z.intervalSumMs/z.intervalCount:0,minIntervalMs:Number.isFinite(z.minIntervalMs)?z.minIntervalMs:0,maxIntervalMs:z.maxIntervalMs,p95IntervalMs:mh(z.intervalSamplesMs,.95),intervalCount:z.intervalCount,seqGapCount:z.seqGapCount,maxSeqGap:z.maxSeqGap,decoderInputFps:Math.max(0,(Number(z.lastInfo?.decoderInputCount||0)-z.sampleDecoderInputBase)*1e3/pe),decoderOutputFps:Math.max(0,(Number(z.lastInfo?.decoderOutputCount||0)-z.sampleDecoderOutputBase)*1e3/pe),sampleMs:pe,lastInfo:z.lastInfo},z.sampleDecoderInputBase=Number(z.lastInfo?.decoderInputCount||0),z.sampleDecoderOutputBase=Number(z.lastInfo?.decoderOutputCount||0),z.sampleChangedFrames=0,Nx(z,M)}Fr(L)},1e3);return()=>window.clearInterval(y)},[]);const Nn=u.useCallback((y,M)=>{const L=performance.now(),F=Ms(y,M.deviceId);Os.current.set(F,L),es.current.delete(F),y==="control"&&si.current.delete(F);const z=_o.current.get(F)||{totalFrames:0,sampleFrames:0,sampleStartedAt:L,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(M.byteLength||0)),String(M.frameMode||M.mode||M.codec||M.mimeType||"").toLowerCase().includes("h264")){z.sampleH264Frames+=1,Number(M.byteLength||0)<=IM&&(z.sampleTinyFrames+=1);const $e=String(M.contentHash||"");$e&&z.lastContentHash===$e&&(z.sampleRepeatedFrames+=1),z.lastContentHash=$e}const Re=Number(M.agentSendGapMs||0);Re>0&&Re<1e3&&gw(z.sourceSendIntervalsMs,Re),z.lastFrame=M,Mx(z,L,M.frameSeq),_o.current.set(F,z)},[]);u.useEffect(()=>{const y=window.setInterval(()=>{const M=performance.now(),L={};for(const[F,z]of _o.current.entries()){const pe=Math.max(1,M-z.sampleStartedAt);L[F]={totalFrames:z.totalFrames,framesPerSecond:z.sampleFrames*1e3/pe,averageIntervalMs:z.intervalCount>0?z.intervalSumMs/z.intervalCount:0,minIntervalMs:Number.isFinite(z.minIntervalMs)?z.minIntervalMs:0,maxIntervalMs:z.maxIntervalMs,p95IntervalMs:mh(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((de,Re)=>de+Re,0)/z.sourceSendIntervalsMs.length:0,sourceSendP95Ms:mh(z.sourceSendIntervalsMs,.95),sourceSendSampleCount:z.sourceSendIntervalsMs.length,sampleMs:pe,lastFrame:z.lastFrame},z.sampleBytes=0,z.sampleH264Frames=0,z.sampleTinyFrames=0,z.sampleRepeatedFrames=0,z.sourceSendIntervalsMs.length=0,Nx(z,M)}zl(L)},1e3);return()=>window.clearInterval(y)},[]);const Ji=u.useCallback(y=>{Nn("wall",y);const M=Nt.current.get(y.deviceId);if(!M)return;const L=Mj(ft,He.h264DecodeAcceleration);Zm(M,y,()=>Nt.current.get(y.deviceId)!==M,Yl,L.acceleration,L.latencyMode).catch(()=>{})},[Yl,ft,Nn,He.h264DecodeAcceleration]),$o=u.useCallback(y=>{Nn("control",y);let M=ut.current.get(y.deviceId);M||(M=document.createElement("canvas"),M.setAttribute("aria-hidden","true"),ut.current.set(y.deviceId,M));const L=M,F=ve.current;Zm(L,y,()=>ut.current.get(y.deviceId)!==L,iu,dt.h264DecodeAcceleration,"interactive").catch(z=>{ve.current!==F||ut.current.get(y.deviceId)!==L||B!==y.deviceId||he(z instanceof Error?z.message:String(z||"Control H.264 decode failed"))})},[B,dt.h264DecodeAcceleration,iu,Nn]),ru=u.useCallback(y=>{const M=ya.current;M&&M!==y&&kc(M),ya.current=y,Fi.current=0,$r.current=0,gs.current=0,Ol.current=0,Hl.current=0,vn.current=0},[]),ui=u.useCallback(()=>{const y=ya.current,M=cn.current;if(!(!y||!M||y.width<=0||y.height<=0||vn.current!==M.layoutVersion))for(const L of M.tiles){const F=ca.current.get(L.deviceId);if(!F||L.width<=0||L.height<=0)continue;const z=Math.max(1,Math.round(L.width)),pe=Math.max(1,Math.round(L.height)),de=OM,Re=HM;(F.width!==de||F.height!==Re)&&(F.width=de,F.height=Re);const $e=F.getContext("2d",{alpha:!1});if($e){$e.imageSmoothingEnabled=!0,$e.imageSmoothingQuality="high";try{$e.drawImage(y,Math.round(L.x),Math.round(L.y),z,pe,0,0,de,Re)}catch{}}}},[]),lu=u.useCallback((y,M)=>{if(M){ca.current.set(y,M),Qe.current.delete(y),window.requestAnimationFrame(ui),window.requestAnimationFrame(()=>ss(y,!0));return}const L=ca.current.get(y);Jr(y,L),ca.current.delete(y),Qe.current.has(y)||Zr(y)},[Zr,ui,ss,Jr]),Kl=u.useCallback((y,M)=>{gs.current=performance.now(),vn.current=Number(y.layoutVersion||0),ui();const L=cn.current?.tiles||[],F=L.length>0?Math.round(y.byteLength/L.length):y.byteLength;for(const z of L){const pe={...y,deviceId:z.deviceId,width:z.width,height:z.height,sourceWidth:z.width,sourceHeight:z.height,byteLength:F};Yl(pe,{...M,deviceId:z.deviceId,width:z.width,height:z.height,byteLength:F}),St.current===z.deviceId&&ss(z.deviceId,!0)}},[Yl,ui,ss]),hf=u.useCallback(y=>{const M=performance.now();Fi.current<=0&&(Fi.current=M),$r.current=M;const L=ya.current;if(!L)return;const F=cn.current?.tiles||[],z=F.length>0?Math.round(y.byteLength/F.length):y.byteLength;for(const pe of F)Nn("wall",{...y,deviceId:pe.deviceId,width:pe.width,height:pe.height,sourceWidth:pe.width,sourceHeight:pe.height,byteLength:z});Zm(L,y,()=>ya.current!==L,Kl).catch(()=>{})},[Kl,Nn]),er=u.useMemo(()=>({fps:ci,maxWidth:On.maxWidth,maxHeight:On.maxHeight,quality:He.quality,mode:ft?"mode3-h264-hw":He.frameMode,frameMode:ft?"mode3-h264-hw":He.frameMode,streamPurpose:"wall",monitorSelections:Qt,onFrame:Ji}),[ci,Ji,On,ft,Qt,He]),Ql=u.useCallback(y=>{if(y.deviceId!==B||y.streamPurpose!=="control"||y.monitorIndex!==Us)return;const M=et.find(L=>L.deviceId===y.deviceId);!M?.sessionId||M.sessionId!==y.sessionId||($(y),V(L=>L==="connecting"?"active":L))},[et,B,Us]);u.useEffect(()=>{$(null)},[B,se,xa,Us]);const el=u.useMemo(()=>({fps:Yi,maxWidth:$s.maxWidth,maxHeight:$s.maxHeight,quality:dt.quality,mode:xa,frameMode:xa,streamPurpose:"control",forceRestart:se!=="",forceRestartToken:se,restartReason:se?"control-session-start":"",monitorSelections:Qt,onFrame:$o,onStreamReady:Ql}),[se,dt.quality,$o,Yi,xa,$s.maxHeight,$s.maxWidth,Ql,Qt]),{frames:Xl,state:tr,error:Vs,stats:da,restartLive:nr}=Ey(Zn,He.autoStartLive&&Zn.length>0,N,er),{frame:di,layout:fa,state:Zl,stats:ou,refreshInputs:Uo}=mj(ua,ft&&He.autoStartLive&&ua.length>0,N,{fps:ei.atlasOutputFps,width:1920,height:1080,tileWidth:On.maxWidth,tileHeight:On.maxHeight,captureDeviceIds:ua,monitorSelections:Qt,onFrame:hf});u.useEffect(()=>{cn.current=fa,fa&&window.requestAnimationFrame(ui)},[fa,ui]),u.useEffect(()=>{if(!ft||Zl!=="open"){Fi.current=0,$r.current=0,gs.current=0;return}const y=window.setInterval(()=>{const M=ya.current,L=performance.now();if(!M||document.visibilityState!=="visible"||L-Gn.current<fh)return;const F=$r.current,z=Fi.current;if(F<=0||z<=0||L-F>500)return;const pe=gs.current||z,de=L-pe;if(de>=DM&&L-Hl.current>=_M){Qm(M)&&(Hl.current=L,Ol.current=L);return}de>=RM&&L-Ol.current>=LM&&QC(M)&&(Ol.current=L)},250);return()=>window.clearInterval(y)},[Zl,ft]);const{frames:qo,state:Go,error:tl,stats:cu,restartLive:nl,reconnectLive:Jl}=Ey(Zi,Zi.length>0,N,el),Jn=u.useMemo(()=>{const y=new Map(Xl);if(ft&&di&&ua.length>0){const M=new Map((fa?.tiles||[]).map(F=>[F.deviceId,F])),L=Math.max(1,M.size);for(const F of ua){const z=M.get(F);z&&y.set(F,{...di,deviceId:F,width:z.width,height:z.height,sourceWidth:z.width,sourceHeight:z.height,byteLength:Math.round(di.byteLength/L)})}}for(const[M,L]of qo.entries())y.set(M,L);for(const M of Qr){if(!Wt.current.has(M)||y.has(M))continue;const L=kn.current.get(M);L&&y.set(M,L)}return y},[di,fa,qo,ua,ft,Xl,Qr,ee]),ar=st&&Zi.length>0?Go:ua.length>0?Zl:tr,ea=st&&Zi.length>0?cu:ua.length>0?ou:da;u.useCallback((y,M="browser-stale")=>{const L=nr(y,M),F=nl(y,M);return L||F},[nl,nr]),u.useEffect(()=>{ft&&ua.length>0&&!st&&Uo()},[ua.length,ft,Uo,st]);const ys=u.useCallback((y,M,L)=>{const F=M==="control"?ut.current.get(y)||null:Nt.current.get(y)||null;if(!F||!Qm(F))return!1;const z=performance.now();return Bs.current.set(Ms(M,y),z),!0},[]),sr=u.useCallback(y=>{if(xa!=="mode3-h264-hw"||!B||I)return!1;const M=et.find(Re=>Re.deviceId===B)||Vn,L=String(M?.platform||"").toLowerCase();if(!["win32","windows","win32nt"].includes(L))return!1;const F="mode5-lzo-delta",z=Ms("control",B),pe=performance.now();Hs.current.set(z,pe),Os.current.delete(z),Pr.current.delete(z),ai.current.delete(z),si.current.delete(z),es.current.delete(z),Qm(ut.current.get(B)||null),Jl([B],"control-decode-fallback"),Q(F),K(`control-${F}-fallback-${B}-${Date.now()}`),be(!1),Zt(!1);const de=y==="no first frame"||y==="control-first-frame-timeout";return he(Re=>Re||(de?`Control frame transport timeout; retrying Control with Mode 5 (${y})`:`H.264 decode failed; retrying Control with Mode 5 (${y})`)),V("connecting"),!0},[et,Vn,B,I,xa,Jl]);u.useEffect(()=>{const y=st?Vn:null;if(y){Il.current={deviceId:y.deviceId,monitorIndex:Us,frameMode:xa,startedAtEpochMs:Date.now()},Zt(B===y.deviceId&&ce||qe.has(y.deviceId));return}Il.current=null,Zt(!1)},[Vn?.sessionId,G,B,ce,xa,Us,st,qe]);const Ws=u.useCallback(async y=>{const M=C.find(de=>de.deviceId===y),L=Ac({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(M?.platform)})==="atlas",F=Ea(Qt[y],M?pa(M):1),z=L?{fps:ei.scalableAtlasInputFps,maxWidth:On.maxWidth,maxHeight:On.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:F}:{fps:ft&&!L?ci:Pe,maxWidth:On.maxWidth,maxHeight:On.maxHeight,quality:He.quality,mode:ft?"mode3-h264-hw":He.frameMode,frameMode:ft?"mode3-h264-hw":He.frameMode,streamPurpose:"wall",monitorIndex:F},pe=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/live/start`,{method:"POST",body:JSON.stringify(z)},N);if(pe?.ok===!1)throw new Error(pe.error||"wall-stream-start-failed");return pe},[Pe,C,as,ci,On.maxHeight,On.maxWidth,N,ft,Qt,He.frameMode,He.quality]),fi=u.useCallback(async y=>{const M=C.find(z=>z.deviceId===y),L=Ac({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(M?.platform)})==="atlas",F=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:L?"atlas":"wall",reason:"control-active"})},N);if(F?.ok===!1)throw new Error(F.error||"wall-stream-stop-failed");return F},[C,as,N,ft]),Ys=u.useCallback(async(y,M="control-session-stop")=>{const L=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:M})},N);if(L?.ok===!1)throw new Error(L.error||"control-stream-stop-failed");return L},[N]),wa=u.useCallback(y=>{const M=ut.current.get(y);M&&(kc(M),ut.current.delete(y));const L=Mt.current.get(y);L&&kc(L),kn.current.delete(y),Wt.current.delete(y),An.current.delete(y)},[]);u.useEffect(()=>{const y=G&&et.find(z=>z.deviceId===G)||null;if(!st||!It||!y){Is.current&&(++Xn.current,Is.current="");return}if(B===y.deviceId&&(q==="active"||q==="warm"||q==="connecting")){V(z=>z==="warm"?"active":z);return}if(Is.current===y.deviceId)return;const M=++Xn.current,L=B;Is.current=y.deviceId,(async()=>{if(L){if(V("stopping"),await Ys(L,"control-session-switch").catch(()=>{}),M!==Xn.current)return;const de=St.current;if(de&&de!==y.deviceId)try{await Ws(de)}catch(Re){Ie(Re instanceof Error?Re.message:String(Re))}finally{St.current===de&&(St.current="",Qa(""))}if(M!==Xn.current)return;wa(L)}if(M!==Xn.current)return;if(Px(y)){try{await fi(y.deviceId)}catch(de){M===Xn.current&&(Is.current="",V("error"),Ie(de instanceof Error?de.message:String(de)));return}if(M!==Xn.current){await Ws(y.deviceId).catch(()=>{});return}St.current=y.deviceId,Qa(y.deviceId),Wt.current.add(y.deviceId)}const z=Ms("control",y.deviceId),pe=`control-session-${M}-${y.deviceId}`;Hs.current.set(z,performance.now()),Os.current.delete(z),Pr.current.delete(z),es.current.delete(z),si.current.delete(z),Q(""),he(""),K(pe),xe(y.deviceId),be(!1),V("connecting"),Xn.current===M&&Is.current===y.deviceId&&(Is.current="")})()},[et,G,B,q,It,wa,Ie,st,Ws,Ys,fi]),u.useEffect(()=>{if(!B||et.some(L=>L.deviceId===B))return;const y=B,M=++Xn.current;V("stopping"),Ys(y,"control-device-disconnected").catch(()=>{}).finally(()=>{M===Xn.current&&(wa(y),be(!1),K(""),Q(""),he(""),xe(L=>L===y?"":L),V("idle"))})},[et,B,wa,Ys]);const Vo=Px(et.find(y=>y.deviceId===B));u.useEffect(()=>{if(Ja.current!==null&&(window.clearTimeout(Ja.current),Ja.current=null),!B||q==="idle"||q==="stopping"||q==="error"||st||_t==="wall"){B&&!st&&_t==="wall"&&V(L=>L==="warm"||L==="active"?"active":L);return}V(L=>L==="idle"||L==="stopping"?L:"warm");const y=B,M=++Xn.current;return Ja.current=window.setTimeout(()=>{Ja.current=null,V("stopping"),Ys(y,"control-session-warm-timeout").catch(()=>{}).finally(()=>{M===Xn.current&&(wa(y),be(!1),K(""),Q(""),he(""),xe(L=>L===y?"":L),V("idle"))})},zM),()=>{Ja.current!==null&&(window.clearTimeout(Ja.current),Ja.current=null)}},[_t,B,q,wa,st,Ys]),u.useEffect(()=>()=>{Ja.current!==null&&window.clearTimeout(Ja.current)},[]),u.useEffect(()=>{const M=B&&(Vo&&(q==="connecting"||q==="active"||q==="warm"||q==="stopping")||ce&&(q==="active"||q==="warm"))?B:"";if(rn.current=M,Pt.current)return;const L=async()=>{for(;;){const z=rn.current,pe=St.current;if(pe===z)return;if(pe){try{await Ws(pe)}catch(de){Ie(de instanceof Error?de.message:String(de))}finally{St.current===pe&&(St.current="",Qa(""))}continue}if(!z)return;try{await fi(z)}catch(de){rn.current=St.current,Ie(de instanceof Error?de.message:String(de));return}St.current=z,Qa(z),Wt.current.add(z)}};let F;F=L().finally(()=>{Pt.current===F&&(Pt.current=null),St.current!==rn.current&&Xa(z=>z+1)}),Pt.current=F},[B,ce,q,Vo,ft,Ie,Ws,fi,Hr]);const is=B&&et.find(y=>y.deviceId===B)||null,xs=!!(st&&Se&&q==="active"&&is?.sessionId&&X?.deviceId===is.deviceId&&X.sessionId===is.sessionId&&X.streamPurpose==="control"&&X.commandId&&X.captureGeneration>0&&X.monitorIndex===Us),{state:Wo,sendInput:ta,stats:Sa,error:rs}=hj(ns&&xs,N),ir=u.useCallback((y,M)=>!xs||!is||!X||y!==is.deviceId?!1:ta(y,{...M,controlSessionId:is.sessionId,controlCommandId:X.commandId,captureGeneration:X.captureGeneration}),[xs,is,X,ta]),Ks=xs&&Wo==="open",{state:mi,lastFrame:eo,stats:Hn,error:to}=Cj(Le?.deviceId||"",Po&&re,N),al=u.useRef(new Map);u.useEffect(()=>{const y=[["hub",j],["registry",l],["license",U],["wall-stream",Vs],["control-stream",tl],["control-decode",ue],["remote-input",rs],["remote-audio",to]];for(const[M,L]of y){const F=String(L||"").trim();if(M==="hub"&&bt?.requiresHubRestart&&bt.stage==="updating"){al.current.delete(M);continue}if(!F){al.current.delete(M);continue}al.current.get(M)!==F&&(al.current.set(M,F),Ie(F))}},[to,ue,tl,j,rs,U,l,Ie,Vs,bt]),u.useEffect(()=>{if(!st||!Se||!ns||!Ks||!Le)return;const y=(F,z)=>{const pe=F.target,de=pe?.tagName?.toLowerCase();pe?.isContentEditable||de==="input"||de==="textarea"||de==="select"||(F.preventDefault(),F.stopPropagation(),ir(Le.deviceId,{type:z,monitorIndex:Ea(Qt[Le.deviceId],pa(Le)),key:F.key,code:F.code,keyCode:F.keyCode||F.which||0,location:F.location,text:F.key.length===1?F.key:"",repeat:z==="keydown"?F.repeat:!1,shiftKey:F.shiftKey,ctrlKey:F.ctrlKey,altKey:F.altKey,metaKey:F.metaKey}))},M=F=>y(F,"keydown"),L=F=>y(F,"keyup");return window.addEventListener("keydown",M),window.addEventListener("keyup",L),()=>{window.removeEventListener("keydown",M),window.removeEventListener("keyup",L)}},[ns,Ks,Se,Qt,Le,ir,st]),u.useEffect(()=>{const y=()=>{document.visibilityState==="visible"&&(Gn.current=performance.now())};return document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),()=>{document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y)}},[]),u.useEffect(()=>{if(!B||q!=="connecting"&&q!=="active"&&q!=="warm"||Go!=="open")return;const y=B,M=Ms("control",y),L=window.setInterval(()=>{const F=performance.now();if(document.visibilityState!=="visible"||F-Gn.current<fh)return;const z=Os.current.get(M)||0,pe=Pr.current.get(M)||0,de=ai.current.get(M)||0,Re=Hs.current.get(M)||F;Hs.current.has(M)||Hs.current.set(M,Re);const $e=z<=0,Xe=$e?F-Re>qM:F-z>Lx,tn=z>0&&(pe<=0||F-pe>Lx);if(!Xe&&tn){const hl=Bs.current.get(M)||0;F-hl>=_x&&ys(y,"control","decoder-paint-stale");return}if(!Xe)return;const dn=si.current.get(M)||0;if(dn>0){if(F-dn<VM)return;si.current.delete(M)}const Wn=es.current.get(M)||0;if(Wn>=WM){if(sr($e?"no first frame":"stale stream"))return;be(!1),Zt(!1),V("error");return}if(F-de<zx(GM,Wn))return;nl([y],$e?"control-first-frame-timeout":"control-receive-stale")&&(ai.current.set(M,F),si.current.set(M,F),Hs.current.set(M,F),es.current.set(M,Wn+1))},650);return()=>window.clearInterval(L)},[Go,B,q,sr,ys,nl]),u.useEffect(()=>{!ue||xa!=="mode3-h264-hw"||sr(ue)||(be(!1),Zt(!1),V("error"))},[ue,xa,sr]),u.useEffect(()=>{!st||!B||!tl||V(y=>y==="error"?y:"error")},[tl,B,st]),u.useEffect(()=>{if(tr!=="open"||!He.autoStartLive||Zn.length===0)return;const y=window.setInterval(()=>{const M=performance.now();if(document.visibilityState!=="visible"||M-Gn.current<fh)return;const L=1e3/Math.max(1,ci||He.fps||1),F=Math.max(YM,Math.ceil(L*4)),z=[];for(const pe of Zn){if(z.length>=XM)break;const de=Ms("wall",pe),Re=Os.current.get(de)||0;if(Re<=0)continue;const $e=ai.current.get(de)||0,Xe=Pr.current.get(de)||0,tn=M-Re>F,dn=Xe<=0||M-Xe>F;if(!tn&&dn){const ml=Bs.current.get(de)||0;M-ml>=_x&&ys(pe,"wall","decoder-paint-stale");continue}if(!tn)continue;const Wn=es.current.get(de)||0;M-$e>=zx(KM,Wn)&&z.push(pe)}if(z.length>0&&nr(z,"wall-frame-stale"))for(const pe of z){const de=Ms("wall",pe);ai.current.set(de,M),es.current.set(de,(es.current.get(de)||0)+1)}},QM);return()=>window.clearInterval(y)},[ci,Zn,ys,nr,He.autoStartLive,He.fps,tr]),u.useEffect(()=>{vt(He.fps),Gi.current=Date.now(),ln.current=0},[He.fps,He.frameMode,He.adaptiveLoadShedding]),u.useEffect(()=>{$C({h264DecodeAcceleration:He.h264DecodeAcceleration})},[He.h264DecodeAcceleration]),u.useEffect(()=>{if(!It||st||!He.visibleOnlyLive){H([]);return}const y=$i.current;if(!y||typeof IntersectionObserver>"u"){H(Kr);return}const M=Array.from(y.querySelectorAll("[data-live-device-id]"));if(M.length===0){H([]);return}const L=new Map,F=()=>{const pe=vh(M.map(de=>String(de.dataset.liveDeviceId||"")).filter(de=>(L.get(de)||0)>0));H(de=>gh(de,pe)?de:pe)},z=new IntersectionObserver(pe=>{for(const de of pe){const Re=String(de.target.dataset.liveDeviceId||"");Re&&L.set(Re,de.isIntersecting?de.intersectionRatio||.01:0)}F()},{root:null,rootMargin:oa.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return M.forEach(pe=>z.observe(pe)),F(),()=>z.disconnect()},[Kr,It,st,Vr,He.visibleOnlyLive,ge]),u.useEffect(()=>{if(!He.adaptiveLoadShedding||!He.autoStartLive||Zn.length===0)return;const y=He.fps;if(Zn.length<=oa.preserveConfiguredFpsDeviceCount){Pe!==y&&(vt(y),Gi.current=Date.now(),ln.current=0);return}if(tr!=="open"||da.sampleMs<500)return;const M=Date.now(),L=Zn.length*Pe,F=da.framesPerSecond,z=da.bytesPerSecond,pe=Math.max(0,...Zn.map(tn=>Bi[Ms("wall",tn)]?.maxIntervalMs||0)),de=Math.max(0,...Zn.map(tn=>zs[Ms("wall",tn)]?.maxIntervalMs||0)),Re=L>8&&F>0&&F<L*.72;if(F>oa.maxWallFramesPerSecond||z>oa.maxWallBytesPerSecond||pe>oa.maxFrameGapMs||de>oa.maxFrameGapMs||Re){ln.current=0;const tn=oa.minFps;if(M-Gi.current>=oa.downshiftCooldownMs&&Pe>tn){const dn=Math.max(tn,hT(Pe,tn));dn<Pe&&(vt(dn),Gi.current=M)}return}const Xe=F<oa.maxWallFramesPerSecond*oa.lowLoadFrameRatio&&z<oa.maxWallBytesPerSecond*oa.lowLoadByteRatio;if(!Xe||Pe>=y){Xe||(ln.current=0);return}if(!ln.current){ln.current=M;return}if(M-ln.current>=oa.recoveryCooldownMs){const tn=Math.min(y,pT(Pe,y));tn>Pe&&(vt(tn),Gi.current=M,ln.current=0)}},[Pe,Zn.length,Zn,zs,Bi,tr,da.bytesPerSecond,da.framesPerSecond,da.lastUpdatedAt,da.sampleMs,He.adaptiveLoadShedding,He.autoStartLive,He.frameMode,He.fps]),u.useEffect(()=>{const y=new URLSearchParams(window.location.search).get("checkout");if(y==="success"){Ie("Checkout returned. Waiting for Dodo confirmation."),O();const M=window.setInterval(()=>{O()},4e3),L=window.setTimeout(()=>{window.clearInterval(M)},45e3);return()=>{window.clearInterval(M),window.clearTimeout(L)}}y==="cancelled"&&Ie("Checkout cancelled.")},[O]),u.useEffect(()=>{!It&&Se&&_e(!1),!It&&re&&Z(!1)},[re,Se,It]),u.useEffect(()=>{const y=Le?.deviceId||"",M=ze.current;if(ze.current=y,!M||M===y)return;const L=++ae.current,F=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";y&&re&&De.current.set(y,F);let z=!0;return(async()=>{try{const de=De.current.get(M);if(De.current.delete(M),await Ge(`/api/remote/devices/${encodeURIComponent(M)}/audio/stop`,{method:"POST",body:JSON.stringify(de?{streamId:de}:{})},N),!z||L!==ae.current||!re||!y||!It||!Wr)return;const Re=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:F,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},N);if(Re.ok===!1)throw new Error(Re.error||"Remote audio start failed.")}catch(de){z&&(De.current.delete(y),Z(!1),Ie(de instanceof Error?de.message:String(de)))}})(),()=>{z=!1}},[re,It,N,Wr,Le?.deviceId]),u.useEffect(()=>{const y=et.map(F=>F.deviceId),M=new Set(y),L=new Map(et.map(F=>[F.deviceId,F]));_(F=>{const z=F.filter(pe=>M.has(pe));return gh(F,z)?F:z}),ne(F=>F&&M.has(F)?F:""),te(F=>F&&M.has(F)?F:""),ps(F=>{let z=!1;const pe={};for(const[de,Re]of Object.entries(F)){const $e=L.get(de);if(!$e){pe[de]=Re;continue}const Xe=Ea(Re,$e?pa($e):1);pe[de]=Xe,Xe!==Re&&(z=!0)}return z?pe:F}),Ur(F=>{const z=F.filter(pe=>M.has(pe));return gh(F,z)?F:z})},[et,$l]),u.useEffect(()=>{Io([]),Oo(!1)},[ss]),u.useEffect(()=>{!li||za!=="selected"||ri.length>0||ba.length===0||Ur(ba.map(y=>y.deviceId))},[ba,ri.length,za,li]),u.useEffect(()=>{try{localStorage.setItem(cw,zt)}catch{}},[zt]),u.useEffect(()=>{cT(He)},[He]),u.useEffect(()=>{dT(dt)},[dt]),u.useEffect(()=>{lT(Qt)},[Qt]);const na=u.useCallback(async()=>{const y=new Set(p);y.add(Cn);try{const pe=await Ge("/api/remote/status",void 0,Cn);vy({endpoint:pe.agentEndpoint,endpoint_candidates:[...pe.agentEndpointCandidates||[],...pe.hostTargetEndpointCandidates||[]]}).forEach(de=>y.add(de))}catch{}const M=[...y].sort((pe,de)=>{const Re=$e=>{const Xe=zc($e);return Xe==="local"?0:Xe==="loopback"?1:2};return Re(pe)-Re(de)||pe.localeCompare(de)});let L=!1,F="",z=!1;try{for(const pe of M){const de=zc(pe);try{if(await Ge("/api/health",void 0,pe),de==="local")return v(!0),So(!0),pe;de==="loopback"&&(L=!0,F=pe)}catch{de==="local"&&(z=!0)}}return L?(z&&Ie("LiveDesk Hub is reachable on this PC, but not through the LAN address yet. Restart LiveDesk Hub to bind 5179 on the network."),v(!0),So(!0),F||Cn):(v(!1),So(!1),"")}catch{return v(!1),So(!1),""}},[p]),ls=async()=>{if(Ae("auth"),jn(!1),await na(),window.liveDesk?.auth?.signInWithGoogle){const L=await window.liveDesk.auth.signInWithGoogle();L?.ok===!1&&(Ie(L.error||"LiveDesk could not open the system browser for Google sign-in."),Ae(""));return}const{data:y,error:M}=await pt.auth.signInWithOAuth({provider:"google",options:{redirectTo:`${window.location.origin}/callback`}});M&&(Ie(M.message),Ae(""))},rr=async()=>{Ae("auth"),jn(!1),await pt.auth.signOut(),(await window.liveDesk?.auth?.persistSession?.(null))?.runtimeCleared===!1?Ie("Signed out locally. The LiveDesk runtime could not be reached to clear its session."):window.liveDesk?.auth?.persistSession||await Ge("/api/auth/session",{method:"DELETE"},Cn).catch(()=>{}),Ae("")};u.useEffect(()=>{if(!Ee)return;const y=L=>{L.target instanceof Element&&(L.target.closest(".account-popover, .rail-account")||jn(!1))},M=L=>{L.key==="Escape"&&jn(!1)};return window.addEventListener("pointerdown",y),window.addEventListener("keydown",M),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",M)}},[Ee]);const sl=u.useCallback(async(y={})=>{const M=y.silent===!0,L=y.takeover===!0,F=y.requestLocalAccess===!0;if(!n?.user){M||Ie("Sign in before publishing this host.","error");return}if(!Ui.current){Ui.current=!0,M||(Ae("host"),ct("Hub · 1/4 · Checking the local runtime…"));try{const pe=(F?await na():"")||N||Cn;if(!(b||await Ge("/api/remote/status",void 0,pe)).started)throw new Error("Start LiveDesk on this computer before syncing the server.");M||ct("Hub · 2/4 · Sending the signed-in session to the Hub…");const Re=await Ge("/api/auth/session",{method:"POST",body:JSON.stringify({accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:n.expires_at,user:{id:n.user.id,email:n.user.email}})},pe);if(!Re.ok||!Re.authenticated)throw new Error(Re.error||"hub-session-sync-failed");M||ct("Hub · 3/4 · Claiming the Hub role and publishing its endpoint…");const $e=await Ge("/api/hub/sync",{method:"POST",body:JSON.stringify({takeover:L})},pe);if(!$e.ok)throw new Error($e.error||"host-target-failed");if(!M){ct("Hub · 4/4 · Verifying the endpoint and lease renewal…");const Xe=await Ge("/api/hub/status",void 0,pe);if(!Xe.hostTargetActive)throw new Error(Xe.hostTargetLease?.lastError||"host-target-not-active-after-sync");const tn=Xe.hostTargetEndpoint||Xe.agentEndpoint||"endpoint ready",dn=Number(Xe.connectedDeviceCount||0),Wn=dn>0?`${dn} client${dn===1?"":"s"} connected.`:"No clients connected yet; reconnect the laptop Client.";Ie(`Hub ready · ${tn} · lease auto-renewal active. ${Wn}`,"success"),(F||w)&&(v(!0),So(!0)),A()}c()}catch(z){if(!M){const pe=z instanceof Error?z.message:String(z);pe.includes("local network access")&&(v(!1),So(!1)),Ie(`Hub setup failed · ${pe}`,"error")}}finally{Ui.current=!1,M||Ae("")}}},[N,w,A,c,na,n,Ie,ct,b]),il=u.useCallback(async()=>{if(!(!b?.update?.canApply||fe==="update")){Ae("update");try{const y=await Ge("/api/update/apply",{method:"POST",body:JSON.stringify({})},N||Cn);if(!y.ok)throw new Error(y.error||"LiveDesk update could not be started.");const M=[...new Set((y.targets||[]).map(z=>String(z.deviceId||"").trim()).filter(Boolean))],L=!!(y.managerUpdateAvailable||y.clientPackageUpdateAvailable),F=y.state==="hub-restart-requested"?Date.now():void 0;(M.length>0||L)&&qn({operationId:String(y.operationId||`wall-update-${Date.now()}`),targetIds:M,stage:y.state==="clients-updated"?"updated":"updating",requiresHubRestart:L,initialHostInstanceId:String(b.hostInstanceId||""),targetManagerVersion:String(y.latestVersion||b.update?.latestVersion||""),targetClientVersion:String(y.latestClientVersion||b.update?.latestClientVersion||""),restartRequestedAt:F,restartDeadlineAt:F?F+Nd:void 0}),ct(y.state==="hub-restart-requested"?Ad:kx),A()}catch(y){Ie(y instanceof Error?y.message:String(y),"error")}finally{Ae("")}}},[fe,N,A,Ie,ct,b]);u.useEffect(()=>{const y=bt,M=b?.update;if(!y||y.stage!=="updating"||!M)return;const L=M.restartResult?.operationId===y.operationId?M.restartResult:null;if(L?.outcome==="restored"){const $e=L.error||`The requested Hub ${L.targetVersion||y.targetManagerVersion||"version"} failed verification.`;qn(Xe=>Xe?.operationId===y.operationId?{...Xe,stage:"restored",error:$e}:Xe),Ie(`LiveDesk update did not complete. Hub ${L.fallbackVersion||L.appVersion||"the previous version"} was restored. ${$e}`,"error");return}if(L?.outcome==="failed"){const $e=L.error||"No verified LiveDesk Hub replacement could be started.";qn(Xe=>Xe?.operationId===y.operationId?{...Xe,stage:"failed",error:$e}:Xe),Ie(`LiveDesk Hub update failed. ${$e}`,"error");return}if(M.operationId===y.operationId&&M.state==="failed"){const $e=M.error||"LiveDesk update failed before the Hub replacement completed.";qn(Xe=>Xe?.operationId===y.operationId?{...Xe,stage:"failed",error:$e}:Xe),Ie($e,"error");return}if(M.operationId===y.operationId){if(M.state==="hub-restart-requested"&&!y.restartDeadlineAt){const $e=Date.now();qn(Xe=>Xe?.operationId===y.operationId?{...Xe,restartRequestedAt:$e,restartDeadlineAt:$e+Nd}:Xe),ct(Ad)}!y.requiresHubRestart&&M.state==="clients-updated"&&(qn($e=>$e?.operationId===y.operationId?{...$e,stage:"updated"}:$e),Ie("LiveDesk clients updated and reconnected successfully.","success"));return}if(!y.requiresHubRestart)return;const F=b.started===!0&&(!y.initialHostInstanceId||b.hostInstanceId&&b.hostInstanceId!==y.initialHostInstanceId),z=!!M.checkedAt,pe=Ax(M.currentVersion,y.targetManagerVersion),de=!y.targetClientVersion||Ax(M.currentClientVersion,y.targetClientVersion),Re=z&&M.state==="idle"&&M.updateAvailable===!1&&pe&&de;F&&Re&&(qn($e=>$e?.operationId===y.operationId?{...$e,stage:"updated"}:$e),Ie(`LiveDesk Hub ${M.currentVersion||L?.appVersion||y.targetManagerVersion} restarted and passed version verification.`,"success"))},[Ie,ct,b,bt]),u.useEffect(()=>{const y=bt;if(!y||y.stage!=="updating"||!y.requiresHubRestart||y.restartDeadlineAt)return;const M=()=>{const F=Date.now();qn(z=>z?.operationId===y.operationId&&z.stage==="updating"&&!z.restartDeadlineAt?{...z,restartRequestedAt:F,restartDeadlineAt:F+Nd}:z),ct(Ad)};if(b?.update?.state==="hub-restart-requested"){M();return}if(!j)return;const L=window.setTimeout(M,BM);return()=>window.clearTimeout(L)},[j,ct,b?.update?.state,bt]),u.useEffect(()=>{const y=bt;if(!y||y.stage!=="updating"||!y.requiresHubRestart||!y.restartDeadlineAt)return;const M=Math.max(0,y.restartDeadlineAt-Date.now()),L=y.operationId,F=window.setTimeout(()=>{const z=`LiveDesk Hub did not return and verify ${y.targetManagerVersion||"the requested version"} within ${Math.round(Nd/6e4)} minutes. Check the Hub terminal or restart log, then run livedesk@latest manually if the Hub is still offline.`;qn(pe=>pe?.operationId===L&&pe.stage==="updating"?{...pe,stage:"failed",error:z}:pe),Ie(z,"error")},M);return()=>window.clearTimeout(F)},[Ie,bt]),u.useEffect(()=>{if(!bt||bt.stage!=="updated")return;const y=bt.operationId,M=window.setTimeout(()=>{qn(L=>L?.operationId===y?null:L)},8e3);return()=>window.clearTimeout(M)},[bt]),u.useEffect(()=>{if(Et!==kx&&Et!==Ad)return;const y=b?.update;if(String(y?.state||"")==="failed"){Ie(y?.error||"LiveDesk update failed.","error");return}bt?.stage==="updated"&&Ie("")},[Et,Ie,b?.update?.error,b?.update?.state,bt?.stage]);const Ca=u.useCallback(async()=>{if(!fe){Ae("pin");try{const M=await Ge("/api/remote/pairing-pin",{method:"POST"},N||Cn);if(!M.ok)throw new Error(M.error||"pin-rotation-failed");await A(),Ie("New PIN published.")}catch(y){Ie(y instanceof Error?y.message:String(y))}finally{Ae("")}}},[fe,N,A]),aa=u.useCallback(y=>{y&&(ne(y),_(M=>M.includes(y)?M:[...M,y]))},[]),bs=u.useCallback(y=>{if(!y)return;const M=oi.has(y);ne(L=>M&&L===y?"":y),_(L=>M?L.filter(F=>F!==y):L.includes(y)?L:[...L,y])},[oi]),sa=u.useCallback(()=>{_([]),ne("")},[Ia]),Oa=u.useCallback(()=>{_(et.map(y=>y.deviceId)),ne("")},[et]),Ha=u.useCallback((y,M)=>{const L=et.find(z=>z.deviceId===y);if(!L)return;const F=pa(L);F<=1||(ps(z=>{const de=(Ea(z[y],F)+M+F)%F;return{...z,[y]:de}}),st&&(Zt(!1),te(y)))},[et,st]);u.useEffect(()=>{const y=M=>{if(st&&Se&&ns)return;const L=M.target,F=L?.tagName?.toLowerCase();L?.isContentEditable||F==="input"||F==="textarea"||F==="select"||((M.ctrlKey||M.metaKey)&&M.key.toLowerCase()==="a"&&(M.preventDefault(),Oa()),M.key==="Escape"&&sa())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[ns,sa,Se,Oa,st]);const uu=(y,M)=>{const L=et.find(z=>z.deviceId===y),F=Ea(M,L?pa(L):1);ps(z=>({...z,[y]:F})),st?(Zt(!1),te(y)):aa(y)},lr=async y=>{if(Zt(!1),te(y),Ft("control"),!Qi.has(y)){_e(!1),Ie(Yr);return}const M=et.find(F=>F.deviceId===y);if(zi(M?.platform)&&(M?.capabilities?.controlPermission===!1||M?.capabilities?.accessibilityPermission===!1)){_e(!1),Ie("Mac remote control needs Accessibility permission. Allow it for the terminal app that starts LiveDesk, then restart the Mac client.","error");return}_e(!0),Ie(`Opening remote control${M?` for ${fs(M)}`:""}.`,"success")},Yo=async()=>{if(!Le){Ie("Select a workstation before playing audio.");return}if(!It){Ie(Yr);return}if(!Wr){Ie("Selected workstation does not report remote audio support yet.");return}if(Te)return;const y=!re,M=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:De.current.get(Le.deviceId);y&&M?De.current.set(Le.deviceId,M):y||De.current.delete(Le.deviceId),Be("audio"),Z(y);try{await Ge(`/api/remote/devices/${encodeURIComponent(Le.deviceId)}/audio/${y?"start":"stop"}`,{method:"POST",body:JSON.stringify({...M?{streamId:M}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},N),Ie(`${y?"Audio started":"Audio stopped"} for ${fs(Le)}.`,"success")}catch(L){y&&De.current.delete(Le.deviceId),Z(!1),Ie(L instanceof Error?L.message:String(L),"error")}finally{Be("")}},du=y=>{const M=y instanceof Error?y.message:String(y);return/remote-actions-disabled|allowAgent-blocked-by-settings/i.test(M)?"Remote actions are off. Turn on Settings > Agent > Enable AI Agent first.":/power-actions-disabled/i.test(M)?"Power actions are off. Turn on Settings > Agent > Allow power actions first.":/agent-tool-capability-unavailable|unsupported-agent-operation/i.test(M)?"This workstation needs a newer LiveDesk Client for power actions.":/device-not-connected|404 device-not-found/i.test(M)?"The workstation disconnected before the action could be sent.":M},un=async y=>{if(!Le||Te)return;const M=Le,F={lock:"Lock",sleep:"Sleep",restart:"Restart",shutdown:"Shut down"}[y];if(!(y!=="lock"&&!window.confirm(`${F} ${fs(M)}? Unsaved work on that computer may be lost.`))){Be(y),Ie(`Sending ${F.toLowerCase()} request to ${fs(M)}...`);try{const z=await Ge(`/api/remote/devices/${encodeURIComponent(M.deviceId)}/quick-actions`,{method:"POST",body:JSON.stringify({action:y})},N);if(!z.ok)throw new Error(z.error||"The remote action could not be sent.");Ie(`${F} request sent to ${fs(M)}.`,"success"),A()}catch(z){Ie(du(z),"error")}finally{Be("")}}},Gt=()=>{Le&&(Je({id:Date.now(),deviceId:Le.deviceId,instruction:"Run command "}),_e(!1),Ft("agents"),Ie(`Command runner opened for ${fs(Le)}.`))},wt=async(y,M,L="files")=>{const F=y.filter(Re=>Re.file.size>=0);if(F.length===0)return{files:0,bytes:0};if(!It)throw new Error(Yr);if(M.length===0)throw new Error("Select at least one connected workstation.");const z=crypto.randomUUID(),pe=F.reduce((Re,$e)=>Re+$e.file.size,0);let de=0;Fs({id:z,status:"reading",progress:1,message:`Preparing ${F.length} ${L}`});try{for(let Re=0;Re<F.length;Re+=1){const $e=F[Re],Xe=$e.file,tn=Math.max(1,Math.ceil(Xe.size/uh));for(let dn=0;dn<tn;dn+=1){const Wn=dn*uh,ml=Math.min(Xe.size,Wn+uh),hl=Xe.size===0?new ArrayBuffer(0):await Xe.slice(Wn,ml).arrayBuffer(),pr=dn===tn-1;Fs({id:z,status:"sending",progress:Math.max(2,Math.min(98,Math.round(de/Math.max(1,pe)*96))),message:`${Re+1}/${F.length} ${$e.relativePath}`});const wi=await Ge("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:z,deviceIds:M,remoteDirectory:zt.trim(),name:Xe.name,relativePath:$e.relativePath,size:Xe.size,type:Xe.type,lastModified:Xe.lastModified,offset:Wn,totalBytes:Xe.size,final:pr,dataBase64:gT(hl)})},N);if(!wi.ok||wi.queued!==M.length)throw new Error(wi.error||`file-chunk-not-queued-${wi.queued}/${M.length}`);de+=hl.byteLength,await new Promise(yu=>window.setTimeout(yu,0))}}return Fs({id:z,status:"queued",progress:100,message:`Sent ${F.length} file${F.length===1?"":"s"} to ${M.length} workstation${M.length===1?"":"s"}`}),window.setTimeout(()=>{Fs(Re=>Re?.id===z&&Re.status==="queued"?null:Re)},4500),{files:F.length,bytes:pe}}catch(Re){throw Fs({id:z,status:"failed",progress:100,message:Re instanceof Error?Re.message:String(Re)}),Re}},ws=async y=>{const M=ba.length>0?ba.map(L=>L.deviceId):Le?[Le.deviceId]:[];try{await wt(Ox(y),M)}catch(L){Ie(L instanceof Error?L.message:String(L))}},ma=async y=>{try{await wt(Ox(y),uf)}catch(M){Ie(M instanceof Error?M.message:String(M))}};u.useEffect(()=>{Kc.current=!1},[]);const Ko=y=>{y.preventDefault(),y.stopPropagation(),_a(!1),ws(y.dataTransfer.files)},Ba=async(y="ltd")=>{if(!n){Ie("Sign in with Google before checkout.");return}if(T&&y===Yt){Ie("LiveDesk license is already active.");return}if(T&&Yt==="pro"){Ie("LiveDesk Pro is already active.");return}Ae("checkout");try{const{data:M,error:L}=await pt.functions.invoke("dodo-checkout",{body:{plan:y}});if(L)throw L;if(!M?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(M.checkout_url)}catch(M){Ie(M instanceof Error?M.message:String(M)),Ae("")}},Ss=ZM(),rl=JM(),or=et.length,Cs=Vl.filter(y=>Jn.has(y)).length,ll=ar==="open"&&ea.sampleMs>0?`${ea.framesPerSecond.toFixed(1)} fps`:ar,Me=Le?st?qo.get(Le.deviceId):Jn.get(Le.deviceId):void 0,cr=Le?Ea(Qt[Le.deviceId],pa(Le)):0,Qs=Le?aT(Le):[],js=typeof Me?.monitorIndex=="number"?Ea(Me.monitorIndex,Math.max(1,Me.monitorCount||1)):cr,Fa=(Me&&js===cr?ww(Me):null)||(Le?bw(Le,cr):null);Fa&&`${Fa.width}${Fa.height}`;const ur=Le?Ms(st?"control":"wall",Le.deviceId):"",yn=ur?Bi[ur]:void 0,Mn=ur?zs[ur]:void 0,xt=Mn?.lastInfo,pi=yn&&yn.sampleMs>0?`${yn.framesPerSecond.toFixed(1)} fps`:"waiting";yn&&`${yn.totalFrames}${pi}`,Mn&&Mn.sampleMs>0&&`${Mn.framesPerSecond.toFixed(1)}`,Mn&&Mn.sampleMs>0&&`${Mn.changedFramesPerSecond.toFixed(1)}`,xt&&(`${xt.frameSeq}${xt.decoderLabel}${xt.queueSize}${xt.renderQueueSize}${xt.droppedForLatency}${xt.decoderFlushCount}${xt.decoderTimestampFallbacks}${xt.decoderInputCount}${xt.decoderOutputCount}`,xt.visualChanged),xt&&`${Math.round(xt.queuedForMs)}${Math.round(xt.decodedForMs)}${Math.round(xt.scheduledForMs)}${xt.drawMs.toFixed(1)}`,xt?.targetPaintIntervalMs&&`${xt.targetPaintIntervalMs.toFixed(1)}${(1e3/xt.targetPaintIntervalMs).toFixed(1)}`,Mn&&`${Mn.decoderInputFps.toFixed(1)}${Mn.decoderOutputFps.toFixed(1)}`,xt?.canvasPresentation,xt&&`${xt.interactiveBufferWaitCount}${Math.round(xt.interactiveBufferWaitMs)}${xt.interactiveQueueDrainCount}`,yn&&(Me?.frameMode==="mode5-lzo-delta"?`${Rc(yn.averageFrameBytes)}${Me.deltaVisualTileCount||0}${Me.deltaRefreshTileCount||0}${Me.deltaTotalTiles||0}`:`${Rc(yn.averageFrameBytes)}${Math.round(yn.tinyFrameRatio*100)}${Math.round(yn.repeatedFrameRatio*100)}`),yn&&yn.sourceSendSampleCount>0&&`${yn.sourceSendAverageMs.toFixed(1)}${yn.sourceSendP95Ms.toFixed(1)}`,Tx(yn),Tx(Mn),yn&&Mn&&`${Ex(yn)}${Ex(Mn)}`,Me?Me.frameMode||Me.mode||Me.codec||Me.mimeType:st?dt.frameMode:He.frameMode,st?dt.frameMode:He.frameMode,Me?`${Me.width}${Me.height}${Rc(Me.byteLength)}`:st?`${$s.maxWidth}${$s.maxHeight}`:`${He.maxWidth}${He.maxHeight}`,Me&&`${Me.isKeyFrame?"key":String(Me.chunkType||"delta")}`,Me&&Me.monitorCount&&((Me.monitorIndex??0)+1,`${Me.monitorCount}`),Me&&[`src ${Math.round(Me.sourceGapMs||0)}ms`,`gap ${Math.round(Me.agentSendGapMs||0)}ms`,`tx ${Math.round(Me.agentSendDurationMs||0)}ms`,`pace ${Math.round(Me.agentPaceMs||0)}ms`,`queue ${Math.round(Me.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Me.agentFrameAgeMs||0)}ms`,Me.browserReceivedEpochMs&&Me.receivedAt?`hub ${Math.max(0,Math.round(Me.browserReceivedEpochMs-Date.parse(Me.receivedAt)))}ms`:"",Me.browserReceivedEpochMs&&Me.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Me.browserReceivedEpochMs-Me.hubPacketEpochMs))}ms`:"",Me.droppedByAgent?`drop ${Me.droppedByAgent}`:"",Me.hubIngressDropped?`ingress-drop ${Me.hubIngressDropped}`:"",Me.hubClientDropped?`ws-drop ${Me.hubClientDropped}`:"",Me.captureStageMs?`capture ${Math.round(Me.captureStageMs)}ms`:"",Me.requestedFps?`req ${Math.round(Me.requestedFps)}fps`:"",Me.effectiveFps?`eff ${Math.round(Me.effectiveFps)}fps`:"",Me.captureAverageMs?`avg ${Math.round(Me.captureAverageMs)}ms`:"",Me.captureP95Ms?`p95 ${Math.round(Me.captureP95Ms)}ms`:"",Me.slowFrameCount?`slow ${Math.round(Me.slowFrameCount)}`:"",Me.captureHelperRestarts?`helper ${Math.round(Me.captureHelperRestarts)}`:"",Me.convertMs?`rgb565 ${Math.round(Me.convertMs)}ms`:"",Me.compressMs?`lzo ${Math.round(Me.compressMs)}ms`:"",Me.captureSourceSerial?`cap #${Me.captureSourceSerial}`:"",Me.captureSourceSkipped?`cap skip ${Me.captureSourceSkipped}`:"",Me.frameMode==="mode5-lzo-delta"?`tiles ${Me.deltaVisualTileCount||0}+${Me.deltaRefreshTileCount||0}/${Me.deltaTotalTiles||0}@${Me.deltaTileSize||0}`:"",Me.platformProfile||Me.hardwareEncoder||"-",Me.atlasComposeMs?`atlas ${Me.atlasComposeMs.toFixed(1)}ms`:"",Me.atlasPoolStarved?`pool ${Me.atlasPoolStarved}`:"",Me.atlasTileCount?`tiles ${Me.atlasReadyTiles||0}/${Me.atlasTileCount}`:"",Me.atlasInputRevision?`input #${Me.atlasInputRevision}`:"",Me.atlasSourceMaxAgeMs!==void 0?`input-age ${Math.round(Me.atlasSourceMaxAgeMs)}ms`:"",xt?.inputFeedbackMs!==void 0&&xt.inputFeedbackAt!==void 0&&performance.now()-xt.inputFeedbackAt<=Cx?`feedback ${Math.round(xt.inputFeedbackMs)}ms`:"",Me.contentHash?`enc ${Me.contentHash.slice(0,6)}`:"",xt?.visualHash?`pix ${xt.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "),Wo==="open"&&[`${Sa.sentPerSecond.toFixed(1)} hz`,Sa.lastInputSeq>0?`rtt ${Math.round(Sa.lastRoundTripMs)}ms`:"",Sa.lastInputSeq>0?`apply ${Sa.lastAgentApplyMs.toFixed(1)}ms`:"",Sa.droppedPerSecond>0?`drop ${Sa.droppedPerSecond.toFixed(1)}/s`:"",Sa.bufferedAmount>0?`buf ${Rc(Sa.bufferedAmount)}`:"",Sa.lastInputType||"ready"].filter(Boolean).join(" / "),xt?.inputFeedbackMs!==void 0&&xt.inputFeedbackAt!==void 0&&performance.now()-xt.inputFeedbackAt<=Cx&&`${Math.round(xt.inputFeedbackMs)}${xt.inputFeedbackSeq||0}`,re&&[mi,`context ${Hn.audioContextState}`,`queue ${Math.round(Hn.queuedMs)}ms`,`last ${Math.round(Hn.lastPacketAgeMs)}ms`,`accepted ${Math.round(Hn.lastAcceptedAgeMs)}ms`,`process ${Math.round(Hn.localProcessingAgeMs)}ms`,`remote ${Math.round(Hn.browserAgeMs)}/${Math.round(Hn.captureAgeMs)}ms`,`heartbeat ${Math.round(Hn.captureStatusAgeMs)}ms`,`capture ${Hn.captureAlive&&Hn.helperAlive?"alive":"down"}`,`drop ${Hn.drops}`,`resync ${Hn.resyncs}`,`restart ${Hn.automaticRestarts}`,Hn.pendingDecodes>0?`decode ${Hn.pendingDecodes}`:"",eo?`#${eo.frameSeq}`:"waiting"].filter(Boolean).join(" / "),Me&&`${Me.frameSeq}${ab(Me.receivedAt||Me.capturedAt)}`;const Jt=Math.max(0,ea.bytesPerSecond*8/1e6),ol=di?.atlasReadyTiles??Cs,no=di?.atlasTileCount??Cs,pf=ol===no?`${no} tiles`:`${ol}/${no} tiles`,gf=ua.length>0;st?`${ll}${Jt.toFixed(Jt>=10?0:1)}`:gf?`${pf}${ll}${Jt.toFixed(Jt>=10?0:1)}`:`${Cs}${ll}${Jt.toFixed(Jt>=10?0:1)}`;const fu=j?"offline":b?.started?"online":"starting",en=ba.length,Qo=st?Le?fs(Le):"No workstation":en===0?"No workstation":en>1?`${en} selected`:Le?fs(Le):"No workstation",cl=st?[Le?.deviceId].filter(y=>!!y):ba.map(y=>y.deviceId),xn=Eo[Fe]||Eo.en,dr=xn.sync||Eo.en.sync,gi=a||R?"checking":T?Yt==="pro"?"Pro LTD active":`Plus LTD ${et.length}/${Ec}`:Fo?`Free ${et.length}/${Tc}`:`Upgrade ${et.length}/${Tc}`,fr=Yt==="pro"?"Pro active":fe==="checkout"?"Opening":Yt==="ltd"?"Pro $199":"Plus $79",mu=T?Yt==="pro"?"Pro active":"Upgrade to Pro LTD":n?fe==="checkout"?"Opening checkout":Yt==="ltd"?"Buy Pro LTD":"Buy Plus LTD":fe==="auth"?"Opening Google":"Sign in to buy",vf=Yt==="pro"||fe==="checkout"||fe==="auth"||a||R,Xo=n?.user?.user_metadata,os=Hx(Xo,"avatar_url","picture"),vi=Hx(Xo,"full_name","name")||n?.user?.email||"Google",ul=vi.slice(0,1).toUpperCase(),hu=b?.started?"Local app ready":"Start LiveDesk",mr=r?.active?"Published":n?"Not published":"Sign in required",Zo=/^\d{6}$/.test(b?.pairingPin||"")?b?.pairingPin:"------",ao=Od.find(y=>y.width===He.maxWidth&&y.height===He.maxHeight)?.id||`${He.maxWidth}x${He.maxHeight}`,so=He.atlasTileSizeMode==="auto"?"auto":ph.find(y=>y.width===He.atlasTileWidth&&y.height===He.atlasTileHeight)?.id||"320x180",pu=hh.find(y=>y.width===dt.maxWidth&&y.height===dt.maxHeight)?.id||`${dt.maxWidth}x${dt.maxHeight}`,gu=Id.find(y=>y.id===He.frameMode)||Id[0],Tn=y=>{va(M=>{const L=y.frameMode?Uh(y.frameMode):M.frameMode,F=y.frameMode!==void 0&&L!==M.frameMode;return{...M,...y,frameMode:L,fps:Gh(y.fps??(F?vw(L):M.fps),L)}})},yi=y=>{const M=Od.find(L=>L.id===y);M&&Tn({maxWidth:M.width,maxHeight:M.height})},vu=y=>{if(y==="auto"){Tn({atlasTileSizeMode:"auto"});return}const M=ph.find(L=>L.id===y);!M?.width||!M?.height||Tn({atlasTileSizeMode:"fixed",atlasTileWidth:M.width,atlasTileHeight:M.height})},xi=y=>{y.frameMode!==void 0&&(Q(""),he("")),Hi(M=>{const L=y.frameMode?qh(y.frameMode):M.frameMode,F=y.frameMode!==void 0&&L!==M.frameMode,z=y.fps??(F?30:M.fps),pe=y.maxWidth??M.maxWidth,de=y.maxHeight??M.maxHeight;return{...M,...y,frameMode:L,fps:ms(z,20,L==="mode3-h264-hw"?60:30,L==="mode3-h264-hw"?60:30),maxWidth:L==="mode3-h264-hw"?pe:Math.min(1920,pe),maxHeight:L==="mode3-h264-hw"?de:Math.min(1080,de)}})},hr=y=>{const M=hh.find(L=>L.id===y);M&&xi({maxWidth:M.width,maxHeight:M.height})},bi=y=>{if(typeof window<"u"&&(y==="support"?window.history.pushState({},"","/support"):_t==="support"&&window.history.pushState({},"","/")),y==="control"){const M=Vn||Ki;if(M&&(Zt(!1),te(M.deviceId)),Ft(y),!It){_e(!1),Ie(Yr);return}_e(!0);return}y==="agents"&&Je(null),y==="wall"&&Ne(M=>M+1),Ft(y),_e(!1)},ks=fe==="update"||bt?.stage==="updating"||["dispatching","waiting-for-clients","hub-restart-requested"].includes(b?.update?.state||""),dl=!!(b?.update?.updateAvailable&&b.update.canApply||ks||!b&&bt),fl=u.useCallback(y=>{if(!bt?.targetIds.includes(y))return;if(bt.stage==="updated")return{state:"updated",label:"Updated"};if(bt.stage==="restored"||bt.stage==="failed")return{state:"failed",label:bt.stage==="restored"?"Update restored":"Update failed",error:bt.error};const M=b?.update?.operationId===bt.operationId?b.update.targets?.find(L=>L.deviceId===y):void 0;switch(M?.state){case"completed":return{state:"updated",label:"Updated"};case"failed":return{state:"failed",label:"Update failed",error:M.error||b?.update?.error};case"pending-offline":return{state:"offline",label:"Waiting for reconnect"};case"queued":return{state:"queued",label:"Queued"};case"waiting":return M.candidateSince?{state:"updating",label:"Verifying restart..."}:{state:"updating",label:"Restarting..."};default:return{state:"updating",label:"Verifying..."}}},[b?.update,bt]);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(sb,{size:25})}),s.jsx("nav",{className:"rail-tools",children:jT.map(y=>{const M=y.icon,L=Fd(y.tooltip,Fe);return s.jsxs("button",{className:`rail-tool ${y.id==="sync-server"?"sync-server":""} ${_t===y.id?"active":""} accent-${y.accent}`,onClick:()=>y.id==="sync-server"?void sl({takeover:!0,requestLocalAccess:!0}):bi(y.id),"data-tooltip":kh(y.label,y.tooltip,Fe),"aria-label":`${y.label}. ${L}`,type:"button",disabled:y.id==="sync-server"&&fe==="host","aria-busy":y.id==="sync-server"&&fe==="host",children:[y.id==="sync-server"&&fe==="host"?s.jsx("span",{className:"sync-server-spinner","aria-hidden":"true"}):s.jsx(M,{size:19}),s.jsx("span",{children:y.id==="sync-server"&&fe==="host"?"Syncing…":y.label})]},y.id)})}),s.jsxs("div",{className:"rail-footer",children:[kT.map(y=>{const M=y.icon;return s.jsxs("button",{className:`rail-tool compact ${_t===y.id?"active":""} accent-${y.accent}`,onClick:()=>bi(y.id),title:y.label,type:"button",children:[s.jsx(M,{size:18}),s.jsx("span",{children:y.label})]},y.id)}),s.jsxs("button",{className:`rail-tool compact local-settings ${ts?"active":""}`,onClick:()=>{Ft("settings"),typeof window<"u"&&window.history.pushState({},"","/"),jn(!1),_e(!1),gt(!1)},title:"Settings",type:"button",children:[s.jsx(Ux,{size:18}),s.jsx("span",{children:"Settings"})]}),s.jsxs("button",{className:`rail-account ${n?"signed-in":""}`,onClick:()=>{jn(y=>!y)},disabled:a||fe==="auth","aria-expanded":Ee,title:n?`Account: ${n.user?.email||vi}`:"Sign in with Google",type:"button",children:[n?os?s.jsx("img",{src:os,alt:vi,referrerPolicy:"no-referrer"}):s.jsx("span",{className:"avatar-fallback",children:ul}):s.jsx(El,{size:18}),s.jsx("span",{children:n?"Account":"Google"})]}),Ee&&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:n&&os?s.jsx("img",{src:os,alt:vi,referrerPolicy:"no-referrer"}):n?s.jsx("span",{children:ul}):s.jsx(El,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:n?vi:"Account"}),s.jsx("p",{children:n?.user?.email||"Not signed in"})]})]}),s.jsxs("dl",{className:"account-popover-facts",children:[s.jsx("dt",{children:"User"}),s.jsx("dd",{children:n?.user?.email||"Not signed in"}),s.jsx("dt",{children:"Network"}),s.jsx("dd",{children:hu}),s.jsx("dt",{children:"Access"}),s.jsx("dd",{children:mr}),s.jsx("dt",{children:"Plan"}),s.jsx("dd",{children:gi}),s.jsx("dt",{children:"Ads"}),s.jsx("dd",{children:Yt==="free"?"Standard banner":"Removed"})]}),n?s.jsxs("button",{className:"account-popover-action",onClick:rr,disabled:fe==="auth",type:"button",children:[s.jsx(qx,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:ls,disabled:fe==="auth",type:"button",children:[s.jsx(El,{size:16}),"Sign in with Google"]})]})]})]}),s.jsxs("section",{className:`desk-stage ${Wi&&!at?"dock-open":""} ${st?"control-stage":""} ${Gr?"agents-stage":""}`,children:[s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(pn,{size:18})}),s.jsxs("div",{className:"brand-copy",children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Control wall for local machines"})]}),dl?s.jsxs("button",{className:"topbar-update-button",onClick:()=>{il()},title:bt?.error||`Update LiveDesk to ${b?.update?.latestVersion||bt?.targetManagerVersion||"latest"}`,"aria-label":ks?"LiveDesk update in progress":`Update LiveDesk to ${b?.update?.latestVersion||bt?.targetManagerVersion||"latest"}`,type:"button",disabled:ks||!b?.update?.canApply,"aria-busy":ks,children:[ks?s.jsx("span",{className:"topbar-update-spinner","aria-hidden":"true"}):s.jsx(Vh,{size:19,"aria-hidden":"true"}),ks&&b?.update?.targetCount?s.jsxs("span",{className:"topbar-update-count","aria-hidden":"true",children:[b.update.completedCount||0,"/",b.update.targetCount]}):null]}):null]}),s.jsxs("div",{className:"topbar-tray",children:[li&&!st&&s.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[s.jsxs("div",{children:[s.jsx(Nl,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Source"}),s.jsx("strong",{children:"LiveDesk Hub"})]})]}),s.jsx(Kh,{size:15}),s.jsx(u0,{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:[Xc," workstation",Xc===1?"":"s"]}),s.jsx("em",{children:zt.trim()||"Desktop/LiveDeskFiles"})]})]})]}),Wi&&!st&&s.jsxs("div",{className:"top-actions",children:[s.jsx(xx,{controller:Xi,onError:Ie}),s.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),s.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:CT.map(y=>s.jsx("button",{className:ge===y.id?"active":"",onClick:()=>Oe(y.id),type:"button",children:y.label},y.id))})]}),st&&s.jsx("div",{className:"top-actions",children:s.jsx(xx,{controller:Xi,onError:Ie})})]})]}),Vi?s.jsxs("section",{className:"doc-page",lang:Fe,dir:Fe==="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(Hd,{size:16}),xn.eyebrow]}),s.jsx("h2",{children:xn.title}),s.jsx("p",{children:xn.intro})]}),s.jsxs("label",{className:"doc-language-picker",children:[s.jsxs("span",{children:[s.jsx(d0,{size:17}),xn.languageLabel]}),s.jsx("select",{value:Fe,onChange:y=>ke(y.target.value),children:NT.map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),s.jsx("section",{className:"doc-grid",children:xn.sections.map((y,M)=>{const F=[Tl,Dd,Bm,Bt,Rl][M]||Hd;return s.jsxs("article",{className:"doc-card",children:[s.jsx("div",{className:"doc-card-icon",children:s.jsx(F,{size:19})}),s.jsxs("div",{children:[s.jsx("h3",{children:y.title}),s.jsx("p",{children:y.body}),s.jsx("ul",{children:y.points.map(z=>s.jsx("li",{children:z},z))})]})]},y.title)})}),dr&&s.jsxs("section",{className:"doc-sync",children:[s.jsxs("div",{className:"doc-sync-head",children:[s.jsx(Bm,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:dr.title}),s.jsx("p",{children:dr.body})]})]}),s.jsx("ul",{children:dr.points.map(y=>s.jsx("li",{children:y},y))})]}),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:xn.firewall.title}),s.jsx("p",{children:xn.firewall.body})]})]}),s.jsx("ul",{children:xn.firewall.points.map(y=>s.jsx("li",{children:y},y))})]}),s.jsxs("section",{className:"doc-command-panel",children:[s.jsxs("div",{className:"doc-command-head",children:[s.jsx(Dd,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:xn.commands.title}),s.jsx("p",{children:xn.commands.body})]})]}),s.jsxs("div",{className:"doc-command-list",children:[xn.commands.manager&&s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:xn.commands.manager}),s.jsx("code",{children:rl}),s.jsx("button",{className:"icon-button",onClick:()=>kl(rl),title:"Copy command",type:"button",children:s.jsx(xl,{size:16})})]}),s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:xn.commands.primary}),s.jsx("code",{children:Ss}),s.jsx("button",{className:"icon-button",onClick:()=>kl(Ss),title:"Copy command",type:"button",children:s.jsx(xl,{size:16})})]}),s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:xn.commands.slot}),s.jsx("code",{children:`${Ss} 3`}),s.jsx("button",{className:"icon-button",onClick:()=>kl(`${Ss} 3`),title:"Copy command",type:"button",children:s.jsx(xl,{size:16})})]})]})]})]}):Gr?s.jsx(gx,{hubUrl:N,devices:C,launchRequest:Ve}):li?s.jsx(mN,{hubUrl:N,devices:et,localFeatureAccess:It,upgradeNotice:Yr,remoteDirectory:zt,onRemoteDirectoryChange:zn,targetMode:za,selectedTargetIds:ri,onTargetModeChange:Pi,onTargetToggle:y=>Ur(M=>M.includes(y)?M.filter(L=>L!==y):[...M,y]),filePickerRef:Ho,folderPickerRef:Pl,onBrowserFileImport:y=>{ma(y)},onBrowserFolderImport:y=>{ma(y)},onNotice:Ie,onTransferChange:y=>{if(!y){Fs(null);return}const M=y.state==="failed"||y.state==="partially-failed"||y.state==="cancelled"?"failed":y.state==="completed"?"queued":y.state==="sending"?"sending":"reading";Fs({id:y.id,status:M,progress:y.progress,message:y.message}),["completed","partially-failed","failed","cancelled"].includes(y.state)&&window.setTimeout(()=>Fs(L=>L?.id===y.id?null:L),4500)}}):Qc?s.jsx(eb,{session:n,currentProductKey:"livedesk",appVersion:"",onSignIn:ls}):ts?s.jsx(Ej,{hubUrl:N,runtimeRole:b?.runtimeRole||"hub",runtimeDeviceId:b?.deviceId||"",sessionAccessToken:n?.access_token||"",pin:s.jsxs(Rj,{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(an,{size:20})]}),s.jsxs("div",{className:"settings-pin-display",children:[s.jsx("span",{children:"Hub PIN"}),s.jsx("strong",{children:Zo}),s.jsxs("button",{className:"text-button ghost compact",onClick:Ca,disabled:!b?.started||fe==="pin",type:"button",children:[s.jsx(Ts,{size:15}),fe==="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:fu})]}),s.jsx("span",{className:`settings-status-dot state-${fu}`})]}),s.jsxs("dl",{className:"settings-facts",children:[s.jsx("dt",{children:"Address"}),s.jsx("dd",{children:N||"-"}),s.jsx("dt",{children:"Connected workstations"}),s.jsxs("dd",{children:[or,"/",$l]}),s.jsx("dt",{children:"Sync access"}),s.jsx("dd",{children:b?.started?"Local app ready":"Start Hub first"}),s.jsx("dt",{children:"Plan"}),s.jsx("dd",{children:gi})]}),s.jsxs("div",{className:"settings-action-row",children:[s.jsxs("button",{className:"text-button primary",onClick:()=>sl({takeover:!0,requestLocalAccess:!0}),disabled:!n||fe==="host",type:"button",children:[fe==="host"?s.jsx("span",{className:"sync-server-spinner","aria-hidden":"true"}):s.jsx(Bm,{size:16}),fe==="host"?"Syncing…":"Sync access"]}),s.jsxs("button",{className:"text-button buy",onClick:()=>Ba(Yt==="ltd"?"pro":"ltd"),disabled:fe==="checkout"||Yt==="pro",type:"button",children:[s.jsx(ko,{size:16}),fr]})]})]})]}),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(Ao,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Remote folder"}),s.jsx("input",{value:zt,onChange:y=>zn(y.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),s.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:s.jsx(Dj,{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(Fc,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Frame mode"}),s.jsx("select",{value:He.frameMode,onChange:y=>Tn({frameMode:Uh(y.target.value)}),children:Id.map(y=>s.jsxs("option",{value:y.id,children:[y.label," - ",y.detail]},y.id))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"H.264 decode"}),s.jsx("select",{value:He.h264DecodeAcceleration,onChange:y=>Tn({h264DecodeAcceleration:Xd(y.target.value)}),children:$h.map(y=>s.jsx("option",{value:y.id,children:y.label},y.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:He.fps,onChange:y=>Tn({fps:Gh(y.target.value,He.frameMode)}),children:vp.filter(y=>y<=yw(He.frameMode)).map(y=>s.jsx("option",{value:y,children:y},y))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:ft?"Atlas tile":"Resolution"}),s.jsx("select",{value:ft?so:ao,onChange:y=>ft?vu(y.target.value):yi(y.target.value),children:(ft?ph:Od).map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Quality"}),s.jsx("select",{value:He.quality,onChange:y=>Tn({quality:ms(y.target.value,20,95,ga.quality)}),children:Rx.map(y=>s.jsx("option",{value:y,children:y},y))})]})]}),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(pn,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.autoStartLive,onChange:y=>Tn({autoStartLive:y.target.checked})}),s.jsx("span",{children:"Auto live on connected screens"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.visibleOnlyLive,onChange:y=>Tn({visibleOnlyLive:y.target.checked})}),s.jsx("span",{children:"Stream visible tiles first"})]}),!ft&&s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.adaptiveSizeByWall,onChange:y=>Tn({adaptiveSizeByWall:y.target.checked})}),s.jsx("span",{children:"Fit stream size to Wall"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.adaptiveLoadShedding,onChange:y=>Tn({adaptiveLoadShedding:y.target.checked})}),s.jsx("span",{children:"Reduce FPS under load"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.showScreenStatus,onChange:y=>Tn({showScreenStatus:y.target.checked})}),s.jsx("span",{children:"Screen status overlay"})]}),s.jsxs("div",{className:"settings-summary",children:[s.jsx("span",{children:gu.label}),s.jsxs("strong",{children:[On.maxWidth,"x",On.maxHeight," / ",Pe,"fps"]})]}),s.jsxs("button",{className:"settings-reset",onClick:()=>va(ga),type:"button",children:[s.jsx(Lc,{size:15})," Reset Wall settings"]})]})]})}),control:s.jsx(Lj,{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(Rd,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Frame mode"}),s.jsx("select",{value:dt.frameMode,onChange:y=>xi({frameMode:qh(y.target.value)}),children:$M.map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]}),dt.frameMode==="mode3-h264-hw"&&s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"H.264 decode"}),s.jsx("select",{value:dt.h264DecodeAcceleration,onChange:y=>xi({h264DecodeAcceleration:Xd(y.target.value)}),children:$h.map(y=>s.jsx("option",{value:y.id,children:y.label},y.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:dt.fps,onChange:y=>xi({fps:ms(y.target.value,20,60,Ra.fps)}),children:UM.filter(y=>dt.frameMode==="mode3-h264-hw"||y<=30).map(y=>s.jsx("option",{value:y,children:y},y))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Resolution"}),s.jsx("select",{value:pu,onChange:y=>hr(y.target.value),children:hh.filter(y=>dt.frameMode==="mode3-h264-hw"||y.width<=1920).map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),dt.frameMode==="mode3-h264-hw"&&s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Quality"}),s.jsx("select",{value:dt.quality,onChange:y=>xi({quality:ms(y.target.value,20,95,Ra.quality)}),children:Rx.map(y=>s.jsx("option",{value:y,children:y},y))})]})]}),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(an,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:dt.showScreenStatus,onChange:y=>xi({showScreenStatus:y.target.checked})}),s.jsx("span",{children:"Screen status overlay"})]}),s.jsxs("div",{className:"settings-summary control",children:[s.jsx("span",{children:dt.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":"Mode 3 H.264"}),s.jsxs("strong",{children:[$s.maxWidth,"x",$s.maxHeight," / ",Yi,"fps"]})]}),s.jsxs("button",{className:"settings-reset",onClick:()=>Hi(Ra),type:"button",children:[s.jsx(Lc,{size:15})," Reset Control settings"]})]})]})}),agent:s.jsx(_j,{hubUrl:N}),captureGallery:s.jsx(hM,{hubUrl:N,onToast:Ie}),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(xl,{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:Ss}),s.jsx("button",{className:"icon-button",onClick:()=>kl(Ss),title:"Copy client command",type:"button",children:s.jsx(xl,{size:16})})]}),s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Slot example"}),s.jsx("code",{children:`${Ss} 3`}),s.jsx("button",{className:"icon-button",onClick:()=>kl(`${Ss} 3`),title:"Copy slot command",type:"button",children:s.jsx(xl,{size:16})})]}),s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Hub"}),s.jsx("code",{children:rl}),s.jsx("button",{className:"icon-button",onClick:()=>kl(rl),title:"Copy Hub command",type:"button",children:s.jsx(xl,{size:16})})]})]})]})}):qr?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(Sh,{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:()=>bi("wall"),title:"Close pricing",type:"button",children:s.jsx(Ya,{size:18})})]}),s.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[s.jsx("span",{children:"Current plan"}),s.jsx("strong",{children:nu.name}),s.jsxs("small",{children:[et.length,"/",PM(ql)," connected devices"]})]}),s.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[s.jsxs("article",{className:`pricing-plan-card ${Yt==="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:Sl.free.audience}),s.jsx("h3",{children:"Monitor your local wall"}),s.jsx("p",{children:Sl.free.note}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Up to ",Tc," devices"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Live view and local control"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Standard ad-supported banner"]})]}),s.jsx("span",{className:"pricing-current-label",children:Yt==="free"?"Current plan":"Included for everyone"})]}),s.jsxs("article",{className:`pricing-plan-card featured ${Yt==="ltd"?"current":""}`,children:[s.jsxs("div",{className:"pricing-plan-topline",children:[s.jsxs("span",{className:"pricing-plan-badge plus",children:[s.jsx(f0,{size:14})," Plus"]}),s.jsx("strong",{children:"$5"})]}),s.jsx("p",{className:"pricing-plan-audience",children:Sl.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(Fn,{size:16})," Up to ",Ec," devices"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," No standard ad banner"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," ",Sl.ltd.ltd]})]}),s.jsxs("button",{className:"pricing-plan-button",onClick:n?()=>Ba("ltd"):ls,disabled:Yt!=="free"||fe==="checkout"||fe==="auth"||a||R,type:"button",children:[s.jsx(ko,{size:16}),Yt==="free"?n?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),s.jsxs("article",{className:`pricing-plan-card pro ${Yt==="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:Sl.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(Fn,{size:16})," 30+ workstation walls"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Commercial use included"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," ",Sl.pro.ltd]})]}),s.jsxs("button",{className:"pricing-plan-button",onClick:n?()=>Ba("pro"):ls,disabled:Yt==="pro"||fe==="checkout"||fe==="auth"||a||R,type:"button",children:[s.jsx(ko,{size:16}),Yt==="pro"?"Pro active":n?"Choose Pro":"Sign in for Pro"]})]})]}),s.jsxs("section",{className:"pricing-includes",children:[s.jsxs("div",{children:[s.jsx(an,{size:17}),s.jsx("span",{children:"Screen wall"}),s.jsx("strong",{children:"120+ slots"})]}),s.jsxs("div",{children:[s.jsx(Rd,{size:17}),s.jsx("span",{children:"Focused control"}),s.jsx("strong",{children:"Local-first"})]}),s.jsxs("div",{children:[s.jsx(iy,{size:17}),s.jsx("span",{children:"Remote audio"}),s.jsx("strong",{children:"Available"})]}),s.jsxs("div",{children:[s.jsx(Ao,{size:17}),s.jsx("span",{children:"File transfer"}),s.jsx("strong",{children:"Included"})]})]}),s.jsxs("p",{className:"pricing-note",children:[s.jsx(Fn,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),s.jsxs("button",{className:"pricing-primary-cta",onClick:n?()=>Ba(Yt==="ltd"?"pro":"ltd"):ls,disabled:vf,type:"button",children:[s.jsx(ko,{size:18}),mu]})]}):s.jsx(s.Fragment,{children:s.jsxs("section",{className:`monitor-layout ${at?"dock-collapsed":""}`,children:[s.jsxs("section",{ref:$i,className:`screen-wall-panel ${Bl?"drop-active":""}`,onClick:y=>{y.currentTarget===y.target&&sa()},onDragEnter:y=>{y.preventDefault(),_a(!0)},onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="copy"},onDragLeave:y=>{y.currentTarget===y.target&&_a(!1)},onDrop:Ko,children:[ua.length>0&&s.jsx("canvas",{ref:ru,className:"atlas-source-canvas",width:fa?.width||1920,height:fa?.height||1080,"aria-hidden":"true"}),st?s.jsx("section",{className:"control-focus",children:s.jsxs("div",{className:"control-wall",children:[Le&&Qs.length>1&&s.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:Qs.map(y=>s.jsxs("button",{className:y.index===cr?"active":"",onClick:()=>uu(Le.deviceId,y.index),title:sT(y),type:"button",children:[s.jsx("span",{children:y.name||`Display ${y.index+1}`}),y.width>0&&y.height>0&&s.jsxs("small",{children:[y.width,"x",y.height]})]},y.index))}),Le?s.jsx(wh,{device:Le,frame:Me,selected:!1,controlEnabled:ns&&Se&&Ks,showStatus:dt.showScreenStatus,monitorIndex:Ea(Qt[Le.deviceId],pa(Le)),monitorCount:pa(Le),onSelect:()=>{},onFocusDevice:()=>te(Le.deviceId),onOpenControl:()=>lr(Le.deviceId),onCycleMonitor:y=>Ha(Le.deviceId,y),onCanvasReady:mf,sendInput:ir,presentationReady:Za},Le.deviceId):s.jsxs("div",{className:"control-empty",children:[s.jsx(an,{size:30}),s.jsx("strong",{children:"No workstation"}),s.jsx("span",{children:"Open a workstation from the Wall."})]}),Le&&Ul&&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."})]}),Le&&!Ul&&!Za&&s.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[q!=="error"&&s.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),s.jsx("strong",{children:q==="error"?"Connection failed":"Connecting"}),s.jsx("small",{children:q==="error"?"See the notification for details. Reopen Control to retry.":tl||ue?"Control stream is recovering. See the notification for details.":ar==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):ft?s.jsx("div",{className:`screen-wall atlas-slot-wall size-${ge}`,onClick:y=>{y.currentTarget===y.target&&sa()},children:Vr.map((y,M)=>y?s.jsx(wh,{device:y,frame:Jn.get(y.deviceId),selected:oi.has(y.deviceId),controlEnabled:!1,showStatus:He.showScreenStatus,monitorIndex:Ea(Qt[y.deviceId],pa(y)),monitorCount:pa(y),onSelect:()=>bs(y.deviceId),onFocusDevice:()=>aa(y.deviceId),onOpenControl:()=>lr(y.deviceId),onCycleMonitor:L=>Ha(y.deviceId,L),onCanvasReady:Ac({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(y.platform)})==="direct"?su:lu,sendInput:ir,updateIndicator:fl(y.deviceId),presentationReady:He.autoStartLive&&In.includes(y.deviceId)?qe.has(y.deviceId):void 0,showPresentationSpinner:He.autoStartLive&&In.includes(y.deviceId)},y.deviceId):s.jsx(Fx,{index:M},`slot-${M}`))}):s.jsx("div",{className:`screen-wall size-${ge}`,onClick:y=>{y.currentTarget===y.target&&sa()},children:Vr.map((y,M)=>y?s.jsx(wh,{device:y,frame:Jn.get(y.deviceId),selected:oi.has(y.deviceId),controlEnabled:ns&&Se&&Ks&&Le?.deviceId===y.deviceId,showStatus:He.showScreenStatus,monitorIndex:Ea(Qt[y.deviceId],pa(y)),monitorCount:pa(y),onSelect:()=>bs(y.deviceId),onFocusDevice:()=>aa(y.deviceId),onOpenControl:()=>lr(y.deviceId),onCycleMonitor:L=>Ha(y.deviceId,L),onCanvasReady:su,sendInput:ir,updateIndicator:fl(y.deviceId),presentationReady:He.autoStartLive&&In.includes(y.deviceId)?qe.has(y.deviceId):void 0,showPresentationSpinner:He.autoStartLive&&In.includes(y.deviceId)},y.deviceId):s.jsx(Fx,{index:M},`slot-${M}`))}),s.jsx(ET,{visible:au&&!st})]}),!ts&&s.jsxs("aside",{className:`right-dock actions-mode ${at?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[s.jsx("button",{className:"dock-toggle",onClick:()=>gt(y=>!y),"aria-label":at?"Show control panel":"Hide control panel",title:at?"Show control panel":"Hide control panel",type:"button",children:at?s.jsx(Zx,{size:18}):s.jsx(Qh,{size:18})}),!at&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"action-dock",children:[s.jsx("input",{ref:vs,className:"hidden-file-input",type:"file",multiple:!0,onChange:y=>{y.currentTarget.files&&ws(y.currentTarget.files),y.currentTarget.value=""}}),s.jsxs("div",{className:"manual-action-bar",role:"toolbar","aria-label":"Manual workstation controls",children:[s.jsx("button",{className:`manual-action ${Se?"active":""}`,onClick:()=>{if(Le){if(st&&Se){_e(!1),Ie("Remote control paused. Screen viewing stays on.");return}lr(Le.deviceId)}},disabled:!ns||!!Te,"aria-label":"Control","aria-pressed":st&&Se,title:Ul?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":ns?Ks?"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(Rd,{size:17})}),s.jsx("button",{className:`manual-action ${re?"active":""}`,onClick:()=>{Yo()},disabled:!Po||!!Te,type:"button","aria-label":"Audio","aria-pressed":re,title:Wr?re?"Stop hearing this workstation":"Hear this workstation":"Audio is not available on this workstation",children:Te==="audio"?s.jsx(Js,{className:"spin",size:17}):s.jsx(iy,{size:17})}),s.jsx("button",{className:"manual-action",onClick:()=>{Ie(`Choose files to send to ${Qo}.`),vs.current?.click()},disabled:!!Te||!It||(st?!Le:ba.length===0),type:"button","aria-label":"Send files",title:"Choose files and send them to the selected workstation",children:s.jsx(Ao,{size:17})}),s.jsx("button",{className:"manual-action",onClick:Gt,disabled:!Le||!It||!!Te||!tu,type:"button","aria-label":"Run command",title:tu?"Run command":"Command runner is not available on this workstation",children:s.jsx(Dd,{size:17})}),s.jsx("button",{className:"manual-action",onClick:()=>{un("restart")},disabled:!Le||!It||!!Te||!eu,type:"button","aria-label":"Restart",title:eu?"Restart workstation":"Restart is not available on this workstation",children:Te==="restart"?s.jsx(Js,{className:"spin",size:17}):s.jsx(Lc,{size:17})}),s.jsx("button",{className:"manual-action",onClick:()=>{un("lock")},disabled:!Le||!It||!!Te,type:"button","aria-label":"Lock",title:"Lock workstation",children:Te==="lock"?s.jsx(Js,{className:"spin",size:17}):s.jsx(Ts,{size:17})}),s.jsx("button",{className:"manual-action",onClick:()=>{un("sleep")},disabled:!Le||!It||!!Te,type:"button","aria-label":"Sleep",title:"Put workstation to sleep",children:Te==="sleep"?s.jsx(Js,{className:"spin",size:17}):s.jsx(m0,{size:17})}),s.jsx("button",{className:"manual-action danger",onClick:()=>{un("shutdown")},disabled:!Le||!It||!!Te,type:"button","aria-label":"Shut down",title:"Shut down workstation",children:Te==="shutdown"?s.jsx(Js,{className:"spin",size:17}):s.jsx(h0,{size:17})})]})]}),s.jsx(gx,{hubUrl:N,devices:C,variant:"dock",selectedDeviceIds:cl})]})]})]})})]}),ii&&s.jsxs("aside",{className:`transfer-bar state-${ii.status}`,"aria-live":"polite",children:[s.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:ii.status==="queued"?s.jsx(Fn,{size:18}):ii.status==="failed"?s.jsx(Ya,{size:18}):s.jsx(Kx,{size:18})}),s.jsxs("div",{className:"transfer-bar-copy",children:[s.jsx("p",{children:ii.message}),s.jsx("div",{className:"transfer-bar-track",children:s.jsx("span",{style:{width:`${Math.max(0,Math.min(100,ii.progress))}%`}})})]}),s.jsxs("strong",{children:[Math.max(0,Math.min(100,ii.progress)),"%"]})]}),We&&s.jsxs("aside",{className:`livedesk-toast tone-${We.tone}`,role:We.tone==="error"?"alert":"status","aria-live":We.tone==="error"?"assertive":"polite","aria-busy":We.tone==="progress",children:[We.tone==="progress"&&s.jsx("span",{className:"livedesk-toast-spinner","aria-hidden":"true"}),s.jsx("span",{children:We.message}),s.jsx("button",{className:"livedesk-toast-close",onClick:()=>Ie(""),type:"button","aria-label":"Dismiss notification",title:"Dismiss notification",children:s.jsx(Ya,{size:15})})]})]})}function DT(){if(typeof window>"u")return[];const n=window.location.origin;return window.location.port==="5179"?[n]:["http://127.0.0.1:5179"]}function LT(){const[a,r]=u.useState(null);return u.useEffect(()=>{let l=!1,c=!1;const d=async()=>{for(const g of DT())try{const v=await fetch(`${g}/api/runtime`,{cache:"no-store"});if(!v.ok)continue;const x=(await v.json()).role==="hub"?"hub":"client";c=!0,l||r(x);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(xC,{}):s.jsx(RT,{}):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..."})]})}S0.createRoot(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(LT,{})}));
|
|
24
|
+
${jn}`:jn;if(!st){try{if(Y==="custom"){const zt=await ZN(n,D,ne);if(!zt.ok)throw new Error(zt.error||"Custom Agent policy could not be saved.")}const nt=await VN(n,{instruction:Ls,deviceIds:gt,permissionMode:Y,customPolicyId:D});if(!nt.ok||!nt.runId)throw new Error(nt.error||"Codex Agent run could not be started.");B(nt.approvals||[]),ve({runId:nt.runId,stage:nt.stage||nt.status||"queued",message:nt.progressMessage||"Codex request queued on the Hub."}),R(nt.runId);return}catch(nt){try{const zt=await GN(n,Ls);zt.ok&&zt.plan&&(st={operation:zt.plan.operation,query:zt.plan.targetQuery})}catch{A(zt=>[...zt,{type:"error",id:Sl("unsupported"),text:cM(nt)}])}}if(!st)return}try{const nt=await eM(n,{instruction:Ls,deviceIds:gt,operation:st.operation,targetQuery:st.query});if(!nt.ok||!nt.batch||!nt.batchId)throw new Error(nt.error||"작업을 만들지 못했습니다.");const zt={type:"task",id:Sl("task"),batchId:nt.batchId,operation:st.operation,instruction:ke,states:kd(nt.batch,a),status:nt.batch.status};Z.current.add(nt.batchId),A(zn=>[...zn,zt]),k(nt.batchId)}catch(nt){X(nt instanceof Error?nt.message:String(nt))}},Ve=async(ge,Oe)=>{se(ge.approvalId);try{const Fe=await QN(n,ge.runId,ge.approvalId,Oe);if(!Fe.ok)throw new Error(Fe.error||"Agent approval could not be applied.");await Te(ge.runId)}catch(Fe){X(Fe instanceof Error?Fe.message:String(Fe))}finally{se("")}},Je=async ge=>{se(ge.approvalId);try{const Oe=await XN(n,ge.runId,ge.approvalId);if(!Oe.ok)throw new Error(Oe.error||"Agent approval could not be rejected.");await Te(ge.runId)}catch(Oe){X(Oe instanceof Error?Oe.message:String(Oe))}finally{se("")}},Et=async(ge,Oe)=>{O(ge);try{if(Oe){const ke=await YN(n,Oe);for(const st of ke.taskBatches||[])ae(st);R(st=>st===Oe?"":st),ve(st=>st?.runId===Oe?null:st);return}const Fe=await nM(n,ge);ae(Fe),k(ke=>ke===ge?"":ke)}catch(Fe){X(Fe instanceof Error?Fe.message:String(Fe))}finally{O("")}},je=async()=>{if(!(K||!N&&!T)){I(!0);try{const ge=await KN(n);if(!ge.ok)throw new Error(ge.error||"모든 Agent 작업을 취소하지 못했습니다.");k(""),R(""),ve(null),B([]),A(Oe=>Oe.map(Fe=>Fe.type==="task"&&["queued","running"].includes(Fe.status)?{...Fe,status:"cancelled",states:Fe.states.map(ke=>["queued","running"].includes(ke.status)?{...ke,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:ke)}:Fe))}catch(ge){X(ge instanceof Error?ge.message:String(ge))}finally{I(!1)}}},We=async ge=>{O(ge);try{const Oe=await aM(n,ge);if(!Oe.ok||!Oe.batch||!Oe.batchId)throw new Error(Oe.error||"재시도하지 못했습니다.");_e.current.delete(Oe.batchId),A(Fe=>Fe.map(ke=>ke.type==="task"&&ke.batchId===ge?{...ke,batchId:Oe.batchId,states:kd(Oe.batch,a),status:Oe.batch.status}:ke)),k(Oe.batchId)}catch(Oe){X(Oe instanceof Error?Oe.message:String(Oe))}finally{O("")}},it=ge=>{C(ge),ue(!1),window.requestAnimationFrame(()=>Se.current?.focus())},ot=u.useMemo(()=>a.filter(Qd),[a]),gn=u.useMemo(()=>ot.filter(ge=>g.includes(ge.deviceId)),[ot,g]),Kt=m==="auto"?`Auto · ${ot.length} available`:m==="all"?`All ${ot.length} computers`:gn.length===1?Kd(gn[0]):`${gn.length} selected`,Ie=m==="auto"?"LiveDesk chooses the best computer for each task.":m==="all"?"The Agent may coordinate every connected computer.":gn.length>0?gn.map(Kd).join(" · "):"Select one or more computers on the Wall.",ct=m==="selected"&&gn.length===1?["Diagnose this computer","Analyze recent errors","Summarize running applications","Check disk and GPU capacity"]:m==="all"?["Compare all computer health","Find the busiest computer","Check disk capacity everywhere","Divide a task across computers"]:["Use the fastest computer","Find an idle computer","Choose the best GPU","Check all computer health"],_t=m==="selected"?gn.length>0?"What should this computer do?":"Choose a computer or use Auto.":m==="all"?"Use all your computers together.":"What should LiveDesk handle?",Ft=m==="auto"?"LiveDesk can inspect the available computers and choose the best target.":"Describe the outcome. LiveDesk will plan, request approval when needed, and show progress per computer.";return s.jsxs("section",{className:`agents-page ${d?"agents-dock-console":""}`,children:[d&&s.jsxs("header",{className:"agent-console-header",children:[s.jsxs("div",{className:"agent-console-title",children:[s.jsx("span",{className:"agent-console-mark",children:s.jsx(Es,{size:16})}),s.jsxs("div",{children:[s.jsx("small",{children:"Live agent"}),s.jsx("strong",{children:"Agent Console"})]}),s.jsx("i",{children:"Ready"})]}),s.jsxs("section",{className:"agent-console-target","aria-label":"Agent target scope",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Target"}),s.jsx("strong",{children:Kt}),s.jsx("small",{children:Ie})]}),s.jsxs("div",{className:"agent-console-target-modes",children:[s.jsxs("button",{className:m==="selected"?"active":"",onClick:()=>p("selected"),type:"button",children:[s.jsx(Ii,{size:12})," Selected"]}),s.jsxs("button",{className:m==="all"?"active":"",onClick:()=>p("all"),type:"button",children:[s.jsx($c,{size:12})," All"]}),s.jsxs("button",{type:"button",disabled:!0,title:"Saved workstation groups are coming next.",children:[s.jsx($c,{size:12})," Group"]}),s.jsxs("button",{className:m==="auto"?"active":"",onClick:()=>p("auto"),type:"button",children:[s.jsx(Es,{size:12})," Auto"]})]})]}),s.jsx("div",{className:"agent-console-interaction-modes","aria-label":"Agent interaction mode",children:["auto","ask","plan","execute"].map(ge=>s.jsxs("button",{className:w===ge?"active":"",onClick:()=>x(ge),type:"button",children:[ge==="auto"?s.jsx(Es,{size:12}):ge==="execute"?s.jsx(an,{size:12}):null,ge[0].toUpperCase()+ge.slice(1)]},ge))})]}),s.jsxs("div",{className:"agents-workspace",children:[(N||T)&&s.jsxs("div",{className:"agents-page-status",children:[s.jsxs("span",{children:[ze.length," workstations · ",lM(Y)]}),s.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{je()},disabled:K,children:K?"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(Jd,{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:()=>q(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"danger",onClick:()=>{const ge=Q;q(null),ce(!0),Be(ge.instruction,ge.targetIds,!0)},children:"Run with Full Access"})]})]})}),be&&s.jsx("div",{className:"agents-error",role:"alert",children:be}),s.jsx(NN,{items:j,onCancel:Et,onRetry:We,busyBatchId:U,approvals:te,onApprove:Ve,onReject:Je,busyApprovalId:xe,progress:he,emptyTitle:d?_t:void 0,emptyBody:d?Ft:void 0}),d&&j.length===0&&!he&&s.jsx("div",{className:"agent-console-suggestions","aria-label":"Suggested Agent commands",children:ct.map(ge=>s.jsx("button",{type:"button",onClick:()=>it(ge),children:ge},ge))}),s.jsxs("div",{className:"agents-composer-shell",children:[$&&s.jsx(UN,{devices:a,targetMode:m,selectedIds:g,permissionMode:Y,customCategories:ne,onSelectPrompt:it,onClose:()=>ue(!1)}),s.jsx(pN,{ref:Se,value:b,onChange:C,onSubmit:()=>{Be()},onOpenSuggestedTasks:()=>ue(ge=>!ge),suggestedOpen:$,suggestedTaskCount:Le,disabled:!!N||!!T,placeholder:d?"Tell LiveDesk what outcome you want...":void 0})]})]}),!d&&s.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[s.jsx(qN,{devices:a,mode:m,selectedIds:g,onModeChange:p,onToggle:ge=>v(Oe=>Oe.includes(ge)?Oe.filter(Fe=>Fe!==ge):[...Oe,ge]),permissionMode:Y,onPermissionModeChange:ge=>{_(ge),ge!=="full-access"&&ce(!1)}}),Y==="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:gN.map(ge=>s.jsxs("label",{children:[s.jsx("span",{children:oM(ge)}),s.jsxs("select",{value:ne[ge],onChange:Oe=>G(Fe=>({...Fe,[ge]:Oe.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"})]})]},ge))})]})]})]})}function sw(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function iw(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function rw(n,a,r){const l=encodeURIComponent(JSON.stringify({kind:a.kind,fileName:a.fileName,mimeType:n.type||"application/octet-stream",durationMs:a.durationMs,target:sw(a.target)})),c=await fetch(`${Hr(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 iw(c));return await c.json()}async function uM(n,a){return await Ge("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:sw(n.target)})},a)}async function dM(n,a,r,l){const c=await fetch(`${Hr(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 iw(c));return await c.json()}async function fM(n,a,r){return await Ge(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},r)}async function yx(n,a){await Ge(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function mM(n){return await Ge("/api/captures",void 0,n)}function xx(n,a){return`${Hr(a)}/api/captures/${encodeURIComponent(n)}/content`}async function hM(n,a){return await Ge(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function pM({hubUrl:n,onToast:a}){const[r,l]=u.useState([]),[c,d]=u.useState(!0),m=u.useCallback(async()=>{d(!0);try{l((await mM(n)).captures||[])}catch(g){a(g instanceof Error?g.message:String(g))}finally{d(!1)}},[n,a]);u.useEffect(()=>{m()},[m]);const p=async g=>{const v=xx(g.id,n);if(navigator.share)try{await navigator.share({title:g.fileName,url:v});return}catch{}window.open(v,"_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(Do,{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(g=>{const v=xx(g.id,n);return s.jsxs("article",{className:"capture-gallery-card",children:[g.mimeType.startsWith("image/")?s.jsx("img",{src:v,alt:g.target.label}):s.jsx("video",{src:v,controls:!0,preload:"metadata"}),s.jsxs("div",{className:"capture-gallery-card-body",children:[s.jsx("strong",{children:g.fileName}),s.jsxs("small",{children:[g.target.label," · ",new Date(g.createdAt).toLocaleString()," · ",Math.ceil(g.sizeBytes/1024)," KB"]}),s.jsxs("div",{children:[s.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(v,"_blank","noopener,noreferrer"),type:"button",children:s.jsx(r0,{size:15})}),s.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${v}?download=1`,download:g.fileName,children:s.jsx(Wh,{size:15})}),s.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(g)},type:"button",children:s.jsx(l0,{size:15})}),s.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${g.fileName}?`)&&hM(g.id,n).then(()=>m()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:s.jsx(Yh,{size:15})})]})]})]},g.id)})})]})}function Ad(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 bx({controller:n,compact:a=!1,onFirstRollingUse:r,onError:l}){const{state:c,settings:d,videoSupported:m}=n,p=async x=>{try{await x()}catch(b){l?.(b instanceof Error?b.message:String(b))}},g=async()=>{if(d.rollingEnabled){n.setRollingEnabled(!1);return}(r?await r():window.confirm(`Keep the most recent 30 seconds in memory temporarily?
|
|
25
|
+
Nothing is saved until you press Save Last 30s.`))&&n.setRollingEnabled(!0)},v=c.recording?`Stop recording · ${Ad(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${Ad(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(o0,{size:17})}),s.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":v,title:v,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(iy,{size:14,fill:"currentColor"}),s.jsx("span",{children:Ad(c.recordingStartedAt)})]}):s.jsx(Xx,{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 g(),type:"button",children:[s.jsx(c0,{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(iy,{size:14,fill:"currentColor"}),s.jsx("span",{children:Ad(c.timelapseStartedAt)})]}):s.jsx(u0,{size:17})})]})}async function gM(n,a={}){const r=n.filter(x=>x.canvas&&x.canvas.width>0&&x.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),g=Math.floor(c/m),v=document.createElement("canvas");v.width=Math.max(320,p*d),v.height=Math.max(180,g*m);const w=v.getContext("2d",{alpha:!1});if(!w)return v;w.fillStyle="#0b1220",w.fillRect(0,0,v.width,v.height),w.font="600 14px system-ui, sans-serif",w.textBaseline="bottom";for(let x=0;x<r.length;x+=1){const b=r[x],C=x%d,j=Math.floor(x/d),A=C*p,N=j*g,k=b.canvas,T=Math.min(p/k.width,g/k.height),R=Math.max(1,Math.floor(k.width*T)),U=Math.max(1,Math.floor(k.height*T)),O=A+Math.floor((p-R)/2),Y=N+Math.floor((g-U)/2);w.drawImage(k,O,Y,R,U),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(A,N+g-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,A+9,N+g-9))}return v}function vM(n){return n?.signature||"none"}function yM(n){return n?.label||"No capture target"}function wx(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function xM(){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 bM(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"Wall"}function wM(n){return`LiveDesk_${n.type==="wall"||n.type==="selection"?"Wall":`${bM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${xM()}.png`}async function SM(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 rw(l,{kind:"screenshot",fileName:wM(a),target:a},r);try{await navigator.clipboard.write([new ClipboardItem({"image/png":l})])}catch{}return c.capture}function lw(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function CM(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 ow(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=lw();if(!a)throw new Error("This browser does not support WebM recording.");const r=n.kind||"recording",l=await uM({kind:r,fileName:CM(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,g=!1,v=null,w=Promise.resolve();return d.ondataavailable=x=>{if(!x.data||x.data.size===0)return;const b=p++;w=w.then(()=>dM(l.sessionId,b,x.data,n.hubUrl).then(()=>{})).catch(C=>{v=v||(C instanceof Error?C:new Error(String(C))),n.onError?.(v)})},d.onerror=()=>{v=new Error("Video recording stopped unexpectedly."),n.onError?.(v)},d.start(1e3),{requestFrame:()=>{c.getVideoTracks()[0]?.requestFrame?.()},stop:async()=>{if(!g){if(g=!0,await new Promise(x=>{d.addEventListener("stop",()=>x(),{once:!0}),d.stop()}),c.getTracks().forEach(x=>x.stop()),await w,v)throw await yx(l.sessionId,n.hubUrl).catch(()=>{}),v;await fM(l.sessionId,Math.max(0,performance.now()-m),n.hubUrl)}},cancel:async()=>{g||(g=!0,d.stop(),c.getTracks().forEach(x=>x.stop()),await yx(l.sessionId,n.hubUrl).catch(()=>{}))}}}class jM{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=lw();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 rw(l,{kind:"last-30s",fileName:d,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},r)}}async function kM(n,a,r,l,c){const d=await ow({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 cw="livedesk.captureSettings";function AM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(cw)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function NM(n){const[a,r]=u.useState(AM),[l,c]=u.useState(0),[d,m]=u.useState(0),[p,g]=u.useState(0),[v,w]=u.useState(!1),x=u.useRef(void 0),b=u.useRef(!1),C=u.useRef(""),j=u.useRef(null),A=u.useRef(null),N=u.useRef(null),k=u.useRef(null),T=u.useRef(new jM),R=n.sourceRegistry.resolveCurrentTarget(),U=vM(R),O=yM(R),Y=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;u.useEffect(()=>{if(localStorage.setItem(cw,JSON.stringify(a)),!b.current)return;const q=JSON.stringify(a);q!==C.current&&(C.current=q,Ge("/api/settings",{method:"PATCH",body:JSON.stringify({revision:x.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(V=>{x.current=Number(V.revision||x.current||0)}).catch(()=>{}))},[n.hubUrl,a]),u.useEffect(()=>{let q=!0;return Ge("/api/settings",void 0,n.hubUrl).then(V=>{if(!q)return;const ce=V.settings?.filesAudio||{},be=typeof ce.rollingBufferEnabled=="boolean"?ce.rollingBufferEnabled:a.rollingEnabled,X=ce.recordingQuality==="high"?"high":"standard",$=[5,10,30,60].includes(Number(ce.timelapseIntervalSeconds))?Number(ce.timelapseIntervalSeconds):a.timelapseIntervalSeconds,ue=typeof ce.includeRemoteCursor=="boolean"?ce.includeRemoteCursor:a.includeRemoteCursor,he={rollingEnabled:be,recordingQuality:X,timelapseIntervalSeconds:$,includeRemoteCursor:ue};x.current=Number(V.revision||0),C.current=JSON.stringify(he),b.current=!0,r(he)}).catch(()=>{b.current=!0}),()=>{q=!1}},[n.hubUrl]);const _=u.useCallback(async q=>{if(q.sourceCanvas&&q.sourceCanvas.width>0&&q.sourceCanvas.height>0)return{target:wx(q),canvas:q.sourceCanvas,cleanup:()=>{}};const V=await n.sourceRegistry.composeWall(q.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let ce=!1;const be=window.setInterval(async()=>{if(ce)return;const X=await n.sourceRegistry.composeWall(q.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!X||ce||((V.width!==X.width||V.height!==X.height)&&(V.width=X.width,V.height=X.height),V.getContext("2d")?.drawImage(X,0,0))},100);return{target:wx(q),canvas:V,cleanup:()=>{ce=!0,window.clearInterval(be)}}},[n.sourceRegistry]);u.useEffect(()=>{const q=T.current;if(!a.rollingEnabled||!R||!Y){q.stop(),g(0);return}let V=!1,ce=null;return(async()=>{try{if(ce=await _(R),V)return;await q.start(ce.canvas,ce.target);const X=window.setInterval(()=>g(Math.round(q.seconds)),500),$=()=>{window.clearInterval(X),ce?.cleanup()};q.__cleanup=$}catch(X){V||n.onToast(X instanceof Error?X.message:String(X))}})(),()=>{V=!0,q.stop(),q.__cleanup?.(),q.__cleanup=void 0,g(0)}},[_,n.onToast,a.rollingEnabled,U,Y]);const D=u.useCallback(q=>r(V=>({...V,rollingEnabled:q})),[]),ne=u.useCallback(q=>r(V=>({...V,recordingQuality:q})),[]),G=u.useCallback(q=>r(V=>({...V,timelapseIntervalSeconds:q})),[]),te=u.useCallback(async()=>{const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let V=null;try{V=await _(q),await SM(V.canvas,V.target,n.hubUrl),n.onToast("Screenshot saved")}finally{V?.cleanup(),w(!1)}},[_,n.hubUrl,n.onToast,n.sourceRegistry]),B=u.useCallback(async()=>{if(N.current)throw new Error("Stop the timelapse before recording.");const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");const V=await _(q),ce=await ow({canvas:V.canvas,target:V.target,fps:q.type==="control"?30:15,hubUrl:n.hubUrl,onError:be=>n.onToast(be.message)});A.current=V.cleanup,j.current=ce,c(Date.now()),n.onToast("Recording started")},[_,n.hubUrl,n.onToast,n.sourceRegistry]),xe=u.useCallback(async()=>{const q=j.current;if(q){w(!0);try{await q.stop(),n.onToast("Recording saved")}finally{j.current=null,A.current?.(),A.current=null,c(0),w(!1)}}},[n.onToast]),se=u.useCallback(async()=>{if(j.current||N.current)throw new Error("Last 30s is unavailable during a recording.");const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await T.current.save(q,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),K=u.useCallback(async()=>{if(j.current)throw new Error("Stop the recording before starting a timelapse.");const q=n.sourceRegistry.resolveCurrentTarget();if(!q)throw new Error("화면이 준비된 후 다시 시도하세요.");const V=await _(q),ce=await kM(V.canvas,V.target,a.timelapseIntervalSeconds,n.hubUrl,be=>n.onToast(be.message));k.current=V.cleanup,N.current=ce,m(Date.now()),n.onToast("Timelapse started")},[_,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),I=u.useCallback(async()=>{const q=N.current;if(q){w(!0);try{await q.stop(),n.onToast("Timelapse saved")}finally{N.current=null,k.current?.(),k.current=null,m(0),w(!1)}}},[n.onToast]);return u.useEffect(()=>{const q=V=>{!j.current&&!N.current||(V.preventDefault(),V.returnValue="")};return window.addEventListener("beforeunload",q),()=>window.removeEventListener("beforeunload",q)},[]),u.useEffect(()=>()=>{T.current.stop(),j.current?.cancel(),N.current?.cancel(),A.current?.(),k.current?.()},[]),{state:u.useMemo(()=>({recording:!!j.current,recordingStartedAt:l,timelapse:!!N.current,timelapseStartedAt:d,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:v,targetLabel:O}),[p,v,l,a.rollingEnabled,O,d]),settings:a,videoSupported:Y,targetKey:U,setRollingEnabled:D,setRecordingQuality:ne,setTimelapseInterval:G,takeScreenshot:te,startRecording:B,stopRecording:xe,saveLast30Seconds:se,startTimelapse:K,stopTimelapse:I}}const MM=120,TM=999,Ec=5,Rc=30,EM=Number.POSITIVE_INFINITY,uw="livedesk.remoteDirectory",Bh="livedesk.localHubAccessEnabled",dw="livedesk.streamSettings",Fh=16,fw="livedesk.controlStreamSettings",Ph=6,mw="livedesk.wallMonitorSelections",hw=1,dh=512*1024,$h="".trim(),pw="".trim(),Sx="livedesk-adsense-script",fh=!!$h&&!!pw,RM=1e3/60,mh=1500,DM=650,LM=1800,_M=650,zM=2500,Cx=1500,jx=15e3,IM=6e4,kx=240,OM=1024,HM=480,BM=270,Ax="Connected LiveDesk clients are updating in batches. Hub will restart after every target reconnects on the requested versions.",Nd="LiveDesk is replacing the Hub and verifying the requested version.",Md=5*6e4,FM=5e3;function Dr({label:n,tooltip:a,disabled:r=!1,active:l=!1,danger:c=!1,pressed:d,onClick:m,children:p}){return s.jsx("span",{className:`manual-action-tooltip ${r?"disabled":""}`.trim(),"data-tooltip":a,children:s.jsx("button",{className:`manual-action ${l?"active":""} ${c?"danger":""}`.trim(),onClick:m,disabled:r,"aria-label":n,"aria-pressed":d,type:"button",children:p})})}function PM(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 Cl={free:{name:"Free",price:"$0",limit:Ec,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:Rc,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:EM,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},gw={"mode1-jpeg":5,"mode3-h264-hw":30,"mode4-h264-atlas":20};function Nx(n,a){const r=m=>{const g=String(m||"").trim().replace(/^v/i,"").match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/);if(!g)return null;const v=g[4]?g[4].split(".").map(w=>/^\d+$/.test(w)?w.length>1&&w.startsWith("0")?Number.NaN:Number(w):w):[];return v.some(w=>typeof w=="number"&&!Number.isFinite(w))?null:{core:[Number(g[1]),Number(g[2]),Number(g[3])],prerelease:v}},l=r(n),c=r(a);if(!l||!c)return!1;for(let m=0;m<3;m+=1){if(l.core[m]>c.core[m])return!0;if(l.core[m]<c.core[m])return!1}if(l.prerelease.length===0||c.prerelease.length===0)return l.prerelease.length===0;const d=Math.max(l.prerelease.length,c.prerelease.length);for(let m=0;m<d;m+=1){const p=l.prerelease[m],g=c.prerelease[m];if(p===void 0||g===void 0)return g===void 0;if(p!==g){if(typeof p=="number"&&typeof g=="number")return p>g;if(typeof p=="number")return!1;if(typeof g=="number"||p>g)return!0;if(p<g)return!1}}return!0}function Ms(n,a){return`${n}:${a}`}const va={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:gw["mode3-h264-hw"],maxWidth:1920,maxHeight:1080,atlasTileWidth:320,atlasTileHeight:180,atlasTileSizeMode:"auto",quality:75,autoStartLive:!0,showScreenStatus:!0,visibleOnlyLive:!0,adaptiveLoadShedding:!0,adaptiveSizeByWall:!0},Ra={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function hh(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 vw(n,a){n.push(a),n.length>kx&&n.splice(0,n.length-kx)}function Mx(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 Tx(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),vw(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 Ex(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 Rx(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function $M(n){return Number.isFinite(n)?String(n):"30+"}const Od=[{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"}],UM=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"}],Hd=[{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=Hd.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}],yp=[1,2,5,8,12,20,30],qM=[20,30,60],Dx=[45,60,75,90],Lx={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},oa={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:ei.maxDirectFramesPerSecond,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},_x=2200,GM=8e3,VM=3500,WM=7e3,YM=2,KM=2600,QM=4200,XM=750,ZM=2,zx=4200;function Ix(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function Bc(n,a){const r=n.capabilities?.[a];return typeof r=="boolean"?r:/^(1|true|yes|on)$/i.test(String(r||"").trim())}function fs(n){return n.deviceName||n.hostname||n.deviceId}function JM(){return"npx -y --prefer-online livedesk@latest client"}function eT(){return"npx -y --prefer-online livedesk@latest"}function tT(){try{return localStorage.getItem(uw)||""}catch{return""}}function nT(){try{return localStorage.getItem(Bh)==="1"}catch{return!1}}function Co(n){try{n?localStorage.setItem(Bh,"1"):localStorage.removeItem(Bh)}catch{}}function ms(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 Od.some(r=>r.id===a)?a:va.frameMode}function Zd(n){const a=String(n||"").trim();return Uh.some(r=>r.id===a)?a:va.h264DecodeAcceleration}function Gh(n){return n==="mode3-h264-hw"?n:Ra.frameMode}function yw(n){return gw[n]||12}function xw(n){return n==="mode3-h264-hw"?30:n==="mode4-h264-atlas"?20:30}function Vh(n,a){return ms(n,1,xw(a),yw(a))}function zl(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function ga(n){const a=zl(n.status),r=zl(a.screens),l=zl(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 zr(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function aT(n){const a=zl(n.status),l=[zl(a.screens).displays,a.displays,a.monitors];for(const c of l)if(!(!Array.isArray(c)||c.length===0))return c.map(d=>zl(d));return[]}function bw(n,a){const r=aT(n),l=r.find(g=>Number(g.index)===a)||r[a]||r[0]||{},c=zr(l.width),d=zr(l.height),m=[l.name,l.displayName,l.deviceName,l.id].find(g=>typeof g=="string"&&g.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 sT(n){const a=ga(n);return Array.from({length:a},(r,l)=>bw(n,l))}function iT(n){const a=[n.name||`Display ${n.index+1}`];return n.width>0&&n.height>0&&a.push(`${n.width}x${n.height}`),n.primary&&a.push("Primary"),a.join(" - ")}function ww(n,a){const r=bw(n,a);if(r.width>0&&r.height>0)return{width:r.width,height:r.height};const l=zl(n.status),c=zr(l.screenWidth||l.width),d=zr(l.screenHeight||l.height);return c>0&&d>0?{width:c,height:d}:null}function Sw(n){if(!n)return null;const a=zr(n.sourceWidth)||zr(n.width),r=zr(n.sourceHeight)||zr(n.height);return a>0&&r>0?{width:a,height:r}:null}function rT(n,a,r){const d=((typeof a?.monitorIndex=="number"?Ea(a.monitorIndex,Math.max(1,a.monitorCount||1)):r)===r?Sw(a):null)||ww(n,r);return d?Math.max(.25,Math.min(4,d.width/d.height)):16/9}const Td=16/9;function Ea(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 lT(){try{const n=localStorage.getItem(mw);if(!n)return{};const a=JSON.parse(n),r=a&&typeof a=="object"&&!Array.isArray(a)?a.selections:void 0;if(Number(a?.version)!==hw||!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 oT(n){try{localStorage.setItem(mw,JSON.stringify({version:hw,selections:n}))}catch{}}function cT(){try{const n=JSON.parse(localStorage.getItem(dw)||"{}"),a=Number(n.version);if(![Fh,15,14,13,12,11].includes(a))return va;const r=qh(n.frameMode),l=ms(n.maxWidth,320,3840,va.maxWidth),c=ms(n.maxHeight,180,2160,va.maxHeight);return{frameMode:r,h264DecodeAcceleration:Zd(n.h264DecodeAcceleration),fps:a<Fh&&r==="mode3-h264-hw"?va.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:ms(n.quality,20,95,va.quality),autoStartLive:typeof n.autoStartLive=="boolean"?n.autoStartLive:va.autoStartLive,showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:va.showScreenStatus,visibleOnlyLive:typeof n.visibleOnlyLive=="boolean"?n.visibleOnlyLive:va.visibleOnlyLive,adaptiveLoadShedding:typeof n.adaptiveLoadShedding=="boolean"?n.adaptiveLoadShedding:va.adaptiveLoadShedding,adaptiveSizeByWall:typeof n.adaptiveSizeByWall=="boolean"?n.adaptiveSizeByWall:va.adaptiveSizeByWall}}catch{return va}}function uT(n){try{localStorage.setItem(dw,JSON.stringify({...n,version:Fh}))}catch{}}function dT(){try{const n=JSON.parse(localStorage.getItem(fw)||"{}"),a=Number(n.version);if(![Ph,5,4,3,2,1].includes(a))return Ra;const r=ms(n.fps,20,60,Ra.fps),l=a<Ph;return{frameMode:l?Ra.frameMode:Gh(n.frameMode),h264DecodeAcceleration:l?Ra.h264DecodeAcceleration:Zd(n.h264DecodeAcceleration),fps:l?Ra.fps:r,maxWidth:ms(n.maxWidth,1280,3840,Ra.maxWidth),maxHeight:ms(n.maxHeight,720,2160,Ra.maxHeight),quality:ms(n.quality,20,95,Ra.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:Ra.showScreenStatus}}catch{return Ra}}function fT(n){try{localStorage.setItem(fw,JSON.stringify({...n,version:Ph}))}catch{}}function vh(n,a){return n.length!==a.length?!1:n.every((r,l)=>r===a[l])}function yh(n){return[...new Set(n.filter(Boolean))].sort()}function mT(n){return oa.fallbackVisibleCounts[n]||oa.fallbackVisibleCounts.large}function hT(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=Lx[a]||Lx.large;return{maxWidth:Math.min(n.maxWidth,l.maxWidth),maxHeight:Math.min(n.maxHeight,l.maxHeight)}}function pT(n,a=oa.minFps){const r=[...yp].sort((c,d)=>c-d),l=Math.max(a,Math.floor(n/2));return[...r].reverse().find(c=>c<n&&c>=a)||l}function gT(n,a){return[...yp].sort((l,c)=>l-c).find(l=>l>n&&l<=a)||a}function Dc(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 Ox(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 xh(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`${Ox(r)} / ${Ox(n)}`}function vT(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 Hx(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 yT(n){return n===1?"middle":n===2?"right":"left"}function Bx(n,...a){for(const r of a){const l=n?.[r];if(typeof l=="string"&&l.trim())return l.trim()}return""}function Fx(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=TM?a:0}const xT={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function bT(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=xT[c.id]||c.label;return c.value&&c.value!=="-"?`${d} ${c.value}`:d}function of(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 hn(n,...a){for(const r of a){const l=of(n,r),c=Number(l);if(Number.isFinite(c))return c}}function Wa(n,...a){for(const r of a){const l=of(n,r);if(typeof l=="string"&&l.trim())return l.trim();if(typeof l=="number"&&Number.isFinite(l))return String(l)}return""}function wT(n,...a){for(const r of a){const l=of(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 _i(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function bh(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return _i((n-Math.max(0,a))/n)}function jo(n){return n===void 0?"-":`${Math.round(n*100)}%`}function wh(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 jl(n,a=.92,r=.78){return n===void 0?"unknown":n>=a?"critical":n>=r?"warn":"good"}function ST(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 Ed(n,a,r){const l=of(n,`tools.${a}`),c=Wa(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),d=wT(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),m=Wa(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=Wa(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let g="unknown";return c==="busy"?g="busy":["online","running","ready","active"].includes(c)||d===!0?g="online":(["offline","stopped","missing","not-found"].includes(c)||d===!1||l===!1)&&(g="offline"),{id:a,label:r,status:g,detail:g==="offline"?"offline":m||(p?`:${p}`:g==="unknown"?"not reported":g)}}function CT(n){const a=n.status||{},r=hn(a,"cpu.cores","cpuCores","processorCount"),l=hn(a,"loadavg.0","cpu.load1"),c=_i(hn(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=hn(a,"memory.totalBytes","totalMem"),m=hn(a,"memory.freeBytes","freeMem"),p=_i(hn(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??bh(d,m),g=hn(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),v=hn(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=_i(hn(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??bh(g,v),x=hn(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=_i(hn(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),C=Wa(a,"gpu.name","gpu.model","accelerators.gpu.name"),j=hn(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),A=hn(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),N=_i(hn(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??bh(j,A),k=hn(a,"gpu.temperatureC","thermal.gpuC"),T=_i(hn(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),R=Wa(a,"npu.name","npu.model","accelerators.npu.name"),U=hn(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),O=hn(a,"network.rxMbps","network.receiveMbps","network.downMbps"),Y=hn(a,"network.txMbps","network.transmitMbps","network.upMbps"),_=hn(a,"network.latencyMs","network.rttMs"),D=_i(hn(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),ne=Wa(a,"network.link","network.interface","network.name"),G=x===void 0?void 0:_i((x-35)/60),te=Wa(a,"workload.role","role","lane")||(Bc(n,"aiAssist")?"Agent worker":Bc(n,"taskDispatch")?"Task worker":"Local machine"),B=Wa(n.latestTask,"status")||Wa(a,"workload.status")||"idle",xe=Wa(n.latestTask,"title","instructionPreview")||Wa(a,"workload.title"),se=Wa(n.latestTask,"resultSummary","error","instructionPreview")||Wa(a,"workload.summary"),K=[Ed(a,"ollama","Ollama"),Ed(a,"lmStudio","LM Studio"),Ed(a,"comfyui","ComfyUI"),Ed(a,"stableDiffusion","Stable Diffusion")],I=K.some(X=>X.status!=="unknown"),Q=Date.parse(n.lastSeenAt||n.connectedAt||""),q=Number.isFinite(Q)?Date.now()-Q:0;let V="online";n.connected?q>5*6e4?V="stale":(x??0)>=86||(k??0)>=88||(c??0)>=.94||(b??0)>=.96||(N??0)>=.96||(T??0)>=.96||(p??0)>=.94||(w??0)>=.94||(_??0)>=200||B==="failed"?V="critical":(x??0)>=78||(k??0)>=80||(c??0)>=.82||(b??0)>=.86||(N??0)>=.88||(T??0)>=.86||(p??0)>=.82||(w??0)>=.86||(_??0)>=80?V="warn":(["queued","running","targeted"].includes(B)||K.some(X=>X.status==="busy"))&&(V="busy"):V="offline";const ce=K.filter(X=>X.status==="online"||X.status==="busy").length,be=[{id:"cpu",label:"CPU",value:jo(c),detail:r?`${r} cores`:l!==void 0?`load ${l.toFixed(1)}`:"not reported",ratio:c,state:jl(c,.92,.78)},{id:"memory",label:"RAM",value:jo(p),detail:xh(d,m),ratio:p,state:jl(p,.92,.78)},{id:"disk",label:"DISK",value:jo(w),detail:xh(g,v),ratio:w,state:jl(w,.92,.82)},{id:"gpu",label:"GPU",value:jo(b),detail:C||(j&&A!==void 0?`${Dc(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":jl(b,.96,.86)},{id:"vram",label:"VRAM",value:jo(N),detail:xh(j,A),ratio:N,state:jl(N,.96,.88)},{id:"npu",label:"NPU",value:T!==void 0?jo(T):U!==void 0?`${Math.round(U)} TOPS`:"-",detail:R||(U!==void 0?"neural engine":"not reported"),ratio:T,state:jl(T,.96,.86)},{id:"temp",label:"TEMP",value:x===void 0?"-":`${Math.round(x)}C`,detail:ce>0?`${ce} local tools`:`uptime ${ST(hn(a,"uptimeSec"))}`,ratio:G,state:x===void 0?"unknown":x>=86?"critical":x>=78?"warn":"good"},{id:"network",label:"NET",value:wh(O)||(_!==void 0?`${Math.round(_)}ms`:ne||"-"),detail:wh(Y)?`${wh(Y)} up`:ne||"not reported",ratio:D,state:_!==void 0&&_>=200?"critical":_!==void 0&&_>=80?"warn":jl(D,.9,.75)}];return{state:V,label:bT(V,be,B),role:te,taskLabel:xe||(B==="idle"?"idle":B),taskStatus:B,taskSummary:se,tools:I?K:K.map(X=>({...X,detail:"not reported"})),metrics:be}}const jT=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],kT=[{id:"sync-server",label:"Hub",icon:El,accent:"blue",tooltip:"hub"},{id:"wall",label:"Wall",icon:Pc,accent:"blue",tooltip:"wall"},{id:"control",label:"Control",icon:Dd,accent:"red",tooltip:"control"},{id:"share-files",label:"Share Files",icon:Rd,accent:"green",tooltip:"share-files"},{id:"agents",label:"Agents",icon:Ld,accent:"violet",tooltip:"agents"}],AT=[{id:"doc",label:"Doc",icon:Bd,accent:"amber"},{id:"support",label:"Support",icon:Lc,accent:"violet"},{id:"pricing",label:"Pricing",icon:Ao,accent:"green"}];function NT(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 on(n){return NT(n).replaceAll("Sync Server","Hub").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 kl(n){return n.map(a=>on(a))}function ra(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:on(n.title),intro:on(n.intro),sections:[{title:on(n.managerTitle),body:on(n.managerBody),points:kl(n.managerPoints)},{title:on(n.clientTitle),body:on(n.clientBody),points:kl(n.clientPoints)},{title:on(n.syncTitle),body:on(n.syncBody),points:kl(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:on(n.agentTitle),body:on(n.agentBody),points:kl(n.agentPoints)}]:[],{title:on(n.platformTitle),body:on(n.platformBody),points:kl(n.platformPoints)}],sync:{title:on(n.syncTitle),body:on(n.syncBody),points:kl(n.syncPoints)},firewall:{title:on(n.firewallTitle),body:on(n.firewallBody),points:kl(n.firewallPoints)},commands:{title:on(n.commandsTitle),body:on(n.commandsBody),manager:on(n.managerCommandLabel),primary:on(n.clientCommandLabel),slot:on(n.slotCommandLabel),manual:on(n.manualCommandLabel)}}}const Ro={ko:ra({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:ra({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:ra({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":ra({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":ra({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:ra({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:ra({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:ra({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":ra({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:ra({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:ra({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:ra({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:ra({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:ra({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:ra({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:ra({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ı"})},MT=Object.entries(Ro).map(([n,a])=>({id:n,label:a.languageName}));function TT(){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(Ro[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(Ro[l])return l}return"en"}function Px({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(an,{size:24}),s.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function ET(n){if(!n)return!1;const a=String(n.platform||"").trim().toLowerCase();return zi(a)&&n.capabilities?.screenRecordingPermission===!1}function zi(n){const a=String(n||"").trim().toLowerCase();return a==="macos"||a==="darwin"||a==="mac"||a==="macosx"}function $x(n){if(!n)return!1;const a=String(n.capabilities?.liveCaptureConcurrency||"").trim().toLowerCase();return a==="exclusive"?!0:a==="parallel"?!1:zi(n.platform)}function Sh({device:n,frame:a,selected:r,controlEnabled:l,showStatus:c,monitorIndex:d,monitorCount:m,onSelect:p,onFocusDevice:g,onOpenControl:v,onCycleMonitor:w,onCanvasReady:x,sendInput:b,updateIndicator:C,presentationReady:j,showPresentationSpinner:A=!1}){const N=u.useRef(null),k=u.useRef(null),T=u.useRef(0),R=u.useRef(null),U=CT(n),O=["cpu","gpu","memory","vram"].map($=>U.metrics.find(ue=>ue.id===$)).filter($=>!!$),Y=Ea(d,m),_=m>1,D=j??!!a,ne=ET(n)&&!D,G=A&&n.connected&&!D&&!ne,te=rT(n,a,Y),B=te>=Td?100:te/Td*100,xe=te>=Td?Td/te*100:100,se={"--screen-aspect":te.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,B)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,xe)).toFixed(3)}%`},K=u.useCallback($=>{N.current=$,x(n.deviceId,$)},[n.deviceId,x]),I=$=>{const ue=$.currentTarget.getBoundingClientRect();return Aj($.clientX,$.clientY,ue)},Q=$=>({shiftKey:$.shiftKey,ctrlKey:$.ctrlKey,altKey:$.altKey,metaKey:$.metaKey}),q=u.useCallback(()=>{R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)},[]),V=u.useCallback(()=>{const $=k.current;if(!$)return;k.current=null;const ue=Number($.input.normalizedX),he=Number($.input.normalizedY);if(!Number.isFinite(ue)||!Number.isFinite(he))return;b(n.deviceId,{...$.input,normalizedX:ue,normalizedY:he})&&(T.current=performance.now())},[n.deviceId,b]),ce=u.useCallback(()=>{R.current===null&&(R.current=window.requestAnimationFrame(()=>{R.current=null,V()}))},[V]);u.useEffect(()=>()=>{q(),k.current=null},[q]);const be=($,ue)=>{if(!l)return;const he={type:ue,monitorIndex:Y,...I($),button:yT($.button),...Q($)};if(ue==="pointermove"){const ve=performance.now();k.current={input:he},ve-T.current>=RM&&(q(),V()),ce();return}k.current&&(q(),V()),b(n.deviceId,he)},X=u.useCallback($=>{const ue=document.activeElement;ue instanceof HTMLElement&&$.contains(ue)&&ue.classList.contains("monitor-cycle-button")&&ue.blur()},[]);return s.jsx("article",{className:`device-tile ${r?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:se,children:s.jsxs("div",{className:`tile-screen ${D?"has-frame":"is-empty"}`,role:"button",tabIndex:l?-1:0,"aria-pressed":r,onClick:$=>{$.target instanceof Element&&$.target.closest(".monitor-cycle")||l||p()},onKeyDown:$=>{$.target instanceof Element&&$.target.closest(".monitor-cycle")||l||($.key==="Enter"||$.key===" ")&&($.preventDefault(),p())},onDoubleClick:$=>{$.target instanceof Element&&$.target.closest(".monitor-cycle")||($.preventDefault(),v())},onPointerLeave:$=>X($.currentTarget),children:[s.jsx("span",{className:`screen-content ${D?"has-frame":"is-empty"}`,children:s.jsx("canvas",{ref:K,className:`remote-canvas ${D?"has-frame":"is-empty"}`,tabIndex:l?0:-1,onPointerDown:$=>{l&&($.preventDefault(),$.stopPropagation(),g(),$.currentTarget.focus(),$.currentTarget.setPointerCapture($.pointerId),be($,"pointerdown"))},onPointerMove:$=>{l&&$.preventDefault(),be($,"pointermove")},onPointerLeave:$=>{l&&(be($,"pointermove"),q(),V())},onPointerUp:$=>{l&&($.preventDefault(),$.stopPropagation(),be($,"pointerup"),$.currentTarget.hasPointerCapture($.pointerId)&&$.currentTarget.releasePointerCapture($.pointerId))},onPointerCancel:$=>{$.currentTarget.hasPointerCapture($.pointerId)&&$.currentTarget.releasePointerCapture($.pointerId)},onWheel:$=>{l&&($.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:Y,...I($),deltaX:$.deltaX,deltaY:$.deltaY,...Q($)}))},onKeyDown:$=>{l&&($.preventDefault(),$.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:Y,key:$.key,code:$.code,keyCode:$.keyCode||$.which||0,location:$.location,text:$.key.length===1?$.key:"",repeat:$.repeat,...Q($)}))},onKeyUp:$=>{l&&($.preventDefault(),$.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:Y,key:$.key,code:$.code,keyCode:$.keyCode||$.which||0,location:$.location,text:$.key.length===1?$.key:"",repeat:!1,...Q($)}))},onContextMenu:$=>l&&$.preventDefault()})}),!D&&s.jsx("span",{className:"empty-screen",children:s.jsx(an,{size:26})}),G&&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"})]}),ne&&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."})]}),C&&s.jsxs("span",{className:`wall-update-status state-${C.state}`,role:"status","aria-live":"polite",title:C.error||C.label,children:[C.state==="updated"?s.jsx(Fn,{size:20,"aria-hidden":"true"}):C.state==="failed"?s.jsx(Ya,{size:22,"aria-hidden":"true"}):C.state==="offline"?s.jsx(Dl,{size:22,"aria-hidden":"true"}):s.jsx("span",{className:"wall-update-spinner","aria-hidden":"true"}),s.jsx("strong",{children:C.label}),C.error?s.jsx("small",{children:C.error}):null]}),c&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`tile-health-pill state-${U.state}`,children:U.label}),s.jsx("span",{className:"tile-metrics","aria-label":`${fs(n)} status`,children:O.map($=>s.jsxs("span",{className:`tile-metric state-${$.state}`,children:[s.jsx("b",{children:$.label}),s.jsx("em",{children:$.value}),$.ratio!==void 0&&s.jsx("i",{style:{width:`${Math.round($.ratio*100)}%`}})]},$.id))})]}),_&&s.jsxs("span",{className:"monitor-cycle","aria-label":`${fs(n)} display ${Y+1} of ${m}`,onPointerDown:$=>$.stopPropagation(),onClick:$=>$.stopPropagation(),onDoubleClick:$=>$.stopPropagation(),children:[s.jsx("button",{className:"monitor-cycle-button previous",onClick:$=>{$.preventDefault(),$.stopPropagation(),w(-1),$.currentTarget.blur()},title:"Previous display",type:"button",children:s.jsx(Jx,{size:18})}),s.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",Y+1,"/",m]}),s.jsx("button",{className:"monitor-cycle-button next",onClick:$=>{$.preventDefault(),$.stopPropagation(),w(1),$.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(Ii,{size:23,strokeWidth:3.5})})]})})}function RT({visible:n}){return u.useEffect(()=>{if(!n||!fh)return;if(!document.getElementById(Sx)){const r=document.createElement("script");r.id=Sx,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":pw,"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 DT(){const{session:n,loading:a}=sj(),{target:r,error:l,refresh:c}=rj(n),d=u.useMemo(()=>{if(!r?.active)return null;const y=r.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(y)&&y<=Date.now()?null:r},[r]),m=u.useMemo(()=>yy(d),[d]),p=u.useMemo(()=>m.length>0?[...new Set([...m,Cn])]:[Cn],[m]),[g,v]=u.useState(nT),w=u.useMemo(()=>p.some(y=>!!Ic(y)),[p]),x=!w||g,{status:b,devices:C,error:j,refresh:A,hubBaseUrl:N}=ij(p,x),{entitlement:k,licensed:T,loading:R,error:U,refresh:O}=lj(n),[Y,_]=u.useState([]),[D,ne]=u.useState(""),[G,te]=u.useState(""),[B,xe]=u.useState(""),[se,K]=u.useState(""),[I,Q]=u.useState(""),[q,V]=u.useState("idle"),[ce,be]=u.useState(!1),[X,$]=u.useState(null),[ue,he]=u.useState(""),ve=u.useRef("");ve.current=se;const[Se,_e]=u.useState(!1),[re,Z]=u.useState(!1),ze=u.useRef(""),Le=u.useRef(new Map),ae=u.useRef(0),[fe,Ae]=u.useState(""),[Te,Be]=u.useState(""),[Ve,Je]=u.useState(null);u.useEffect(()=>{fe==="auth"&&n?.access_token&&Ae("")},[fe,n?.access_token]);const[Et,je]=u.useState(""),[We,it]=u.useState(null),ot=u.useRef(null),gn=u.useRef(0),Kt=u.useCallback((y,M,L)=>{const F=String(y||"").trim();if(je(F),ot.current!==null&&(window.clearTimeout(ot.current),ot.current=null),!F){it(null);return}const z=++gn.current;if(it({id:z,message:F,tone:M}),!L)return;const pe=window.setTimeout(()=>{it(de=>de?.id===z?null:de),ot.current===pe&&(ot.current=null)},5e3);ot.current=pe},[]),Ie=u.useCallback((y,M="info")=>{Kt(y,M,!0)},[Kt]),ct=u.useCallback(y=>{Kt(y,"progress",!1)},[Kt]);u.useEffect(()=>()=>{ot.current!==null&&window.clearTimeout(ot.current)},[]);const[_t,Ft]=u.useState(()=>typeof window<"u"&&window.location.pathname.startsWith("/support")?"support":"wall");u.useEffect(()=>{const y=()=>{Ft(window.location.pathname.startsWith("/support")?"support":M=>M==="support"?"wall":M)};return window.addEventListener("popstate",y),()=>window.removeEventListener("popstate",y)},[]);const[ge,Oe]=u.useState("large"),[Fe,ke]=u.useState(TT),[st,gt]=u.useState(!1),[Re,jn]=u.useState(!1),[Ls,nt]=u.useState(!1),[zt,zn]=u.useState(tT),[He,ya]=u.useState(cT),[dt,Hi]=u.useState(dT),[Qt,ps]=u.useState(lT),[bt,qn]=u.useState(null),[_s,H]=u.useState([]),[Pe,vt]=u.useState(He.fps),[sn,Qa]=u.useState(""),[Br,Xa]=u.useState(0),[ee,Ne]=u.useState(0),[qe,rt]=u.useState(()=>new Set),Nt=u.useRef(new Map),Mt=u.useRef(new Map),Qe=u.useRef(new Map),ut=u.useRef(new Map),kn=u.useRef(new Map),Wt=u.useRef(new Set),An=u.useRef(new Map),St=u.useRef(""),rn=u.useRef(""),Pt=u.useRef(null),xa=u.useRef(null),ca=u.useRef(new Map),cn=u.useRef(null),vn=u.useRef(0),Fr=u.useRef(new Map),[zs,Pr]=u.useState({}),zo=u.useRef(new Map),[Bi,Il]=u.useState({}),[Za,Zt]=u.useState(!1),Ol=u.useRef(null),Ja=u.useRef(null),Xn=u.useRef(0),Is=u.useRef(""),Os=u.useRef(new Map),$r=u.useRef(new Map),Gn=u.useRef(performance.now()),ai=u.useRef(new Map),si=u.useRef(new Map),Hs=u.useRef(new Map),Bs=u.useRef(new Map),Fi=u.useRef(0),Ur=u.useRef(0),gs=u.useRef(0),Hl=u.useRef(0),Bl=u.useRef(0),Io=u.useRef(new Map),es=u.useRef(new Map),[ii,Fs]=u.useState(null),[Fl,_a]=u.useState(!1),[Kc,Oo]=u.useState([]),[za,Pi]=u.useState("all"),[ri,qr]=u.useState([]),[cf,Pl]=u.useState(!1),[Ps,Ho]=u.useState(!0),$i=u.useRef(null),vs=u.useRef(null),Bo=u.useRef(null),$l=u.useRef(null),Qc=u.useRef(!1),Ui=u.useRef(!1),qi=u.useRef(!1),Gi=u.useRef(0),ln=u.useRef(0),ts=_t==="settings",Gr=_t==="pricing",Vi=_t==="doc",Xc=_t==="support",li=_t==="share-files",Vr=_t==="agents",Wi=!ts&&!Gr&&!Vi&&!Xc&&!li&&!Vr,at=_t==="control",ft=He.frameMode==="mode4-h264-atlas",ba=I||dt.frameMode,Yi=ba!=="mode3-h264-hw"?Math.min(30,dt.fps):dt.fps,$s=ba!=="mode3-h264-hw"?{maxWidth:Math.min(1920,dt.maxWidth),maxHeight:Math.min(1080,dt.maxHeight)}:{maxWidth:dt.maxWidth,maxHeight:dt.maxHeight};u.useEffect(()=>{if(b?.started){if(!n?.access_token){Ge("/api/remote/license",{method:"DELETE"},N).catch(()=>{});return}Ge("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${n.access_token}`}},N).catch(y=>{console.warn("[LiveDesk] Hub license sync failed",y)})}},[k?.updated_at,N,n?.access_token,b?.started]),u.useEffect(()=>{!n?.access_token||!b?.started||b.runtimeRole!=="hub"||!b.deviceId||(async()=>{try{const{data:y,error:M}=await pt.rpc("register_livedesk_device",{p_device_id:b.deviceId,p_device_name:b.deviceName||b.deviceId,p_role:"hub",p_assigned_hub_id:null,p_platform:navigator.platform||navigator.userAgent,p_os_version:navigator.userAgent,p_app_version:b.managerVersion||b.managerPackage||""}),L=Array.isArray(y)?y[0]:y;(M||L?.ok===!1)&&console.warn("[LiveDesk] Hub device role registration failed",M||L?.reason||"unknown-error")}catch(y){console.warn("[LiveDesk] Hub device role registration failed",y)}})()},[n?.access_token,b?.deviceId,b?.deviceName,b?.managerPackage,b?.managerVersion,b?.runtimeRole,b?.started]),u.useEffect(()=>{!n?.access_token||!n.refresh_token||!b?.started||b.runtimeRole!=="hub"||qi.current||(qi.current=!0,Ge("/api/auth/session",{method:"POST",body:JSON.stringify({accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:n.expires_at,user:{id:n.user.id,email:n.user.email}})},N||Cn).then(y=>{y.hostTarget?.ok===!1&&console.warn("[LiveDesk] Hub host target publish is waiting for a valid Hub role:",y.hostTarget.error||"unknown-error"),A()}).catch(y=>{console.warn("[LiveDesk] Hub session sync failed:",y)}).finally(()=>{qi.current=!1}))},[N,A,n?.access_token,n?.expires_at,n?.refresh_token,n?.user?.email,n?.user?.id,b?.runtimeRole,b?.started]);const et=u.useMemo(()=>C.filter(y=>y.connected),[C]),Zc=za==="all"?et.length:ri.filter(y=>et.some(M=>M.deviceId===y)).length,uf=u.useMemo(()=>et.reduce((y,M)=>Math.max(y,Fx(M.slotNumber)),0),[et]),Ul=Math.max(MM,et.length,uf),Wr=u.useMemo(()=>{const y=Array(Ul).fill(null),M=[];for(const L of et){const F=Fx(L.slotNumber);F>0&&F<=Ul&&!y[F-1]?y[F-1]=L:M.push(L)}for(const L of M){const F=y.findIndex(z=>!z);F<0?y.push(L):y[F]=L}return y},[et]),Fo=u.useMemo(()=>et.map(y=>y.deviceId),[et]),oi=u.useMemo(()=>new Set(Y),[Y]),ua=u.useMemo(()=>et.filter(y=>oi.has(y.deviceId)),[et,oi]),Ki=u.useMemo(()=>C.find(y=>y.deviceId===D)||ua[0]||null,[C,D,ua]),Vn=u.useMemo(()=>C.find(y=>y.deviceId===G)||null,[G,C]),Us=Vn?Ea(Qt[Vn.deviceId],ga(Vn)):0,Ee=at?Vn:Ki,Jc=u.useMemo(()=>new Set(ri),[ri]),df=u.useMemo(()=>za==="all"?et.map(y=>y.deviceId):et.filter(y=>Jc.has(y.deviceId)).map(y=>y.deviceId),[et,Jc,za]),ff=Ee?Bc(Ee,"control"):!1,ql=zi(Ee?.platform)&&(Ee?.capabilities?.controlPermission===!1||Ee?.capabilities?.accessibilityPermission===!1),Yr=Ee?Bc(Ee,"audio")||Bc(Ee,"remoteAudio"):!1,eu=Array.isArray(Ee?.capabilities?.agentTools)?Ee.capabilities.agentTools.map(String):[],tu=eu.includes("system.power"),nu=eu.includes("command.run"),Yt=T?k?.plan==="pro"?"pro":"ltd":"free",au=Cl[Yt],Gl=au.limit,Qi=u.useMemo(()=>{if(!Number.isFinite(Gl))return new Set(et.map(M=>M.deviceId));const y=Ee?[Ee,...et.filter(M=>M.deviceId!==Ee.deviceId)]:et;return new Set(y.slice(0,Gl).map(M=>M.deviceId))},[Gl,et,Ee]),mf=!Ee||Qi.has(Ee.deviceId),Po=Yt==="free",It=mf,Kr=Yt==="ltd"?`Plus includes up to ${Rc} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${Ec} workstations. Upgrade to Plus for ${Rc} devices and no ads.`,su=Yt==="free",ns=It&&!!Ee&&ff,$o=It&&!!Ee&&Yr,Qr=u.useMemo(()=>Wr.filter(y=>!!y?.connected).slice(0,mT(ge)).map(y=>y.deviceId),[Wr,ge]),Xr=u.useMemo(()=>ft?Fo:He.visibleOnlyLive?_s.length>0?_s:Qr:Fo,[Qr,ft,_s,He.visibleOnlyLive,Fo]),In=u.useMemo(()=>yh(Xr.filter(y=>Qi.has(y))),[Qi,Xr]),qs=u.useMemo(()=>In.filter(y=>y!==sn),[In,sn]),Vl=u.useMemo(()=>new Map(et.map(y=>[y.deviceId,y.platform])),[et]),as=Nj(ft,In.length),da=u.useMemo(()=>ft?qs.filter(y=>Nc({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(Vl.get(y))})==="atlas"):[],[as,ft,Vl,qs]),Zn=u.useMemo(()=>qs.filter(y=>Nc({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(Vl.get(y))})==="direct"),[as,ft,Vl,qs]);u.useEffect(()=>{const y=new Set(In);rt(M=>{let L=!1;const F=new Set;for(const z of M)y.has(z)?F.add(z):L=!0;return L?F:M})},[In]);const Zr=u.useMemo(()=>{const y=z=>et.find(pe=>pe.deviceId===z)||null,M=z=>Ea(Qt[z],y(z)?ga(y(z)):0),L=(z,pe=M(z))=>z===B&&(q==="connecting"||q==="active"||q==="warm")?ut.current.get(z)||Mt.current.get(z)||null:ft?ca.current.get(z)||Nt.current.get(z)||null:Nt.current.get(z)||null,F=(z,pe=M(z))=>{const de=y(z);return`${de?fs(de):z} · Monitor ${pe+1}`};return{resolveCurrentTarget(){if(at&&Vn){const $e=Us;return{type:"control",deviceIds:[Vn.deviceId],monitorIndex:$e,label:`${fs(Vn)} · Monitor ${$e+1}`,sourceCanvas:L(Vn.deviceId,$e),signature:`control:${Vn.deviceId}:${$e}:${dt.frameMode}`}}const z=ua.map($e=>$e.deviceId).filter($e=>qs.includes($e)),pe=Ki&&qs.includes(Ki.deviceId)?Ki.deviceId:"",de=z.length>0?z:pe?[pe]:qs,De=z.length===0&&!pe;if(de.length===0)return null;if(de.length===1){const $e=de[0],Xe=M($e);return{type:De?"wall":z.length>1?"selection":"device",deviceIds:de,monitorIndex:Xe,label:De?"Wall":F($e,Xe),sourceCanvas:De?null:L($e,Xe),signature:`${De?"wall":"device"}:${$e}:${Xe}:${ft?"atlas":"direct"}`}}return{type:z.length>1?"selection":"wall",deviceIds:de,label:z.length>1?`${de.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${z.length>1?"selection":"wall"}:${de.join(",")}:${ge}`}},getDeviceCanvas:L,composeWall(z,pe={}){return gM(z.map(de=>{const De=M(de);return{deviceId:de,label:F(de,De),canvas:L(de,De)}}),pe)}}},[et,Vn,B,q,dt.frameMode,Nt,ft,Qt,Us,ua,at,qs,Ki,ge]),Xi=NM({hubUrl:N,sourceRegistry:Zr,onToast:Ie}),Zi=u.useMemo(()=>It&&B&&Qi.has(B)&&(q==="connecting"||q==="active"||q==="warm")?[B]:[],[B,q,It,Qi]),Wl=u.useMemo(()=>yh([...In,...Zi]),[Zi,In]),On=u.useMemo(()=>hT(He,ge),[He,ge]),ci=Mj({mode4Enabled:ft,directMode4WallEnabled:as,adaptiveFps:Pe,directDeviceCount:Zn.length}),Ia=u.useCallback((y,M,L)=>{if(y.width<=0||y.height<=0)return!1;const F=L?Math.min(1,L.maxWidth/y.width,L.maxHeight/y.height):1,z=Math.max(1,Math.round(y.width*F)),pe=Math.max(1,Math.round(y.height*F));(M.width!==z||M.height!==pe)&&(M.width=z,M.height=pe);const de=M.getContext("2d",{alpha:!1});return de?(de.imageSmoothingEnabled=!0,de.imageSmoothingQuality="high",de.drawImage(y,0,0,y.width,y.height,0,0,M.width,M.height),!0):!1},[]),Gs=u.useCallback(y=>{y&&rt(M=>{if(M.has(y))return M;const L=new Set(M);return L.add(y),L})},[]),Jr=u.useCallback(y=>{y&&rt(M=>{if(!M.has(y))return M;const L=new Set(M);return L.delete(y),L})},[]),el=u.useCallback((y,M)=>{if(!M||M.width<=0||M.height<=0)return!1;const L=document.createElement("canvas");return L.width=M.width,L.height=M.height,Ia(M,L)?(Qe.current.set(y,L),Gs(y),!0):!1},[Gs,Ia]),ss=u.useCallback((y,M=!1)=>{if(!Wt.current.has(y))return!1;const L=performance.now(),F=An.current.get(y)||0,z=Math.max(1,Math.min(ei.controlWallReuseMaxFps,Yi)),pe=Yi>z?Math.max(0,1e3/z-2):0;if(!M&&L-F<pe)return!1;const de=ut.current.get(y)||Mt.current.get(y),De=Nt.current.get(y)||ca.current.get(y);return!de||!De||!Ia(de,De,On)?!1:(An.current.set(y,L),Gs(y),!0)},[Yi,On,Gs,Ia]);u.useEffect(()=>{St.current=sn},[sn]);const iu=u.useCallback((y,M)=>{const L=Nt.current.get(y);if(L&&L!==M&&(el(y,L),Ac(L)),M){Nt.current.set(y,M),Qe.current.delete(y),ss(y,!0);return}Nt.current.delete(y),Qe.current.has(y)||Jr(y)},[Jr,ss,el]),hf=u.useCallback((y,M)=>{const L=Mt.current.get(y);if(L&&L!==M&&Ac(L),M){Mt.current.set(y,M);const F=ut.current.get(y)||Qe.current.get(y)||Nt.current.get(y)||ca.current.get(y);F&&Ia(F,M)&&y===G&&Zt(!0);return}Mt.current.delete(y)},[G,Ia]),Yl=u.useCallback((y,M,L)=>{const F=performance.now(),z=Ms(y,L.deviceId);let pe=L;if(y==="control"&&L.visualChanged){const De=mj(L.deviceId),$e=Io.current.get(L.deviceId)||0,Xe=De?F-De.sentAt:Number.POSITIVE_INFINITY;De&&De.inputSeq>$e&&Xe<=Cx&&(pe={...L,inputFeedbackSeq:De.inputSeq,inputFeedbackMs:Math.max(0,Xe),inputFeedbackAt:F},Io.current.set(L.deviceId,De.inputSeq))}$r.current.set(z,F);const de=Fr.current.get(z)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:F,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};y==="control"&&pe.inputFeedbackMs===void 0&&de.lastInfo?.inputFeedbackMs!==void 0&&de.lastInfo.inputFeedbackAt!==void 0&&F-de.lastInfo.inputFeedbackAt<=Cx&&(pe={...pe,inputFeedbackSeq:de.lastInfo.inputFeedbackSeq,inputFeedbackMs:de.lastInfo.inputFeedbackMs,inputFeedbackAt:de.lastInfo.inputFeedbackAt}),de.totalFrames+=1,de.sampleFrames+=1,Tx(de,F,pe.frameSeq),pe.visualChanged&&(de.totalChangedFrames+=1,de.sampleChangedFrames+=1),de.lastInfo=pe,Fr.current.set(z,de)},[]),Kl=u.useCallback((y,M)=>{Yl("wall",y,M),y.kind==="live"&&Gs(y.deviceId);const L=ce&&B===y.deviceId;St.current!==y.deviceId&&!L&&(Wt.current.delete(y.deviceId),An.current.delete(y.deviceId))},[B,ce,Gs,Yl]),ru=u.useCallback((y,M)=>{Yl("control",y,M),he(pe=>pe&&"");const L=ut.current.get(y.deviceId),F=Mt.current.get(y.deviceId);L&&L.width>0&&L.height>0&&(F&&Ia(L,F),kn.current.set(y.deviceId,{...y,payload:new Uint8Array(0),byteLength:0}),Qe.current.delete(y.deviceId),Wt.current.add(y.deviceId),y.deviceId===B&&(be(!0),V(pe=>pe==="connecting"?"active":pe)),ss(y.deviceId));const z=Ol.current;!z||!PM(z,y)||Zt(!0)},[B,Ia,ss,Yl]);u.useEffect(()=>{const y=window.setInterval(()=>{const M=performance.now(),L={};for(const[F,z]of Fr.current.entries()){const pe=Math.max(1,M-z.sampleStartedAt);L[F]={totalFrames:z.totalFrames,totalChangedFrames:z.totalChangedFrames,framesPerSecond:z.sampleFrames*1e3/pe,changedFramesPerSecond:z.sampleChangedFrames*1e3/pe,averageIntervalMs:z.intervalCount>0?z.intervalSumMs/z.intervalCount:0,minIntervalMs:Number.isFinite(z.minIntervalMs)?z.minIntervalMs:0,maxIntervalMs:z.maxIntervalMs,p95IntervalMs:hh(z.intervalSamplesMs,.95),intervalCount:z.intervalCount,seqGapCount:z.seqGapCount,maxSeqGap:z.maxSeqGap,decoderInputFps:Math.max(0,(Number(z.lastInfo?.decoderInputCount||0)-z.sampleDecoderInputBase)*1e3/pe),decoderOutputFps:Math.max(0,(Number(z.lastInfo?.decoderOutputCount||0)-z.sampleDecoderOutputBase)*1e3/pe),sampleMs:pe,lastInfo:z.lastInfo},z.sampleDecoderInputBase=Number(z.lastInfo?.decoderInputCount||0),z.sampleDecoderOutputBase=Number(z.lastInfo?.decoderOutputCount||0),z.sampleChangedFrames=0,Mx(z,M)}Pr(L)},1e3);return()=>window.clearInterval(y)},[]);const Nn=u.useCallback((y,M)=>{const L=performance.now(),F=Ms(y,M.deviceId);Os.current.set(F,L),es.current.delete(F),y==="control"&&si.current.delete(F);const z=zo.current.get(F)||{totalFrames:0,sampleFrames:0,sampleStartedAt:L,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(M.byteLength||0)),String(M.frameMode||M.mode||M.codec||M.mimeType||"").toLowerCase().includes("h264")){z.sampleH264Frames+=1,Number(M.byteLength||0)<=OM&&(z.sampleTinyFrames+=1);const $e=String(M.contentHash||"");$e&&z.lastContentHash===$e&&(z.sampleRepeatedFrames+=1),z.lastContentHash=$e}const De=Number(M.agentSendGapMs||0);De>0&&De<1e3&&vw(z.sourceSendIntervalsMs,De),z.lastFrame=M,Tx(z,L,M.frameSeq),zo.current.set(F,z)},[]);u.useEffect(()=>{const y=window.setInterval(()=>{const M=performance.now(),L={};for(const[F,z]of zo.current.entries()){const pe=Math.max(1,M-z.sampleStartedAt);L[F]={totalFrames:z.totalFrames,framesPerSecond:z.sampleFrames*1e3/pe,averageIntervalMs:z.intervalCount>0?z.intervalSumMs/z.intervalCount:0,minIntervalMs:Number.isFinite(z.minIntervalMs)?z.minIntervalMs:0,maxIntervalMs:z.maxIntervalMs,p95IntervalMs:hh(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((de,De)=>de+De,0)/z.sourceSendIntervalsMs.length:0,sourceSendP95Ms:hh(z.sourceSendIntervalsMs,.95),sourceSendSampleCount:z.sourceSendIntervalsMs.length,sampleMs:pe,lastFrame:z.lastFrame},z.sampleBytes=0,z.sampleH264Frames=0,z.sampleTinyFrames=0,z.sampleRepeatedFrames=0,z.sourceSendIntervalsMs.length=0,Mx(z,M)}Il(L)},1e3);return()=>window.clearInterval(y)},[]);const Ji=u.useCallback(y=>{Nn("wall",y);const M=Nt.current.get(y.deviceId);if(!M)return;const L=Tj(ft,He.h264DecodeAcceleration);Jm(M,y,()=>Nt.current.get(y.deviceId)!==M,Kl,L.acceleration,L.latencyMode).catch(()=>{})},[Kl,ft,Nn,He.h264DecodeAcceleration]),Uo=u.useCallback(y=>{Nn("control",y);let M=ut.current.get(y.deviceId);M||(M=document.createElement("canvas"),M.setAttribute("aria-hidden","true"),ut.current.set(y.deviceId,M));const L=M,F=ve.current;Jm(L,y,()=>ut.current.get(y.deviceId)!==L,ru,dt.h264DecodeAcceleration,"interactive").catch(z=>{ve.current!==F||ut.current.get(y.deviceId)!==L||B!==y.deviceId||he(z instanceof Error?z.message:String(z||"Control H.264 decode failed"))})},[B,dt.h264DecodeAcceleration,ru,Nn]),lu=u.useCallback(y=>{const M=xa.current;M&&M!==y&&Ac(M),xa.current=y,Fi.current=0,Ur.current=0,gs.current=0,Hl.current=0,Bl.current=0,vn.current=0},[]),ui=u.useCallback(()=>{const y=xa.current,M=cn.current;if(!(!y||!M||y.width<=0||y.height<=0||vn.current!==M.layoutVersion))for(const L of M.tiles){const F=ca.current.get(L.deviceId);if(!F||L.width<=0||L.height<=0)continue;const z=Math.max(1,Math.round(L.width)),pe=Math.max(1,Math.round(L.height)),de=HM,De=BM;(F.width!==de||F.height!==De)&&(F.width=de,F.height=De);const $e=F.getContext("2d",{alpha:!1});if($e){$e.imageSmoothingEnabled=!0,$e.imageSmoothingQuality="high";try{$e.drawImage(y,Math.round(L.x),Math.round(L.y),z,pe,0,0,de,De)}catch{}}}},[]),ou=u.useCallback((y,M)=>{if(M){ca.current.set(y,M),Qe.current.delete(y),window.requestAnimationFrame(ui),window.requestAnimationFrame(()=>ss(y,!0));return}const L=ca.current.get(y);el(y,L),ca.current.delete(y),Qe.current.has(y)||Jr(y)},[Jr,ui,ss,el]),Ql=u.useCallback((y,M)=>{gs.current=performance.now(),vn.current=Number(y.layoutVersion||0),ui();const L=cn.current?.tiles||[],F=L.length>0?Math.round(y.byteLength/L.length):y.byteLength;for(const z of L){const pe={...y,deviceId:z.deviceId,width:z.width,height:z.height,sourceWidth:z.width,sourceHeight:z.height,byteLength:F};Kl(pe,{...M,deviceId:z.deviceId,width:z.width,height:z.height,byteLength:F}),St.current===z.deviceId&&ss(z.deviceId,!0)}},[Kl,ui,ss]),pf=u.useCallback(y=>{const M=performance.now();Fi.current<=0&&(Fi.current=M),Ur.current=M;const L=xa.current;if(!L)return;const F=cn.current?.tiles||[],z=F.length>0?Math.round(y.byteLength/F.length):y.byteLength;for(const pe of F)Nn("wall",{...y,deviceId:pe.deviceId,width:pe.width,height:pe.height,sourceWidth:pe.width,sourceHeight:pe.height,byteLength:z});Jm(L,y,()=>xa.current!==L,Ql).catch(()=>{})},[Ql,Nn]),er=u.useMemo(()=>({fps:ci,maxWidth:On.maxWidth,maxHeight:On.maxHeight,quality:He.quality,mode:ft?"mode3-h264-hw":He.frameMode,frameMode:ft?"mode3-h264-hw":He.frameMode,streamPurpose:"wall",monitorSelections:Qt,onFrame:Ji}),[ci,Ji,On,ft,Qt,He]),Xl=u.useCallback(y=>{if(y.deviceId!==B||y.streamPurpose!=="control"||y.monitorIndex!==Us)return;const M=et.find(L=>L.deviceId===y.deviceId);!M?.sessionId||M.sessionId!==y.sessionId||($(y),V(L=>L==="connecting"?"active":L))},[et,B,Us]);u.useEffect(()=>{$(null)},[B,se,ba,Us]);const tl=u.useMemo(()=>({fps:Yi,maxWidth:$s.maxWidth,maxHeight:$s.maxHeight,quality:dt.quality,mode:ba,frameMode:ba,streamPurpose:"control",forceRestart:se!=="",forceRestartToken:se,restartReason:se?"control-session-start":"",monitorSelections:Qt,onFrame:Uo,onStreamReady:Xl}),[se,dt.quality,Uo,Yi,ba,$s.maxHeight,$s.maxWidth,Xl,Qt]),{frames:Zl,state:tr,error:Vs,stats:fa,restartLive:nr}=Ry(Zn,He.autoStartLive&&Zn.length>0,N,er),{frame:di,layout:ma,state:Jl,stats:cu,refreshInputs:qo}=hj(da,ft&&He.autoStartLive&&da.length>0,N,{fps:ei.atlasOutputFps,width:1920,height:1080,tileWidth:On.maxWidth,tileHeight:On.maxHeight,captureDeviceIds:da,monitorSelections:Qt,onFrame:pf});u.useEffect(()=>{cn.current=ma,ma&&window.requestAnimationFrame(ui)},[ma,ui]),u.useEffect(()=>{if(!ft||Jl!=="open"){Fi.current=0,Ur.current=0,gs.current=0;return}const y=window.setInterval(()=>{const M=xa.current,L=performance.now();if(!M||document.visibilityState!=="visible"||L-Gn.current<mh)return;const F=Ur.current,z=Fi.current;if(F<=0||z<=0||L-F>500)return;const pe=gs.current||z,de=L-pe;if(de>=LM&&L-Bl.current>=zM){Xm(M)&&(Bl.current=L,Hl.current=L);return}de>=DM&&L-Hl.current>=_M&&XC(M)&&(Hl.current=L)},250);return()=>window.clearInterval(y)},[Jl,ft]);const{frames:Go,state:Vo,error:nl,stats:uu,restartLive:al,reconnectLive:eo}=Ry(Zi,Zi.length>0,N,tl),Jn=u.useMemo(()=>{const y=new Map(Zl);if(ft&&di&&da.length>0){const M=new Map((ma?.tiles||[]).map(F=>[F.deviceId,F])),L=Math.max(1,M.size);for(const F of da){const z=M.get(F);z&&y.set(F,{...di,deviceId:F,width:z.width,height:z.height,sourceWidth:z.width,sourceHeight:z.height,byteLength:Math.round(di.byteLength/L)})}}for(const[M,L]of Go.entries())y.set(M,L);for(const M of Xr){if(!Wt.current.has(M)||y.has(M))continue;const L=kn.current.get(M);L&&y.set(M,L)}return y},[di,ma,Go,da,ft,Zl,Xr,ee]),ar=at&&Zi.length>0?Vo:da.length>0?Jl:tr,ea=at&&Zi.length>0?uu:da.length>0?cu:fa;u.useCallback((y,M="browser-stale")=>{const L=nr(y,M),F=al(y,M);return L||F},[al,nr]),u.useEffect(()=>{ft&&da.length>0&&!at&&qo()},[da.length,ft,qo,at]);const ys=u.useCallback((y,M,L)=>{const F=M==="control"?ut.current.get(y)||null:Nt.current.get(y)||null;if(!F||!Xm(F))return!1;const z=performance.now();return Bs.current.set(Ms(M,y),z),!0},[]),sr=u.useCallback(y=>{if(ba!=="mode3-h264-hw"||!B||I)return!1;const M=et.find(De=>De.deviceId===B)||Vn,L=String(M?.platform||"").toLowerCase();if(!["win32","windows","win32nt"].includes(L))return!1;const F="mode5-lzo-delta",z=Ms("control",B),pe=performance.now();Hs.current.set(z,pe),Os.current.delete(z),$r.current.delete(z),ai.current.delete(z),si.current.delete(z),es.current.delete(z),Xm(ut.current.get(B)||null),eo([B],"control-decode-fallback"),Q(F),K(`control-${F}-fallback-${B}-${Date.now()}`),be(!1),Zt(!1);const de=y==="no first frame"||y==="control-first-frame-timeout";return he(De=>De||(de?`Control frame transport timeout; retrying Control with Mode 5 (${y})`:`H.264 decode failed; retrying Control with Mode 5 (${y})`)),V("connecting"),!0},[et,Vn,B,I,ba,eo]);u.useEffect(()=>{const y=at?Vn:null;if(y){Ol.current={deviceId:y.deviceId,monitorIndex:Us,frameMode:ba,startedAtEpochMs:Date.now()},Zt(B===y.deviceId&&ce||qe.has(y.deviceId));return}Ol.current=null,Zt(!1)},[Vn?.sessionId,G,B,ce,ba,Us,at,qe]);const Ws=u.useCallback(async y=>{const M=C.find(de=>de.deviceId===y),L=Nc({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(M?.platform)})==="atlas",F=Ea(Qt[y],M?ga(M):1),z=L?{fps:ei.scalableAtlasInputFps,maxWidth:On.maxWidth,maxHeight:On.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:F}:{fps:ft&&!L?ci:Pe,maxWidth:On.maxWidth,maxHeight:On.maxHeight,quality:He.quality,mode:ft?"mode3-h264-hw":He.frameMode,frameMode:ft?"mode3-h264-hw":He.frameMode,streamPurpose:"wall",monitorIndex:F},pe=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/live/start`,{method:"POST",body:JSON.stringify(z)},N);if(pe?.ok===!1)throw new Error(pe.error||"wall-stream-start-failed");return pe},[Pe,C,as,ci,On.maxHeight,On.maxWidth,N,ft,Qt,He.frameMode,He.quality]),fi=u.useCallback(async y=>{const M=C.find(z=>z.deviceId===y),L=Nc({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(M?.platform)})==="atlas",F=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:L?"atlas":"wall",reason:"control-active"})},N);if(F?.ok===!1)throw new Error(F.error||"wall-stream-stop-failed");return F},[C,as,N,ft]),Ys=u.useCallback(async(y,M="control-session-stop")=>{const L=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:M})},N);if(L?.ok===!1)throw new Error(L.error||"control-stream-stop-failed");return L},[N]),wa=u.useCallback(y=>{const M=ut.current.get(y);M&&(Ac(M),ut.current.delete(y));const L=Mt.current.get(y);L&&Ac(L),kn.current.delete(y),Wt.current.delete(y),An.current.delete(y)},[]);u.useEffect(()=>{const y=G&&et.find(z=>z.deviceId===G)||null;if(!at||!It||!y){Is.current&&(++Xn.current,Is.current="");return}if(B===y.deviceId&&(q==="active"||q==="warm"||q==="connecting")){V(z=>z==="warm"?"active":z);return}if(Is.current===y.deviceId)return;const M=++Xn.current,L=B;Is.current=y.deviceId,(async()=>{if(L){if(V("stopping"),await Ys(L,"control-session-switch").catch(()=>{}),M!==Xn.current)return;const de=St.current;if(de&&de!==y.deviceId)try{await Ws(de)}catch(De){Ie(De instanceof Error?De.message:String(De))}finally{St.current===de&&(St.current="",Qa(""))}if(M!==Xn.current)return;wa(L)}if(M!==Xn.current)return;if($x(y)){try{await fi(y.deviceId)}catch(de){M===Xn.current&&(Is.current="",V("error"),Ie(de instanceof Error?de.message:String(de)));return}if(M!==Xn.current){await Ws(y.deviceId).catch(()=>{});return}St.current=y.deviceId,Qa(y.deviceId),Wt.current.add(y.deviceId)}const z=Ms("control",y.deviceId),pe=`control-session-${M}-${y.deviceId}`;Hs.current.set(z,performance.now()),Os.current.delete(z),$r.current.delete(z),es.current.delete(z),si.current.delete(z),Q(""),he(""),K(pe),xe(y.deviceId),be(!1),V("connecting"),Xn.current===M&&Is.current===y.deviceId&&(Is.current="")})()},[et,G,B,q,It,wa,Ie,at,Ws,Ys,fi]),u.useEffect(()=>{if(!B||et.some(L=>L.deviceId===B))return;const y=B,M=++Xn.current;V("stopping"),Ys(y,"control-device-disconnected").catch(()=>{}).finally(()=>{M===Xn.current&&(wa(y),be(!1),K(""),Q(""),he(""),xe(L=>L===y?"":L),V("idle"))})},[et,B,wa,Ys]);const Wo=$x(et.find(y=>y.deviceId===B));u.useEffect(()=>{if(Ja.current!==null&&(window.clearTimeout(Ja.current),Ja.current=null),!B||q==="idle"||q==="stopping"||q==="error"||at||_t==="wall"){B&&!at&&_t==="wall"&&V(L=>L==="warm"||L==="active"?"active":L);return}V(L=>L==="idle"||L==="stopping"?L:"warm");const y=B,M=++Xn.current;return Ja.current=window.setTimeout(()=>{Ja.current=null,V("stopping"),Ys(y,"control-session-warm-timeout").catch(()=>{}).finally(()=>{M===Xn.current&&(wa(y),be(!1),K(""),Q(""),he(""),xe(L=>L===y?"":L),V("idle"))})},IM),()=>{Ja.current!==null&&(window.clearTimeout(Ja.current),Ja.current=null)}},[_t,B,q,wa,at,Ys]),u.useEffect(()=>()=>{Ja.current!==null&&window.clearTimeout(Ja.current)},[]),u.useEffect(()=>{const M=B&&(Wo&&(q==="connecting"||q==="active"||q==="warm"||q==="stopping")||ce&&(q==="active"||q==="warm"))?B:"";if(rn.current=M,Pt.current)return;const L=async()=>{for(;;){const z=rn.current,pe=St.current;if(pe===z)return;if(pe){try{await Ws(pe)}catch(de){Ie(de instanceof Error?de.message:String(de))}finally{St.current===pe&&(St.current="",Qa(""))}continue}if(!z)return;try{await fi(z)}catch(de){rn.current=St.current,Ie(de instanceof Error?de.message:String(de));return}St.current=z,Qa(z),Wt.current.add(z)}};let F;F=L().finally(()=>{Pt.current===F&&(Pt.current=null),St.current!==rn.current&&Xa(z=>z+1)}),Pt.current=F},[B,ce,q,Wo,ft,Ie,Ws,fi,Br]);const is=B&&et.find(y=>y.deviceId===B)||null,xs=!!(at&&Se&&q==="active"&&is?.sessionId&&X?.deviceId===is.deviceId&&X.sessionId===is.sessionId&&X.streamPurpose==="control"&&X.commandId&&X.captureGeneration>0&&X.monitorIndex===Us),{state:Yo,sendInput:ta,stats:Sa,error:rs}=pj(ns&&xs,N),ir=u.useCallback((y,M)=>!xs||!is||!X||y!==is.deviceId?!1:ta(y,{...M,controlSessionId:is.sessionId,controlCommandId:X.commandId,captureGeneration:X.captureGeneration}),[xs,is,X,ta]),Ks=xs&&Yo==="open",{state:mi,lastFrame:to,stats:Hn,error:no}=jj(Ee?.deviceId||"",$o&&re,N),sl=u.useRef(new Map);u.useEffect(()=>{const y=[["hub",j],["registry",l],["license",U],["wall-stream",Vs],["control-stream",nl],["control-decode",ue],["remote-input",rs],["remote-audio",no]];for(const[M,L]of y){const F=String(L||"").trim();if(M==="hub"&&bt?.requiresHubRestart&&bt.stage==="updating"){sl.current.delete(M);continue}if(!F){sl.current.delete(M);continue}sl.current.get(M)!==F&&(sl.current.set(M,F),Ie(F))}},[no,ue,nl,j,rs,U,l,Ie,Vs,bt]),u.useEffect(()=>{if(!at||!Se||!ns||!Ks||!Ee)return;const y=(F,z)=>{const pe=F.target,de=pe?.tagName?.toLowerCase();pe?.isContentEditable||de==="input"||de==="textarea"||de==="select"||(F.preventDefault(),F.stopPropagation(),ir(Ee.deviceId,{type:z,monitorIndex:Ea(Qt[Ee.deviceId],ga(Ee)),key:F.key,code:F.code,keyCode:F.keyCode||F.which||0,location:F.location,text:F.key.length===1?F.key:"",repeat:z==="keydown"?F.repeat:!1,shiftKey:F.shiftKey,ctrlKey:F.ctrlKey,altKey:F.altKey,metaKey:F.metaKey}))},M=F=>y(F,"keydown"),L=F=>y(F,"keyup");return window.addEventListener("keydown",M),window.addEventListener("keyup",L),()=>{window.removeEventListener("keydown",M),window.removeEventListener("keyup",L)}},[ns,Ks,Se,Qt,Ee,ir,at]),u.useEffect(()=>{const y=()=>{document.visibilityState==="visible"&&(Gn.current=performance.now())};return document.addEventListener("visibilitychange",y),window.addEventListener("pageshow",y),()=>{document.removeEventListener("visibilitychange",y),window.removeEventListener("pageshow",y)}},[]),u.useEffect(()=>{if(!B||q!=="connecting"&&q!=="active"&&q!=="warm"||Vo!=="open")return;const y=B,M=Ms("control",y),L=window.setInterval(()=>{const F=performance.now();if(document.visibilityState!=="visible"||F-Gn.current<mh)return;const z=Os.current.get(M)||0,pe=$r.current.get(M)||0,de=ai.current.get(M)||0,De=Hs.current.get(M)||F;Hs.current.has(M)||Hs.current.set(M,De);const $e=z<=0,Xe=$e?F-De>GM:F-z>_x,tn=z>0&&(pe<=0||F-pe>_x);if(!Xe&&tn){const pl=Bs.current.get(M)||0;F-pl>=zx&&ys(y,"control","decoder-paint-stale");return}if(!Xe)return;const dn=si.current.get(M)||0;if(dn>0){if(F-dn<WM)return;si.current.delete(M)}const Wn=es.current.get(M)||0;if(Wn>=YM){if(sr($e?"no first frame":"stale stream"))return;be(!1),Zt(!1),V("error");return}if(F-de<Ix(VM,Wn))return;al([y],$e?"control-first-frame-timeout":"control-receive-stale")&&(ai.current.set(M,F),si.current.set(M,F),Hs.current.set(M,F),es.current.set(M,Wn+1))},650);return()=>window.clearInterval(L)},[Vo,B,q,sr,ys,al]),u.useEffect(()=>{!ue||ba!=="mode3-h264-hw"||sr(ue)||(be(!1),Zt(!1),V("error"))},[ue,ba,sr]),u.useEffect(()=>{!at||!B||!nl||V(y=>y==="error"?y:"error")},[nl,B,at]),u.useEffect(()=>{if(tr!=="open"||!He.autoStartLive||Zn.length===0)return;const y=window.setInterval(()=>{const M=performance.now();if(document.visibilityState!=="visible"||M-Gn.current<mh)return;const L=1e3/Math.max(1,ci||He.fps||1),F=Math.max(KM,Math.ceil(L*4)),z=[];for(const pe of Zn){if(z.length>=ZM)break;const de=Ms("wall",pe),De=Os.current.get(de)||0;if(De<=0)continue;const $e=ai.current.get(de)||0,Xe=$r.current.get(de)||0,tn=M-De>F,dn=Xe<=0||M-Xe>F;if(!tn&&dn){const hl=Bs.current.get(de)||0;M-hl>=zx&&ys(pe,"wall","decoder-paint-stale");continue}if(!tn)continue;const Wn=es.current.get(de)||0;M-$e>=Ix(QM,Wn)&&z.push(pe)}if(z.length>0&&nr(z,"wall-frame-stale"))for(const pe of z){const de=Ms("wall",pe);ai.current.set(de,M),es.current.set(de,(es.current.get(de)||0)+1)}},XM);return()=>window.clearInterval(y)},[ci,Zn,ys,nr,He.autoStartLive,He.fps,tr]),u.useEffect(()=>{vt(He.fps),Gi.current=Date.now(),ln.current=0},[He.fps,He.frameMode,He.adaptiveLoadShedding]),u.useEffect(()=>{UC({h264DecodeAcceleration:He.h264DecodeAcceleration})},[He.h264DecodeAcceleration]),u.useEffect(()=>{if(!It||at||!He.visibleOnlyLive){H([]);return}const y=$i.current;if(!y||typeof IntersectionObserver>"u"){H(Qr);return}const M=Array.from(y.querySelectorAll("[data-live-device-id]"));if(M.length===0){H([]);return}const L=new Map,F=()=>{const pe=yh(M.map(de=>String(de.dataset.liveDeviceId||"")).filter(de=>(L.get(de)||0)>0));H(de=>vh(de,pe)?de:pe)},z=new IntersectionObserver(pe=>{for(const de of pe){const De=String(de.target.dataset.liveDeviceId||"");De&&L.set(De,de.isIntersecting?de.intersectionRatio||.01:0)}F()},{root:null,rootMargin:oa.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return M.forEach(pe=>z.observe(pe)),F(),()=>z.disconnect()},[Qr,It,at,Wr,He.visibleOnlyLive,ge]),u.useEffect(()=>{if(!He.adaptiveLoadShedding||!He.autoStartLive||Zn.length===0)return;const y=He.fps;if(Zn.length<=oa.preserveConfiguredFpsDeviceCount){Pe!==y&&(vt(y),Gi.current=Date.now(),ln.current=0);return}if(tr!=="open"||fa.sampleMs<500)return;const M=Date.now(),L=Zn.length*Pe,F=fa.framesPerSecond,z=fa.bytesPerSecond,pe=Math.max(0,...Zn.map(tn=>Bi[Ms("wall",tn)]?.maxIntervalMs||0)),de=Math.max(0,...Zn.map(tn=>zs[Ms("wall",tn)]?.maxIntervalMs||0)),De=L>8&&F>0&&F<L*.72;if(F>oa.maxWallFramesPerSecond||z>oa.maxWallBytesPerSecond||pe>oa.maxFrameGapMs||de>oa.maxFrameGapMs||De){ln.current=0;const tn=oa.minFps;if(M-Gi.current>=oa.downshiftCooldownMs&&Pe>tn){const dn=Math.max(tn,pT(Pe,tn));dn<Pe&&(vt(dn),Gi.current=M)}return}const Xe=F<oa.maxWallFramesPerSecond*oa.lowLoadFrameRatio&&z<oa.maxWallBytesPerSecond*oa.lowLoadByteRatio;if(!Xe||Pe>=y){Xe||(ln.current=0);return}if(!ln.current){ln.current=M;return}if(M-ln.current>=oa.recoveryCooldownMs){const tn=Math.min(y,gT(Pe,y));tn>Pe&&(vt(tn),Gi.current=M,ln.current=0)}},[Pe,Zn.length,Zn,zs,Bi,tr,fa.bytesPerSecond,fa.framesPerSecond,fa.lastUpdatedAt,fa.sampleMs,He.adaptiveLoadShedding,He.autoStartLive,He.frameMode,He.fps]),u.useEffect(()=>{const y=new URLSearchParams(window.location.search).get("checkout");if(y==="success"){Ie("Checkout returned. Waiting for Dodo confirmation."),O();const M=window.setInterval(()=>{O()},4e3),L=window.setTimeout(()=>{window.clearInterval(M)},45e3);return()=>{window.clearInterval(M),window.clearTimeout(L)}}y==="cancelled"&&Ie("Checkout cancelled.")},[O]),u.useEffect(()=>{!It&&Se&&_e(!1),!It&&re&&Z(!1)},[re,Se,It]),u.useEffect(()=>{const y=Ee?.deviceId||"",M=ze.current;if(ze.current=y,!M||M===y)return;const L=++ae.current,F=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";y&&re&&Le.current.set(y,F);let z=!0;return(async()=>{try{const de=Le.current.get(M);if(Le.current.delete(M),await Ge(`/api/remote/devices/${encodeURIComponent(M)}/audio/stop`,{method:"POST",body:JSON.stringify(de?{streamId:de}:{})},N),!z||L!==ae.current||!re||!y||!It||!Yr)return;const De=await Ge(`/api/remote/devices/${encodeURIComponent(y)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:F,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},N);if(De.ok===!1)throw new Error(De.error||"Remote audio start failed.")}catch(de){z&&(Le.current.delete(y),Z(!1),Ie(de instanceof Error?de.message:String(de)))}})(),()=>{z=!1}},[re,It,N,Yr,Ee?.deviceId]),u.useEffect(()=>{const y=et.map(F=>F.deviceId),M=new Set(y),L=new Map(et.map(F=>[F.deviceId,F]));_(F=>{const z=F.filter(pe=>M.has(pe));return vh(F,z)?F:z}),ne(F=>F&&M.has(F)?F:""),te(F=>F&&M.has(F)?F:""),ps(F=>{let z=!1;const pe={};for(const[de,De]of Object.entries(F)){const $e=L.get(de);if(!$e){pe[de]=De;continue}const Xe=Ea(De,$e?ga($e):1);pe[de]=Xe,Xe!==De&&(z=!0)}return z?pe:F}),qr(F=>{const z=F.filter(pe=>M.has(pe));return vh(F,z)?F:z})},[et,Ul]),u.useEffect(()=>{Oo([]),Ho(!1)},[ss]),u.useEffect(()=>{!li||za!=="selected"||ri.length>0||ua.length===0||qr(ua.map(y=>y.deviceId))},[ua,ri.length,za,li]),u.useEffect(()=>{try{localStorage.setItem(uw,zt)}catch{}},[zt]),u.useEffect(()=>{uT(He)},[He]),u.useEffect(()=>{fT(dt)},[dt]),u.useEffect(()=>{oT(Qt)},[Qt]);const na=u.useCallback(async()=>{const y=new Set(p);y.add(Cn);try{const pe=await Ge("/api/remote/status",void 0,Cn);yy({endpoint:pe.agentEndpoint,endpoint_candidates:[...pe.agentEndpointCandidates||[],...pe.hostTargetEndpointCandidates||[]]}).forEach(de=>y.add(de))}catch{}const M=[...y].sort((pe,de)=>{const De=$e=>{const Xe=Ic($e);return Xe==="local"?0:Xe==="loopback"?1:2};return De(pe)-De(de)||pe.localeCompare(de)});let L=!1,F="",z=!1;try{for(const pe of M){const de=Ic(pe);try{if(await Ge("/api/health",void 0,pe),de==="local")return v(!0),Co(!0),pe;de==="loopback"&&(L=!0,F=pe)}catch{de==="local"&&(z=!0)}}return L?(z&&Ie("LiveDesk Hub is reachable on this PC, but not through the LAN address yet. Restart LiveDesk Hub to bind 5179 on the network."),v(!0),Co(!0),F||Cn):(v(!1),Co(!1),"")}catch{return v(!1),Co(!1),""}},[p]),ls=async()=>{if(Ae("auth"),jn(!1),await na(),window.liveDesk?.auth?.signInWithGoogle){const L=await window.liveDesk.auth.signInWithGoogle();L?.ok===!1&&(Ie(L.error||"LiveDesk could not open the system browser for Google sign-in."),Ae(""));return}const{data:y,error:M}=await pt.auth.signInWithOAuth({provider:"google",options:{redirectTo:`${window.location.origin}/callback`}});M&&(Ie(M.message),Ae(""))},rr=async()=>{Ae("auth"),jn(!1),await pt.auth.signOut(),(await window.liveDesk?.auth?.persistSession?.(null))?.runtimeCleared===!1?Ie("Signed out locally. The LiveDesk runtime could not be reached to clear its session."):window.liveDesk?.auth?.persistSession||await Ge("/api/auth/session",{method:"DELETE"},Cn).catch(()=>{}),Ae("")};u.useEffect(()=>{if(!Re)return;const y=L=>{L.target instanceof Element&&(L.target.closest(".account-popover, .rail-account")||jn(!1))},M=L=>{L.key==="Escape"&&jn(!1)};return window.addEventListener("pointerdown",y),window.addEventListener("keydown",M),()=>{window.removeEventListener("pointerdown",y),window.removeEventListener("keydown",M)}},[Re]);const il=u.useCallback(async(y={})=>{const M=y.silent===!0,L=y.takeover===!0,F=y.requestLocalAccess===!0;if(!n?.user){M||Ie("Sign in before publishing this host.","error");return}if(!Ui.current){Ui.current=!0,M||(Ae("host"),ct("Hub · 1/4 · Checking the local runtime…"));try{const pe=(F?await na():"")||N||Cn;if(!(b||await Ge("/api/remote/status",void 0,pe)).started)throw new Error("Start LiveDesk on this computer before syncing the server.");M||ct("Hub · 2/4 · Sending the signed-in session to the Hub…");const De=await Ge("/api/auth/session",{method:"POST",body:JSON.stringify({accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:n.expires_at,user:{id:n.user.id,email:n.user.email}})},pe);if(!De.ok||!De.authenticated)throw new Error(De.error||"hub-session-sync-failed");M||ct("Hub · 3/4 · Claiming the Hub role and publishing its endpoint…");const $e=await Ge("/api/hub/sync",{method:"POST",body:JSON.stringify({takeover:L})},pe);if(!$e.ok)throw new Error($e.error||"host-target-failed");if(!M){ct("Hub · 4/4 · Verifying the endpoint and lease renewal…");const Xe=await Ge("/api/hub/status",void 0,pe);if(!Xe.hostTargetActive)throw new Error(Xe.hostTargetLease?.lastError||"host-target-not-active-after-sync");const tn=Xe.hostTargetEndpoint||Xe.agentEndpoint||"endpoint ready",dn=Number(Xe.connectedDeviceCount||0),Wn=dn>0?`${dn} client${dn===1?"":"s"} connected.`:"No clients connected yet; reconnect the laptop Client.";Ie(`Hub ready · ${tn} · lease auto-renewal active. ${Wn}`,"success"),(F||w)&&(v(!0),Co(!0)),A()}c()}catch(z){if(!M){const pe=z instanceof Error?z.message:String(z);pe.includes("local network access")&&(v(!1),Co(!1)),Ie(`Hub setup failed · ${pe}`,"error")}}finally{Ui.current=!1,M||Ae("")}}},[N,w,A,c,na,n,Ie,ct,b]),rl=u.useCallback(async()=>{if(!(!b?.update?.canApply||fe==="update")){Ae("update");try{const y=await Ge("/api/update/apply",{method:"POST",body:JSON.stringify({})},N||Cn);if(!y.ok)throw new Error(y.error||"LiveDesk update could not be started.");const M=[...new Set((y.targets||[]).map(z=>String(z.deviceId||"").trim()).filter(Boolean))],L=!!(y.managerUpdateAvailable||y.clientPackageUpdateAvailable),F=y.state==="hub-restart-requested"?Date.now():void 0;(M.length>0||L)&&qn({operationId:String(y.operationId||`wall-update-${Date.now()}`),targetIds:M,stage:y.state==="clients-updated"?"updated":"updating",requiresHubRestart:L,initialHostInstanceId:String(b.hostInstanceId||""),targetManagerVersion:String(y.latestVersion||b.update?.latestVersion||""),targetClientVersion:String(y.latestClientVersion||b.update?.latestClientVersion||""),restartRequestedAt:F,restartDeadlineAt:F?F+Md:void 0}),ct(y.state==="hub-restart-requested"?Nd:Ax),A()}catch(y){Ie(y instanceof Error?y.message:String(y),"error")}finally{Ae("")}}},[fe,N,A,Ie,ct,b]);u.useEffect(()=>{const y=bt,M=b?.update;if(!y||y.stage!=="updating"||!M)return;const L=M.restartResult?.operationId===y.operationId?M.restartResult:null;if(L?.outcome==="restored"){const $e=L.error||`The requested Hub ${L.targetVersion||y.targetManagerVersion||"version"} failed verification.`;qn(Xe=>Xe?.operationId===y.operationId?{...Xe,stage:"restored",error:$e}:Xe),Ie(`LiveDesk update did not complete. Hub ${L.fallbackVersion||L.appVersion||"the previous version"} was restored. ${$e}`,"error");return}if(L?.outcome==="failed"){const $e=L.error||"No verified LiveDesk Hub replacement could be started.";qn(Xe=>Xe?.operationId===y.operationId?{...Xe,stage:"failed",error:$e}:Xe),Ie(`LiveDesk Hub update failed. ${$e}`,"error");return}if(M.operationId===y.operationId&&M.state==="failed"){const $e=M.error||"LiveDesk update failed before the Hub replacement completed.";qn(Xe=>Xe?.operationId===y.operationId?{...Xe,stage:"failed",error:$e}:Xe),Ie($e,"error");return}if(M.operationId===y.operationId){if(M.state==="hub-restart-requested"&&!y.restartDeadlineAt){const $e=Date.now();qn(Xe=>Xe?.operationId===y.operationId?{...Xe,restartRequestedAt:$e,restartDeadlineAt:$e+Md}:Xe),ct(Nd)}!y.requiresHubRestart&&M.state==="clients-updated"&&(qn($e=>$e?.operationId===y.operationId?{...$e,stage:"updated"}:$e),Ie("LiveDesk clients updated and reconnected successfully.","success"));return}if(!y.requiresHubRestart)return;const F=b.started===!0&&(!y.initialHostInstanceId||b.hostInstanceId&&b.hostInstanceId!==y.initialHostInstanceId),z=!!M.checkedAt,pe=Nx(M.currentVersion,y.targetManagerVersion),de=!y.targetClientVersion||Nx(M.currentClientVersion,y.targetClientVersion),De=z&&M.state==="idle"&&M.updateAvailable===!1&&pe&&de;F&&De&&(qn($e=>$e?.operationId===y.operationId?{...$e,stage:"updated"}:$e),Ie(`LiveDesk Hub ${M.currentVersion||L?.appVersion||y.targetManagerVersion} restarted and passed version verification.`,"success"))},[Ie,ct,b,bt]),u.useEffect(()=>{const y=bt;if(!y||y.stage!=="updating"||!y.requiresHubRestart||y.restartDeadlineAt)return;const M=()=>{const F=Date.now();qn(z=>z?.operationId===y.operationId&&z.stage==="updating"&&!z.restartDeadlineAt?{...z,restartRequestedAt:F,restartDeadlineAt:F+Md}:z),ct(Nd)};if(b?.update?.state==="hub-restart-requested"){M();return}if(!j)return;const L=window.setTimeout(M,FM);return()=>window.clearTimeout(L)},[j,ct,b?.update?.state,bt]),u.useEffect(()=>{const y=bt;if(!y||y.stage!=="updating"||!y.requiresHubRestart||!y.restartDeadlineAt)return;const M=Math.max(0,y.restartDeadlineAt-Date.now()),L=y.operationId,F=window.setTimeout(()=>{const z=`LiveDesk Hub did not return and verify ${y.targetManagerVersion||"the requested version"} within ${Math.round(Md/6e4)} minutes. Check the Hub terminal or restart log, then run livedesk@latest manually if the Hub is still offline.`;qn(pe=>pe?.operationId===L&&pe.stage==="updating"?{...pe,stage:"failed",error:z}:pe),Ie(z,"error")},M);return()=>window.clearTimeout(F)},[Ie,bt]),u.useEffect(()=>{if(!bt||bt.stage!=="updated")return;const y=bt.operationId,M=window.setTimeout(()=>{qn(L=>L?.operationId===y?null:L)},8e3);return()=>window.clearTimeout(M)},[bt]),u.useEffect(()=>{if(Et!==Ax&&Et!==Nd)return;const y=b?.update;if(String(y?.state||"")==="failed"){Ie(y?.error||"LiveDesk update failed.","error");return}bt?.stage==="updated"&&Ie("")},[Et,Ie,b?.update?.error,b?.update?.state,bt?.stage]);const Ca=u.useCallback(async()=>{if(!fe){Ae("pin");try{const M=await Ge("/api/remote/pairing-pin",{method:"POST"},N||Cn);if(!M.ok)throw new Error(M.error||"pin-rotation-failed");await A(),Ie("New PIN published.")}catch(y){Ie(y instanceof Error?y.message:String(y))}finally{Ae("")}}},[fe,N,A]),aa=u.useCallback(y=>{y&&(ne(y),_(M=>M.includes(y)?M:[...M,y]))},[]),bs=u.useCallback(y=>{if(!y)return;const M=oi.has(y);ne(L=>M?L===y?"":L:y),_(L=>M?L.filter(F=>F!==y):L.includes(y)?L:[...L,y])},[oi]),sa=u.useCallback(()=>{_([]),ne("")},[Ia]),Oa=u.useCallback(()=>{_(et.map(y=>y.deviceId)),ne("")},[et]),Ha=u.useCallback((y,M)=>{const L=et.find(z=>z.deviceId===y);if(!L)return;const F=ga(L);F<=1||(ps(z=>{const de=(Ea(z[y],F)+M+F)%F;return{...z,[y]:de}}),at&&(Zt(!1),te(y)))},[et,at]);u.useEffect(()=>{const y=M=>{if(at&&Se&&ns)return;const L=M.target,F=L?.tagName?.toLowerCase();L?.isContentEditable||F==="input"||F==="textarea"||F==="select"||((M.ctrlKey||M.metaKey)&&M.key.toLowerCase()==="a"&&(M.preventDefault(),Oa()),M.key==="Escape"&&sa())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[ns,sa,Se,Oa,at]);const du=(y,M)=>{const L=et.find(z=>z.deviceId===y),F=Ea(M,L?ga(L):1);ps(z=>({...z,[y]:F})),at?(Zt(!1),te(y)):aa(y)},lr=async y=>{if(Zt(!1),te(y),Ft("control"),!Qi.has(y)){_e(!1),Ie(Kr);return}const M=et.find(F=>F.deviceId===y);if(zi(M?.platform)&&(M?.capabilities?.controlPermission===!1||M?.capabilities?.accessibilityPermission===!1)){_e(!1),Ie("Mac remote control needs Accessibility permission. Allow it for the terminal app that starts LiveDesk, then restart the Mac client.","error");return}_e(!0),Ie(`Opening remote control${M?` for ${fs(M)}`:""}.`,"success")},Ko=async()=>{if(!Ee){Ie("Select a workstation before playing audio.");return}if(!It){Ie(Kr);return}if(!Yr){Ie("Selected workstation does not report remote audio support yet.");return}if(Te)return;const y=!re,M=y?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:Le.current.get(Ee.deviceId);y&&M?Le.current.set(Ee.deviceId,M):y||Le.current.delete(Ee.deviceId),Be("audio"),Z(y);try{await Ge(`/api/remote/devices/${encodeURIComponent(Ee.deviceId)}/audio/${y?"start":"stop"}`,{method:"POST",body:JSON.stringify({...M?{streamId:M}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},N),Ie(`${y?"Audio started":"Audio stopped"} for ${fs(Ee)}.`,"success")}catch(L){y&&Le.current.delete(Ee.deviceId),Z(!1),Ie(L instanceof Error?L.message:String(L),"error")}finally{Be("")}},fu=y=>{const M=y instanceof Error?y.message:String(y);return/remote-actions-disabled|allowAgent-blocked-by-settings/i.test(M)?"Remote actions are off. Turn on Settings > Agent > Enable AI Agent first.":/power-actions-disabled/i.test(M)?"Power actions are off. Turn on Settings > Agent > Allow power actions first.":/agent-tool-capability-unavailable|unsupported-agent-operation/i.test(M)?"This workstation needs a newer LiveDesk Client for power actions.":/device-not-connected|404 device-not-found/i.test(M)?"The workstation disconnected before the action could be sent.":M},un=async y=>{if(!Ee||Te)return;const M=Ee,F={lock:"Lock",sleep:"Sleep",restart:"Restart",shutdown:"Shut down"}[y];if(!(y!=="lock"&&!window.confirm(`${F} ${fs(M)}? Unsaved work on that computer may be lost.`))){Be(y),Ie(`Sending ${F.toLowerCase()} request to ${fs(M)}...`);try{const z=await Ge(`/api/remote/devices/${encodeURIComponent(M.deviceId)}/quick-actions`,{method:"POST",body:JSON.stringify({action:y})},N);if(!z.ok)throw new Error(z.error||"The remote action could not be sent.");Ie(`${F} request sent to ${fs(M)}.`,"success"),A()}catch(z){Ie(fu(z),"error")}finally{Be("")}}},Gt=()=>{Ee&&(Je({id:Date.now(),deviceId:Ee.deviceId,instruction:"Run command "}),_e(!1),Ft("agents"),Ie(`Command runner opened for ${fs(Ee)}.`))},wt=async(y,M,L="files")=>{const F=y.filter(De=>De.file.size>=0);if(F.length===0)return{files:0,bytes:0};if(!It)throw new Error(Kr);if(M.length===0)throw new Error("Select at least one connected workstation.");const z=crypto.randomUUID(),pe=F.reduce((De,$e)=>De+$e.file.size,0);let de=0;Fs({id:z,status:"reading",progress:1,message:`Preparing ${F.length} ${L}`});try{for(let De=0;De<F.length;De+=1){const $e=F[De],Xe=$e.file,tn=Math.max(1,Math.ceil(Xe.size/dh));for(let dn=0;dn<tn;dn+=1){const Wn=dn*dh,hl=Math.min(Xe.size,Wn+dh),pl=Xe.size===0?new ArrayBuffer(0):await Xe.slice(Wn,hl).arrayBuffer(),pr=dn===tn-1;Fs({id:z,status:"sending",progress:Math.max(2,Math.min(98,Math.round(de/Math.max(1,pe)*96))),message:`${De+1}/${F.length} ${$e.relativePath}`});const wi=await Ge("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:z,deviceIds:M,remoteDirectory:zt.trim(),name:Xe.name,relativePath:$e.relativePath,size:Xe.size,type:Xe.type,lastModified:Xe.lastModified,offset:Wn,totalBytes:Xe.size,final:pr,dataBase64:vT(pl)})},N);if(!wi.ok||wi.queued!==M.length)throw new Error(wi.error||`file-chunk-not-queued-${wi.queued}/${M.length}`);de+=pl.byteLength,await new Promise(xu=>window.setTimeout(xu,0))}}return Fs({id:z,status:"queued",progress:100,message:`Sent ${F.length} file${F.length===1?"":"s"} to ${M.length} workstation${M.length===1?"":"s"}`}),window.setTimeout(()=>{Fs(De=>De?.id===z&&De.status==="queued"?null:De)},4500),{files:F.length,bytes:pe}}catch(De){throw Fs({id:z,status:"failed",progress:100,message:De instanceof Error?De.message:String(De)}),De}},ws=async y=>{const M=ua.length>0?ua.map(L=>L.deviceId):Ee?[Ee.deviceId]:[];try{await wt(Hx(y),M)}catch(L){Ie(L instanceof Error?L.message:String(L))}},ha=async y=>{try{await wt(Hx(y),df)}catch(M){Ie(M instanceof Error?M.message:String(M))}};u.useEffect(()=>{Qc.current=!1},[]);const Qo=y=>{y.preventDefault(),y.stopPropagation(),_a(!1),ws(y.dataTransfer.files)},Ba=async(y="ltd")=>{if(!n){Ie("Sign in with Google before checkout.");return}if(T&&y===Yt){Ie("LiveDesk license is already active.");return}if(T&&Yt==="pro"){Ie("LiveDesk Pro is already active.");return}Ae("checkout");try{const{data:M,error:L}=await pt.functions.invoke("dodo-checkout",{body:{plan:y}});if(L)throw L;if(!M?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(M.checkout_url)}catch(M){Ie(M instanceof Error?M.message:String(M)),Ae("")}},Ss=JM(),ll=eT(),or=et.length,Cs=Wl.filter(y=>Jn.has(y)).length,ol=ar==="open"&&ea.sampleMs>0?`${ea.framesPerSecond.toFixed(1)} fps`:ar,Me=Ee?at?Go.get(Ee.deviceId):Jn.get(Ee.deviceId):void 0,cr=Ee?Ea(Qt[Ee.deviceId],ga(Ee)):0,Qs=Ee?sT(Ee):[],js=typeof Me?.monitorIndex=="number"?Ea(Me.monitorIndex,Math.max(1,Me.monitorCount||1)):cr,Fa=(Me&&js===cr?Sw(Me):null)||(Ee?ww(Ee,cr):null);Fa&&`${Fa.width}${Fa.height}`;const ur=Ee?Ms(at?"control":"wall",Ee.deviceId):"",yn=ur?Bi[ur]:void 0,Mn=ur?zs[ur]:void 0,xt=Mn?.lastInfo,pi=yn&&yn.sampleMs>0?`${yn.framesPerSecond.toFixed(1)} fps`:"waiting";yn&&`${yn.totalFrames}${pi}`,Mn&&Mn.sampleMs>0&&`${Mn.framesPerSecond.toFixed(1)}`,Mn&&Mn.sampleMs>0&&`${Mn.changedFramesPerSecond.toFixed(1)}`,xt&&(`${xt.frameSeq}${xt.decoderLabel}${xt.queueSize}${xt.renderQueueSize}${xt.droppedForLatency}${xt.decoderFlushCount}${xt.decoderTimestampFallbacks}${xt.decoderInputCount}${xt.decoderOutputCount}`,xt.visualChanged),xt&&`${Math.round(xt.queuedForMs)}${Math.round(xt.decodedForMs)}${Math.round(xt.scheduledForMs)}${xt.drawMs.toFixed(1)}`,xt?.targetPaintIntervalMs&&`${xt.targetPaintIntervalMs.toFixed(1)}${(1e3/xt.targetPaintIntervalMs).toFixed(1)}`,Mn&&`${Mn.decoderInputFps.toFixed(1)}${Mn.decoderOutputFps.toFixed(1)}`,xt?.canvasPresentation,xt&&`${xt.interactiveBufferWaitCount}${Math.round(xt.interactiveBufferWaitMs)}${xt.interactiveQueueDrainCount}`,yn&&(Me?.frameMode==="mode5-lzo-delta"?`${Dc(yn.averageFrameBytes)}${Me.deltaVisualTileCount||0}${Me.deltaRefreshTileCount||0}${Me.deltaTotalTiles||0}`:`${Dc(yn.averageFrameBytes)}${Math.round(yn.tinyFrameRatio*100)}${Math.round(yn.repeatedFrameRatio*100)}`),yn&&yn.sourceSendSampleCount>0&&`${yn.sourceSendAverageMs.toFixed(1)}${yn.sourceSendP95Ms.toFixed(1)}`,Ex(yn),Ex(Mn),yn&&Mn&&`${Rx(yn)}${Rx(Mn)}`,Me?Me.frameMode||Me.mode||Me.codec||Me.mimeType:at?dt.frameMode:He.frameMode,at?dt.frameMode:He.frameMode,Me?`${Me.width}${Me.height}${Dc(Me.byteLength)}`:at?`${$s.maxWidth}${$s.maxHeight}`:`${He.maxWidth}${He.maxHeight}`,Me&&`${Me.isKeyFrame?"key":String(Me.chunkType||"delta")}`,Me&&Me.monitorCount&&((Me.monitorIndex??0)+1,`${Me.monitorCount}`),Me&&[`src ${Math.round(Me.sourceGapMs||0)}ms`,`gap ${Math.round(Me.agentSendGapMs||0)}ms`,`tx ${Math.round(Me.agentSendDurationMs||0)}ms`,`pace ${Math.round(Me.agentPaceMs||0)}ms`,`queue ${Math.round(Me.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Me.agentFrameAgeMs||0)}ms`,Me.browserReceivedEpochMs&&Me.receivedAt?`hub ${Math.max(0,Math.round(Me.browserReceivedEpochMs-Date.parse(Me.receivedAt)))}ms`:"",Me.browserReceivedEpochMs&&Me.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Me.browserReceivedEpochMs-Me.hubPacketEpochMs))}ms`:"",Me.droppedByAgent?`drop ${Me.droppedByAgent}`:"",Me.hubIngressDropped?`ingress-drop ${Me.hubIngressDropped}`:"",Me.hubClientDropped?`ws-drop ${Me.hubClientDropped}`:"",Me.captureStageMs?`capture ${Math.round(Me.captureStageMs)}ms`:"",Me.requestedFps?`req ${Math.round(Me.requestedFps)}fps`:"",Me.effectiveFps?`eff ${Math.round(Me.effectiveFps)}fps`:"",Me.captureAverageMs?`avg ${Math.round(Me.captureAverageMs)}ms`:"",Me.captureP95Ms?`p95 ${Math.round(Me.captureP95Ms)}ms`:"",Me.slowFrameCount?`slow ${Math.round(Me.slowFrameCount)}`:"",Me.captureHelperRestarts?`helper ${Math.round(Me.captureHelperRestarts)}`:"",Me.convertMs?`rgb565 ${Math.round(Me.convertMs)}ms`:"",Me.compressMs?`lzo ${Math.round(Me.compressMs)}ms`:"",Me.captureSourceSerial?`cap #${Me.captureSourceSerial}`:"",Me.captureSourceSkipped?`cap skip ${Me.captureSourceSkipped}`:"",Me.frameMode==="mode5-lzo-delta"?`tiles ${Me.deltaVisualTileCount||0}+${Me.deltaRefreshTileCount||0}/${Me.deltaTotalTiles||0}@${Me.deltaTileSize||0}`:"",Me.platformProfile||Me.hardwareEncoder||"-",Me.atlasComposeMs?`atlas ${Me.atlasComposeMs.toFixed(1)}ms`:"",Me.atlasPoolStarved?`pool ${Me.atlasPoolStarved}`:"",Me.atlasTileCount?`tiles ${Me.atlasReadyTiles||0}/${Me.atlasTileCount}`:"",Me.atlasInputRevision?`input #${Me.atlasInputRevision}`:"",Me.atlasSourceMaxAgeMs!==void 0?`input-age ${Math.round(Me.atlasSourceMaxAgeMs)}ms`:"",xt?.inputFeedbackMs!==void 0&&xt.inputFeedbackAt!==void 0&&performance.now()-xt.inputFeedbackAt<=jx?`feedback ${Math.round(xt.inputFeedbackMs)}ms`:"",Me.contentHash?`enc ${Me.contentHash.slice(0,6)}`:"",xt?.visualHash?`pix ${xt.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "),Yo==="open"&&[`${Sa.sentPerSecond.toFixed(1)} hz`,Sa.lastInputSeq>0?`rtt ${Math.round(Sa.lastRoundTripMs)}ms`:"",Sa.lastInputSeq>0?`apply ${Sa.lastAgentApplyMs.toFixed(1)}ms`:"",Sa.droppedPerSecond>0?`drop ${Sa.droppedPerSecond.toFixed(1)}/s`:"",Sa.bufferedAmount>0?`buf ${Dc(Sa.bufferedAmount)}`:"",Sa.lastInputType||"ready"].filter(Boolean).join(" / "),xt?.inputFeedbackMs!==void 0&&xt.inputFeedbackAt!==void 0&&performance.now()-xt.inputFeedbackAt<=jx&&`${Math.round(xt.inputFeedbackMs)}${xt.inputFeedbackSeq||0}`,re&&[mi,`context ${Hn.audioContextState}`,`queue ${Math.round(Hn.queuedMs)}ms`,`last ${Math.round(Hn.lastPacketAgeMs)}ms`,`accepted ${Math.round(Hn.lastAcceptedAgeMs)}ms`,`process ${Math.round(Hn.localProcessingAgeMs)}ms`,`remote ${Math.round(Hn.browserAgeMs)}/${Math.round(Hn.captureAgeMs)}ms`,`heartbeat ${Math.round(Hn.captureStatusAgeMs)}ms`,`capture ${Hn.captureAlive&&Hn.helperAlive?"alive":"down"}`,`drop ${Hn.drops}`,`resync ${Hn.resyncs}`,`restart ${Hn.automaticRestarts}`,Hn.pendingDecodes>0?`decode ${Hn.pendingDecodes}`:"",to?`#${to.frameSeq}`:"waiting"].filter(Boolean).join(" / "),Me&&`${Me.frameSeq}${sb(Me.receivedAt||Me.capturedAt)}`;const Jt=Math.max(0,ea.bytesPerSecond*8/1e6),cl=di?.atlasReadyTiles??Cs,ao=di?.atlasTileCount??Cs,gf=cl===ao?`${ao} tiles`:`${cl}/${ao} tiles`,vf=da.length>0;at?`${ol}${Jt.toFixed(Jt>=10?0:1)}`:vf?`${gf}${ol}${Jt.toFixed(Jt>=10?0:1)}`:`${Cs}${ol}${Jt.toFixed(Jt>=10?0:1)}`;const mu=j?"offline":b?.started?"online":"starting",en=ua.length,Xo=at?Ee?fs(Ee):"No workstation":en===0?"No workstation":en>1?`${en} selected`:Ee?fs(Ee):"No workstation",ul=at?[Ee?.deviceId].filter(y=>!!y):ua.map(y=>y.deviceId),xn=Ro[Fe]||Ro.en,dr=xn.sync||Ro.en.sync,gi=a||R?"checking":T?Yt==="pro"?"Pro LTD active":`Plus LTD ${et.length}/${Rc}`:Po?`Free ${et.length}/${Ec}`:`Upgrade ${et.length}/${Ec}`,fr=Yt==="pro"?"Pro active":fe==="checkout"?"Opening":Yt==="ltd"?"Pro $199":"Plus $79",hu=T?Yt==="pro"?"Pro active":"Upgrade to Pro LTD":n?fe==="checkout"?"Opening checkout":Yt==="ltd"?"Buy Pro LTD":"Buy Plus LTD":fe==="auth"?"Opening Google":"Sign in to buy",yf=Yt==="pro"||fe==="checkout"||fe==="auth"||a||R,Zo=n?.user?.user_metadata,os=Bx(Zo,"avatar_url","picture"),vi=Bx(Zo,"full_name","name")||n?.user?.email||"Google",dl=vi.slice(0,1).toUpperCase(),pu=b?.started?"Local app ready":"Start LiveDesk",mr=r?.active?"Published":n?"Not published":"Sign in required",Jo=/^\d{6}$/.test(b?.pairingPin||"")?b?.pairingPin:"------",so=Hd.find(y=>y.width===He.maxWidth&&y.height===He.maxHeight)?.id||`${He.maxWidth}x${He.maxHeight}`,io=He.atlasTileSizeMode==="auto"?"auto":gh.find(y=>y.width===He.atlasTileWidth&&y.height===He.atlasTileHeight)?.id||"320x180",gu=ph.find(y=>y.width===dt.maxWidth&&y.height===dt.maxHeight)?.id||`${dt.maxWidth}x${dt.maxHeight}`,vu=Od.find(y=>y.id===He.frameMode)||Od[0],Tn=y=>{ya(M=>{const L=y.frameMode?qh(y.frameMode):M.frameMode,F=y.frameMode!==void 0&&L!==M.frameMode;return{...M,...y,frameMode:L,fps:Vh(y.fps??(F?yw(L):M.fps),L)}})},yi=y=>{const M=Hd.find(L=>L.id===y);M&&Tn({maxWidth:M.width,maxHeight:M.height})},yu=y=>{if(y==="auto"){Tn({atlasTileSizeMode:"auto"});return}const M=gh.find(L=>L.id===y);!M?.width||!M?.height||Tn({atlasTileSizeMode:"fixed",atlasTileWidth:M.width,atlasTileHeight:M.height})},xi=y=>{y.frameMode!==void 0&&(Q(""),he("")),Hi(M=>{const L=y.frameMode?Gh(y.frameMode):M.frameMode,F=y.frameMode!==void 0&&L!==M.frameMode,z=y.fps??(F?30:M.fps),pe=y.maxWidth??M.maxWidth,de=y.maxHeight??M.maxHeight;return{...M,...y,frameMode:L,fps:ms(z,20,L==="mode3-h264-hw"?60:30,L==="mode3-h264-hw"?60:30),maxWidth:L==="mode3-h264-hw"?pe:Math.min(1920,pe),maxHeight:L==="mode3-h264-hw"?de:Math.min(1080,de)}})},hr=y=>{const M=ph.find(L=>L.id===y);M&&xi({maxWidth:M.width,maxHeight:M.height})},bi=y=>{if(typeof window<"u"&&(y==="support"?window.history.pushState({},"","/support"):_t==="support"&&window.history.pushState({},"","/")),y==="control"){const M=Vn||Ki;if(M&&(Zt(!1),te(M.deviceId)),Ft(y),!It){_e(!1),Ie(Kr);return}_e(!0);return}y==="agents"&&Je(null),y==="wall"&&Ne(M=>M+1),Ft(y),_e(!1)},ks=fe==="update"||bt?.stage==="updating"||["dispatching","waiting-for-clients","hub-restart-requested"].includes(b?.update?.state||""),fl=!!(b?.update?.updateAvailable&&b.update.canApply||ks||!b&&bt),ml=u.useCallback(y=>{if(!bt?.targetIds.includes(y))return;if(bt.stage==="updated")return{state:"updated",label:"Updated"};if(bt.stage==="restored"||bt.stage==="failed")return{state:"failed",label:bt.stage==="restored"?"Update restored":"Update failed",error:bt.error};const M=b?.update?.operationId===bt.operationId?b.update.targets?.find(L=>L.deviceId===y):void 0;switch(M?.state){case"completed":return{state:"updated",label:"Updated"};case"failed":return{state:"failed",label:"Update failed",error:M.error||b?.update?.error};case"pending-offline":return{state:"offline",label:"Waiting for reconnect"};case"queued":return{state:"queued",label:"Queued"};case"waiting":return M.candidateSince?{state:"updating",label:"Verifying restart..."}:{state:"updating",label:"Restarting..."};default:return{state:"updating",label:"Verifying..."}}},[b?.update,bt]);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(ib,{size:25})}),s.jsx("nav",{className:"rail-tools",children:kT.map(y=>{const M=y.icon,L=Pd(y.tooltip,Fe);return s.jsxs("button",{className:`rail-tool ${y.id==="sync-server"?"sync-server":""} ${_t===y.id?"active":""} accent-${y.accent}`,onClick:()=>y.id==="sync-server"?void il({takeover:!0,requestLocalAccess:!0}):bi(y.id),"data-tooltip":Ah(y.label,y.tooltip,Fe),"aria-label":`${y.label}. ${L}`,type:"button",disabled:y.id==="sync-server"&&fe==="host","aria-busy":y.id==="sync-server"&&fe==="host",children:[y.id==="sync-server"&&fe==="host"?s.jsx("span",{className:"sync-server-spinner","aria-hidden":"true"}):s.jsx(M,{size:19}),s.jsx("span",{children:y.id==="sync-server"&&fe==="host"?"Syncing…":y.label})]},y.id)})}),s.jsxs("div",{className:"rail-footer",children:[AT.map(y=>{const M=y.icon;return s.jsxs("button",{className:`rail-tool compact ${_t===y.id?"active":""} accent-${y.accent}`,onClick:()=>bi(y.id),title:y.label,type:"button",children:[s.jsx(M,{size:18}),s.jsx("span",{children:y.label})]},y.id)}),s.jsxs("button",{className:`rail-tool compact local-settings ${ts?"active":""}`,onClick:()=>{Ft("settings"),typeof window<"u"&&window.history.pushState({},"","/"),jn(!1),_e(!1),gt(!1)},title:"Settings",type:"button",children:[s.jsx(qx,{size:18}),s.jsx("span",{children:"Settings"})]}),s.jsxs("button",{className:`rail-account ${n?"signed-in":""}`,onClick:()=>{jn(y=>!y)},disabled:a||fe==="auth","aria-expanded":Re,title:n?`Account: ${n.user?.email||vi}`:"Sign in with Google",type:"button",children:[n?os?s.jsx("img",{src:os,alt:vi,referrerPolicy:"no-referrer"}):s.jsx("span",{className:"avatar-fallback",children:dl}):s.jsx(Rl,{size:18}),s.jsx("span",{children:n?"Account":"Google"})]}),Re&&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:n&&os?s.jsx("img",{src:os,alt:vi,referrerPolicy:"no-referrer"}):n?s.jsx("span",{children:dl}):s.jsx(Rl,{size:18})}),s.jsxs("div",{children:[s.jsx("strong",{children:n?vi:"Account"}),s.jsx("p",{children:n?.user?.email||"Not signed in"})]})]}),s.jsxs("dl",{className:"account-popover-facts",children:[s.jsx("dt",{children:"User"}),s.jsx("dd",{children:n?.user?.email||"Not signed in"}),s.jsx("dt",{children:"Network"}),s.jsx("dd",{children:pu}),s.jsx("dt",{children:"Access"}),s.jsx("dd",{children:mr}),s.jsx("dt",{children:"Plan"}),s.jsx("dd",{children:gi}),s.jsx("dt",{children:"Ads"}),s.jsx("dd",{children:Yt==="free"?"Standard banner":"Removed"})]}),n?s.jsxs("button",{className:"account-popover-action",onClick:rr,disabled:fe==="auth",type:"button",children:[s.jsx(Gx,{size:16}),"Logout"]}):s.jsxs("button",{className:"account-popover-action primary",onClick:ls,disabled:fe==="auth",type:"button",children:[s.jsx(Rl,{size:16}),"Sign in with Google"]})]})]})]}),s.jsxs("section",{className:`desk-stage ${Wi&&!st?"dock-open":""} ${at?"control-stage":""} ${Vr?"agents-stage":""}`,children:[s.jsxs("header",{className:"topbar",children:[s.jsxs("div",{className:"brand",children:[s.jsx("span",{className:"brand-mark",children:s.jsx(pn,{size:18})}),s.jsxs("div",{className:"brand-copy",children:[s.jsx("h1",{children:"LiveDesk"}),s.jsx("p",{children:"Control wall for local machines"})]}),fl?s.jsxs("button",{className:"topbar-update-button",onClick:()=>{rl()},title:bt?.error||`Update LiveDesk to ${b?.update?.latestVersion||bt?.targetManagerVersion||"latest"}`,"aria-label":ks?"LiveDesk update in progress":`Update LiveDesk to ${b?.update?.latestVersion||bt?.targetManagerVersion||"latest"}`,type:"button",disabled:ks||!b?.update?.canApply,"aria-busy":ks,children:[ks?s.jsx("span",{className:"topbar-update-spinner","aria-hidden":"true"}):s.jsx(Wh,{size:19,"aria-hidden":"true"}),ks&&b?.update?.targetCount?s.jsxs("span",{className:"topbar-update-count","aria-hidden":"true",children:[b.update.completedCount||0,"/",b.update.targetCount]}):null]}):null]}),s.jsxs("div",{className:"topbar-tray",children:[li&&!at&&s.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[s.jsxs("div",{children:[s.jsx(Ml,{size:17}),s.jsxs("span",{children:[s.jsx("small",{children:"Source"}),s.jsx("strong",{children:"LiveDesk Hub"})]})]}),s.jsx(Qh,{size:15}),s.jsx(d0,{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:[Zc," workstation",Zc===1?"":"s"]}),s.jsx("em",{children:zt.trim()||"Desktop/LiveDeskFiles"})]})]})]}),Wi&&!at&&s.jsxs("div",{className:"top-actions",children:[s.jsx(bx,{controller:Xi,onError:Ie}),s.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),s.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:jT.map(y=>s.jsx("button",{className:ge===y.id?"active":"",onClick:()=>Oe(y.id),type:"button",children:y.label},y.id))})]}),at&&s.jsx("div",{className:"top-actions",children:s.jsx(bx,{controller:Xi,onError:Ie})})]})]}),Vi?s.jsxs("section",{className:"doc-page",lang:Fe,dir:Fe==="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(Bd,{size:16}),xn.eyebrow]}),s.jsx("h2",{children:xn.title}),s.jsx("p",{children:xn.intro})]}),s.jsxs("label",{className:"doc-language-picker",children:[s.jsxs("span",{children:[s.jsx(f0,{size:17}),xn.languageLabel]}),s.jsx("select",{value:Fe,onChange:y=>ke(y.target.value),children:MT.map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),s.jsx("section",{className:"doc-grid",children:xn.sections.map((y,M)=>{const F=[El,Ld,Fm,Bt,Dl][M]||Bd;return s.jsxs("article",{className:"doc-card",children:[s.jsx("div",{className:"doc-card-icon",children:s.jsx(F,{size:19})}),s.jsxs("div",{children:[s.jsx("h3",{children:y.title}),s.jsx("p",{children:y.body}),s.jsx("ul",{children:y.points.map(z=>s.jsx("li",{children:z},z))})]})]},y.title)})}),dr&&s.jsxs("section",{className:"doc-sync",children:[s.jsxs("div",{className:"doc-sync-head",children:[s.jsx(Fm,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:dr.title}),s.jsx("p",{children:dr.body})]})]}),s.jsx("ul",{children:dr.points.map(y=>s.jsx("li",{children:y},y))})]}),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:xn.firewall.title}),s.jsx("p",{children:xn.firewall.body})]})]}),s.jsx("ul",{children:xn.firewall.points.map(y=>s.jsx("li",{children:y},y))})]}),s.jsxs("section",{className:"doc-command-panel",children:[s.jsxs("div",{className:"doc-command-head",children:[s.jsx(Ld,{size:20}),s.jsxs("div",{children:[s.jsx("h3",{children:xn.commands.title}),s.jsx("p",{children:xn.commands.body})]})]}),s.jsxs("div",{className:"doc-command-list",children:[xn.commands.manager&&s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:xn.commands.manager}),s.jsx("code",{children:ll}),s.jsx("button",{className:"icon-button",onClick:()=>Al(ll),title:"Copy command",type:"button",children:s.jsx(bl,{size:16})})]}),s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:xn.commands.primary}),s.jsx("code",{children:Ss}),s.jsx("button",{className:"icon-button",onClick:()=>Al(Ss),title:"Copy command",type:"button",children:s.jsx(bl,{size:16})})]}),s.jsxs("div",{className:"doc-command-row",children:[s.jsx("span",{children:xn.commands.slot}),s.jsx("code",{children:`${Ss} 3`}),s.jsx("button",{className:"icon-button",onClick:()=>Al(`${Ss} 3`),title:"Copy command",type:"button",children:s.jsx(bl,{size:16})})]})]})]})]}):Vr?s.jsx(vx,{hubUrl:N,devices:C,launchRequest:Ve}):li?s.jsx(hN,{hubUrl:N,devices:et,localFeatureAccess:It,upgradeNotice:Kr,remoteDirectory:zt,onRemoteDirectoryChange:zn,targetMode:za,selectedTargetIds:ri,onTargetModeChange:Pi,onTargetToggle:y=>qr(M=>M.includes(y)?M.filter(L=>L!==y):[...M,y]),filePickerRef:Bo,folderPickerRef:$l,onBrowserFileImport:y=>{ha(y)},onBrowserFolderImport:y=>{ha(y)},onNotice:Ie,onTransferChange:y=>{if(!y){Fs(null);return}const M=y.state==="failed"||y.state==="partially-failed"||y.state==="cancelled"?"failed":y.state==="completed"?"queued":y.state==="sending"?"sending":"reading";Fs({id:y.id,status:M,progress:y.progress,message:y.message}),["completed","partially-failed","failed","cancelled"].includes(y.state)&&window.setTimeout(()=>Fs(L=>L?.id===y.id?null:L),4500)}}):Xc?s.jsx(tb,{session:n,currentProductKey:"livedesk",appVersion:"",onSignIn:ls}):ts?s.jsx(Rj,{hubUrl:N,runtimeRole:b?.runtimeRole||"hub",runtimeDeviceId:b?.deviceId||"",sessionAccessToken:n?.access_token||"",pin:s.jsxs(Dj,{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(an,{size:20})]}),s.jsxs("div",{className:"settings-pin-display",children:[s.jsx("span",{children:"Hub PIN"}),s.jsx("strong",{children:Jo}),s.jsxs("button",{className:"text-button ghost compact",onClick:Ca,disabled:!b?.started||fe==="pin",type:"button",children:[s.jsx(Ts,{size:15}),fe==="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:mu})]}),s.jsx("span",{className:`settings-status-dot state-${mu}`})]}),s.jsxs("dl",{className:"settings-facts",children:[s.jsx("dt",{children:"Address"}),s.jsx("dd",{children:N||"-"}),s.jsx("dt",{children:"Connected workstations"}),s.jsxs("dd",{children:[or,"/",Ul]}),s.jsx("dt",{children:"Sync access"}),s.jsx("dd",{children:b?.started?"Local app ready":"Start Hub first"}),s.jsx("dt",{children:"Plan"}),s.jsx("dd",{children:gi})]}),s.jsxs("div",{className:"settings-action-row",children:[s.jsxs("button",{className:"text-button primary",onClick:()=>il({takeover:!0,requestLocalAccess:!0}),disabled:!n||fe==="host",type:"button",children:[fe==="host"?s.jsx("span",{className:"sync-server-spinner","aria-hidden":"true"}):s.jsx(Fm,{size:16}),fe==="host"?"Syncing…":"Sync access"]}),s.jsxs("button",{className:"text-button buy",onClick:()=>Ba(Yt==="ltd"?"pro":"ltd"),disabled:fe==="checkout"||Yt==="pro",type:"button",children:[s.jsx(Ao,{size:16}),fr]})]})]})]}),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(No,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Remote folder"}),s.jsx("input",{value:zt,onChange:y=>zn(y.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),s.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:s.jsx(Lj,{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(Pc,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Frame mode"}),s.jsx("select",{value:He.frameMode,onChange:y=>Tn({frameMode:qh(y.target.value)}),children:Od.map(y=>s.jsxs("option",{value:y.id,children:[y.label," - ",y.detail]},y.id))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"H.264 decode"}),s.jsx("select",{value:He.h264DecodeAcceleration,onChange:y=>Tn({h264DecodeAcceleration:Zd(y.target.value)}),children:Uh.map(y=>s.jsx("option",{value:y.id,children:y.label},y.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:He.fps,onChange:y=>Tn({fps:Vh(y.target.value,He.frameMode)}),children:yp.filter(y=>y<=xw(He.frameMode)).map(y=>s.jsx("option",{value:y,children:y},y))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:ft?"Atlas tile":"Resolution"}),s.jsx("select",{value:ft?io:so,onChange:y=>ft?yu(y.target.value):yi(y.target.value),children:(ft?gh:Hd).map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Quality"}),s.jsx("select",{value:He.quality,onChange:y=>Tn({quality:ms(y.target.value,20,95,va.quality)}),children:Dx.map(y=>s.jsx("option",{value:y,children:y},y))})]})]}),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(pn,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.autoStartLive,onChange:y=>Tn({autoStartLive:y.target.checked})}),s.jsx("span",{children:"Auto live on connected screens"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.visibleOnlyLive,onChange:y=>Tn({visibleOnlyLive:y.target.checked})}),s.jsx("span",{children:"Stream visible tiles first"})]}),!ft&&s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.adaptiveSizeByWall,onChange:y=>Tn({adaptiveSizeByWall:y.target.checked})}),s.jsx("span",{children:"Fit stream size to Wall"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.adaptiveLoadShedding,onChange:y=>Tn({adaptiveLoadShedding:y.target.checked})}),s.jsx("span",{children:"Reduce FPS under load"})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:He.showScreenStatus,onChange:y=>Tn({showScreenStatus:y.target.checked})}),s.jsx("span",{children:"Screen status overlay"})]}),s.jsxs("div",{className:"settings-summary",children:[s.jsx("span",{children:vu.label}),s.jsxs("strong",{children:[On.maxWidth,"x",On.maxHeight," / ",Pe,"fps"]})]}),s.jsxs("button",{className:"settings-reset",onClick:()=>ya(va),type:"button",children:[s.jsx(_c,{size:15})," Reset Wall settings"]})]})]})}),control:s.jsx(_j,{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(Dd,{size:20})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Frame mode"}),s.jsx("select",{value:dt.frameMode,onChange:y=>xi({frameMode:Gh(y.target.value)}),children:UM.map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]}),dt.frameMode==="mode3-h264-hw"&&s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"H.264 decode"}),s.jsx("select",{value:dt.h264DecodeAcceleration,onChange:y=>xi({h264DecodeAcceleration:Zd(y.target.value)}),children:Uh.map(y=>s.jsx("option",{value:y.id,children:y.label},y.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:dt.fps,onChange:y=>xi({fps:ms(y.target.value,20,60,Ra.fps)}),children:qM.filter(y=>dt.frameMode==="mode3-h264-hw"||y<=30).map(y=>s.jsx("option",{value:y,children:y},y))})]}),s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Resolution"}),s.jsx("select",{value:gu,onChange:y=>hr(y.target.value),children:ph.filter(y=>dt.frameMode==="mode3-h264-hw"||y.width<=1920).map(y=>s.jsx("option",{value:y.id,children:y.label},y.id))})]})]}),dt.frameMode==="mode3-h264-hw"&&s.jsxs("label",{className:"settings-field",children:[s.jsx("span",{children:"Quality"}),s.jsx("select",{value:dt.quality,onChange:y=>xi({quality:ms(y.target.value,20,95,Ra.quality)}),children:Dx.map(y=>s.jsx("option",{value:y,children:y},y))})]})]}),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(an,{size:20})]}),s.jsxs("label",{className:"settings-toggle",children:[s.jsx("input",{type:"checkbox",checked:dt.showScreenStatus,onChange:y=>xi({showScreenStatus:y.target.checked})}),s.jsx("span",{children:"Screen status overlay"})]}),s.jsxs("div",{className:"settings-summary control",children:[s.jsx("span",{children:dt.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":"Mode 3 H.264"}),s.jsxs("strong",{children:[$s.maxWidth,"x",$s.maxHeight," / ",Yi,"fps"]})]}),s.jsxs("button",{className:"settings-reset",onClick:()=>Hi(Ra),type:"button",children:[s.jsx(_c,{size:15})," Reset Control settings"]})]})]})}),agent:s.jsx(zj,{hubUrl:N}),captureGallery:s.jsx(pM,{hubUrl:N,onToast:Ie}),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(bl,{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:Ss}),s.jsx("button",{className:"icon-button",onClick:()=>Al(Ss),title:"Copy client command",type:"button",children:s.jsx(bl,{size:16})})]}),s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Slot example"}),s.jsx("code",{children:`${Ss} 3`}),s.jsx("button",{className:"icon-button",onClick:()=>Al(`${Ss} 3`),title:"Copy slot command",type:"button",children:s.jsx(bl,{size:16})})]}),s.jsxs("div",{className:"settings-command-row",children:[s.jsx("span",{children:"Hub"}),s.jsx("code",{children:ll}),s.jsx("button",{className:"icon-button",onClick:()=>Al(ll),title:"Copy Hub command",type:"button",children:s.jsx(bl,{size:16})})]})]})]})}):Gr?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(Ch,{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:()=>bi("wall"),title:"Close pricing",type:"button",children:s.jsx(Ya,{size:18})})]}),s.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[s.jsx("span",{children:"Current plan"}),s.jsx("strong",{children:au.name}),s.jsxs("small",{children:[et.length,"/",$M(Gl)," connected devices"]})]}),s.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[s.jsxs("article",{className:`pricing-plan-card ${Yt==="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:Cl.free.audience}),s.jsx("h3",{children:"Monitor your local wall"}),s.jsx("p",{children:Cl.free.note}),s.jsxs("ul",{children:[s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Up to ",Ec," devices"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Live view and local control"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Standard ad-supported banner"]})]}),s.jsx("span",{className:"pricing-current-label",children:Yt==="free"?"Current plan":"Included for everyone"})]}),s.jsxs("article",{className:`pricing-plan-card featured ${Yt==="ltd"?"current":""}`,children:[s.jsxs("div",{className:"pricing-plan-topline",children:[s.jsxs("span",{className:"pricing-plan-badge plus",children:[s.jsx(m0,{size:14})," Plus"]}),s.jsx("strong",{children:"$5"})]}),s.jsx("p",{className:"pricing-plan-audience",children:Cl.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(Fn,{size:16})," Up to ",Rc," devices"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," No standard ad banner"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," ",Cl.ltd.ltd]})]}),s.jsxs("button",{className:"pricing-plan-button",onClick:n?()=>Ba("ltd"):ls,disabled:Yt!=="free"||fe==="checkout"||fe==="auth"||a||R,type:"button",children:[s.jsx(Ao,{size:16}),Yt==="free"?n?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),s.jsxs("article",{className:`pricing-plan-card pro ${Yt==="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:Cl.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(Fn,{size:16})," 30+ workstation walls"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," Commercial use included"]}),s.jsxs("li",{children:[s.jsx(Fn,{size:16})," ",Cl.pro.ltd]})]}),s.jsxs("button",{className:"pricing-plan-button",onClick:n?()=>Ba("pro"):ls,disabled:Yt==="pro"||fe==="checkout"||fe==="auth"||a||R,type:"button",children:[s.jsx(Ao,{size:16}),Yt==="pro"?"Pro active":n?"Choose Pro":"Sign in for Pro"]})]})]}),s.jsxs("section",{className:"pricing-includes",children:[s.jsxs("div",{children:[s.jsx(an,{size:17}),s.jsx("span",{children:"Screen wall"}),s.jsx("strong",{children:"120+ slots"})]}),s.jsxs("div",{children:[s.jsx(Dd,{size:17}),s.jsx("span",{children:"Focused control"}),s.jsx("strong",{children:"Local-first"})]}),s.jsxs("div",{children:[s.jsx(ry,{size:17}),s.jsx("span",{children:"Remote audio"}),s.jsx("strong",{children:"Available"})]}),s.jsxs("div",{children:[s.jsx(No,{size:17}),s.jsx("span",{children:"File transfer"}),s.jsx("strong",{children:"Included"})]})]}),s.jsxs("p",{className:"pricing-note",children:[s.jsx(Fn,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),s.jsxs("button",{className:"pricing-primary-cta",onClick:n?()=>Ba(Yt==="ltd"?"pro":"ltd"):ls,disabled:yf,type:"button",children:[s.jsx(Ao,{size:18}),hu]})]}):s.jsx(s.Fragment,{children:s.jsxs("section",{className:`monitor-layout ${st?"dock-collapsed":""}`,children:[s.jsxs("section",{ref:$i,className:`screen-wall-panel ${Fl?"drop-active":""}`,onClick:y=>{y.currentTarget===y.target&&sa()},onDragEnter:y=>{y.preventDefault(),_a(!0)},onDragOver:y=>{y.preventDefault(),y.dataTransfer.dropEffect="copy"},onDragLeave:y=>{y.currentTarget===y.target&&_a(!1)},onDrop:Qo,children:[da.length>0&&s.jsx("canvas",{ref:lu,className:"atlas-source-canvas",width:ma?.width||1920,height:ma?.height||1080,"aria-hidden":"true"}),at?s.jsx("section",{className:"control-focus",children:s.jsxs("div",{className:"control-wall",children:[Ee&&Qs.length>1&&s.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:Qs.map(y=>s.jsxs("button",{className:y.index===cr?"active":"",onClick:()=>du(Ee.deviceId,y.index),title:iT(y),type:"button",children:[s.jsx("span",{children:y.name||`Display ${y.index+1}`}),y.width>0&&y.height>0&&s.jsxs("small",{children:[y.width,"x",y.height]})]},y.index))}),Ee?s.jsx(Sh,{device:Ee,frame:Me,selected:!1,controlEnabled:ns&&Se&&Ks,showStatus:dt.showScreenStatus,monitorIndex:Ea(Qt[Ee.deviceId],ga(Ee)),monitorCount:ga(Ee),onSelect:()=>{},onFocusDevice:()=>te(Ee.deviceId),onOpenControl:()=>lr(Ee.deviceId),onCycleMonitor:y=>Ha(Ee.deviceId,y),onCanvasReady:hf,sendInput:ir,presentationReady:Za},Ee.deviceId):s.jsxs("div",{className:"control-empty",children:[s.jsx(an,{size:30}),s.jsx("strong",{children:"No workstation"}),s.jsx("span",{children:"Open a workstation from the Wall."})]}),Ee&&ql&&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."})]}),Ee&&!ql&&!Za&&s.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[q!=="error"&&s.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),s.jsx("strong",{children:q==="error"?"Connection failed":"Connecting"}),s.jsx("small",{children:q==="error"?"See the notification for details. Reopen Control to retry.":nl||ue?"Control stream is recovering. See the notification for details.":ar==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):ft?s.jsx("div",{className:`screen-wall atlas-slot-wall size-${ge}`,onClick:y=>{y.currentTarget===y.target&&sa()},children:Wr.map((y,M)=>y?s.jsx(Sh,{device:y,frame:Jn.get(y.deviceId),selected:oi.has(y.deviceId),controlEnabled:!1,showStatus:He.showScreenStatus,monitorIndex:Ea(Qt[y.deviceId],ga(y)),monitorCount:ga(y),onSelect:()=>bs(y.deviceId),onFocusDevice:()=>aa(y.deviceId),onOpenControl:()=>lr(y.deviceId),onCycleMonitor:L=>Ha(y.deviceId,L),onCanvasReady:Nc({mode4Enabled:ft,directMode4WallEnabled:as,isMac:zi(y.platform)})==="direct"?iu:ou,sendInput:ir,updateIndicator:ml(y.deviceId),presentationReady:He.autoStartLive&&In.includes(y.deviceId)?qe.has(y.deviceId):void 0,showPresentationSpinner:He.autoStartLive&&In.includes(y.deviceId)},y.deviceId):s.jsx(Px,{index:M},`slot-${M}`))}):s.jsx("div",{className:`screen-wall size-${ge}`,onClick:y=>{y.currentTarget===y.target&&sa()},children:Wr.map((y,M)=>y?s.jsx(Sh,{device:y,frame:Jn.get(y.deviceId),selected:oi.has(y.deviceId),controlEnabled:ns&&Se&&Ks&&Ee?.deviceId===y.deviceId,showStatus:He.showScreenStatus,monitorIndex:Ea(Qt[y.deviceId],ga(y)),monitorCount:ga(y),onSelect:()=>bs(y.deviceId),onFocusDevice:()=>aa(y.deviceId),onOpenControl:()=>lr(y.deviceId),onCycleMonitor:L=>Ha(y.deviceId,L),onCanvasReady:iu,sendInput:ir,updateIndicator:ml(y.deviceId),presentationReady:He.autoStartLive&&In.includes(y.deviceId)?qe.has(y.deviceId):void 0,showPresentationSpinner:He.autoStartLive&&In.includes(y.deviceId)},y.deviceId):s.jsx(Px,{index:M},`slot-${M}`))}),s.jsx(RT,{visible:su&&!at})]}),!ts&&s.jsxs("aside",{className:`right-dock actions-mode ${st?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[s.jsx("button",{className:"dock-toggle",onClick:()=>gt(y=>!y),"aria-label":st?"Show control panel":"Hide control panel",title:st?"Show control panel":"Hide control panel",type:"button",children:st?s.jsx(Jx,{size:18}):s.jsx(Xh,{size:18})}),!st&&s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"action-dock",children:[s.jsx("input",{ref:vs,className:"hidden-file-input",type:"file",multiple:!0,onChange:y=>{y.currentTarget.files&&ws(y.currentTarget.files),y.currentTarget.value=""}}),s.jsxs("div",{className:"manual-action-bar",role:"toolbar","aria-label":"Manual workstation controls",children:[s.jsx(Dr,{label:"Control",tooltip:Ee?ql?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":ns?Ks?"Keyboard and mouse control is ready":"Waiting for the current Control capture session":"Remote control is not available on this workstation":"Select a workstation to use Control",onClick:()=>{if(Ee){if(at&&Se){_e(!1),Ie("Remote control paused. Screen viewing stays on.");return}lr(Ee.deviceId)}},disabled:!ns||!!Te,active:Se,pressed:at&&Se,children:s.jsx(Dd,{size:17})}),s.jsx(Dr,{label:"Audio",tooltip:Ee?Yr?re?"Stop hearing this workstation":"Hear this workstation":"Audio is not available on this workstation":"Select a workstation to use Audio",onClick:()=>{Ko()},disabled:!$o||!!Te,active:re,pressed:re,children:Te==="audio"?s.jsx(Js,{className:"spin",size:17}):s.jsx(ry,{size:17})}),s.jsx(Dr,{label:"Send files",tooltip:ua.length===0&&!at?"Select one or more workstations to send files":Ee?"Choose files and send them to the selected workstation":"Select a workstation to send files",onClick:()=>{Ie(`Choose files to send to ${Xo}.`),vs.current?.click()},disabled:!!Te||!It||(at?!Ee:ua.length===0),children:s.jsx(No,{size:17})}),s.jsx(Dr,{label:"Run command",tooltip:Ee?nu?"Run command":"Command runner is not available on this workstation":"Select a workstation to run a command",onClick:Gt,disabled:!Ee||!It||!!Te||!nu,children:s.jsx(Ld,{size:17})}),s.jsx(Dr,{label:"Restart",tooltip:Ee?tu?"Restart workstation":"Restart is not available on this workstation":"Select a workstation to restart",onClick:()=>{un("restart")},disabled:!Ee||!It||!!Te||!tu,children:Te==="restart"?s.jsx(Js,{className:"spin",size:17}):s.jsx(_c,{size:17})}),s.jsx(Dr,{label:"Lock",tooltip:Ee?"Lock workstation":"Select a workstation to lock",onClick:()=>{un("lock")},disabled:!Ee||!It||!!Te,children:Te==="lock"?s.jsx(Js,{className:"spin",size:17}):s.jsx(Ts,{size:17})}),s.jsx(Dr,{label:"Sleep",tooltip:Ee?"Put workstation to sleep":"Select a workstation to put to sleep",onClick:()=>{un("sleep")},disabled:!Ee||!It||!!Te,children:Te==="sleep"?s.jsx(Js,{className:"spin",size:17}):s.jsx(h0,{size:17})}),s.jsx(Dr,{label:"Shut down",tooltip:Ee?"Shut down workstation":"Select a workstation to shut down",onClick:()=>{un("shutdown")},disabled:!Ee||!It||!!Te,danger:!0,children:Te==="shutdown"?s.jsx(Js,{className:"spin",size:17}):s.jsx(p0,{size:17})})]})]}),s.jsx(vx,{hubUrl:N,devices:C,variant:"dock",selectedDeviceIds:ul})]})]})]})})]}),ii&&s.jsxs("aside",{className:`transfer-bar state-${ii.status}`,"aria-live":"polite",children:[s.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:ii.status==="queued"?s.jsx(Fn,{size:18}):ii.status==="failed"?s.jsx(Ya,{size:18}):s.jsx(Qx,{size:18})}),s.jsxs("div",{className:"transfer-bar-copy",children:[s.jsx("p",{children:ii.message}),s.jsx("div",{className:"transfer-bar-track",children:s.jsx("span",{style:{width:`${Math.max(0,Math.min(100,ii.progress))}%`}})})]}),s.jsxs("strong",{children:[Math.max(0,Math.min(100,ii.progress)),"%"]})]}),We&&s.jsxs("aside",{className:`livedesk-toast tone-${We.tone}`,role:We.tone==="error"?"alert":"status","aria-live":We.tone==="error"?"assertive":"polite","aria-busy":We.tone==="progress",children:[We.tone==="progress"&&s.jsx("span",{className:"livedesk-toast-spinner","aria-hidden":"true"}),s.jsx("span",{children:We.message}),s.jsx("button",{className:"livedesk-toast-close",onClick:()=>Ie(""),type:"button","aria-label":"Dismiss notification",title:"Dismiss notification",children:s.jsx(Ya,{size:15})})]})]})}function LT(){if(typeof window>"u")return[];const n=window.location.origin;return window.location.port==="5179"?[n]:["http://127.0.0.1:5179"]}function _T(){const[a,r]=u.useState(null);return u.useEffect(()=>{let l=!1,c=!1;const d=async()=>{for(const g of LT())try{const v=await fetch(`${g}/api/runtime`,{cache:"no-store"});if(!v.ok)continue;const x=(await v.json()).role==="hub"?"hub":"client";c=!0,l||r(x);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(bC,{}):s.jsx(DT,{}):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..."})]})}C0.createRoot(document.getElementById("root")).render(s.jsx(u.StrictMode,{children:s.jsx(_T,{})}));
|