livedesk 0.1.301 → 0.1.302

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ import{r as eS,a as f,R as fr,D as wc,C as Mh,b as On,W as bc,S as gy,K as Sc,c as en,A as Zt,d as Sd,L as Ai,M as Jt,e as tS,f as Ec,g as or,F as ao,B as _v,T as nS,h as aS,i as Nh,j as jc,m as Th,H as mc,U as sS,N as Eh,k as vy,l as iS,n as jd,o as zv,p as Rh,q as xy,s as Ld,t as yy,u as hd,v as ro,w as Cc,X as Ps,x as lS,y as oo,z as wy,E as rS,G as by,I as oS,J as cS,O as uS,P as ih,Q as dS,V as fS,Y as mS,Z as hS,_ as pS,$ as hc,a0 as Iv,a1 as gS,a2 as vS,a3 as xS,a4 as yS,a5 as wS,a6 as bS,a7 as SS,a8 as jS,a9 as CS,aa as Sy,ab as kS,ac as AS,ad as Ov,ae as MS,af as NS,ag as pd,ah as pc,ai as lh,aj as gc,ak as TS,al as Cm,am as ES,an as RS,ao as DS,ap as Bv,aq as Jl,ar as LS,as as Fv,at as jy,au as Hv,av as _S}from"./icons-CdkvkkTQ.js";import{r as Cy}from"./react-B-tFFyG1.js";import{c as zS}from"./supabase-C7qjtLN3.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const m of u.addedNodes)m.tagName==="LINK"&&m.rel==="modulepreload"&&r(m)}).observe(document,{childList:!0,subtree:!0});function l(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(c){if(c.ep)return;c.ep=!0;const u=l(c);fetch(c.href,u)}})();var km={exports:{}},oc={};var Pv;function IS(){if(Pv)return oc;Pv=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function l(r,c,u){var m=null;if(u!==void 0&&(m=""+u),c.key!==void 0&&(m=""+c.key),"key"in c){u={};for(var p in c)p!=="key"&&(u[p]=c[p])}else u=c;return c=u.ref,{$$typeof:n,type:r,key:m,ref:c!==void 0?c:null,props:u}}return oc.Fragment=a,oc.jsx=l,oc.jsxs=l,oc}var $v;function OS(){return $v||($v=1,km.exports=IS()),km.exports}var i=OS(),Am={exports:{}},cc={},Mm={exports:{}},Nm={};var Uv;function BS(){return Uv||(Uv=1,(function(n){function a(z,Q){var X=z.length;z.push(Q);e:for(;0<X;){var P=X-1>>>1,le=z[P];if(0<c(le,Q))z[P]=Q,z[X]=le,X=P;else break e}}function l(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var Q=z[0],X=z.pop();if(X!==Q){z[0]=X;e:for(var P=0,le=z.length,we=le>>>1;P<we;){var L=2*(P+1)-1,$=z[L],xe=L+1,Se=z[xe];if(0>c($,X))xe<le&&0>c(Se,$)?(z[P]=Se,z[xe]=X,P=xe):(z[P]=$,z[L]=X,P=L);else if(xe<le&&0>c(Se,X))z[P]=Se,z[xe]=X,P=xe;else break e}}return Q}function c(z,Q){var X=z.sortIndex-Q.sortIndex;return X!==0?X:z.id-Q.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;n.unstable_now=function(){return u.now()}}else{var m=Date,p=m.now();n.unstable_now=function(){return m.now()-p}}var v=[],g=[],w=1,y=null,b=3,j=!1,C=!1,A=!1,T=!1,k=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function U(z){for(var Q=l(g);Q!==null;){if(Q.callback===null)r(g);else if(Q.startTime<=z)r(g),Q.sortIndex=Q.expirationTime,a(v,Q);else break;Q=l(g)}}function F(z){if(A=!1,U(z),!C)if(l(v)!==null)C=!0,V||(V=!0,K());else{var Q=l(g);Q!==null&&W(F,Q.startTime-z)}}var V=!1,_=-1,I=5,me=-1;function Y(){return T?!0:!(n.unstable_now()-me<I)}function ue(){if(T=!1,V){var z=n.unstable_now();me=z;var Q=!0;try{e:{C=!1,A&&(A=!1,E(_),_=-1),j=!0;var X=b;try{t:{for(U(z),y=l(v);y!==null&&!(y.expirationTime>z&&Y());){var P=y.callback;if(typeof P=="function"){y.callback=null,b=y.priorityLevel;var le=P(y.expirationTime<=z);if(z=n.unstable_now(),typeof le=="function"){y.callback=le,U(z),Q=!0;break t}y===l(v)&&r(v),U(z)}else r(v);y=l(v)}if(y!==null)Q=!0;else{var we=l(g);we!==null&&W(F,we.startTime-z),Q=!1}}break e}finally{y=null,b=X,j=!1}Q=void 0}}finally{Q?K():V=!1}}}var K;if(typeof R=="function")K=function(){R(ue)};else if(typeof MessageChannel<"u"){var ie=new MessageChannel,ee=ie.port2;ie.port1.onmessage=ue,K=function(){ee.postMessage(null)}}else K=function(){k(ue,0)};function W(z,Q){_=k(function(){z(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(z){z.callback=null},n.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<z?Math.floor(1e3/z):5},n.unstable_getCurrentPriorityLevel=function(){return b},n.unstable_next=function(z){switch(b){case 1:case 2:case 3:var Q=3;break;default:Q=b}var X=b;b=Q;try{return z()}finally{b=X}},n.unstable_requestPaint=function(){T=!0},n.unstable_runWithPriority=function(z,Q){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var X=b;b=z;try{return Q()}finally{b=X}},n.unstable_scheduleCallback=function(z,Q,X){var P=n.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?P+X:P):X=P,z){case 1:var le=-1;break;case 2:le=250;break;case 5:le=1073741823;break;case 4:le=1e4;break;default:le=5e3}return le=X+le,z={id:w++,callback:Q,priorityLevel:z,startTime:X,expirationTime:le,sortIndex:-1},X>P?(z.sortIndex=X,a(g,z),l(v)===null&&z===l(g)&&(A?(E(_),_=-1):A=!0,W(F,X-P))):(z.sortIndex=le,a(v,z),C||j||(C=!0,V||(V=!0,K()))),z},n.unstable_shouldYield=Y,n.unstable_wrapCallback=function(z){var Q=b;return function(){var X=b;b=Q;try{return z.apply(this,arguments)}finally{b=X}}}})(Nm)),Nm}var qv;function FS(){return qv||(qv=1,Mm.exports=BS()),Mm.exports}var Gv;function HS(){if(Gv)return cc;Gv=1;var n=FS(),a=eS(),l=Cy();function r(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var s=2;s<arguments.length;s++)t+="&args[]="+encodeURIComponent(arguments[s])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var t=e,s=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(s=t.return),e=t.return;while(e)}return t.tag===3?s:null}function m(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function p(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function v(e){if(u(e)!==e)throw Error(r(188))}function g(e){var t=e.alternate;if(!t){if(t=u(e),t===null)throw Error(r(188));return t!==e?null:e}for(var s=e,o=t;;){var d=s.return;if(d===null)break;var h=d.alternate;if(h===null){if(o=d.return,o!==null){s=o;continue}break}if(d.child===h.child){for(h=d.child;h;){if(h===s)return v(d),e;if(h===o)return v(d),t;h=h.sibling}throw Error(r(188))}if(s.return!==o.return)s=d,o=h;else{for(var S=!1,N=d.child;N;){if(N===s){S=!0,s=d,o=h;break}if(N===o){S=!0,o=d,s=h;break}N=N.sibling}if(!S){for(N=h.child;N;){if(N===s){S=!0,s=h,o=d;break}if(N===o){S=!0,o=h,s=d;break}N=N.sibling}if(!S)throw Error(r(189))}}if(s.alternate!==o)throw Error(r(190))}if(s.tag!==3)throw Error(r(188));return s.stateNode.current===s?e:t}function w(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=w(e),t!==null)return t;e=e.sibling}return null}var y=Object.assign,b=Symbol.for("react.element"),j=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),R=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),V=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),me=Symbol.for("react.activity"),Y=Symbol.for("react.memo_cache_sentinel"),ue=Symbol.iterator;function K(e){return e===null||typeof e!="object"?null:(e=ue&&e[ue]||e["@@iterator"],typeof e=="function"?e:null)}var ie=Symbol.for("react.client.reference");function ee(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ie?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case A:return"Fragment";case k:return"Profiler";case T:return"StrictMode";case F:return"Suspense";case V:return"SuspenseList";case me:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case C:return"Portal";case R:return e.displayName||"Context";case E:return(e._context.displayName||"Context")+".Consumer";case 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:ee(e.type)||"Memo";case I:t=e._payload,e=e._init;try{return ee(e(t))}catch{}}return null}var W=Array.isArray,z=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},P=[],le=-1;function we(e){return{current:e}}function L(e){0>le||(e.current=P[le],P[le]=null,le--)}function $(e,t){le++,P[le]=e.current,e.current=t}var xe=we(null),Se=we(null),fe=we(null),Te=we(null);function Ie(e,t){switch($(fe,t),$(Se,e),$(xe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?av(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=av(t),e=sv(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}L(xe),$(xe,e)}function oe(){L(xe),L(Se),L(fe)}function Ye(e){e.memoizedState!==null&&$(Te,e);var t=xe.current,s=sv(t,e.type);t!==s&&($(Se,e),$(xe,s))}function De(e){Se.current===e&&(L(xe),L(Se)),Te.current===e&&(L(Te),sc._currentValue=X)}var We,D;function ne(e){if(We===void 0)try{throw Error()}catch(s){var t=s.stack.trim().match(/\n( *(at )?)/);We=t&&t[1]||"",D=-1<s.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<s.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+We+e+D}var je=!1;function te(e,t){if(!e||je)return"";je=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(t){var be=function(){throw Error()};if(Object.defineProperty(be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(be,[])}catch(de){var re=de}Reflect.construct(e,[],be)}else{try{be.call()}catch(de){re=de}e.call(be.prototype)}}else{try{throw Error()}catch(de){re=de}(be=e())&&typeof be.catch=="function"&&be.catch(function(){})}}catch(de){if(de&&re&&typeof de.stack=="string")return[de.stack,re.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var h=o.DetermineComponentFrameRoot(),S=h[0],N=h[1];if(S&&N){var H=S.split(`
4
+ `),se=N.split(`
5
+ `);for(d=o=0;o<H.length&&!H[o].includes("DetermineComponentFrameRoot");)o++;for(;d<se.length&&!se[d].includes("DetermineComponentFrameRoot");)d++;if(o===H.length||d===se.length)for(o=H.length-1,d=se.length-1;1<=o&&0<=d&&H[o]!==se[d];)d--;for(;1<=o&&0<=d;o--,d--)if(H[o]!==se[d]){if(o!==1||d!==1)do if(o--,d--,0>d||H[o]!==se[d]){var pe=`
6
+ `+H[o].replace(" at new "," at ");return e.displayName&&pe.includes("<anonymous>")&&(pe=pe.replace("<anonymous>",e.displayName)),pe}while(1<=o&&0<=d);break}}}finally{je=!1,Error.prepareStackTrace=s}return(s=e?e.displayName||e.name:"")?ne(s):""}function ce(e,t){switch(e.tag){case 26:case 27:case 5:return ne(e.type);case 16:return ne("Lazy");case 13:return e.child!==t&&t!==null?ne("Suspense Fallback"):ne("Suspense");case 19:return ne("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 ne("Activity");default:return""}}function Me(e){try{var t="",s=null;do t+=ce(e,s),s=e,e=e.return;while(e);return t}catch(o){return`
7
+ Error generating stack: `+o.message+`
8
+ `+o.stack}}var Ce=Object.prototype.hasOwnProperty,it=n.unstable_scheduleCallback,he=n.unstable_cancelCallback,Fe=n.unstable_shouldYield,Le=n.unstable_requestPaint,Ge=n.unstable_now,ea=n.unstable_getCurrentPriorityLevel,gn=n.unstable_ImmediatePriority,kn=n.unstable_UserBlockingPriority,Yn=n.unstable_NormalPriority,Ml=n.unstable_LowPriority,Da=n.unstable_IdlePriority,Bn=n.log,mr=n.unstable_setDisableYieldValue,ys=null,mt=null;function An(e){if(typeof Bn=="function"&&mr(e),mt&&typeof mt.setStrictMode=="function")try{mt.setStrictMode(ys,e)}catch{}}var Ne=Math.clz32?Math.clz32:hr,Nl=Math.log,Je=Math.LN2;function hr(e){return e>>>=0,e===0?32:31-(Nl(e)/Je|0)|0}var kt=256,La=262144,Gt=4194304;function Wn(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 ga(e,t,s){var o=e.pendingLanes;if(o===0)return 0;var d=0,h=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var N=o&134217727;return N!==0?(o=N&~h,o!==0?d=Wn(o):(S&=N,S!==0?d=Wn(S):s||(s=N&~e,s!==0&&(d=Wn(s))))):(N=o&~h,N!==0?d=Wn(N):S!==0?d=Wn(S):s||(s=o&~e,s!==0&&(d=Wn(s)))),d===0?0:t!==0&&t!==d&&(t&h)===0&&(h=d&-d,s=t&-t,h>=s||h===32&&(s&4194048)!==0)?t:d}function _a(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Vt(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 qs(){var e=Gt;return Gt<<=1,(Gt&62914560)===0&&(Gt=4194304),e}function ws(e){for(var t=[],s=0;31>s;s++)t.push(e);return t}function bs(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function pr(e,t,s,o,d,h){var S=e.pendingLanes;e.pendingLanes=s,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=s,e.entangledLanes&=s,e.errorRecoveryDisabledLanes&=s,e.shellSuspendCounter=0;var N=e.entanglements,H=e.expirationTimes,se=e.hiddenUpdates;for(s=S&~s;0<s;){var pe=31-Ne(s),be=1<<pe;N[pe]=0,H[pe]=-1;var re=se[pe];if(re!==null)for(se[pe]=null,pe=0;pe<re.length;pe++){var de=re[pe];de!==null&&(de.lane&=-536870913)}s&=~be}o!==0&&gr(e,o,0),h!==0&&d===0&&e.tag!==0&&(e.suspendedLanes|=h&~(S&~t))}function gr(e,t,s){e.pendingLanes|=t,e.suspendedLanes&=~t;var o=31-Ne(t);e.entangledLanes|=t,e.entanglements[o]=e.entanglements[o]|1073741824|s&261930}function za(e,t){var s=e.entangledLanes|=t;for(e=e.entanglements;s;){var o=31-Ne(s),d=1<<o;d&t|e[o]&t&&(e[o]|=t),s&=~d}}function Ss(e,t){var s=t&-t;return s=(s&42)!==0?1:Mn(s),(s&(e.suspendedLanes|t))!==0?0:s}function Mn(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 ta(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function tn(){var e=Q.p;return e!==0?e:(e=window.event,e===void 0?32:Mv(e.type))}function Gs(e,t){var s=Q.p;try{return Q.p=e,t()}finally{Q.p=s}}var Nn=Math.random().toString(36).slice(2),J="__reactFiber$"+Nn,ke="__reactProps$"+Nn,_e="__reactContainer$"+Nn,Ke="__reactEvents$"+Nn,xt="__reactListeners$"+Nn,gt="__reactHandles$"+Nn,$e="__reactResources$"+Nn,dt="__reactMarker$"+Nn;function nn(e){delete e[J],delete e[ke],delete e[Ke],delete e[xt],delete e[gt]}function Ft(e){var t=e[J];if(t)return t;for(var s=e.parentNode;s;){if(t=s[_e]||s[J]){if(s=t.alternate,t.child!==null||s!==null&&s.child!==null)for(e=dv(e);e!==null;){if(s=e[J])return s;e=dv(e)}return t}e=s,s=e.parentNode}return null}function Tn(e){if(e=e[J]||e[_e]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function At(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(r(33))}function Ht(e){var t=e[$e];return t||(t=e[$e]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Dt(e){e[dt]=!0}var js=new Set,vn={};function Yt(e,t){bt(e,t),bt(e+"Capture",t)}function bt(e,t){for(vn[e]=t,e=0;e<t.length;e++)js.add(t[e])}var Ia=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]*$"),Ja={},es={};function Tl(e){return Ce.call(es,e)?!0:Ce.call(Ja,e)?!1:Ia.test(e)?es[e]=!0:(Ja[e]=!0,!1)}function Vs(e,t,s){if(Tl(t))if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var o=t.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+s)}}function Cs(e,t,s){if(s===null)e.removeAttribute(t);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+s)}}function Fn(e,t,s,o){if(o===null)e.removeAttribute(s);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(s);return}e.setAttributeNS(t,s,""+o)}}function un(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vr(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function El(e,t,s){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var d=o.get,h=o.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return d.call(this)},set:function(S){s=""+S,h.call(this,S)}}),Object.defineProperty(e,t,{enumerable:o.enumerable}),{getValue:function(){return s},setValue:function(S){s=""+S},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ni(e){if(!e._valueTracker){var t=vr(e)?"checked":"value";e._valueTracker=El(e,t,""+e[t])}}function Rl(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var s=t.getValue(),o="";return e&&(o=vr(e)?e.checked?"true":"false":e.value),e=o,e!==s?(t.setValue(e),!0):!1}function Ys(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 fo=/[\n"\\]/g;function Kn(e){return e.replace(fo,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Oa(e,t,s,o,d,h,S,N){e.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?e.type=S:e.removeAttribute("type"),t!=null?S==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+un(t)):e.value!==""+un(t)&&(e.value=""+un(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?Ba(e,S,un(t)):s!=null?Ba(e,S,un(s)):o!=null&&e.removeAttribute("value"),d==null&&h!=null&&(e.defaultChecked=!!h),d!=null&&(e.checked=d&&typeof d!="function"&&typeof d!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?e.name=""+un(N):e.removeAttribute("name")}function ks(e,t,s,o,d,h,S,N){if(h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.type=h),t!=null||s!=null){if(!(h!=="submit"&&h!=="reset"||t!=null)){Ni(e);return}s=s!=null?""+un(s):"",t=t!=null?""+un(t):s,N||t===e.value||(e.value=t),e.defaultValue=t}o=o??d,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=N?e.checked:!!o,e.defaultChecked=!!o,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),Ni(e)}function Ba(e,t,s){t==="number"&&Ys(e.ownerDocument)===e||e.defaultValue===""+s||(e.defaultValue=""+s)}function Ti(e,t,s,o){if(e=e.options,t){t={};for(var d=0;d<s.length;d++)t["$"+s[d]]=!0;for(s=0;s<e.length;s++)d=t.hasOwnProperty("$"+e[s].value),e[s].selected!==d&&(e[s].selected=d),d&&o&&(e[s].defaultSelected=!0)}else{for(s=""+un(s),t=null,d=0;d<e.length;d++){if(e[d].value===s){e[d].selected=!0,o&&(e[d].defaultSelected=!0);return}t!==null||e[d].disabled||(t=e[d])}t!==null&&(t.selected=!0)}}function xr(e,t,s){if(t!=null&&(t=""+un(t),t!==e.value&&(e.value=t),s==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=s!=null?""+un(s):""}function $d(e,t,s,o){if(t==null){if(o!=null){if(s!=null)throw Error(r(92));if(W(o)){if(1<o.length)throw Error(r(93));o=o[0]}s=o}s==null&&(s=""),t=s}s=un(t),e.defaultValue=s,o=e.textContent,o===s&&o!==""&&o!==null&&(e.value=o),Ni(e)}function Ei(e,t){if(t){var s=e.firstChild;if(s&&s===e.lastChild&&s.nodeType===3){s.nodeValue=t;return}}e.textContent=t}var Ri=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 Oc(e,t,s){var o=t.indexOf("--")===0;s==null||typeof s=="boolean"||s===""?o?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":o?e.setProperty(t,s):typeof s!="number"||s===0||Ri.has(t)?t==="float"?e.cssFloat=s:e[t]=(""+s).trim():e[t]=s+"px"}function Ws(e,t,s){if(t!=null&&typeof t!="object")throw Error(r(62));if(e=e.style,s!=null){for(var o in s)!s.hasOwnProperty(o)||t!=null&&t.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var d in t)o=t[d],t.hasOwnProperty(d)&&s[d]!==o&&Oc(e,d,o)}else for(var h in t)t.hasOwnProperty(h)&&Oc(e,h,t[h])}function Dl(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 Xh=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"]]),Zh=/^[\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 mo(e){return Zh.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ts(){}var yr=null;function wr(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Di=null,Li=null;function Bc(e){var t=Tn(e);if(t&&(e=t.stateNode)){var s=e[ke]||null;e:switch(e=t.stateNode,t.type){case"input":if(Oa(e,s.value,s.defaultValue,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name),t=s.name,s.type==="radio"&&t!=null){for(s=e;s.parentNode;)s=s.parentNode;for(s=s.querySelectorAll('input[name="'+Kn(""+t)+'"][type="radio"]'),t=0;t<s.length;t++){var o=s[t];if(o!==e&&o.form===e.form){var d=o[ke]||null;if(!d)throw Error(r(90));Oa(o,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(t=0;t<s.length;t++)o=s[t],o.form===e.form&&Rl(o)}break e;case"textarea":xr(e,s.value,s.defaultValue);break e;case"select":t=s.value,t!=null&&Ti(e,!!s.multiple,t,!1)}}}var Ll=!1;function ho(e,t,s){if(Ll)return e(t,s);Ll=!0;try{var o=e(t);return o}finally{if(Ll=!1,(Di!==null||Li!==null)&&(Mu(),Di&&(t=Di,e=Li,Li=Di=null,Bc(t),e)))for(t=0;t<e.length;t++)Bc(e[t])}}function ns(e,t){var s=e.stateNode;if(s===null)return null;var o=s[ke]||null;if(o===null)return null;s=o[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(s&&typeof s!="function")throw Error(r(231,t,typeof s));return s}var xn=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_i=!1;if(xn)try{var zi={};Object.defineProperty(zi,"passive",{get:function(){_i=!0}}),window.addEventListener("test",zi,zi),window.removeEventListener("test",zi,zi)}catch{_i=!1}var as=null,br=null,As=null;function po(){if(As)return As;var e,t=br,s=t.length,o,d="value"in as?as.value:as.textContent,h=d.length;for(e=0;e<s&&t[e]===d[e];e++);var S=s-e;for(o=1;o<=S&&t[s-o]===d[h-o];o++);return As=d.slice(e,1<o?1-o:void 0)}function _l(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 Ve(){return!0}function at(){return!1}function Et(e){function t(s,o,d,h,S){this._reactName=s,this._targetInst=d,this.type=o,this.nativeEvent=h,this.target=S,this.currentTarget=null;for(var N in e)e.hasOwnProperty(N)&&(s=e[N],this[N]=s?s(h):h[N]);return this.isDefaultPrevented=(h.defaultPrevented!=null?h.defaultPrevented:h.returnValue===!1)?Ve:at,this.isPropagationStopped=at,this}return y(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var s=this.nativeEvent;s&&(s.preventDefault?s.preventDefault():typeof s.returnValue!="unknown"&&(s.returnValue=!1),this.isDefaultPrevented=Ve)},stopPropagation:function(){var s=this.nativeEvent;s&&(s.stopPropagation?s.stopPropagation():typeof s.cancelBubble!="unknown"&&(s.cancelBubble=!0),this.isPropagationStopped=Ve)},persist:function(){},isPersistent:Ve}),t}var ss={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},va=Et(ss),Qe=y({},ss,{view:0,detail:0}),Fc=Et(Qe),go,Ii,is,Oi=y({},Qe,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ls,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!==is&&(is&&e.type==="mousemove"?(go=e.screenX-is.screenX,Ii=e.screenY-is.screenY):Ii=go=0,is=e),go)},movementY:function(e){return"movementY"in e?e.movementY:Ii}}),Ks=Et(Oi),xa=y({},Oi,{dataTransfer:0}),Bi=Et(xa),En=y({},Qe,{relatedTarget:0}),Fi=Et(En),Ee=y({},ss,{animationName:0,elapsedTime:0,pseudoElement:0}),Hc=Et(Ee),Ud=y({},ss,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Fa=Et(Ud),qd=y({},ss,{data:0}),Pc=Et(qd),zl={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rt={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"},$c={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Sr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=$c[e])?!!t[e]:!1}function ls(){return Sr}var Gd=y({},Qe,{key:function(e){if(e.key){var t=zl[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_l(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Rt[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ls,charCode:function(e){return e.type==="keypress"?_l(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_l(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Vd=Et(Gd),Wt=y({},Oi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qs=Et(Wt),Yd=y({},Qe,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ls}),Uc=Et(Yd),rs=y({},ss,{propertyName:0,elapsedTime:0,pseudoElement:0}),qc=Et(rs),jr=y({},Oi,{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}),Xs=Et(jr),Ha=y({},ss,{newState:0,oldState:0}),dn=Et(Ha),Wd=[9,13,27,32],Cr=xn&&"CompositionEvent"in window,Pa=null;xn&&"documentMode"in document&&(Pa=document.documentMode);var Kd=xn&&"TextEvent"in window&&!Pa,Pt=xn&&(!Cr||Pa&&8<Pa&&11>=Pa),Ms=" ",Il=!1;function Ol(e,t){switch(e){case"keyup":return Wd.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function $a(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Hi=!1;function Qd(e,t){switch(e){case"compositionend":return $a(t);case"keypress":return t.which!==32?null:(Il=!0,Ms);case"textInput":return e=t.data,e===Ms&&Il?null:e;default:return null}}function kr(e,t){if(Hi)return e==="compositionend"||!Cr&&Ol(e,t)?(e=po(),As=br=as=null,Hi=!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 Pt&&t.locale!=="ko"?null:t.data;default:return null}}var Ar={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 vo(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!Ar[e.type]:t==="textarea"}function Zs(e,t,s,o){Di?Li?Li.push(o):Li=[o]:Di=o,t=_u(t,"onChange"),0<t.length&&(s=new va("onChange","change",null,s,o),e.push({event:s,listeners:t}))}var Pi=null,$i=null;function Xd(e){Xg(e,0)}function os(e){var t=At(e);if(Rl(t))return e}function Gc(e,t){if(e==="change")return t}var xo=!1;if(xn){var yo;if(xn){var wo="oninput"in document;if(!wo){var Vc=document.createElement("div");Vc.setAttribute("oninput","return;"),wo=typeof Vc.oninput=="function"}yo=wo}else yo=!1;xo=yo&&(!document.documentMode||9<document.documentMode)}function bo(){Pi&&(Pi.detachEvent("onpropertychange",Ui),$i=Pi=null)}function Ui(e){if(e.propertyName==="value"&&os($i)){var t=[];Zs(t,$i,e,wr(e)),ho(Xd,t)}}function Yc(e,t,s){e==="focusin"?(bo(),Pi=t,$i=s,Pi.attachEvent("onpropertychange",Ui)):e==="focusout"&&bo()}function Ns(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return os($i)}function Mr(e,t){if(e==="click")return os(t)}function qi(e,t){if(e==="input"||e==="change")return os(t)}function Js(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Rn=typeof Object.is=="function"?Object.is:Js;function Bl(e,t){if(Rn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(o=0;o<s.length;o++){var d=s[o];if(!Ce.call(t,d)||!Rn(e[d],t[d]))return!1}return!0}function So(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Nr(e,t){var s=So(e);e=0;for(var o;s;){if(s.nodeType===3){if(o=e+s.textContent.length,e<=t&&o>=t)return{node:s,offset:t-e};e=o}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=So(s)}}function Tr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Tr(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Gi(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Ys(e.document);t instanceof e.HTMLIFrameElement;){try{var s=typeof t.contentWindow.location.href=="string"}catch{s=!1}if(s)e=t.contentWindow;else break;t=Ys(e.document)}return t}function jo(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 Er=xn&&"documentMode"in document&&11>=document.documentMode,ei=null,Vi=null,ti=null,Fl=!1;function Hl(e,t,s){var o=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;Fl||ei==null||ei!==Ys(o)||(o=ei,"selectionStart"in o&&jo(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}),ti&&Bl(ti,o)||(ti=o,o=_u(Vi,"onSelect"),0<o.length&&(t=new va("onSelect","select",null,t,s),e.push({event:t,listeners:o}),t.target=ei)))}function Ua(e,t){var s={};return s[e.toLowerCase()]=t.toLowerCase(),s["Webkit"+e]="webkit"+t,s["Moz"+e]="moz"+t,s}var Ts={animationend:Ua("Animation","AnimationEnd"),animationiteration:Ua("Animation","AnimationIteration"),animationstart:Ua("Animation","AnimationStart"),transitionrun:Ua("Transition","TransitionRun"),transitionstart:Ua("Transition","TransitionStart"),transitioncancel:Ua("Transition","TransitionCancel"),transitionend:Ua("Transition","TransitionEnd")},Rr={},ni={};xn&&(ni=document.createElement("div").style,"AnimationEvent"in window||(delete Ts.animationend.animation,delete Ts.animationiteration.animation,delete Ts.animationstart.animation),"TransitionEvent"in window||delete Ts.transitionend.transition);function na(e){if(Rr[e])return Rr[e];if(!Ts[e])return e;var t=Ts[e],s;for(s in t)if(t.hasOwnProperty(s)&&s in ni)return Rr[e]=t[s];return e}var Pl=na("animationend"),Yi=na("animationiteration"),ya=na("animationstart"),Wc=na("transitionrun"),Co=na("transitionstart"),Kc=na("transitioncancel"),yn=na("transitionend"),ko=new Map,$l="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(" ");$l.push("scrollEnd");function Qn(e,t){ko.set(e,t),Yt(t,[e])}var Es=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)},aa=[],wa=0,Ao=0;function Dr(){for(var e=wa,t=Ao=wa=0;t<e;){var s=aa[t];aa[t++]=null;var o=aa[t];aa[t++]=null;var d=aa[t];aa[t++]=null;var h=aa[t];if(aa[t++]=null,o!==null&&d!==null){var S=o.pending;S===null?d.next=d:(d.next=S.next,S.next=d),o.pending=d}h!==0&&Mo(s,d,h)}}function ai(e,t,s,o){aa[wa++]=e,aa[wa++]=t,aa[wa++]=s,aa[wa++]=o,Ao|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Lr(e,t,s,o){return ai(e,t,s,o),Wi(e)}function ba(e,t){return ai(e,null,null,t),Wi(e)}function Mo(e,t,s){e.lanes|=s;var o=e.alternate;o!==null&&(o.lanes|=s);for(var d=!1,h=e.return;h!==null;)h.childLanes|=s,o=h.alternate,o!==null&&(o.childLanes|=s),h.tag===22&&(e=h.stateNode,e===null||e._visibility&1||(d=!0)),e=h,h=h.return;return e.tag===3?(h=e.stateNode,d&&t!==null&&(d=31-Ne(s),e=h.hiddenUpdates,o=e[d],o===null?e[d]=[t]:o.push(t),t.lane=s|536870912),h):null}function Wi(e){if(50<Xo)throw Xo=0,Wf=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var si={};function Zd(e,t,s,o){this.tag=e,this.key=s,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Dn(e,t,s,o){return new Zd(e,t,s,o)}function No(e){return e=e.prototype,!(!e||!e.isReactComponent)}function qa(e,t){var s=e.alternate;return s===null?(s=Dn(e.tag,t,e.key,e.mode),s.elementType=e.elementType,s.type=e.type,s.stateNode=e.stateNode,s.alternate=e,e.alternate=s):(s.pendingProps=t,s.type=e.type,s.flags=0,s.subtreeFlags=0,s.deletions=null),s.flags=e.flags&65011712,s.childLanes=e.childLanes,s.lanes=e.lanes,s.child=e.child,s.memoizedProps=e.memoizedProps,s.memoizedState=e.memoizedState,s.updateQueue=e.updateQueue,t=e.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},s.sibling=e.sibling,s.index=e.index,s.ref=e.ref,s.refCleanup=e.refCleanup,s}function To(e,t){e.flags&=65011714;var s=e.alternate;return s===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=s.childLanes,e.lanes=s.lanes,e.child=s.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=s.memoizedProps,e.memoizedState=s.memoizedState,e.updateQueue=s.updateQueue,e.type=s.type,t=s.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Ul(e,t,s,o,d,h){var S=0;if(o=e,typeof e=="function")No(e)&&(S=1);else if(typeof e=="string")S=$b(e,s,xe.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case me:return e=Dn(31,s,t,d),e.elementType=me,e.lanes=h,e;case A:return ii(s.children,d,h,t);case T:S=8,d|=24;break;case k:return e=Dn(12,s,t,d|2),e.elementType=k,e.lanes=h,e;case F:return e=Dn(13,s,t,d),e.elementType=F,e.lanes=h,e;case V:return e=Dn(19,s,t,d),e.elementType=V,e.lanes=h,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:S=10;break e;case E:S=9;break e;case U:S=11;break e;case _:S=14;break e;case I:S=16,o=null;break e}S=29,s=Error(r(130,e===null?"null":typeof e,"")),o=null}return t=Dn(S,s,t,d),t.elementType=e,t.type=o,t.lanes=h,t}function ii(e,t,s,o){return e=Dn(7,e,o,t),e.lanes=s,e}function Ki(e,t,s){return e=Dn(6,e,null,t),e.lanes=s,e}function cs(e){var t=Dn(18,null,null,0);return t.stateNode=e,t}function Qi(e,t,s){return t=Dn(4,e.children!==null?e.children:[],e.key,t),t.lanes=s,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Qc=new WeakMap;function Hn(e,t){if(typeof e=="object"&&e!==null){var s=Qc.get(e);return s!==void 0?s:(t={value:e,source:t,stack:Me(t)},Qc.set(e,t),t)}return{value:e,source:t,stack:Me(t)}}var Rs=[],Ae=0,li=null,Xi=0,sa=[],Sa=0,Ga=null,Va=1,Xn="";function Mt(e,t){Rs[Ae++]=Xi,Rs[Ae++]=li,li=e,Xi=t}function Pn(e,t,s){sa[Sa++]=Va,sa[Sa++]=Xn,sa[Sa++]=Ga,Ga=e;var o=Va;e=Xn;var d=32-Ne(o)-1;o&=~(1<<d),s+=1;var h=32-Ne(t)+d;if(30<h){var S=d-d%5;h=(o&(1<<S)-1).toString(32),o>>=S,d-=S,Va=1<<32-Ne(t)+d|s<<d|o,Xn=h+e}else Va=1<<h|s<<d|o,Xn=e}function st(e){e.return!==null&&(Mt(e,1),Pn(e,1,0))}function Eo(e){for(;e===li;)li=Rs[--Ae],Rs[Ae]=null,Xi=Rs[--Ae],Rs[Ae]=null;for(;e===Ga;)Ga=sa[--Sa],sa[Sa]=null,Xn=sa[--Sa],sa[Sa]=null,Va=sa[--Sa],sa[Sa]=null}function Xc(e,t){sa[Sa++]=Va,sa[Sa++]=Xn,sa[Sa++]=Ga,Va=t.id,Xn=t.overflow,Ga=e}var fn=null,Nt=null,lt=!1,Ds=null,ia=!1,Ro=Error(r(519));function Ls(e){var t=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ql(Hn(t,e)),Ro}function Zc(e){var t=e.stateNode,s=e.type,o=e.memoizedProps;switch(t[J]=e,t[ke]=o,s){case"dialog":ot("cancel",t),ot("close",t);break;case"iframe":case"object":case"embed":ot("load",t);break;case"video":case"audio":for(s=0;s<Jo.length;s++)ot(Jo[s],t);break;case"source":ot("error",t);break;case"img":case"image":case"link":ot("error",t),ot("load",t);break;case"details":ot("toggle",t);break;case"input":ot("invalid",t),ks(t,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":ot("invalid",t);break;case"textarea":ot("invalid",t),$d(t,o.value,o.defaultValue,o.children)}s=o.children,typeof s!="string"&&typeof s!="number"&&typeof s!="bigint"||t.textContent===""+s||o.suppressHydrationWarning===!0||tv(t.textContent,s)?(o.popover!=null&&(ot("beforetoggle",t),ot("toggle",t)),o.onScroll!=null&&ot("scroll",t),o.onScrollEnd!=null&&ot("scrollend",t),o.onClick!=null&&(t.onclick=ts),t=!0):t=!1,t||Ls(e,!0)}function Jc(e){for(fn=e.return;fn;)switch(fn.tag){case 5:case 31:case 13:ia=!1;return;case 27:case 3:ia=!0;return;default:fn=fn.return}}function Zi(e){if(e!==fn)return!1;if(!lt)return Jc(e),lt=!0,!1;var t=e.tag,s;if((s=t!==3&&t!==27)&&((s=t===5)&&(s=e.type,s=!(s!=="form"&&s!=="button")||cm(e.type,e.memoizedProps)),s=!s),s&&Nt&&Ls(e),Jc(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Nt=uv(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(317));Nt=uv(e)}else t===27?(t=Nt,fl(e.type)?(e=hm,hm=null,Nt=e):Nt=t):Nt=fn?Ka(e.stateNode.nextSibling):null;return!0}function ri(){Nt=fn=null,lt=!1}function Do(){var e=Ds;return e!==null&&(ca===null?ca=e:ca.push.apply(ca,e),Ds=null),e}function ql(e){Ds===null?Ds=[e]:Ds.push(e)}var Lo=we(null),us=null,ja=null;function _s(e,t,s){$(Lo,t._currentValue),t._currentValue=s}function ds(e){e._currentValue=Lo.current,L(Lo)}function _o(e,t,s){for(;e!==null;){var o=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,o!==null&&(o.childLanes|=t)):o!==null&&(o.childLanes&t)!==t&&(o.childLanes|=t),e===s)break;e=e.return}}function zo(e,t,s,o){var d=e.child;for(d!==null&&(d.return=e);d!==null;){var h=d.dependencies;if(h!==null){var S=d.child;h=h.firstContext;e:for(;h!==null;){var N=h;h=d;for(var H=0;H<t.length;H++)if(N.context===t[H]){h.lanes|=s,N=h.alternate,N!==null&&(N.lanes|=s),_o(h.return,s,e),o||(S=null);break e}h=N.next}}else if(d.tag===18){if(S=d.return,S===null)throw Error(r(341));S.lanes|=s,h=S.alternate,h!==null&&(h.lanes|=s),_o(S,s,e),S=null}else S=d.child;if(S!==null)S.return=d;else for(S=d;S!==null;){if(S===e){S=null;break}if(d=S.sibling,d!==null){d.return=S.return,S=d;break}S=S.return}d=S}}function Ji(e,t,s,o){e=null;for(var d=t,h=!1;d!==null;){if(!h){if((d.flags&524288)!==0)h=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var S=d.alternate;if(S===null)throw Error(r(387));if(S=S.memoizedProps,S!==null){var N=d.type;Rn(d.pendingProps.value,S.value)||(e!==null?e.push(N):e=[N])}}else if(d===Te.current){if(S=d.alternate,S===null)throw Error(r(387));S.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(e!==null?e.push(sc):e=[sc])}d=d.return}e!==null&&zo(t,e,s,o),t.flags|=262144}function _r(e){for(e=e.firstContext;e!==null;){if(!Rn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function oi(e){us=e,ja=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function mn(e){return ci(us,e)}function zr(e,t){return us===null&&oi(e),ci(e,t)}function ci(e,t){var s=t._currentValue;if(t={context:t,memoizedValue:s,next:null},ja===null){if(e===null)throw Error(r(308));ja=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ja=ja.next=t;return s}var eu=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(s,o){e.push(o)}};this.abort=function(){t.aborted=!0,e.forEach(function(s){return s()})}},Io=n.unstable_scheduleCallback,Jd=n.unstable_NormalPriority,$t={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Ir(){return{controller:new eu,data:new Map,refCount:0}}function zs(e){e.refCount--,e.refCount===0&&Io(Jd,function(){e.controller.abort()})}var Gl=null,hn=0,fs=0,ui=null;function ef(e,t){if(Gl===null){var s=Gl=[];hn=0,fs=em(),ui={status:"pending",value:void 0,then:function(o){s.push(o)}}}return hn++,t.then(tf,tf),t}function tf(){if(--hn===0&&Gl!==null){ui!==null&&(ui.status="fulfilled");var e=Gl;Gl=null,fs=0,ui=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function nf(e,t){var s=[],o={status:"pending",value:null,reason:null,then:function(d){s.push(d)}};return e.then(function(){o.status="fulfilled",o.value=t;for(var d=0;d<s.length;d++)(0,s[d])(t)},function(d){for(o.status="rejected",o.reason=d,d=0;d<s.length;d++)(0,s[d])(void 0)}),o}var tu=z.S;z.S=function(e,t){kg=Ge(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&ef(e,t),tu!==null&&tu(e,t)};var Is=we(null);function el(){var e=Is.current;return e!==null?e:Tt.pooledCache}function Os(e,t){t===null?$(Is,Is.current):$(Is,t.pool)}function Oo(){var e=el();return e===null?null:{parent:$t._currentValue,pool:e}}var tl=Error(r(460)),Bo=Error(r(474)),Or=Error(r(542)),Br={then:function(){}};function nu(e){return e=e.status,e==="fulfilled"||e==="rejected"}function au(e,t,s){switch(s=e[s],s===void 0?e.push(t):s!==t&&(t.then(ts,ts),t=s),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,iu(e),e;default:if(typeof t.status=="string")t.then(ts,ts);else{if(e=Tt,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status="pending",e.then(function(o){if(t.status==="pending"){var d=t;d.status="fulfilled",d.value=o}},function(o){if(t.status==="pending"){var d=t;d.status="rejected",d.reason=o}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,iu(e),e}throw an=t,tl}}function di(e){try{var t=e._init;return t(e._payload)}catch(s){throw s!==null&&typeof s=="object"&&typeof s.then=="function"?(an=s,tl):s}}var an=null;function su(){if(an===null)throw Error(r(459));var e=an;return an=null,e}function iu(e){if(e===tl||e===Or)throw Error(r(483))}var Ca=null,Vl=0;function nl(e){var t=Vl;return Vl+=1,Ca===null&&(Ca=[]),au(Ca,e,t)}function Yl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Wl(e,t){throw t.$$typeof===b?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function x(e){function t(Z,G){if(e){var ae=Z.deletions;ae===null?(Z.deletions=[G],Z.flags|=16):ae.push(G)}}function s(Z,G){if(!e)return null;for(;G!==null;)t(Z,G),G=G.sibling;return null}function o(Z){for(var G=new Map;Z!==null;)Z.key!==null?G.set(Z.key,Z):G.set(Z.index,Z),Z=Z.sibling;return G}function d(Z,G){return Z=qa(Z,G),Z.index=0,Z.sibling=null,Z}function h(Z,G,ae){return Z.index=ae,e?(ae=Z.alternate,ae!==null?(ae=ae.index,ae<G?(Z.flags|=67108866,G):ae):(Z.flags|=67108866,G)):(Z.flags|=1048576,G)}function S(Z){return e&&Z.alternate===null&&(Z.flags|=67108866),Z}function N(Z,G,ae,ye){return G===null||G.tag!==6?(G=Ki(ae,Z.mode,ye),G.return=Z,G):(G=d(G,ae),G.return=Z,G)}function H(Z,G,ae,ye){var Ue=ae.type;return Ue===A?pe(Z,G,ae.props.children,ye,ae.key):G!==null&&(G.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===I&&di(Ue)===G.type)?(G=d(G,ae.props),Yl(G,ae),G.return=Z,G):(G=Ul(ae.type,ae.key,ae.props,null,Z.mode,ye),Yl(G,ae),G.return=Z,G)}function se(Z,G,ae,ye){return G===null||G.tag!==4||G.stateNode.containerInfo!==ae.containerInfo||G.stateNode.implementation!==ae.implementation?(G=Qi(ae,Z.mode,ye),G.return=Z,G):(G=d(G,ae.children||[]),G.return=Z,G)}function pe(Z,G,ae,ye,Ue){return G===null||G.tag!==7?(G=ii(ae,Z.mode,ye,Ue),G.return=Z,G):(G=d(G,ae),G.return=Z,G)}function be(Z,G,ae){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Ki(""+G,Z.mode,ae),G.return=Z,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case j:return ae=Ul(G.type,G.key,G.props,null,Z.mode,ae),Yl(ae,G),ae.return=Z,ae;case C:return G=Qi(G,Z.mode,ae),G.return=Z,G;case I:return G=di(G),be(Z,G,ae)}if(W(G)||K(G))return G=ii(G,Z.mode,ae,null),G.return=Z,G;if(typeof G.then=="function")return be(Z,nl(G),ae);if(G.$$typeof===R)return be(Z,zr(Z,G),ae);Wl(Z,G)}return null}function re(Z,G,ae,ye){var Ue=G!==null?G.key:null;if(typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint")return Ue!==null?null:N(Z,G,""+ae,ye);if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case j:return ae.key===Ue?H(Z,G,ae,ye):null;case C:return ae.key===Ue?se(Z,G,ae,ye):null;case I:return ae=di(ae),re(Z,G,ae,ye)}if(W(ae)||K(ae))return Ue!==null?null:pe(Z,G,ae,ye,null);if(typeof ae.then=="function")return re(Z,G,nl(ae),ye);if(ae.$$typeof===R)return re(Z,G,zr(Z,ae),ye);Wl(Z,ae)}return null}function de(Z,G,ae,ye,Ue){if(typeof ye=="string"&&ye!==""||typeof ye=="number"||typeof ye=="bigint")return Z=Z.get(ae)||null,N(G,Z,""+ye,Ue);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case j:return Z=Z.get(ye.key===null?ae:ye.key)||null,H(G,Z,ye,Ue);case C:return Z=Z.get(ye.key===null?ae:ye.key)||null,se(G,Z,ye,Ue);case I:return ye=di(ye),de(Z,G,ae,ye,Ue)}if(W(ye)||K(ye))return Z=Z.get(ae)||null,pe(G,Z,ye,Ue,null);if(typeof ye.then=="function")return de(Z,G,ae,nl(ye),Ue);if(ye.$$typeof===R)return de(Z,G,ae,zr(G,ye),Ue);Wl(G,ye)}return null}function Oe(Z,G,ae,ye){for(var Ue=null,ht=null,He=G,nt=G=0,ut=null;He!==null&&nt<ae.length;nt++){He.index>nt?(ut=He,He=null):ut=He.sibling;var pt=re(Z,He,ae[nt],ye);if(pt===null){He===null&&(He=ut);break}e&&He&&pt.alternate===null&&t(Z,He),G=h(pt,G,nt),ht===null?Ue=pt:ht.sibling=pt,ht=pt,He=ut}if(nt===ae.length)return s(Z,He),lt&&Mt(Z,nt),Ue;if(He===null){for(;nt<ae.length;nt++)He=be(Z,ae[nt],ye),He!==null&&(G=h(He,G,nt),ht===null?Ue=He:ht.sibling=He,ht=He);return lt&&Mt(Z,nt),Ue}for(He=o(He);nt<ae.length;nt++)ut=de(He,Z,nt,ae[nt],ye),ut!==null&&(e&&ut.alternate!==null&&He.delete(ut.key===null?nt:ut.key),G=h(ut,G,nt),ht===null?Ue=ut:ht.sibling=ut,ht=ut);return e&&He.forEach(function(vl){return t(Z,vl)}),lt&&Mt(Z,nt),Ue}function qe(Z,G,ae,ye){if(ae==null)throw Error(r(151));for(var Ue=null,ht=null,He=G,nt=G=0,ut=null,pt=ae.next();He!==null&&!pt.done;nt++,pt=ae.next()){He.index>nt?(ut=He,He=null):ut=He.sibling;var vl=re(Z,He,pt.value,ye);if(vl===null){He===null&&(He=ut);break}e&&He&&vl.alternate===null&&t(Z,He),G=h(vl,G,nt),ht===null?Ue=vl:ht.sibling=vl,ht=vl,He=ut}if(pt.done)return s(Z,He),lt&&Mt(Z,nt),Ue;if(He===null){for(;!pt.done;nt++,pt=ae.next())pt=be(Z,pt.value,ye),pt!==null&&(G=h(pt,G,nt),ht===null?Ue=pt:ht.sibling=pt,ht=pt);return lt&&Mt(Z,nt),Ue}for(He=o(He);!pt.done;nt++,pt=ae.next())pt=de(He,Z,nt,pt.value,ye),pt!==null&&(e&&pt.alternate!==null&&He.delete(pt.key===null?nt:pt.key),G=h(pt,G,nt),ht===null?Ue=pt:ht.sibling=pt,ht=pt);return e&&He.forEach(function(Jb){return t(Z,Jb)}),lt&&Mt(Z,nt),Ue}function Ct(Z,G,ae,ye){if(typeof ae=="object"&&ae!==null&&ae.type===A&&ae.key===null&&(ae=ae.props.children),typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case j:e:{for(var Ue=ae.key;G!==null;){if(G.key===Ue){if(Ue=ae.type,Ue===A){if(G.tag===7){s(Z,G.sibling),ye=d(G,ae.props.children),ye.return=Z,Z=ye;break e}}else if(G.elementType===Ue||typeof Ue=="object"&&Ue!==null&&Ue.$$typeof===I&&di(Ue)===G.type){s(Z,G.sibling),ye=d(G,ae.props),Yl(ye,ae),ye.return=Z,Z=ye;break e}s(Z,G);break}else t(Z,G);G=G.sibling}ae.type===A?(ye=ii(ae.props.children,Z.mode,ye,ae.key),ye.return=Z,Z=ye):(ye=Ul(ae.type,ae.key,ae.props,null,Z.mode,ye),Yl(ye,ae),ye.return=Z,Z=ye)}return S(Z);case C:e:{for(Ue=ae.key;G!==null;){if(G.key===Ue)if(G.tag===4&&G.stateNode.containerInfo===ae.containerInfo&&G.stateNode.implementation===ae.implementation){s(Z,G.sibling),ye=d(G,ae.children||[]),ye.return=Z,Z=ye;break e}else{s(Z,G);break}else t(Z,G);G=G.sibling}ye=Qi(ae,Z.mode,ye),ye.return=Z,Z=ye}return S(Z);case I:return ae=di(ae),Ct(Z,G,ae,ye)}if(W(ae))return Oe(Z,G,ae,ye);if(K(ae)){if(Ue=K(ae),typeof Ue!="function")throw Error(r(150));return ae=Ue.call(ae),qe(Z,G,ae,ye)}if(typeof ae.then=="function")return Ct(Z,G,nl(ae),ye);if(ae.$$typeof===R)return Ct(Z,G,zr(Z,ae),ye);Wl(Z,ae)}return typeof ae=="string"&&ae!==""||typeof ae=="number"||typeof ae=="bigint"?(ae=""+ae,G!==null&&G.tag===6?(s(Z,G.sibling),ye=d(G,ae),ye.return=Z,Z=ye):(s(Z,G),ye=Ki(ae,Z.mode,ye),ye.return=Z,Z=ye),S(Z)):s(Z,G)}return function(Z,G,ae,ye){try{Vl=0;var Ue=Ct(Z,G,ae,ye);return Ca=null,Ue}catch(He){if(He===tl||He===Or)throw He;var ht=Dn(29,He,null,Z.mode);return ht.lanes=ye,ht.return=Z,ht}}}var M=x(!0),O=x(!1),q=!1;function B(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ve(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 ge(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Re(e,t,s){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(vt&2)!==0){var d=o.pending;return d===null?t.next=t:(t.next=d.next,d.next=t),o.pending=t,t=Wi(e),Mo(e,null,s),t}return ai(e,o,t,s),Wi(e)}function Pe(e,t,s){if(t=t.updateQueue,t!==null&&(t=t.shared,(s&4194048)!==0)){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,za(e,s)}}function Xe(e,t){var s=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,s===o)){var d=null,h=null;if(s=s.firstBaseUpdate,s!==null){do{var S={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};h===null?d=h=S:h=h.next=S,s=s.next}while(s!==null);h===null?d=h=t:h=h.next=t}else d=h=t;s={baseState:o.baseState,firstBaseUpdate:d,lastBaseUpdate:h,shared:o.shared,callbacks:o.callbacks},e.updateQueue=s;return}e=s.lastBaseUpdate,e===null?s.firstBaseUpdate=t:e.next=t,s.lastBaseUpdate=t}var Lt=!1;function sn(){if(Lt){var e=ui;if(e!==null)throw e}}function Ln(e,t,s,o){Lt=!1;var d=e.updateQueue;q=!1;var h=d.firstBaseUpdate,S=d.lastBaseUpdate,N=d.shared.pending;if(N!==null){d.shared.pending=null;var H=N,se=H.next;H.next=null,S===null?h=se:S.next=se,S=H;var pe=e.alternate;pe!==null&&(pe=pe.updateQueue,N=pe.lastBaseUpdate,N!==S&&(N===null?pe.firstBaseUpdate=se:N.next=se,pe.lastBaseUpdate=H))}if(h!==null){var be=d.baseState;S=0,pe=se=H=null,N=h;do{var re=N.lane&-536870913,de=re!==N.lane;if(de?(ct&re)===re:(o&re)===re){re!==0&&re===fs&&(Lt=!0),pe!==null&&(pe=pe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var Oe=e,qe=N;re=t;var Ct=s;switch(qe.tag){case 1:if(Oe=qe.payload,typeof Oe=="function"){be=Oe.call(Ct,be,re);break e}be=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=qe.payload,re=typeof Oe=="function"?Oe.call(Ct,be,re):Oe,re==null)break e;be=y({},be,re);break e;case 2:q=!0}}re=N.callback,re!==null&&(e.flags|=64,de&&(e.flags|=8192),de=d.callbacks,de===null?d.callbacks=[re]:de.push(re))}else de={lane:re,tag:N.tag,payload:N.payload,callback:N.callback,next:null},pe===null?(se=pe=de,H=be):pe=pe.next=de,S|=re;if(N=N.next,N===null){if(N=d.shared.pending,N===null)break;de=N,N=de.next,de.next=null,d.lastBaseUpdate=de,d.shared.pending=null}}while(!0);pe===null&&(H=be),d.baseState=H,d.firstBaseUpdate=se,d.lastBaseUpdate=pe,h===null&&(d.shared.lanes=0),rl|=S,e.lanes=S,e.memoizedState=be}}function ms(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function Bs(e,t){var s=e.callbacks;if(s!==null)for(e.callbacks=null,e=0;e<s.length;e++)ms(s[e],t)}var Ya=we(null),fi=we(0);function lu(e,t){e=bi,$(fi,e),$(Ya,t),bi=e|t.baseLanes}function af(){$(fi,bi),$(Ya,Ya.current)}function sf(){bi=fi.current,L(Ya),L(fi)}var ka=we(null),Wa=null;function al(e){var t=e.alternate;$(Kt,Kt.current&1),$(ka,e),Wa===null&&(t===null||Ya.current!==null||t.memoizedState!==null)&&(Wa=e)}function lf(e){$(Kt,Kt.current),$(ka,e),Wa===null&&(Wa=e)}function Jh(e){e.tag===22?($(Kt,Kt.current),$(ka,e),Wa===null&&(Wa=e)):sl()}function sl(){$(Kt,Kt.current),$(ka,ka.current)}function Aa(e){L(ka),Wa===e&&(Wa=null),L(Kt)}var Kt=we(0);function ru(e){for(var t=e;t!==null;){if(t.tag===13){var s=t.memoizedState;if(s!==null&&(s=s.dehydrated,s===null||fm(s)||mm(s)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var mi=0,et=null,St=null,ln=null,ou=!1,Fr=!1,Kl=!1,cu=0,Fo=0,Hr=null,Uw=0;function Ut(){throw Error(r(321))}function rf(e,t){if(t===null)return!1;for(var s=0;s<t.length&&s<e.length;s++)if(!Rn(e[s],t[s]))return!1;return!0}function of(e,t,s,o,d,h){return mi=h,et=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,z.H=e===null||e.memoizedState===null?Ip:jf,Kl=!1,h=s(o,d),Kl=!1,Fr&&(h=tp(t,s,o,d)),ep(e),h}function ep(e){z.H=$o;var t=St!==null&&St.next!==null;if(mi=0,ln=St=et=null,ou=!1,Fo=0,Hr=null,t)throw Error(r(300));e===null||rn||(e=e.dependencies,e!==null&&_r(e)&&(rn=!0))}function tp(e,t,s,o){et=e;var d=0;do{if(Fr&&(Hr=null),Fo=0,Fr=!1,25<=d)throw Error(r(301));if(d+=1,ln=St=null,e.updateQueue!=null){var h=e.updateQueue;h.lastEffect=null,h.events=null,h.stores=null,h.memoCache!=null&&(h.memoCache.index=0)}z.H=Op,h=t(s,o)}while(Fr);return h}function qw(){var e=z.H,t=e.useState()[0];return t=typeof t.then=="function"?Ho(t):t,e=e.useState()[0],(St!==null?St.memoizedState:null)!==e&&(et.flags|=1024),t}function cf(){var e=cu!==0;return cu=0,e}function uf(e,t,s){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s}function df(e){if(ou){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ou=!1}mi=0,ln=St=et=null,Fr=!1,Fo=cu=0,Hr=null}function Zn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ln===null?et.memoizedState=ln=e:ln=ln.next=e,ln}function Qt(){if(St===null){var e=et.alternate;e=e!==null?e.memoizedState:null}else e=St.next;var t=ln===null?et.memoizedState:ln.next;if(t!==null)ln=t,St=e;else{if(e===null)throw et.alternate===null?Error(r(467)):Error(r(310));St=e,e={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},ln===null?et.memoizedState=ln=e:ln=ln.next=e}return ln}function uu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ho(e){var t=Fo;return Fo+=1,Hr===null&&(Hr=[]),e=au(Hr,e,t),t=et,(ln===null?t.memoizedState:ln.next)===null&&(t=t.alternate,z.H=t===null||t.memoizedState===null?Ip:jf),e}function du(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Ho(e);if(e.$$typeof===R)return mn(e)}throw Error(r(438,String(e)))}function ff(e){var t=null,s=et.updateQueue;if(s!==null&&(t=s.memoCache),t==null){var o=et.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(t={data:o.data.map(function(d){return d.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),s===null&&(s=uu(),et.updateQueue=s),s.memoCache=t,s=t.data[t.index],s===void 0)for(s=t.data[t.index]=Array(e),o=0;o<e;o++)s[o]=Y;return t.index++,s}function hi(e,t){return typeof t=="function"?t(e):t}function fu(e){var t=Qt();return mf(t,St,e)}function mf(e,t,s){var o=e.queue;if(o===null)throw Error(r(311));o.lastRenderedReducer=s;var d=e.baseQueue,h=o.pending;if(h!==null){if(d!==null){var S=d.next;d.next=h.next,h.next=S}t.baseQueue=d=h,o.pending=null}if(h=e.baseState,d===null)e.memoizedState=h;else{t=d.next;var N=S=null,H=null,se=t,pe=!1;do{var be=se.lane&-536870913;if(be!==se.lane?(ct&be)===be:(mi&be)===be){var re=se.revertLane;if(re===0)H!==null&&(H=H.next={lane:0,revertLane:0,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null}),be===fs&&(pe=!0);else if((mi&re)===re){se=se.next,re===fs&&(pe=!0);continue}else be={lane:0,revertLane:se.revertLane,gesture:null,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},H===null?(N=H=be,S=h):H=H.next=be,et.lanes|=re,rl|=re;be=se.action,Kl&&s(h,be),h=se.hasEagerState?se.eagerState:s(h,be)}else re={lane:be,revertLane:se.revertLane,gesture:se.gesture,action:se.action,hasEagerState:se.hasEagerState,eagerState:se.eagerState,next:null},H===null?(N=H=re,S=h):H=H.next=re,et.lanes|=be,rl|=be;se=se.next}while(se!==null&&se!==t);if(H===null?S=h:H.next=N,!Rn(h,e.memoizedState)&&(rn=!0,pe&&(s=ui,s!==null)))throw s;e.memoizedState=h,e.baseState=S,e.baseQueue=H,o.lastRenderedState=h}return d===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function hf(e){var t=Qt(),s=t.queue;if(s===null)throw Error(r(311));s.lastRenderedReducer=e;var o=s.dispatch,d=s.pending,h=t.memoizedState;if(d!==null){s.pending=null;var S=d=d.next;do h=e(h,S.action),S=S.next;while(S!==d);Rn(h,t.memoizedState)||(rn=!0),t.memoizedState=h,t.baseQueue===null&&(t.baseState=h),s.lastRenderedState=h}return[h,o]}function np(e,t,s){var o=et,d=Qt(),h=lt;if(h){if(s===void 0)throw Error(r(407));s=s()}else s=t();var S=!Rn((St||d).memoizedState,s);if(S&&(d.memoizedState=s,rn=!0),d=d.queue,vf(ip.bind(null,o,d,e),[e]),d.getSnapshot!==t||S||ln!==null&&ln.memoizedState.tag&1){if(o.flags|=2048,Pr(9,{destroy:void 0},sp.bind(null,o,d,s,t),null),Tt===null)throw Error(r(349));h||(mi&127)!==0||ap(o,t,s)}return s}function ap(e,t,s){e.flags|=16384,e={getSnapshot:t,value:s},t=et.updateQueue,t===null?(t=uu(),et.updateQueue=t,t.stores=[e]):(s=t.stores,s===null?t.stores=[e]:s.push(e))}function sp(e,t,s,o){t.value=s,t.getSnapshot=o,lp(t)&&rp(e)}function ip(e,t,s){return s(function(){lp(t)&&rp(e)})}function lp(e){var t=e.getSnapshot;e=e.value;try{var s=t();return!Rn(e,s)}catch{return!0}}function rp(e){var t=ba(e,2);t!==null&&ua(t,e,2)}function pf(e){var t=Zn();if(typeof e=="function"){var s=e;if(e=s(),Kl){An(!0);try{s()}finally{An(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:e},t}function op(e,t,s,o){return e.baseState=s,mf(e,St,typeof o=="function"?o:hi)}function Gw(e,t,s,o,d){if(pu(e))throw Error(r(485));if(e=t.action,e!==null){var h={payload:d,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){h.listeners.push(S)}};z.T!==null?s(!0):h.isTransition=!1,o(h),s=t.pending,s===null?(h.next=t.pending=h,cp(t,h)):(h.next=s.next,t.pending=s.next=h)}}function cp(e,t){var s=t.action,o=t.payload,d=e.state;if(t.isTransition){var h=z.T,S={};z.T=S;try{var N=s(d,o),H=z.S;H!==null&&H(S,N),up(e,t,N)}catch(se){gf(e,t,se)}finally{h!==null&&S.types!==null&&(h.types=S.types),z.T=h}}else try{h=s(d,o),up(e,t,h)}catch(se){gf(e,t,se)}}function up(e,t,s){s!==null&&typeof s=="object"&&typeof s.then=="function"?s.then(function(o){dp(e,t,o)},function(o){return gf(e,t,o)}):dp(e,t,s)}function dp(e,t,s){t.status="fulfilled",t.value=s,fp(t),e.state=s,t=e.pending,t!==null&&(s=t.next,s===t?e.pending=null:(s=s.next,t.next=s,cp(e,s)))}function gf(e,t,s){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do t.status="rejected",t.reason=s,fp(t),t=t.next;while(t!==o)}e.action=null}function fp(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function mp(e,t){return t}function hp(e,t){if(lt){var s=Tt.formState;if(s!==null){e:{var o=et;if(lt){if(Nt){t:{for(var d=Nt,h=ia;d.nodeType!==8;){if(!h){d=null;break t}if(d=Ka(d.nextSibling),d===null){d=null;break t}}h=d.data,d=h==="F!"||h==="F"?d:null}if(d){Nt=Ka(d.nextSibling),o=d.data==="F!";break e}}Ls(o)}o=!1}o&&(t=s[0])}}return s=Zn(),s.memoizedState=s.baseState=t,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:mp,lastRenderedState:t},s.queue=o,s=Lp.bind(null,et,o),o.dispatch=s,o=pf(!1),h=Sf.bind(null,et,!1,o.queue),o=Zn(),d={state:t,dispatch:null,action:e,pending:null},o.queue=d,s=Gw.bind(null,et,d,h,s),d.dispatch=s,o.memoizedState=e,[t,s,!1]}function pp(e){var t=Qt();return gp(t,St,e)}function gp(e,t,s){if(t=mf(e,t,mp)[0],e=fu(hi)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var o=Ho(t)}catch(S){throw S===tl?Or:S}else o=t;t=Qt();var d=t.queue,h=d.dispatch;return s!==t.memoizedState&&(et.flags|=2048,Pr(9,{destroy:void 0},Vw.bind(null,d,s),null)),[o,h,e]}function Vw(e,t){e.action=t}function vp(e){var t=Qt(),s=St;if(s!==null)return gp(t,s,e);Qt(),t=t.memoizedState,s=Qt();var o=s.queue.dispatch;return s.memoizedState=e,[t,o,!1]}function Pr(e,t,s,o){return e={tag:e,create:s,deps:o,inst:t,next:null},t=et.updateQueue,t===null&&(t=uu(),et.updateQueue=t),s=t.lastEffect,s===null?t.lastEffect=e.next=e:(o=s.next,s.next=e,e.next=o,t.lastEffect=e),e}function xp(){return Qt().memoizedState}function mu(e,t,s,o){var d=Zn();et.flags|=e,d.memoizedState=Pr(1|t,{destroy:void 0},s,o===void 0?null:o)}function hu(e,t,s,o){var d=Qt();o=o===void 0?null:o;var h=d.memoizedState.inst;St!==null&&o!==null&&rf(o,St.memoizedState.deps)?d.memoizedState=Pr(t,h,s,o):(et.flags|=e,d.memoizedState=Pr(1|t,h,s,o))}function yp(e,t){mu(8390656,8,e,t)}function vf(e,t){hu(2048,8,e,t)}function Yw(e){et.flags|=4;var t=et.updateQueue;if(t===null)t=uu(),et.updateQueue=t,t.events=[e];else{var s=t.events;s===null?t.events=[e]:s.push(e)}}function wp(e){var t=Qt().memoizedState;return Yw({ref:t,nextImpl:e}),function(){if((vt&2)!==0)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function bp(e,t){return hu(4,2,e,t)}function Sp(e,t){return hu(4,4,e,t)}function jp(e,t){if(typeof t=="function"){e=e();var s=t(e);return function(){typeof s=="function"?s():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Cp(e,t,s){s=s!=null?s.concat([e]):null,hu(4,4,jp.bind(null,t,e),s)}function xf(){}function kp(e,t){var s=Qt();t=t===void 0?null:t;var o=s.memoizedState;return t!==null&&rf(t,o[1])?o[0]:(s.memoizedState=[e,t],e)}function Ap(e,t){var s=Qt();t=t===void 0?null:t;var o=s.memoizedState;if(t!==null&&rf(t,o[1]))return o[0];if(o=e(),Kl){An(!0);try{e()}finally{An(!1)}}return s.memoizedState=[o,t],o}function yf(e,t,s){return s===void 0||(mi&1073741824)!==0&&(ct&261930)===0?e.memoizedState=t:(e.memoizedState=s,e=Mg(),et.lanes|=e,rl|=e,s)}function Mp(e,t,s,o){return Rn(s,t)?s:Ya.current!==null?(e=yf(e,s,o),Rn(e,t)||(rn=!0),e):(mi&42)===0||(mi&1073741824)!==0&&(ct&261930)===0?(rn=!0,e.memoizedState=s):(e=Mg(),et.lanes|=e,rl|=e,t)}function Np(e,t,s,o,d){var h=Q.p;Q.p=h!==0&&8>h?h:8;var S=z.T,N={};z.T=N,Sf(e,!1,t,s);try{var H=d(),se=z.S;if(se!==null&&se(N,H),H!==null&&typeof H=="object"&&typeof H.then=="function"){var pe=nf(H,o);Po(e,t,pe,Ta(e))}else Po(e,t,o,Ta(e))}catch(be){Po(e,t,{then:function(){},status:"rejected",reason:be},Ta())}finally{Q.p=h,S!==null&&N.types!==null&&(S.types=N.types),z.T=S}}function Ww(){}function wf(e,t,s,o){if(e.tag!==5)throw Error(r(476));var d=Tp(e).queue;Np(e,d,t,X,s===null?Ww:function(){return Ep(e),s(o)})}function Tp(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:X},next:null};var s={};return t.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:hi,lastRenderedState:s},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ep(e){var t=Tp(e);t.next===null&&(t=e.alternate.memoizedState),Po(e,t.next.queue,{},Ta())}function bf(){return mn(sc)}function Rp(){return Qt().memoizedState}function Dp(){return Qt().memoizedState}function Kw(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var s=Ta();e=ge(s);var o=Re(t,e,s);o!==null&&(ua(o,t,s),Pe(o,t,s)),t={cache:Ir()},e.payload=t;return}t=t.return}}function Qw(e,t,s){var o=Ta();s={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},pu(e)?_p(t,s):(s=Lr(e,t,s,o),s!==null&&(ua(s,e,o),zp(s,t,o)))}function Lp(e,t,s){var o=Ta();Po(e,t,s,o)}function Po(e,t,s,o){var d={lane:o,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(pu(e))_p(t,d);else{var h=e.alternate;if(e.lanes===0&&(h===null||h.lanes===0)&&(h=t.lastRenderedReducer,h!==null))try{var S=t.lastRenderedState,N=h(S,s);if(d.hasEagerState=!0,d.eagerState=N,Rn(N,S))return ai(e,t,d,0),Tt===null&&Dr(),!1}catch{}if(s=Lr(e,t,d,o),s!==null)return ua(s,e,o),zp(s,t,o),!0}return!1}function Sf(e,t,s,o){if(o={lane:2,revertLane:em(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},pu(e)){if(t)throw Error(r(479))}else t=Lr(e,s,o,2),t!==null&&ua(t,e,2)}function pu(e){var t=e.alternate;return e===et||t!==null&&t===et}function _p(e,t){Fr=ou=!0;var s=e.pending;s===null?t.next=t:(t.next=s.next,s.next=t),e.pending=t}function zp(e,t,s){if((s&4194048)!==0){var o=t.lanes;o&=e.pendingLanes,s|=o,t.lanes=s,za(e,s)}}var $o={readContext:mn,use:du,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};$o.useEffectEvent=Ut;var Ip={readContext:mn,use:du,useCallback:function(e,t){return Zn().memoizedState=[e,t===void 0?null:t],e},useContext:mn,useEffect:yp,useImperativeHandle:function(e,t,s){s=s!=null?s.concat([e]):null,mu(4194308,4,jp.bind(null,t,e),s)},useLayoutEffect:function(e,t){return mu(4194308,4,e,t)},useInsertionEffect:function(e,t){mu(4,2,e,t)},useMemo:function(e,t){var s=Zn();t=t===void 0?null:t;var o=e();if(Kl){An(!0);try{e()}finally{An(!1)}}return s.memoizedState=[o,t],o},useReducer:function(e,t,s){var o=Zn();if(s!==void 0){var d=s(t);if(Kl){An(!0);try{s(t)}finally{An(!1)}}}else d=t;return o.memoizedState=o.baseState=d,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:d},o.queue=e,e=e.dispatch=Qw.bind(null,et,e),[o.memoizedState,e]},useRef:function(e){var t=Zn();return e={current:e},t.memoizedState=e},useState:function(e){e=pf(e);var t=e.queue,s=Lp.bind(null,et,t);return t.dispatch=s,[e.memoizedState,s]},useDebugValue:xf,useDeferredValue:function(e,t){var s=Zn();return yf(s,e,t)},useTransition:function(){var e=pf(!1);return e=Np.bind(null,et,e.queue,!0,!1),Zn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,s){var o=et,d=Zn();if(lt){if(s===void 0)throw Error(r(407));s=s()}else{if(s=t(),Tt===null)throw Error(r(349));(ct&127)!==0||ap(o,t,s)}d.memoizedState=s;var h={value:s,getSnapshot:t};return d.queue=h,yp(ip.bind(null,o,h,e),[e]),o.flags|=2048,Pr(9,{destroy:void 0},sp.bind(null,o,h,s,t),null),s},useId:function(){var e=Zn(),t=Tt.identifierPrefix;if(lt){var s=Xn,o=Va;s=(o&~(1<<32-Ne(o)-1)).toString(32)+s,t="_"+t+"R_"+s,s=cu++,0<s&&(t+="H"+s.toString(32)),t+="_"}else s=Uw++,t="_"+t+"r_"+s.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:bf,useFormState:hp,useActionState:hp,useOptimistic:function(e){var t=Zn();t.memoizedState=t.baseState=e;var s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=s,t=Sf.bind(null,et,!0,s),s.dispatch=t,[e,t]},useMemoCache:ff,useCacheRefresh:function(){return Zn().memoizedState=Kw.bind(null,et)},useEffectEvent:function(e){var t=Zn(),s={impl:e};return t.memoizedState=s,function(){if((vt&2)!==0)throw Error(r(440));return s.impl.apply(void 0,arguments)}}},jf={readContext:mn,use:du,useCallback:kp,useContext:mn,useEffect:vf,useImperativeHandle:Cp,useInsertionEffect:bp,useLayoutEffect:Sp,useMemo:Ap,useReducer:fu,useRef:xp,useState:function(){return fu(hi)},useDebugValue:xf,useDeferredValue:function(e,t){var s=Qt();return Mp(s,St.memoizedState,e,t)},useTransition:function(){var e=fu(hi)[0],t=Qt().memoizedState;return[typeof e=="boolean"?e:Ho(e),t]},useSyncExternalStore:np,useId:Rp,useHostTransitionStatus:bf,useFormState:pp,useActionState:pp,useOptimistic:function(e,t){var s=Qt();return op(s,St,e,t)},useMemoCache:ff,useCacheRefresh:Dp};jf.useEffectEvent=wp;var Op={readContext:mn,use:du,useCallback:kp,useContext:mn,useEffect:vf,useImperativeHandle:Cp,useInsertionEffect:bp,useLayoutEffect:Sp,useMemo:Ap,useReducer:hf,useRef:xp,useState:function(){return hf(hi)},useDebugValue:xf,useDeferredValue:function(e,t){var s=Qt();return St===null?yf(s,e,t):Mp(s,St.memoizedState,e,t)},useTransition:function(){var e=hf(hi)[0],t=Qt().memoizedState;return[typeof e=="boolean"?e:Ho(e),t]},useSyncExternalStore:np,useId:Rp,useHostTransitionStatus:bf,useFormState:vp,useActionState:vp,useOptimistic:function(e,t){var s=Qt();return St!==null?op(s,St,e,t):(s.baseState=e,[e,s.queue.dispatch])},useMemoCache:ff,useCacheRefresh:Dp};Op.useEffectEvent=wp;function Cf(e,t,s,o){t=e.memoizedState,s=s(o,t),s=s==null?t:y({},t,s),e.memoizedState=s,e.lanes===0&&(e.updateQueue.baseState=s)}var kf={enqueueSetState:function(e,t,s){e=e._reactInternals;var o=Ta(),d=ge(o);d.payload=t,s!=null&&(d.callback=s),t=Re(e,d,o),t!==null&&(ua(t,e,o),Pe(t,e,o))},enqueueReplaceState:function(e,t,s){e=e._reactInternals;var o=Ta(),d=ge(o);d.tag=1,d.payload=t,s!=null&&(d.callback=s),t=Re(e,d,o),t!==null&&(ua(t,e,o),Pe(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var s=Ta(),o=ge(s);o.tag=2,t!=null&&(o.callback=t),t=Re(e,o,s),t!==null&&(ua(t,e,s),Pe(t,e,s))}};function Bp(e,t,s,o,d,h,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,h,S):t.prototype&&t.prototype.isPureReactComponent?!Bl(s,o)||!Bl(d,h):!0}function Fp(e,t,s,o){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(s,o),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(s,o),t.state!==e&&kf.enqueueReplaceState(t,t.state,null)}function Ql(e,t){var s=t;if("ref"in t){s={};for(var o in t)o!=="ref"&&(s[o]=t[o])}if(e=e.defaultProps){s===t&&(s=y({},s));for(var d in e)s[d]===void 0&&(s[d]=e[d])}return s}function Hp(e){Es(e)}function Pp(e){console.error(e)}function $p(e){Es(e)}function gu(e,t){try{var s=e.onUncaughtError;s(t.value,{componentStack:t.stack})}catch(o){setTimeout(function(){throw o})}}function Up(e,t,s){try{var o=e.onCaughtError;o(s.value,{componentStack:s.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function Af(e,t,s){return s=ge(s),s.tag=3,s.payload={element:null},s.callback=function(){gu(e,t)},s}function qp(e){return e=ge(e),e.tag=3,e}function Gp(e,t,s,o){var d=s.type.getDerivedStateFromError;if(typeof d=="function"){var h=o.value;e.payload=function(){return d(h)},e.callback=function(){Up(t,s,o)}}var S=s.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){Up(t,s,o),typeof d!="function"&&(ol===null?ol=new Set([this]):ol.add(this));var N=o.stack;this.componentDidCatch(o.value,{componentStack:N!==null?N:""})})}function Xw(e,t,s,o,d){if(s.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(t=s.alternate,t!==null&&Ji(t,s,d,!0),s=ka.current,s!==null){switch(s.tag){case 31:case 13:return Wa===null?Nu():s.alternate===null&&qt===0&&(qt=3),s.flags&=-257,s.flags|=65536,s.lanes=d,o===Br?s.flags|=16384:(t=s.updateQueue,t===null?s.updateQueue=new Set([o]):t.add(o),Xf(e,o,d)),!1;case 22:return s.flags|=65536,o===Br?s.flags|=16384:(t=s.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([o])},s.updateQueue=t):(s=t.retryQueue,s===null?t.retryQueue=new Set([o]):s.add(o)),Xf(e,o,d)),!1}throw Error(r(435,s.tag))}return Xf(e,o,d),Nu(),!1}if(lt)return t=ka.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=d,o!==Ro&&(e=Error(r(422),{cause:o}),ql(Hn(e,s)))):(o!==Ro&&(t=Error(r(423),{cause:o}),ql(Hn(t,s))),e=e.current.alternate,e.flags|=65536,d&=-d,e.lanes|=d,o=Hn(o,s),d=Af(e.stateNode,o,d),Xe(e,d),qt!==4&&(qt=2)),!1;var h=Error(r(520),{cause:o});if(h=Hn(h,s),Qo===null?Qo=[h]:Qo.push(h),qt!==4&&(qt=2),t===null)return!0;o=Hn(o,s),s=t;do{switch(s.tag){case 3:return s.flags|=65536,e=d&-d,s.lanes|=e,e=Af(s.stateNode,o,e),Xe(s,e),!1;case 1:if(t=s.type,h=s.stateNode,(s.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||h!==null&&typeof h.componentDidCatch=="function"&&(ol===null||!ol.has(h))))return s.flags|=65536,d&=-d,s.lanes|=d,d=qp(d),Gp(d,e,s,o),Xe(s,d),!1}s=s.return}while(s!==null);return!1}var Mf=Error(r(461)),rn=!1;function _n(e,t,s,o){t.child=e===null?O(t,null,s,o):M(t,e.child,s,o)}function Vp(e,t,s,o,d){s=s.render;var h=t.ref;if("ref"in o){var S={};for(var N in o)N!=="ref"&&(S[N]=o[N])}else S=o;return oi(t),o=of(e,t,s,S,h,d),N=cf(),e!==null&&!rn?(uf(e,t,d),pi(e,t,d)):(lt&&N&&st(t),t.flags|=1,_n(e,t,o,d),t.child)}function Yp(e,t,s,o,d){if(e===null){var h=s.type;return typeof h=="function"&&!No(h)&&h.defaultProps===void 0&&s.compare===null?(t.tag=15,t.type=h,Wp(e,t,h,o,d)):(e=Ul(s.type,null,o,t,t.mode,d),e.ref=t.ref,e.return=t,t.child=e)}if(h=e.child,!zf(e,d)){var S=h.memoizedProps;if(s=s.compare,s=s!==null?s:Bl,s(S,o)&&e.ref===t.ref)return pi(e,t,d)}return t.flags|=1,e=qa(h,o),e.ref=t.ref,e.return=t,t.child=e}function Wp(e,t,s,o,d){if(e!==null){var h=e.memoizedProps;if(Bl(h,o)&&e.ref===t.ref)if(rn=!1,t.pendingProps=o=h,zf(e,d))(e.flags&131072)!==0&&(rn=!0);else return t.lanes=e.lanes,pi(e,t,d)}return Nf(e,t,s,o,d)}function Kp(e,t,s,o){var d=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|s:s,e!==null){for(o=t.child=e.child,d=0;o!==null;)d=d|o.lanes|o.childLanes,o=o.sibling;o=d&~h}else o=0,t.child=null;return Qp(e,t,h,s,o)}if((s&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Os(t,h!==null?h.cachePool:null),h!==null?lu(t,h):af(),Jh(t);else return o=t.lanes=536870912,Qp(e,t,h!==null?h.baseLanes|s:s,s,o)}else h!==null?(Os(t,h.cachePool),lu(t,h),sl(),t.memoizedState=null):(e!==null&&Os(t,null),af(),sl());return _n(e,t,d,s),t.child}function Uo(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Qp(e,t,s,o,d){var h=el();return h=h===null?null:{parent:$t._currentValue,pool:h},t.memoizedState={baseLanes:s,cachePool:h},e!==null&&Os(t,null),af(),Jh(t),e!==null&&Ji(e,t,o,!0),t.childLanes=d,null}function vu(e,t){return t=yu({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Xp(e,t,s){return M(t,e.child,null,s),e=vu(t,t.pendingProps),e.flags|=2,Aa(t),t.memoizedState=null,e}function Zw(e,t,s){var o=t.pendingProps,d=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(lt){if(o.mode==="hidden")return e=vu(t,o),t.lanes=536870912,Uo(null,e);if(lf(t),(e=Nt)?(e=cv(e,ia),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ga!==null?{id:Va,overflow:Xn}:null,retryLane:536870912,hydrationErrors:null},s=cs(e),s.return=t,t.child=s,fn=t,Nt=null)):e=null,e===null)throw Ls(t);return t.lanes=536870912,null}return vu(t,o)}var h=e.memoizedState;if(h!==null){var S=h.dehydrated;if(lf(t),d)if(t.flags&256)t.flags&=-257,t=Xp(e,t,s);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(rn||Ji(e,t,s,!1),d=(s&e.childLanes)!==0,rn||d){if(o=Tt,o!==null&&(S=Ss(o,s),S!==0&&S!==h.retryLane))throw h.retryLane=S,ba(e,S),ua(o,e,S),Mf;Nu(),t=Xp(e,t,s)}else e=h.treeContext,Nt=Ka(S.nextSibling),fn=t,lt=!0,Ds=null,ia=!1,e!==null&&Xc(t,e),t=vu(t,o),t.flags|=4096;return t}return e=qa(e.child,{mode:o.mode,children:o.children}),e.ref=t.ref,t.child=e,e.return=t,e}function xu(e,t){var s=t.ref;if(s===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof s!="function"&&typeof s!="object")throw Error(r(284));(e===null||e.ref!==s)&&(t.flags|=4194816)}}function Nf(e,t,s,o,d){return oi(t),s=of(e,t,s,o,void 0,d),o=cf(),e!==null&&!rn?(uf(e,t,d),pi(e,t,d)):(lt&&o&&st(t),t.flags|=1,_n(e,t,s,d),t.child)}function Zp(e,t,s,o,d,h){return oi(t),t.updateQueue=null,s=tp(t,o,s,d),ep(e),o=cf(),e!==null&&!rn?(uf(e,t,h),pi(e,t,h)):(lt&&o&&st(t),t.flags|=1,_n(e,t,s,h),t.child)}function Jp(e,t,s,o,d){if(oi(t),t.stateNode===null){var h=si,S=s.contextType;typeof S=="object"&&S!==null&&(h=mn(S)),h=new s(o,h),t.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=kf,t.stateNode=h,h._reactInternals=t,h=t.stateNode,h.props=o,h.state=t.memoizedState,h.refs={},B(t),S=s.contextType,h.context=typeof S=="object"&&S!==null?mn(S):si,h.state=t.memoizedState,S=s.getDerivedStateFromProps,typeof S=="function"&&(Cf(t,s,S,o),h.state=t.memoizedState),typeof s.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&&kf.enqueueReplaceState(h,h.state,null),Ln(t,o,h,d),sn(),h.state=t.memoizedState),typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!0}else if(e===null){h=t.stateNode;var N=t.memoizedProps,H=Ql(s,N);h.props=H;var se=h.context,pe=s.contextType;S=si,typeof pe=="object"&&pe!==null&&(S=mn(pe));var be=s.getDerivedStateFromProps;pe=typeof be=="function"||typeof h.getSnapshotBeforeUpdate=="function",N=t.pendingProps!==N,pe||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(N||se!==S)&&Fp(t,h,o,S),q=!1;var re=t.memoizedState;h.state=re,Ln(t,o,h,d),sn(),se=t.memoizedState,N||re!==se||q?(typeof be=="function"&&(Cf(t,s,be,o),se=t.memoizedState),(H=q||Bp(t,s,H,o,re,se,S))?(pe||typeof h.UNSAFE_componentWillMount!="function"&&typeof h.componentWillMount!="function"||(typeof h.componentWillMount=="function"&&h.componentWillMount(),typeof h.UNSAFE_componentWillMount=="function"&&h.UNSAFE_componentWillMount()),typeof h.componentDidMount=="function"&&(t.flags|=4194308)):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=o,t.memoizedState=se),h.props=o,h.state=se,h.context=S,o=H):(typeof h.componentDidMount=="function"&&(t.flags|=4194308),o=!1)}else{h=t.stateNode,ve(e,t),S=t.memoizedProps,pe=Ql(s,S),h.props=pe,be=t.pendingProps,re=h.context,se=s.contextType,H=si,typeof se=="object"&&se!==null&&(H=mn(se)),N=s.getDerivedStateFromProps,(se=typeof N=="function"||typeof h.getSnapshotBeforeUpdate=="function")||typeof h.UNSAFE_componentWillReceiveProps!="function"&&typeof h.componentWillReceiveProps!="function"||(S!==be||re!==H)&&Fp(t,h,o,H),q=!1,re=t.memoizedState,h.state=re,Ln(t,o,h,d),sn();var de=t.memoizedState;S!==be||re!==de||q||e!==null&&e.dependencies!==null&&_r(e.dependencies)?(typeof N=="function"&&(Cf(t,s,N,o),de=t.memoizedState),(pe=q||Bp(t,s,pe,o,re,de,H)||e!==null&&e.dependencies!==null&&_r(e.dependencies))?(se||typeof h.UNSAFE_componentWillUpdate!="function"&&typeof h.componentWillUpdate!="function"||(typeof h.componentWillUpdate=="function"&&h.componentWillUpdate(o,de,H),typeof h.UNSAFE_componentWillUpdate=="function"&&h.UNSAFE_componentWillUpdate(o,de,H)),typeof h.componentDidUpdate=="function"&&(t.flags|=4),typeof h.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=1024),t.memoizedProps=o,t.memoizedState=de),h.props=o,h.state=de,h.context=H,o=pe):(typeof h.componentDidUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=4),typeof h.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&re===e.memoizedState||(t.flags|=1024),o=!1)}return h=o,xu(e,t),o=(t.flags&128)!==0,h||o?(h=t.stateNode,s=o&&typeof s.getDerivedStateFromError!="function"?null:h.render(),t.flags|=1,e!==null&&o?(t.child=M(t,e.child,null,d),t.child=M(t,null,s,d)):_n(e,t,s,d),t.memoizedState=h.state,e=t.child):e=pi(e,t,d),e}function eg(e,t,s,o){return ri(),t.flags|=256,_n(e,t,s,o),t.child}var Tf={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ef(e){return{baseLanes:e,cachePool:Oo()}}function Rf(e,t,s){return e=e!==null?e.childLanes&~s:0,t&&(e|=Na),e}function tg(e,t,s){var o=t.pendingProps,d=!1,h=(t.flags&128)!==0,S;if((S=h)||(S=e!==null&&e.memoizedState===null?!1:(Kt.current&2)!==0),S&&(d=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(lt){if(d?al(t):sl(),(e=Nt)?(e=cv(e,ia),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ga!==null?{id:Va,overflow:Xn}:null,retryLane:536870912,hydrationErrors:null},s=cs(e),s.return=t,t.child=s,fn=t,Nt=null)):e=null,e===null)throw Ls(t);return mm(e)?t.lanes=32:t.lanes=536870912,null}var N=o.children;return o=o.fallback,d?(sl(),d=t.mode,N=yu({mode:"hidden",children:N},d),o=ii(o,d,s,null),N.return=t,o.return=t,N.sibling=o,t.child=N,o=t.child,o.memoizedState=Ef(s),o.childLanes=Rf(e,S,s),t.memoizedState=Tf,Uo(null,o)):(al(t),Df(t,N))}var H=e.memoizedState;if(H!==null&&(N=H.dehydrated,N!==null)){if(h)t.flags&256?(al(t),t.flags&=-257,t=Lf(e,t,s)):t.memoizedState!==null?(sl(),t.child=e.child,t.flags|=128,t=null):(sl(),N=o.fallback,d=t.mode,o=yu({mode:"visible",children:o.children},d),N=ii(N,d,s,null),N.flags|=2,o.return=t,N.return=t,o.sibling=N,t.child=o,M(t,e.child,null,s),o=t.child,o.memoizedState=Ef(s),o.childLanes=Rf(e,S,s),t.memoizedState=Tf,t=Uo(null,o));else if(al(t),mm(N)){if(S=N.nextSibling&&N.nextSibling.dataset,S)var se=S.dgst;S=se,o=Error(r(419)),o.stack="",o.digest=S,ql({value:o,source:null,stack:null}),t=Lf(e,t,s)}else if(rn||Ji(e,t,s,!1),S=(s&e.childLanes)!==0,rn||S){if(S=Tt,S!==null&&(o=Ss(S,s),o!==0&&o!==H.retryLane))throw H.retryLane=o,ba(e,o),ua(S,e,o),Mf;fm(N)||Nu(),t=Lf(e,t,s)}else fm(N)?(t.flags|=192,t.child=e.child,t=null):(e=H.treeContext,Nt=Ka(N.nextSibling),fn=t,lt=!0,Ds=null,ia=!1,e!==null&&Xc(t,e),t=Df(t,o.children),t.flags|=4096);return t}return d?(sl(),N=o.fallback,d=t.mode,H=e.child,se=H.sibling,o=qa(H,{mode:"hidden",children:o.children}),o.subtreeFlags=H.subtreeFlags&65011712,se!==null?N=qa(se,N):(N=ii(N,d,s,null),N.flags|=2),N.return=t,o.return=t,o.sibling=N,t.child=o,Uo(null,o),o=t.child,N=e.child.memoizedState,N===null?N=Ef(s):(d=N.cachePool,d!==null?(H=$t._currentValue,d=d.parent!==H?{parent:H,pool:H}:d):d=Oo(),N={baseLanes:N.baseLanes|s,cachePool:d}),o.memoizedState=N,o.childLanes=Rf(e,S,s),t.memoizedState=Tf,Uo(e.child,o)):(al(t),s=e.child,e=s.sibling,s=qa(s,{mode:"visible",children:o.children}),s.return=t,s.sibling=null,e!==null&&(S=t.deletions,S===null?(t.deletions=[e],t.flags|=16):S.push(e)),t.child=s,t.memoizedState=null,s)}function Df(e,t){return t=yu({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function yu(e,t){return e=Dn(22,e,null,t),e.lanes=0,e}function Lf(e,t,s){return M(t,e.child,null,s),e=Df(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function ng(e,t,s){e.lanes|=t;var o=e.alternate;o!==null&&(o.lanes|=t),_o(e.return,t,s)}function _f(e,t,s,o,d,h){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:o,tail:s,tailMode:d,treeForkCount:h}:(S.isBackwards=t,S.rendering=null,S.renderingStartTime=0,S.last=o,S.tail=s,S.tailMode=d,S.treeForkCount=h)}function ag(e,t,s){var o=t.pendingProps,d=o.revealOrder,h=o.tail;o=o.children;var S=Kt.current,N=(S&2)!==0;if(N?(S=S&1|2,t.flags|=128):S&=1,$(Kt,S),_n(e,t,o,s),o=lt?Xi:0,!N&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ng(e,s,t);else if(e.tag===19)ng(e,s,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(d){case"forwards":for(s=t.child,d=null;s!==null;)e=s.alternate,e!==null&&ru(e)===null&&(d=s),s=s.sibling;s=d,s===null?(d=t.child,t.child=null):(d=s.sibling,s.sibling=null),_f(t,!1,d,s,h,o);break;case"backwards":case"unstable_legacy-backwards":for(s=null,d=t.child,t.child=null;d!==null;){if(e=d.alternate,e!==null&&ru(e)===null){t.child=d;break}e=d.sibling,d.sibling=s,s=d,d=e}_f(t,!0,s,null,h,o);break;case"together":_f(t,!1,null,null,void 0,o);break;default:t.memoizedState=null}return t.child}function pi(e,t,s){if(e!==null&&(t.dependencies=e.dependencies),rl|=t.lanes,(s&t.childLanes)===0)if(e!==null){if(Ji(e,t,s,!1),(s&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,s=qa(e,e.pendingProps),t.child=s,s.return=t;e.sibling!==null;)e=e.sibling,s=s.sibling=qa(e,e.pendingProps),s.return=t;s.sibling=null}return t.child}function zf(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&_r(e)))}function Jw(e,t,s){switch(t.tag){case 3:Ie(t,t.stateNode.containerInfo),_s(t,$t,e.memoizedState.cache),ri();break;case 27:case 5:Ye(t);break;case 4:Ie(t,t.stateNode.containerInfo);break;case 10:_s(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,lf(t),null;break;case 13:var o=t.memoizedState;if(o!==null)return o.dehydrated!==null?(al(t),t.flags|=128,null):(s&t.child.childLanes)!==0?tg(e,t,s):(al(t),e=pi(e,t,s),e!==null?e.sibling:null);al(t);break;case 19:var d=(e.flags&128)!==0;if(o=(s&t.childLanes)!==0,o||(Ji(e,t,s,!1),o=(s&t.childLanes)!==0),d){if(o)return ag(e,t,s);t.flags|=128}if(d=t.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),$(Kt,Kt.current),o)break;return null;case 22:return t.lanes=0,Kp(e,t,s,t.pendingProps);case 24:_s(t,$t,e.memoizedState.cache)}return pi(e,t,s)}function sg(e,t,s){if(e!==null)if(e.memoizedProps!==t.pendingProps)rn=!0;else{if(!zf(e,s)&&(t.flags&128)===0)return rn=!1,Jw(e,t,s);rn=(e.flags&131072)!==0}else rn=!1,lt&&(t.flags&1048576)!==0&&Pn(t,Xi,t.index);switch(t.lanes=0,t.tag){case 16:e:{var o=t.pendingProps;if(e=di(t.elementType),t.type=e,typeof e=="function")No(e)?(o=Ql(e,o),t.tag=1,t=Jp(null,t,e,o,s)):(t.tag=0,t=Nf(null,t,e,o,s));else{if(e!=null){var d=e.$$typeof;if(d===U){t.tag=11,t=Vp(null,t,e,o,s);break e}else if(d===_){t.tag=14,t=Yp(null,t,e,o,s);break e}}throw t=ee(e)||e,Error(r(306,t,""))}}return t;case 0:return Nf(e,t,t.type,t.pendingProps,s);case 1:return o=t.type,d=Ql(o,t.pendingProps),Jp(e,t,o,d,s);case 3:e:{if(Ie(t,t.stateNode.containerInfo),e===null)throw Error(r(387));o=t.pendingProps;var h=t.memoizedState;d=h.element,ve(e,t),Ln(t,o,null,s);var S=t.memoizedState;if(o=S.cache,_s(t,$t,o),o!==h.cache&&zo(t,[$t],s,!0),sn(),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=eg(e,t,o,s);break e}else if(o!==d){d=Hn(Error(r(424)),t),ql(d),t=eg(e,t,o,s);break e}else for(e=t.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Nt=Ka(e.firstChild),fn=t,lt=!0,Ds=null,ia=!0,s=O(t,null,o,s),t.child=s;s;)s.flags=s.flags&-3|4096,s=s.sibling;else{if(ri(),o===d){t=pi(e,t,s);break e}_n(e,t,o,s)}t=t.child}return t;case 26:return xu(e,t),e===null?(s=pv(t.type,null,t.pendingProps,null))?t.memoizedState=s:lt||(s=t.type,e=t.pendingProps,o=zu(fe.current).createElement(s),o[J]=t,o[ke]=e,zn(o,s,e),Dt(o),t.stateNode=o):t.memoizedState=pv(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ye(t),e===null&&lt&&(o=t.stateNode=fv(t.type,t.pendingProps,fe.current),fn=t,ia=!0,d=Nt,fl(t.type)?(hm=d,Nt=Ka(o.firstChild)):Nt=d),_n(e,t,t.pendingProps.children,s),xu(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&lt&&((d=o=Nt)&&(o=Tb(o,t.type,t.pendingProps,ia),o!==null?(t.stateNode=o,fn=t,Nt=Ka(o.firstChild),ia=!1,d=!0):d=!1),d||Ls(t)),Ye(t),d=t.type,h=t.pendingProps,S=e!==null?e.memoizedProps:null,o=h.children,cm(d,h)?o=null:S!==null&&cm(d,S)&&(t.flags|=32),t.memoizedState!==null&&(d=of(e,t,qw,null,null,s),sc._currentValue=d),xu(e,t),_n(e,t,o,s),t.child;case 6:return e===null&&lt&&((e=s=Nt)&&(s=Eb(s,t.pendingProps,ia),s!==null?(t.stateNode=s,fn=t,Nt=null,e=!0):e=!1),e||Ls(t)),null;case 13:return tg(e,t,s);case 4:return Ie(t,t.stateNode.containerInfo),o=t.pendingProps,e===null?t.child=M(t,null,o,s):_n(e,t,o,s),t.child;case 11:return Vp(e,t,t.type,t.pendingProps,s);case 7:return _n(e,t,t.pendingProps,s),t.child;case 8:return _n(e,t,t.pendingProps.children,s),t.child;case 12:return _n(e,t,t.pendingProps.children,s),t.child;case 10:return o=t.pendingProps,_s(t,t.type,o.value),_n(e,t,o.children,s),t.child;case 9:return d=t.type._context,o=t.pendingProps.children,oi(t),d=mn(d),o=o(d),t.flags|=1,_n(e,t,o,s),t.child;case 14:return Yp(e,t,t.type,t.pendingProps,s);case 15:return Wp(e,t,t.type,t.pendingProps,s);case 19:return ag(e,t,s);case 31:return Zw(e,t,s);case 22:return Kp(e,t,s,t.pendingProps);case 24:return oi(t),o=mn($t),e===null?(d=el(),d===null&&(d=Tt,h=Ir(),d.pooledCache=h,h.refCount++,h!==null&&(d.pooledCacheLanes|=s),d=h),t.memoizedState={parent:o,cache:d},B(t),_s(t,$t,d)):((e.lanes&s)!==0&&(ve(e,t),Ln(t,null,null,s),sn()),d=e.memoizedState,h=t.memoizedState,d.parent!==o?(d={parent:o,cache:o},t.memoizedState=d,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=d),_s(t,$t,o)):(o=h.cache,_s(t,$t,o),o!==d.cache&&zo(t,[$t],s,!0))),_n(e,t,t.pendingProps.children,s),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function gi(e){e.flags|=4}function If(e,t,s,o,d){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(d&335544128)===d)if(e.stateNode.complete)e.flags|=8192;else if(Rg())e.flags|=8192;else throw an=Br,Bo}else e.flags&=-16777217}function ig(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!wv(t))if(Rg())e.flags|=8192;else throw an=Br,Bo}function wu(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?qs():536870912,e.lanes|=t,Gr|=t)}function qo(e,t){if(!lt)switch(e.tailMode){case"hidden":t=e.tail;for(var s=null;t!==null;)t.alternate!==null&&(s=t),t=t.sibling;s===null?e.tail=null:s.sibling=null;break;case"collapsed":s=e.tail;for(var o=null;s!==null;)s.alternate!==null&&(o=s),s=s.sibling;o===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function _t(e){var t=e.alternate!==null&&e.alternate.child===e.child,s=0,o=0;if(t)for(var d=e.child;d!==null;)s|=d.lanes|d.childLanes,o|=d.subtreeFlags&65011712,o|=d.flags&65011712,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)s|=d.lanes|d.childLanes,o|=d.subtreeFlags,o|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=o,e.childLanes=s,t}function eb(e,t,s){var o=t.pendingProps;switch(Eo(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return _t(t),null;case 1:return _t(t),null;case 3:return s=t.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),t.memoizedState.cache!==o&&(t.flags|=2048),ds($t),oe(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Zi(t)?gi(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,Do())),_t(t),null;case 26:var d=t.type,h=t.memoizedState;return e===null?(gi(t),h!==null?(_t(t),ig(t,h)):(_t(t),If(t,d,null,o,s))):h?h!==e.memoizedState?(gi(t),_t(t),ig(t,h)):(_t(t),t.flags&=-16777217):(e=e.memoizedProps,e!==o&&gi(t),_t(t),If(t,d,e,o,s)),null;case 27:if(De(t),s=fe.current,d=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&gi(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return _t(t),null}e=xe.current,Zi(t)?Zc(t):(e=fv(d,o,s),t.stateNode=e,gi(t))}return _t(t),null;case 5:if(De(t),d=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==o&&gi(t);else{if(!o){if(t.stateNode===null)throw Error(r(166));return _t(t),null}if(h=xe.current,Zi(t))Zc(t);else{var S=zu(fe.current);switch(h){case 1:h=S.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:h=S.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":h=S.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":h=S.createElementNS("http://www.w3.org/1998/Math/MathML",d);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(d,{is:o.is}):S.createElement(d)}}h[J]=t,h[ke]=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(zn(h,d,o),d){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&gi(t)}}return _t(t),If(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,s),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==o&&gi(t);else{if(typeof o!="string"&&t.stateNode===null)throw Error(r(166));if(e=fe.current,Zi(t)){if(e=t.stateNode,s=t.memoizedProps,o=null,d=fn,d!==null)switch(d.tag){case 27:case 5:o=d.memoizedProps}e[J]=t,e=!!(e.nodeValue===s||o!==null&&o.suppressHydrationWarning===!0||tv(e.nodeValue,s)),e||Ls(t,!0)}else e=zu(e).createTextNode(o),e[J]=t,t.stateNode=e}return _t(t),null;case 31:if(s=t.memoizedState,e===null||e.memoizedState!==null){if(o=Zi(t),s!==null){if(e===null){if(!o)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[J]=t}else ri(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;_t(t),e=!1}else s=Do(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=s),e=!0;if(!e)return t.flags&256?(Aa(t),t):(Aa(t),null);if((t.flags&128)!==0)throw Error(r(558))}return _t(t),null;case 13:if(o=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=Zi(t),o!==null&&o.dehydrated!==null){if(e===null){if(!d)throw Error(r(318));if(d=t.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(r(317));d[J]=t}else ri(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;_t(t),d=!1}else d=Do(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return t.flags&256?(Aa(t),t):(Aa(t),null)}return Aa(t),(t.flags&128)!==0?(t.lanes=s,t):(s=o!==null,e=e!==null&&e.memoizedState!==null,s&&(o=t.child,d=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(d=o.alternate.memoizedState.cachePool.pool),h=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(h=o.memoizedState.cachePool.pool),h!==d&&(o.flags|=2048)),s!==e&&s&&(t.child.flags|=8192),wu(t,t.updateQueue),_t(t),null);case 4:return oe(),e===null&&sm(t.stateNode.containerInfo),_t(t),null;case 10:return ds(t.type),_t(t),null;case 19:if(L(Kt),o=t.memoizedState,o===null)return _t(t),null;if(d=(t.flags&128)!==0,h=o.rendering,h===null)if(d)qo(o,!1);else{if(qt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(h=ru(e),h!==null){for(t.flags|=128,qo(o,!1),e=h.updateQueue,t.updateQueue=e,wu(t,e),t.subtreeFlags=0,e=s,s=t.child;s!==null;)To(s,e),s=s.sibling;return $(Kt,Kt.current&1|2),lt&&Mt(t,o.treeForkCount),t.child}e=e.sibling}o.tail!==null&&Ge()>ku&&(t.flags|=128,d=!0,qo(o,!1),t.lanes=4194304)}else{if(!d)if(e=ru(h),e!==null){if(t.flags|=128,d=!0,e=e.updateQueue,t.updateQueue=e,wu(t,e),qo(o,!0),o.tail===null&&o.tailMode==="hidden"&&!h.alternate&&!lt)return _t(t),null}else 2*Ge()-o.renderingStartTime>ku&&s!==536870912&&(t.flags|=128,d=!0,qo(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=Ge(),e.sibling=null,s=Kt.current,$(Kt,d?s&1|2:s&1),lt&&Mt(t,o.treeForkCount),e):(_t(t),null);case 22:case 23:return Aa(t),sf(),o=t.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(t.flags|=8192):o&&(t.flags|=8192),o?(s&536870912)!==0&&(t.flags&128)===0&&(_t(t),t.subtreeFlags&6&&(t.flags|=8192)):_t(t),s=t.updateQueue,s!==null&&wu(t,s.retryQueue),s=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),o=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(o=t.memoizedState.cachePool.pool),o!==s&&(t.flags|=2048),e!==null&&L(Is),null;case 24:return s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),ds($t),_t(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function tb(e,t){switch(Eo(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ds($t),oe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return De(t),null;case 31:if(t.memoizedState!==null){if(Aa(t),t.alternate===null)throw Error(r(340));ri()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Aa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));ri()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L(Kt),null;case 4:return oe(),null;case 10:return ds(t.type),null;case 22:case 23:return Aa(t),sf(),e!==null&&L(Is),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ds($t),null;case 25:return null;default:return null}}function lg(e,t){switch(Eo(t),t.tag){case 3:ds($t),oe();break;case 26:case 27:case 5:De(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&Aa(t);break;case 13:Aa(t);break;case 19:L(Kt);break;case 10:ds(t.type);break;case 22:case 23:Aa(t),sf(),e!==null&&L(Is);break;case 24:ds($t)}}function Go(e,t){try{var s=t.updateQueue,o=s!==null?s.lastEffect:null;if(o!==null){var d=o.next;s=d;do{if((s.tag&e)===e){o=void 0;var h=s.create,S=s.inst;o=h(),S.destroy=o}s=s.next}while(s!==d)}}catch(N){wt(t,t.return,N)}}function il(e,t,s){try{var o=t.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var h=d.next;o=h;do{if((o.tag&e)===e){var S=o.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,d=t;var H=s,se=N;try{se()}catch(pe){wt(d,H,pe)}}}o=o.next}while(o!==h)}}catch(pe){wt(t,t.return,pe)}}function rg(e){var t=e.updateQueue;if(t!==null){var s=e.stateNode;try{Bs(t,s)}catch(o){wt(e,e.return,o)}}}function og(e,t,s){s.props=Ql(e.type,e.memoizedProps),s.state=e.memoizedState;try{s.componentWillUnmount()}catch(o){wt(e,t,o)}}function Vo(e,t){try{var s=e.ref;if(s!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof s=="function"?e.refCleanup=s(o):s.current=o}}catch(d){wt(e,t,d)}}function Fs(e,t){var s=e.ref,o=e.refCleanup;if(s!==null)if(typeof o=="function")try{o()}catch(d){wt(e,t,d)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(d){wt(e,t,d)}else s.current=null}function cg(e){var t=e.type,s=e.memoizedProps,o=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":s.autoFocus&&o.focus();break e;case"img":s.src?o.src=s.src:s.srcSet&&(o.srcset=s.srcSet)}}catch(d){wt(e,e.return,d)}}function Of(e,t,s){try{var o=e.stateNode;jb(o,e.type,s,t),o[ke]=t}catch(d){wt(e,e.return,d)}}function ug(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&fl(e.type)||e.tag===4}function Bf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ug(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&&fl(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 Ff(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(e,t):(t=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,t.appendChild(e),s=s._reactRootContainer,s!=null||t.onclick!==null||(t.onclick=ts));else if(o!==4&&(o===27&&fl(e.type)&&(s=e.stateNode,t=null),e=e.child,e!==null))for(Ff(e,t,s),e=e.sibling;e!==null;)Ff(e,t,s),e=e.sibling}function bu(e,t,s){var o=e.tag;if(o===5||o===6)e=e.stateNode,t?s.insertBefore(e,t):s.appendChild(e);else if(o!==4&&(o===27&&fl(e.type)&&(s=e.stateNode),e=e.child,e!==null))for(bu(e,t,s),e=e.sibling;e!==null;)bu(e,t,s),e=e.sibling}function dg(e){var t=e.stateNode,s=e.memoizedProps;try{for(var o=e.type,d=t.attributes;d.length;)t.removeAttributeNode(d[0]);zn(t,o,s),t[J]=e,t[ke]=s}catch(h){wt(e,e.return,h)}}var vi=!1,on=!1,Hf=!1,fg=typeof WeakSet=="function"?WeakSet:Set,wn=null;function nb(e,t){if(e=e.containerInfo,rm=$u,e=Gi(e),jo(e)){if("selectionStart"in e)var s={start:e.selectionStart,end:e.selectionEnd};else e:{s=(s=e.ownerDocument)&&s.defaultView||window;var o=s.getSelection&&s.getSelection();if(o&&o.rangeCount!==0){s=o.anchorNode;var d=o.anchorOffset,h=o.focusNode;o=o.focusOffset;try{s.nodeType,h.nodeType}catch{s=null;break e}var S=0,N=-1,H=-1,se=0,pe=0,be=e,re=null;t:for(;;){for(var de;be!==s||d!==0&&be.nodeType!==3||(N=S+d),be!==h||o!==0&&be.nodeType!==3||(H=S+o),be.nodeType===3&&(S+=be.nodeValue.length),(de=be.firstChild)!==null;)re=be,be=de;for(;;){if(be===e)break t;if(re===s&&++se===d&&(N=S),re===h&&++pe===o&&(H=S),(de=be.nextSibling)!==null)break;be=re,re=be.parentNode}be=de}s=N===-1||H===-1?null:{start:N,end:H}}else s=null}s=s||{start:0,end:0}}else s=null;for(om={focusedElem:e,selectionRange:s},$u=!1,wn=t;wn!==null;)if(t=wn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,wn=e;else for(;wn!==null;){switch(t=wn,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(s=0;s<e.length;s++)d=e[s],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&h!==null){e=void 0,s=t,d=h.memoizedProps,h=h.memoizedState,o=s.stateNode;try{var Oe=Ql(s.type,d);e=o.getSnapshotBeforeUpdate(Oe,h),o.__reactInternalSnapshotBeforeUpdate=e}catch(qe){wt(s,s.return,qe)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,s=e.nodeType,s===9)dm(e);else if(s===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":dm(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(r(163))}if(e=t.sibling,e!==null){e.return=t.return,wn=e;break}wn=t.return}}function mg(e,t,s){var o=s.flags;switch(s.tag){case 0:case 11:case 15:yi(e,s),o&4&&Go(5,s);break;case 1:if(yi(e,s),o&4)if(e=s.stateNode,t===null)try{e.componentDidMount()}catch(S){wt(s,s.return,S)}else{var d=Ql(s.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(d,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){wt(s,s.return,S)}}o&64&&rg(s),o&512&&Vo(s,s.return);break;case 3:if(yi(e,s),o&64&&(e=s.updateQueue,e!==null)){if(t=null,s.child!==null)switch(s.child.tag){case 27:case 5:t=s.child.stateNode;break;case 1:t=s.child.stateNode}try{Bs(e,t)}catch(S){wt(s,s.return,S)}}break;case 27:t===null&&o&4&&dg(s);case 26:case 5:yi(e,s),t===null&&o&4&&cg(s),o&512&&Vo(s,s.return);break;case 12:yi(e,s);break;case 31:yi(e,s),o&4&&gg(e,s);break;case 13:yi(e,s),o&4&&vg(e,s),o&64&&(e=s.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(s=db.bind(null,s),Rb(e,s))));break;case 22:if(o=s.memoizedState!==null||vi,!o){t=t!==null&&t.memoizedState!==null||on,d=vi;var h=on;vi=o,(on=t)&&!h?wi(e,s,(s.subtreeFlags&8772)!==0):yi(e,s),vi=d,on=h}break;case 30:break;default:yi(e,s)}}function hg(e){var t=e.alternate;t!==null&&(e.alternate=null,hg(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&nn(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 It=null,la=!1;function xi(e,t,s){for(s=s.child;s!==null;)pg(e,t,s),s=s.sibling}function pg(e,t,s){if(mt&&typeof mt.onCommitFiberUnmount=="function")try{mt.onCommitFiberUnmount(ys,s)}catch{}switch(s.tag){case 26:on||Fs(s,t),xi(e,t,s),s.memoizedState?s.memoizedState.count--:s.stateNode&&(s=s.stateNode,s.parentNode.removeChild(s));break;case 27:on||Fs(s,t);var o=It,d=la;fl(s.type)&&(It=s.stateNode,la=!1),xi(e,t,s),tc(s.stateNode),It=o,la=d;break;case 5:on||Fs(s,t);case 6:if(o=It,d=la,It=null,xi(e,t,s),It=o,la=d,It!==null)if(la)try{(It.nodeType===9?It.body:It.nodeName==="HTML"?It.ownerDocument.body:It).removeChild(s.stateNode)}catch(h){wt(s,t,h)}else try{It.removeChild(s.stateNode)}catch(h){wt(s,t,h)}break;case 18:It!==null&&(la?(e=It,rv(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,s.stateNode),Jr(e)):rv(It,s.stateNode));break;case 4:o=It,d=la,It=s.stateNode.containerInfo,la=!0,xi(e,t,s),It=o,la=d;break;case 0:case 11:case 14:case 15:il(2,s,t),on||il(4,s,t),xi(e,t,s);break;case 1:on||(Fs(s,t),o=s.stateNode,typeof o.componentWillUnmount=="function"&&og(s,t,o)),xi(e,t,s);break;case 21:xi(e,t,s);break;case 22:on=(o=on)||s.memoizedState!==null,xi(e,t,s),on=o;break;default:xi(e,t,s)}}function gg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Jr(e)}catch(s){wt(t,t.return,s)}}}function vg(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Jr(e)}catch(s){wt(t,t.return,s)}}function ab(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new fg),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new fg),t;default:throw Error(r(435,e.tag))}}function Su(e,t){var s=ab(e);t.forEach(function(o){if(!s.has(o)){s.add(o);var d=fb.bind(null,e,o);o.then(d,d)}})}function ra(e,t){var s=t.deletions;if(s!==null)for(var o=0;o<s.length;o++){var d=s[o],h=e,S=t,N=S;e:for(;N!==null;){switch(N.tag){case 27:if(fl(N.type)){It=N.stateNode,la=!1;break e}break;case 5:It=N.stateNode,la=!1;break e;case 3:case 4:It=N.stateNode.containerInfo,la=!0;break e}N=N.return}if(It===null)throw Error(r(160));pg(h,S,d),It=null,la=!1,h=d.alternate,h!==null&&(h.return=null),d.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)xg(t,e),t=t.sibling}var hs=null;function xg(e,t){var s=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ra(t,e),oa(e),o&4&&(il(3,e,e.return),Go(3,e),il(5,e,e.return));break;case 1:ra(t,e),oa(e),o&512&&(on||s===null||Fs(s,s.return)),o&64&&vi&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(s=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=s===null?o:s.concat(o))));break;case 26:var d=hs;if(ra(t,e),oa(e),o&512&&(on||s===null||Fs(s,s.return)),o&4){var h=s!==null?s.memoizedState:null;if(o=e.memoizedState,s===null)if(o===null)if(e.stateNode===null){e:{o=e.type,s=e.memoizedProps,d=d.ownerDocument||d;t:switch(o){case"title":h=d.getElementsByTagName("title")[0],(!h||h[dt]||h[J]||h.namespaceURI==="http://www.w3.org/2000/svg"||h.hasAttribute("itemprop"))&&(h=d.createElement(o),d.head.insertBefore(h,d.querySelector("head > title"))),zn(h,o,s),h[J]=e,Dt(h),o=h;break e;case"link":var S=xv("link","href",d).get(o+(s.href||""));if(S){for(var N=0;N<S.length;N++)if(h=S[N],h.getAttribute("href")===(s.href==null||s.href===""?null:s.href)&&h.getAttribute("rel")===(s.rel==null?null:s.rel)&&h.getAttribute("title")===(s.title==null?null:s.title)&&h.getAttribute("crossorigin")===(s.crossOrigin==null?null:s.crossOrigin)){S.splice(N,1);break t}}h=d.createElement(o),zn(h,o,s),d.head.appendChild(h);break;case"meta":if(S=xv("meta","content",d).get(o+(s.content||""))){for(N=0;N<S.length;N++)if(h=S[N],h.getAttribute("content")===(s.content==null?null:""+s.content)&&h.getAttribute("name")===(s.name==null?null:s.name)&&h.getAttribute("property")===(s.property==null?null:s.property)&&h.getAttribute("http-equiv")===(s.httpEquiv==null?null:s.httpEquiv)&&h.getAttribute("charset")===(s.charSet==null?null:s.charSet)){S.splice(N,1);break t}}h=d.createElement(o),zn(h,o,s),d.head.appendChild(h);break;default:throw Error(r(468,o))}h[J]=e,Dt(h),o=h}e.stateNode=o}else yv(d,e.type,e.stateNode);else e.stateNode=vv(d,o,e.memoizedProps);else h!==o?(h===null?s.stateNode!==null&&(s=s.stateNode,s.parentNode.removeChild(s)):h.count--,o===null?yv(d,e.type,e.stateNode):vv(d,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Of(e,e.memoizedProps,s.memoizedProps)}break;case 27:ra(t,e),oa(e),o&512&&(on||s===null||Fs(s,s.return)),s!==null&&o&4&&Of(e,e.memoizedProps,s.memoizedProps);break;case 5:if(ra(t,e),oa(e),o&512&&(on||s===null||Fs(s,s.return)),e.flags&32){d=e.stateNode;try{Ei(d,"")}catch(Oe){wt(e,e.return,Oe)}}o&4&&e.stateNode!=null&&(d=e.memoizedProps,Of(e,d,s!==null?s.memoizedProps:d)),o&1024&&(Hf=!0);break;case 6:if(ra(t,e),oa(e),o&4){if(e.stateNode===null)throw Error(r(162));o=e.memoizedProps,s=e.stateNode;try{s.nodeValue=o}catch(Oe){wt(e,e.return,Oe)}}break;case 3:if(Bu=null,d=hs,hs=Iu(t.containerInfo),ra(t,e),hs=d,oa(e),o&4&&s!==null&&s.memoizedState.isDehydrated)try{Jr(t.containerInfo)}catch(Oe){wt(e,e.return,Oe)}Hf&&(Hf=!1,yg(e));break;case 4:o=hs,hs=Iu(e.stateNode.containerInfo),ra(t,e),oa(e),hs=o;break;case 12:ra(t,e),oa(e);break;case 31:ra(t,e),oa(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Su(e,o)));break;case 13:ra(t,e),oa(e),e.child.flags&8192&&e.memoizedState!==null!=(s!==null&&s.memoizedState!==null)&&(Cu=Ge()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Su(e,o)));break;case 22:d=e.memoizedState!==null;var H=s!==null&&s.memoizedState!==null,se=vi,pe=on;if(vi=se||d,on=pe||H,ra(t,e),on=pe,vi=se,oa(e),o&8192)e:for(t=e.stateNode,t._visibility=d?t._visibility&-2:t._visibility|1,d&&(s===null||H||vi||on||Xl(e)),s=null,t=e;;){if(t.tag===5||t.tag===26){if(s===null){H=s=t;try{if(h=H.stateNode,d)S=h.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{N=H.stateNode;var be=H.memoizedProps.style,re=be!=null&&be.hasOwnProperty("display")?be.display:null;N.style.display=re==null||typeof re=="boolean"?"":(""+re).trim()}}catch(Oe){wt(H,H.return,Oe)}}}else if(t.tag===6){if(s===null){H=t;try{H.stateNode.nodeValue=d?"":H.memoizedProps}catch(Oe){wt(H,H.return,Oe)}}}else if(t.tag===18){if(s===null){H=t;try{var de=H.stateNode;d?ov(de,!0):ov(H.stateNode,!1)}catch(Oe){wt(H,H.return,Oe)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;s===t&&(s=null),t=t.return}s===t&&(s=null),t.sibling.return=t.return,t=t.sibling}o&4&&(o=e.updateQueue,o!==null&&(s=o.retryQueue,s!==null&&(o.retryQueue=null,Su(e,s))));break;case 19:ra(t,e),oa(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Su(e,o)));break;case 30:break;case 21:break;default:ra(t,e),oa(e)}}function oa(e){var t=e.flags;if(t&2){try{for(var s,o=e.return;o!==null;){if(ug(o)){s=o;break}o=o.return}if(s==null)throw Error(r(160));switch(s.tag){case 27:var d=s.stateNode,h=Bf(e);bu(e,h,d);break;case 5:var S=s.stateNode;s.flags&32&&(Ei(S,""),s.flags&=-33);var N=Bf(e);bu(e,N,S);break;case 3:case 4:var H=s.stateNode.containerInfo,se=Bf(e);Ff(e,se,H);break;default:throw Error(r(161))}}catch(pe){wt(e,e.return,pe)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yg(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;yg(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function yi(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)mg(e,t.alternate,t),t=t.sibling}function Xl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:il(4,t,t.return),Xl(t);break;case 1:Fs(t,t.return);var s=t.stateNode;typeof s.componentWillUnmount=="function"&&og(t,t.return,s),Xl(t);break;case 27:tc(t.stateNode);case 26:case 5:Fs(t,t.return),Xl(t);break;case 22:t.memoizedState===null&&Xl(t);break;case 30:Xl(t);break;default:Xl(t)}e=e.sibling}}function wi(e,t,s){for(s=s&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var o=t.alternate,d=e,h=t,S=h.flags;switch(h.tag){case 0:case 11:case 15:wi(d,h,s),Go(4,h);break;case 1:if(wi(d,h,s),o=h,d=o.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(se){wt(o,o.return,se)}if(o=h,d=o.updateQueue,d!==null){var N=o.stateNode;try{var H=d.shared.hiddenCallbacks;if(H!==null)for(d.shared.hiddenCallbacks=null,d=0;d<H.length;d++)ms(H[d],N)}catch(se){wt(o,o.return,se)}}s&&S&64&&rg(h),Vo(h,h.return);break;case 27:dg(h);case 26:case 5:wi(d,h,s),s&&o===null&&S&4&&cg(h),Vo(h,h.return);break;case 12:wi(d,h,s);break;case 31:wi(d,h,s),s&&S&4&&gg(d,h);break;case 13:wi(d,h,s),s&&S&4&&vg(d,h);break;case 22:h.memoizedState===null&&wi(d,h,s),Vo(h,h.return);break;case 30:break;default:wi(d,h,s)}t=t.sibling}}function Pf(e,t){var s=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(s=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==s&&(e!=null&&e.refCount++,s!=null&&zs(s))}function $f(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&zs(e))}function ps(e,t,s,o){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)wg(e,t,s,o),t=t.sibling}function wg(e,t,s,o){var d=t.flags;switch(t.tag){case 0:case 11:case 15:ps(e,t,s,o),d&2048&&Go(9,t);break;case 1:ps(e,t,s,o);break;case 3:ps(e,t,s,o),d&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&zs(e)));break;case 12:if(d&2048){ps(e,t,s,o),e=t.stateNode;try{var h=t.memoizedProps,S=h.id,N=h.onPostCommit;typeof N=="function"&&N(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(H){wt(t,t.return,H)}}else ps(e,t,s,o);break;case 31:ps(e,t,s,o);break;case 13:ps(e,t,s,o);break;case 23:break;case 22:h=t.stateNode,S=t.alternate,t.memoizedState!==null?h._visibility&2?ps(e,t,s,o):Yo(e,t):h._visibility&2?ps(e,t,s,o):(h._visibility|=2,$r(e,t,s,o,(t.subtreeFlags&10256)!==0||!1)),d&2048&&Pf(S,t);break;case 24:ps(e,t,s,o),d&2048&&$f(t.alternate,t);break;default:ps(e,t,s,o)}}function $r(e,t,s,o,d){for(d=d&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var h=e,S=t,N=s,H=o,se=S.flags;switch(S.tag){case 0:case 11:case 15:$r(h,S,N,H,d),Go(8,S);break;case 23:break;case 22:var pe=S.stateNode;S.memoizedState!==null?pe._visibility&2?$r(h,S,N,H,d):Yo(h,S):(pe._visibility|=2,$r(h,S,N,H,d)),d&&se&2048&&Pf(S.alternate,S);break;case 24:$r(h,S,N,H,d),d&&se&2048&&$f(S.alternate,S);break;default:$r(h,S,N,H,d)}t=t.sibling}}function Yo(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var s=e,o=t,d=o.flags;switch(o.tag){case 22:Yo(s,o),d&2048&&Pf(o.alternate,o);break;case 24:Yo(s,o),d&2048&&$f(o.alternate,o);break;default:Yo(s,o)}t=t.sibling}}var Wo=8192;function Ur(e,t,s){if(e.subtreeFlags&Wo)for(e=e.child;e!==null;)bg(e,t,s),e=e.sibling}function bg(e,t,s){switch(e.tag){case 26:Ur(e,t,s),e.flags&Wo&&e.memoizedState!==null&&Ub(s,hs,e.memoizedState,e.memoizedProps);break;case 5:Ur(e,t,s);break;case 3:case 4:var o=hs;hs=Iu(e.stateNode.containerInfo),Ur(e,t,s),hs=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=Wo,Wo=16777216,Ur(e,t,s),Wo=o):Ur(e,t,s));break;default:Ur(e,t,s)}}function Sg(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 Ko(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];wn=o,Cg(o,e)}Sg(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)jg(e),e=e.sibling}function jg(e){switch(e.tag){case 0:case 11:case 15:Ko(e),e.flags&2048&&il(9,e,e.return);break;case 3:Ko(e);break;case 12:Ko(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,ju(e)):Ko(e);break;default:Ko(e)}}function ju(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var s=0;s<t.length;s++){var o=t[s];wn=o,Cg(o,e)}Sg(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:il(8,t,t.return),ju(t);break;case 22:s=t.stateNode,s._visibility&2&&(s._visibility&=-3,ju(t));break;default:ju(t)}e=e.sibling}}function Cg(e,t){for(;wn!==null;){var s=wn;switch(s.tag){case 0:case 11:case 15:il(8,s,t);break;case 23:case 22:if(s.memoizedState!==null&&s.memoizedState.cachePool!==null){var o=s.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:zs(s.memoizedState.cache)}if(o=s.child,o!==null)o.return=s,wn=o;else e:for(s=e;wn!==null;){o=wn;var d=o.sibling,h=o.return;if(hg(o),o===s){wn=null;break e}if(d!==null){d.return=h,wn=d;break e}wn=h}}}var sb={getCacheForType:function(e){var t=mn($t),s=t.data.get(e);return s===void 0&&(s=e(),t.data.set(e,s)),s},cacheSignal:function(){return mn($t).controller.signal}},ib=typeof WeakMap=="function"?WeakMap:Map,vt=0,Tt=null,rt=null,ct=0,yt=0,Ma=null,ll=!1,qr=!1,Uf=!1,bi=0,qt=0,rl=0,Zl=0,qf=0,Na=0,Gr=0,Qo=null,ca=null,Gf=!1,Cu=0,kg=0,ku=1/0,Au=null,ol=null,pn=0,cl=null,Vr=null,Si=0,Vf=0,Yf=null,Ag=null,Xo=0,Wf=null;function Ta(){return(vt&2)!==0&&ct!==0?ct&-ct:z.T!==null?em():tn()}function Mg(){if(Na===0)if((ct&536870912)===0||lt){var e=La;La<<=1,(La&3932160)===0&&(La=262144),Na=e}else Na=536870912;return e=ka.current,e!==null&&(e.flags|=32),Na}function ua(e,t,s){(e===Tt&&(yt===2||yt===9)||e.cancelPendingCommit!==null)&&(Yr(e,0),ul(e,ct,Na,!1)),bs(e,s),((vt&2)===0||e!==Tt)&&(e===Tt&&((vt&2)===0&&(Zl|=s),qt===4&&ul(e,ct,Na,!1)),Hs(e))}function Ng(e,t,s){if((vt&6)!==0)throw Error(r(327));var o=!s&&(t&127)===0&&(t&e.expiredLanes)===0||_a(e,t),d=o?ob(e,t):Qf(e,t,!0),h=o;do{if(d===0){qr&&!o&&ul(e,t,0,!1);break}else{if(s=e.current.alternate,h&&!lb(s)){d=Qf(e,t,!1),h=!1;continue}if(d===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 N=e;d=Qo;var H=N.current.memoizedState.isDehydrated;if(H&&(Yr(N,S).flags|=256),S=Qf(N,S,!1),S!==2){if(Uf&&!H){N.errorRecoveryDisabledLanes|=h,Zl|=h,d=4;break e}h=ca,ca=d,h!==null&&(ca===null?ca=h:ca.push.apply(ca,h))}d=S}if(h=!1,d!==2)continue}}if(d===1){Yr(e,0),ul(e,t,0,!0);break}e:{switch(o=e,h=d,h){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:ul(o,t,Na,!ll);break e;case 2:ca=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(d=Cu+300-Ge(),10<d)){if(ul(o,t,Na,!ll),ga(o,0,!0)!==0)break e;Si=t,o.timeoutHandle=iv(Tg.bind(null,o,s,ca,Au,Gf,t,Na,Zl,Gr,ll,h,"Throttled",-0,0),d);break e}Tg(o,s,ca,Au,Gf,t,Na,Zl,Gr,ll,h,null,-0,0)}}break}while(!0);Hs(e)}function Tg(e,t,s,o,d,h,S,N,H,se,pe,be,re,de){if(e.timeoutHandle=-1,be=t.subtreeFlags,be&8192||(be&16785408)===16785408){be={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ts},bg(t,h,be);var Oe=(h&62914560)===h?Cu-Ge():(h&4194048)===h?kg-Ge():0;if(Oe=qb(be,Oe),Oe!==null){Si=h,e.cancelPendingCommit=Oe(Og.bind(null,e,t,h,s,o,d,S,N,H,pe,be,null,re,de)),ul(e,h,S,!se);return}}Og(e,t,h,s,o,d,S,N,H)}function lb(e){for(var t=e;;){var s=t.tag;if((s===0||s===11||s===15)&&t.flags&16384&&(s=t.updateQueue,s!==null&&(s=s.stores,s!==null)))for(var o=0;o<s.length;o++){var d=s[o],h=d.getSnapshot;d=d.value;try{if(!Rn(h(),d))return!1}catch{return!1}}if(s=t.child,t.subtreeFlags&16384&&s!==null)s.return=t,t=s;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function ul(e,t,s,o){t&=~qf,t&=~Zl,e.suspendedLanes|=t,e.pingedLanes&=~t,o&&(e.warmLanes|=t),o=e.expirationTimes;for(var d=t;0<d;){var h=31-Ne(d),S=1<<h;o[h]=-1,d&=~S}s!==0&&gr(e,s,t)}function Mu(){return(vt&6)===0?(Zo(0),!1):!0}function Kf(){if(rt!==null){if(yt===0)var e=rt.return;else e=rt,ja=us=null,df(e),Ca=null,Vl=0,e=rt;for(;e!==null;)lg(e.alternate,e),e=e.return;rt=null}}function Yr(e,t){var s=e.timeoutHandle;s!==-1&&(e.timeoutHandle=-1,Ab(s)),s=e.cancelPendingCommit,s!==null&&(e.cancelPendingCommit=null,s()),Si=0,Kf(),Tt=e,rt=s=qa(e.current,null),ct=t,yt=0,Ma=null,ll=!1,qr=_a(e,t),Uf=!1,Gr=Na=qf=Zl=rl=qt=0,ca=Qo=null,Gf=!1,(t&8)!==0&&(t|=t&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=t;0<o;){var d=31-Ne(o),h=1<<d;t|=e[d],o&=~h}return bi=t,Dr(),s}function Eg(e,t){et=null,z.H=$o,t===tl||t===Or?(t=su(),yt=3):t===Bo?(t=su(),yt=4):yt=t===Mf?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ma=t,rt===null&&(qt=1,gu(e,Hn(t,e.current)))}function Rg(){var e=ka.current;return e===null?!0:(ct&4194048)===ct?Wa===null:(ct&62914560)===ct||(ct&536870912)!==0?e===Wa:!1}function Dg(){var e=z.H;return z.H=$o,e===null?$o:e}function Lg(){var e=z.A;return z.A=sb,e}function Nu(){qt=4,ll||(ct&4194048)!==ct&&ka.current!==null||(qr=!0),(rl&134217727)===0&&(Zl&134217727)===0||Tt===null||ul(Tt,ct,Na,!1)}function Qf(e,t,s){var o=vt;vt|=2;var d=Dg(),h=Lg();(Tt!==e||ct!==t)&&(Au=null,Yr(e,t)),t=!1;var S=qt;e:do try{if(yt!==0&&rt!==null){var N=rt,H=Ma;switch(yt){case 8:Kf(),S=6;break e;case 3:case 2:case 9:case 6:ka.current===null&&(t=!0);var se=yt;if(yt=0,Ma=null,Wr(e,N,H,se),s&&qr){S=0;break e}break;default:se=yt,yt=0,Ma=null,Wr(e,N,H,se)}}rb(),S=qt;break}catch(pe){Eg(e,pe)}while(!0);return t&&e.shellSuspendCounter++,ja=us=null,vt=o,z.H=d,z.A=h,rt===null&&(Tt=null,ct=0,Dr()),S}function rb(){for(;rt!==null;)_g(rt)}function ob(e,t){var s=vt;vt|=2;var o=Dg(),d=Lg();Tt!==e||ct!==t?(Au=null,ku=Ge()+500,Yr(e,t)):qr=_a(e,t);e:do try{if(yt!==0&&rt!==null){t=rt;var h=Ma;t:switch(yt){case 1:yt=0,Ma=null,Wr(e,t,h,1);break;case 2:case 9:if(nu(h)){yt=0,Ma=null,zg(t);break}t=function(){yt!==2&&yt!==9||Tt!==e||(yt=7),Hs(e)},h.then(t,t);break e;case 3:yt=7;break e;case 4:yt=5;break e;case 7:nu(h)?(yt=0,Ma=null,zg(t)):(yt=0,Ma=null,Wr(e,t,h,7));break;case 5:var S=null;switch(rt.tag){case 26:S=rt.memoizedState;case 5:case 27:var N=rt;if(S?wv(S):N.stateNode.complete){yt=0,Ma=null;var H=N.sibling;if(H!==null)rt=H;else{var se=N.return;se!==null?(rt=se,Tu(se)):rt=null}break t}}yt=0,Ma=null,Wr(e,t,h,5);break;case 6:yt=0,Ma=null,Wr(e,t,h,6);break;case 8:Kf(),qt=6;break e;default:throw Error(r(462))}}cb();break}catch(pe){Eg(e,pe)}while(!0);return ja=us=null,z.H=o,z.A=d,vt=s,rt!==null?0:(Tt=null,ct=0,Dr(),qt)}function cb(){for(;rt!==null&&!Fe();)_g(rt)}function _g(e){var t=sg(e.alternate,e,bi);e.memoizedProps=e.pendingProps,t===null?Tu(e):rt=t}function zg(e){var t=e,s=t.alternate;switch(t.tag){case 15:case 0:t=Zp(s,t,t.pendingProps,t.type,void 0,ct);break;case 11:t=Zp(s,t,t.pendingProps,t.type.render,t.ref,ct);break;case 5:df(t);default:lg(s,t),t=rt=To(t,bi),t=sg(s,t,bi)}e.memoizedProps=e.pendingProps,t===null?Tu(e):rt=t}function Wr(e,t,s,o){ja=us=null,df(t),Ca=null,Vl=0;var d=t.return;try{if(Xw(e,d,t,s,ct)){qt=1,gu(e,Hn(s,e.current)),rt=null;return}}catch(h){if(d!==null)throw rt=d,h;qt=1,gu(e,Hn(s,e.current)),rt=null;return}t.flags&32768?(lt||o===1?e=!0:qr||(ct&536870912)!==0?e=!1:(ll=e=!0,(o===2||o===9||o===3||o===6)&&(o=ka.current,o!==null&&o.tag===13&&(o.flags|=16384))),Ig(t,e)):Tu(t)}function Tu(e){var t=e;do{if((t.flags&32768)!==0){Ig(t,ll);return}e=t.return;var s=eb(t.alternate,t,bi);if(s!==null){rt=s;return}if(t=t.sibling,t!==null){rt=t;return}rt=t=e}while(t!==null);qt===0&&(qt=5)}function Ig(e,t){do{var s=tb(e.alternate,e);if(s!==null){s.flags&=32767,rt=s;return}if(s=e.return,s!==null&&(s.flags|=32768,s.subtreeFlags=0,s.deletions=null),!t&&(e=e.sibling,e!==null)){rt=e;return}rt=e=s}while(e!==null);qt=6,rt=null}function Og(e,t,s,o,d,h,S,N,H){e.cancelPendingCommit=null;do Eu();while(pn!==0);if((vt&6)!==0)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(h=t.lanes|t.childLanes,h|=Ao,pr(e,s,h,S,N,H),e===Tt&&(rt=Tt=null,ct=0),Vr=t,cl=e,Si=s,Vf=h,Yf=d,Ag=o,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,mb(Yn,function(){return $g(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||o){o=z.T,z.T=null,d=Q.p,Q.p=2,S=vt,vt|=4;try{nb(e,t,s)}finally{vt=S,Q.p=d,z.T=o}}pn=1,Bg(),Fg(),Hg()}}function Bg(){if(pn===1){pn=0;var e=cl,t=Vr,s=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||s){s=z.T,z.T=null;var o=Q.p;Q.p=2;var d=vt;vt|=4;try{xg(t,e);var h=om,S=Gi(e.containerInfo),N=h.focusedElem,H=h.selectionRange;if(S!==N&&N&&N.ownerDocument&&Tr(N.ownerDocument.documentElement,N)){if(H!==null&&jo(N)){var se=H.start,pe=H.end;if(pe===void 0&&(pe=se),"selectionStart"in N)N.selectionStart=se,N.selectionEnd=Math.min(pe,N.value.length);else{var be=N.ownerDocument||document,re=be&&be.defaultView||window;if(re.getSelection){var de=re.getSelection(),Oe=N.textContent.length,qe=Math.min(H.start,Oe),Ct=H.end===void 0?qe:Math.min(H.end,Oe);!de.extend&&qe>Ct&&(S=Ct,Ct=qe,qe=S);var Z=Nr(N,qe),G=Nr(N,Ct);if(Z&&G&&(de.rangeCount!==1||de.anchorNode!==Z.node||de.anchorOffset!==Z.offset||de.focusNode!==G.node||de.focusOffset!==G.offset)){var ae=be.createRange();ae.setStart(Z.node,Z.offset),de.removeAllRanges(),qe>Ct?(de.addRange(ae),de.extend(G.node,G.offset)):(ae.setEnd(G.node,G.offset),de.addRange(ae))}}}}for(be=[],de=N;de=de.parentNode;)de.nodeType===1&&be.push({element:de,left:de.scrollLeft,top:de.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<be.length;N++){var ye=be[N];ye.element.scrollLeft=ye.left,ye.element.scrollTop=ye.top}}$u=!!rm,om=rm=null}finally{vt=d,Q.p=o,z.T=s}}e.current=t,pn=2}}function Fg(){if(pn===2){pn=0;var e=cl,t=Vr,s=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||s){s=z.T,z.T=null;var o=Q.p;Q.p=2;var d=vt;vt|=4;try{mg(e,t.alternate,t)}finally{vt=d,Q.p=o,z.T=s}}pn=3}}function Hg(){if(pn===4||pn===3){pn=0,Le();var e=cl,t=Vr,s=Si,o=Ag;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?pn=5:(pn=0,Vr=cl=null,Pg(e,e.pendingLanes));var d=e.pendingLanes;if(d===0&&(ol=null),ta(s),t=t.stateNode,mt&&typeof mt.onCommitFiberRoot=="function")try{mt.onCommitFiberRoot(ys,t,void 0,(t.current.flags&128)===128)}catch{}if(o!==null){t=z.T,d=Q.p,Q.p=2,z.T=null;try{for(var h=e.onRecoverableError,S=0;S<o.length;S++){var N=o[S];h(N.value,{componentStack:N.stack})}}finally{z.T=t,Q.p=d}}(Si&3)!==0&&Eu(),Hs(e),d=e.pendingLanes,(s&261930)!==0&&(d&42)!==0?e===Wf?Xo++:(Xo=0,Wf=e):Xo=0,Zo(0)}}function Pg(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,zs(t)))}function Eu(){return Bg(),Fg(),Hg(),$g()}function $g(){if(pn!==5)return!1;var e=cl,t=Vf;Vf=0;var s=ta(Si),o=z.T,d=Q.p;try{Q.p=32>s?32:s,z.T=null,s=Yf,Yf=null;var h=cl,S=Si;if(pn=0,Vr=cl=null,Si=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,jg(h.current),wg(h,h.current,S,s),vt=N,Zo(0,!1),mt&&typeof mt.onPostCommitFiberRoot=="function")try{mt.onPostCommitFiberRoot(ys,h)}catch{}return!0}finally{Q.p=d,z.T=o,Pg(e,t)}}function Ug(e,t,s){t=Hn(s,t),t=Af(e.stateNode,t,2),e=Re(e,t,2),e!==null&&(bs(e,2),Hs(e))}function wt(e,t,s){if(e.tag===3)Ug(e,e,s);else for(;t!==null;){if(t.tag===3){Ug(t,e,s);break}else if(t.tag===1){var o=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(ol===null||!ol.has(o))){e=Hn(s,e),s=qp(2),o=Re(t,s,2),o!==null&&(Gp(s,o,t,e),bs(o,2),Hs(o));break}}t=t.return}}function Xf(e,t,s){var o=e.pingCache;if(o===null){o=e.pingCache=new ib;var d=new Set;o.set(t,d)}else d=o.get(t),d===void 0&&(d=new Set,o.set(t,d));d.has(s)||(Uf=!0,d.add(s),e=ub.bind(null,e,t,s),t.then(e,e))}function ub(e,t,s){var o=e.pingCache;o!==null&&o.delete(t),e.pingedLanes|=e.suspendedLanes&s,e.warmLanes&=~s,Tt===e&&(ct&s)===s&&(qt===4||qt===3&&(ct&62914560)===ct&&300>Ge()-Cu?(vt&2)===0&&Yr(e,0):qf|=s,Gr===ct&&(Gr=0)),Hs(e)}function qg(e,t){t===0&&(t=qs()),e=ba(e,t),e!==null&&(bs(e,t),Hs(e))}function db(e){var t=e.memoizedState,s=0;t!==null&&(s=t.retryLane),qg(e,s)}function fb(e,t){var s=0;switch(e.tag){case 31:case 13:var o=e.stateNode,d=e.memoizedState;d!==null&&(s=d.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(r(314))}o!==null&&o.delete(t),qg(e,s)}function mb(e,t){return it(e,t)}var Ru=null,Kr=null,Zf=!1,Du=!1,Jf=!1,dl=0;function Hs(e){e!==Kr&&e.next===null&&(Kr===null?Ru=Kr=e:Kr=Kr.next=e),Du=!0,Zf||(Zf=!0,pb())}function Zo(e,t){if(!Jf&&Du){Jf=!0;do for(var s=!1,o=Ru;o!==null;){if(e!==0){var d=o.pendingLanes;if(d===0)var h=0;else{var S=o.suspendedLanes,N=o.pingedLanes;h=(1<<31-Ne(42|e)+1)-1,h&=d&~(S&~N),h=h&201326741?h&201326741|1:h?h|2:0}h!==0&&(s=!0,Wg(o,h))}else h=ct,h=ga(o,o===Tt?h:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(h&3)===0||_a(o,h)||(s=!0,Wg(o,h));o=o.next}while(s);Jf=!1}}function hb(){Gg()}function Gg(){Du=Zf=!1;var e=0;dl!==0&&kb()&&(e=dl);for(var t=Ge(),s=null,o=Ru;o!==null;){var d=o.next,h=Vg(o,t);h===0?(o.next=null,s===null?Ru=d:s.next=d,d===null&&(Kr=s)):(s=o,(e!==0||(h&3)!==0)&&(Du=!0)),o=d}pn!==0&&pn!==5||Zo(e),dl!==0&&(dl=0)}function Vg(e,t){for(var s=e.suspendedLanes,o=e.pingedLanes,d=e.expirationTimes,h=e.pendingLanes&-62914561;0<h;){var S=31-Ne(h),N=1<<S,H=d[S];H===-1?((N&s)===0||(N&o)!==0)&&(d[S]=Vt(N,t)):H<=t&&(e.expiredLanes|=N),h&=~N}if(t=Tt,s=ct,s=ga(e,e===t?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,s===0||e===t&&(yt===2||yt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&he(o),e.callbackNode=null,e.callbackPriority=0;if((s&3)===0||_a(e,s)){if(t=s&-s,t===e.callbackPriority)return t;switch(o!==null&&he(o),ta(s)){case 2:case 8:s=kn;break;case 32:s=Yn;break;case 268435456:s=Da;break;default:s=Yn}return o=Yg.bind(null,e),s=it(s,o),e.callbackPriority=t,e.callbackNode=s,t}return o!==null&&o!==null&&he(o),e.callbackPriority=2,e.callbackNode=null,2}function Yg(e,t){if(pn!==0&&pn!==5)return e.callbackNode=null,e.callbackPriority=0,null;var s=e.callbackNode;if(Eu()&&e.callbackNode!==s)return null;var o=ct;return o=ga(e,e===Tt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Ng(e,o,t),Vg(e,Ge()),e.callbackNode!=null&&e.callbackNode===s?Yg.bind(null,e):null)}function Wg(e,t){if(Eu())return null;Ng(e,t,!0)}function pb(){Mb(function(){(vt&6)!==0?it(gn,hb):Gg()})}function em(){if(dl===0){var e=fs;e===0&&(e=kt,kt<<=1,(kt&261888)===0&&(kt=256)),dl=e}return dl}function Kg(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:mo(""+e)}function Qg(e,t){var s=t.ownerDocument.createElement("input");return s.name=t.name,s.value=t.value,e.id&&s.setAttribute("form",e.id),t.parentNode.insertBefore(s,t),e=new FormData(e),s.parentNode.removeChild(s),e}function gb(e,t,s,o,d){if(t==="submit"&&s&&s.stateNode===d){var h=Kg((d[ke]||null).action),S=o.submitter;S&&(t=(t=S[ke]||null)?Kg(t.formAction):S.getAttribute("formAction"),t!==null&&(h=t,S=null));var N=new va("action","action",null,o,d);e.push({event:N,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(dl!==0){var H=S?Qg(d,S):new FormData(d);wf(s,{pending:!0,data:H,method:d.method,action:h},null,H)}}else typeof h=="function"&&(N.preventDefault(),H=S?Qg(d,S):new FormData(d),wf(s,{pending:!0,data:H,method:d.method,action:h},h,H))},currentTarget:d}]})}}for(var tm=0;tm<$l.length;tm++){var nm=$l[tm],vb=nm.toLowerCase(),xb=nm[0].toUpperCase()+nm.slice(1);Qn(vb,"on"+xb)}Qn(Pl,"onAnimationEnd"),Qn(Yi,"onAnimationIteration"),Qn(ya,"onAnimationStart"),Qn("dblclick","onDoubleClick"),Qn("focusin","onFocus"),Qn("focusout","onBlur"),Qn(Wc,"onTransitionRun"),Qn(Co,"onTransitionStart"),Qn(Kc,"onTransitionCancel"),Qn(yn,"onTransitionEnd"),bt("onMouseEnter",["mouseout","mouseover"]),bt("onMouseLeave",["mouseout","mouseover"]),bt("onPointerEnter",["pointerout","pointerover"]),bt("onPointerLeave",["pointerout","pointerover"]),Yt("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Yt("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Yt("onBeforeInput",["compositionend","keypress","textInput","paste"]),Yt("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Yt("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Yt("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Jo="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(" "),yb=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Jo));function Xg(e,t){t=(t&4)!==0;for(var s=0;s<e.length;s++){var o=e[s],d=o.event;o=o.listeners;e:{var h=void 0;if(t)for(var S=o.length-1;0<=S;S--){var N=o[S],H=N.instance,se=N.currentTarget;if(N=N.listener,H!==h&&d.isPropagationStopped())break e;h=N,d.currentTarget=se;try{h(d)}catch(pe){Es(pe)}d.currentTarget=null,h=H}else for(S=0;S<o.length;S++){if(N=o[S],H=N.instance,se=N.currentTarget,N=N.listener,H!==h&&d.isPropagationStopped())break e;h=N,d.currentTarget=se;try{h(d)}catch(pe){Es(pe)}d.currentTarget=null,h=H}}}}function ot(e,t){var s=t[Ke];s===void 0&&(s=t[Ke]=new Set);var o=e+"__bubble";s.has(o)||(Zg(t,e,2,!1),s.add(o))}function am(e,t,s){var o=0;t&&(o|=4),Zg(s,e,o,t)}var Lu="_reactListening"+Math.random().toString(36).slice(2);function sm(e){if(!e[Lu]){e[Lu]=!0,js.forEach(function(s){s!=="selectionchange"&&(yb.has(s)||am(s,!1,e),am(s,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Lu]||(t[Lu]=!0,am("selectionchange",!1,t))}}function Zg(e,t,s,o){switch(Mv(t)){case 2:var d=Yb;break;case 8:d=Wb;break;default:d=ym}s=d.bind(null,t,s,e),d=void 0,!_i||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(d=!0),o?d!==void 0?e.addEventListener(t,s,{capture:!0,passive:d}):e.addEventListener(t,s,!0):d!==void 0?e.addEventListener(t,s,{passive:d}):e.addEventListener(t,s,!1)}function im(e,t,s,o,d){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 N=o.stateNode.containerInfo;if(N===d)break;if(S===4)for(S=o.return;S!==null;){var H=S.tag;if((H===3||H===4)&&S.stateNode.containerInfo===d)return;S=S.return}for(;N!==null;){if(S=Ft(N),S===null)return;if(H=S.tag,H===5||H===6||H===26||H===27){o=h=S;continue e}N=N.parentNode}}o=o.return}ho(function(){var se=h,pe=wr(s),be=[];e:{var re=ko.get(e);if(re!==void 0){var de=va,Oe=e;switch(e){case"keypress":if(_l(s)===0)break e;case"keydown":case"keyup":de=Vd;break;case"focusin":Oe="focus",de=Fi;break;case"focusout":Oe="blur",de=Fi;break;case"beforeblur":case"afterblur":de=Fi;break;case"click":if(s.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":de=Ks;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":de=Bi;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":de=Uc;break;case Pl:case Yi:case ya:de=Hc;break;case yn:de=qc;break;case"scroll":case"scrollend":de=Fc;break;case"wheel":de=Xs;break;case"copy":case"cut":case"paste":de=Fa;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":de=Qs;break;case"toggle":case"beforetoggle":de=dn}var qe=(t&4)!==0,Ct=!qe&&(e==="scroll"||e==="scrollend"),Z=qe?re!==null?re+"Capture":null:re;qe=[];for(var G=se,ae;G!==null;){var ye=G;if(ae=ye.stateNode,ye=ye.tag,ye!==5&&ye!==26&&ye!==27||ae===null||Z===null||(ye=ns(G,Z),ye!=null&&qe.push(ec(G,ye,ae))),Ct)break;G=G.return}0<qe.length&&(re=new de(re,Oe,null,s,pe),be.push({event:re,listeners:qe}))}}if((t&7)===0){e:{if(re=e==="mouseover"||e==="pointerover",de=e==="mouseout"||e==="pointerout",re&&s!==yr&&(Oe=s.relatedTarget||s.fromElement)&&(Ft(Oe)||Oe[_e]))break e;if((de||re)&&(re=pe.window===pe?pe:(re=pe.ownerDocument)?re.defaultView||re.parentWindow:window,de?(Oe=s.relatedTarget||s.toElement,de=se,Oe=Oe?Ft(Oe):null,Oe!==null&&(Ct=u(Oe),qe=Oe.tag,Oe!==Ct||qe!==5&&qe!==27&&qe!==6)&&(Oe=null)):(de=null,Oe=se),de!==Oe)){if(qe=Ks,ye="onMouseLeave",Z="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(qe=Qs,ye="onPointerLeave",Z="onPointerEnter",G="pointer"),Ct=de==null?re:At(de),ae=Oe==null?re:At(Oe),re=new qe(ye,G+"leave",de,s,pe),re.target=Ct,re.relatedTarget=ae,ye=null,Ft(pe)===se&&(qe=new qe(Z,G+"enter",Oe,s,pe),qe.target=ae,qe.relatedTarget=Ct,ye=qe),Ct=ye,de&&Oe)t:{for(qe=wb,Z=de,G=Oe,ae=0,ye=Z;ye;ye=qe(ye))ae++;ye=0;for(var Ue=G;Ue;Ue=qe(Ue))ye++;for(;0<ae-ye;)Z=qe(Z),ae--;for(;0<ye-ae;)G=qe(G),ye--;for(;ae--;){if(Z===G||G!==null&&Z===G.alternate){qe=Z;break t}Z=qe(Z),G=qe(G)}qe=null}else qe=null;de!==null&&Jg(be,re,de,qe,!1),Oe!==null&&Ct!==null&&Jg(be,Ct,Oe,qe,!0)}}e:{if(re=se?At(se):window,de=re.nodeName&&re.nodeName.toLowerCase(),de==="select"||de==="input"&&re.type==="file")var ht=Gc;else if(vo(re))if(xo)ht=qi;else{ht=Ns;var He=Yc}else de=re.nodeName,!de||de.toLowerCase()!=="input"||re.type!=="checkbox"&&re.type!=="radio"?se&&Dl(se.elementType)&&(ht=Gc):ht=Mr;if(ht&&(ht=ht(e,se))){Zs(be,ht,s,pe);break e}He&&He(e,re,se),e==="focusout"&&se&&re.type==="number"&&se.memoizedProps.value!=null&&Ba(re,"number",re.value)}switch(He=se?At(se):window,e){case"focusin":(vo(He)||He.contentEditable==="true")&&(ei=He,Vi=se,ti=null);break;case"focusout":ti=Vi=ei=null;break;case"mousedown":Fl=!0;break;case"contextmenu":case"mouseup":case"dragend":Fl=!1,Hl(be,s,pe);break;case"selectionchange":if(Er)break;case"keydown":case"keyup":Hl(be,s,pe)}var nt;if(Cr)e:{switch(e){case"compositionstart":var ut="onCompositionStart";break e;case"compositionend":ut="onCompositionEnd";break e;case"compositionupdate":ut="onCompositionUpdate";break e}ut=void 0}else Hi?Ol(e,s)&&(ut="onCompositionEnd"):e==="keydown"&&s.keyCode===229&&(ut="onCompositionStart");ut&&(Pt&&s.locale!=="ko"&&(Hi||ut!=="onCompositionStart"?ut==="onCompositionEnd"&&Hi&&(nt=po()):(as=pe,br="value"in as?as.value:as.textContent,Hi=!0)),He=_u(se,ut),0<He.length&&(ut=new Pc(ut,e,null,s,pe),be.push({event:ut,listeners:He}),nt?ut.data=nt:(nt=$a(s),nt!==null&&(ut.data=nt)))),(nt=Kd?Qd(e,s):kr(e,s))&&(ut=_u(se,"onBeforeInput"),0<ut.length&&(He=new Pc("onBeforeInput","beforeinput",null,s,pe),be.push({event:He,listeners:ut}),He.data=nt)),gb(be,e,se,s,pe)}Xg(be,t)})}function ec(e,t,s){return{instance:e,listener:t,currentTarget:s}}function _u(e,t){for(var s=t+"Capture",o=[];e!==null;){var d=e,h=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||h===null||(d=ns(e,s),d!=null&&o.unshift(ec(e,d,h)),d=ns(e,t),d!=null&&o.push(ec(e,d,h))),e.tag===3)return o;e=e.return}return[]}function wb(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Jg(e,t,s,o,d){for(var h=t._reactName,S=[];s!==null&&s!==o;){var N=s,H=N.alternate,se=N.stateNode;if(N=N.tag,H!==null&&H===o)break;N!==5&&N!==26&&N!==27||se===null||(H=se,d?(se=ns(s,h),se!=null&&S.unshift(ec(s,se,H))):d||(se=ns(s,h),se!=null&&S.push(ec(s,se,H)))),s=s.return}S.length!==0&&e.push({event:t,listeners:S})}var bb=/\r\n?/g,Sb=/\u0000|\uFFFD/g;function ev(e){return(typeof e=="string"?e:""+e).replace(bb,`
9
+ `).replace(Sb,"")}function tv(e,t){return t=ev(t),ev(e)===t}function jt(e,t,s,o,d,h){switch(s){case"children":typeof o=="string"?t==="body"||t==="textarea"&&o===""||Ei(e,o):(typeof o=="number"||typeof o=="bigint")&&t!=="body"&&Ei(e,""+o);break;case"className":Cs(e,"class",o);break;case"tabIndex":Cs(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":Cs(e,s,o);break;case"style":Ws(e,o,h);break;case"data":if(t!=="object"){Cs(e,"data",o);break}case"src":case"href":if(o===""&&(t!=="a"||s!=="href")){e.removeAttribute(s);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=mo(""+o),e.setAttribute(s,o);break;case"action":case"formAction":if(typeof o=="function"){e.setAttribute(s,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof h=="function"&&(s==="formAction"?(t!=="input"&&jt(e,t,"name",d.name,d,null),jt(e,t,"formEncType",d.formEncType,d,null),jt(e,t,"formMethod",d.formMethod,d,null),jt(e,t,"formTarget",d.formTarget,d,null)):(jt(e,t,"encType",d.encType,d,null),jt(e,t,"method",d.method,d,null),jt(e,t,"target",d.target,d,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(s);break}o=mo(""+o),e.setAttribute(s,o);break;case"onClick":o!=null&&(e.onclick=ts);break;case"onScroll":o!=null&&ot("scroll",e);break;case"onScrollEnd":o!=null&&ot("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(d.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}s=mo(""+o),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,""+o):e.removeAttribute(s);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,""):e.removeAttribute(s);break;case"capture":case"download":o===!0?e.setAttribute(s,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(s,o):e.removeAttribute(s);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(s,o):e.removeAttribute(s);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(s):e.setAttribute(s,o);break;case"popover":ot("beforetoggle",e),ot("toggle",e),Vs(e,"popover",o);break;case"xlinkActuate":Fn(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":Fn(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":Fn(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":Fn(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":Fn(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":Fn(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":Fn(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":Fn(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":Fn(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":Vs(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<s.length)||s[0]!=="o"&&s[0]!=="O"||s[1]!=="n"&&s[1]!=="N")&&(s=Xh.get(s)||s,Vs(e,s,o))}}function lm(e,t,s,o,d,h){switch(s){case"style":Ws(e,o,h);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(r(61));if(s=o.__html,s!=null){if(d.children!=null)throw Error(r(60));e.innerHTML=s}}break;case"children":typeof o=="string"?Ei(e,o):(typeof o=="number"||typeof o=="bigint")&&Ei(e,""+o);break;case"onScroll":o!=null&&ot("scroll",e);break;case"onScrollEnd":o!=null&&ot("scrollend",e);break;case"onClick":o!=null&&(e.onclick=ts);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!vn.hasOwnProperty(s))e:{if(s[0]==="o"&&s[1]==="n"&&(d=s.endsWith("Capture"),t=s.slice(2,d?s.length-7:void 0),h=e[ke]||null,h=h!=null?h[s]:null,typeof h=="function"&&e.removeEventListener(t,h,d),typeof o=="function")){typeof h!="function"&&h!==null&&(s in e?e[s]=null:e.hasAttribute(s)&&e.removeAttribute(s)),e.addEventListener(t,o,d);break e}s in e?e[s]=o:o===!0?e.setAttribute(s,""):Vs(e,s,o)}}}function zn(e,t,s){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ot("error",e),ot("load",e);var o=!1,d=!1,h;for(h in s)if(s.hasOwnProperty(h)){var S=s[h];if(S!=null)switch(h){case"src":o=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:jt(e,t,h,S,s,null)}}d&&jt(e,t,"srcSet",s.srcSet,s,null),o&&jt(e,t,"src",s.src,s,null);return;case"input":ot("invalid",e);var N=h=S=d=null,H=null,se=null;for(o in s)if(s.hasOwnProperty(o)){var pe=s[o];if(pe!=null)switch(o){case"name":d=pe;break;case"type":S=pe;break;case"checked":H=pe;break;case"defaultChecked":se=pe;break;case"value":h=pe;break;case"defaultValue":N=pe;break;case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(r(137,t));break;default:jt(e,t,o,pe,s,null)}}ks(e,h,N,H,se,S,d,!1);return;case"select":ot("invalid",e),o=S=h=null;for(d in s)if(s.hasOwnProperty(d)&&(N=s[d],N!=null))switch(d){case"value":h=N;break;case"defaultValue":S=N;break;case"multiple":o=N;default:jt(e,t,d,N,s,null)}t=h,s=S,e.multiple=!!o,t!=null?Ti(e,!!o,t,!1):s!=null&&Ti(e,!!o,s,!0);return;case"textarea":ot("invalid",e),h=d=o=null;for(S in s)if(s.hasOwnProperty(S)&&(N=s[S],N!=null))switch(S){case"value":o=N;break;case"defaultValue":d=N;break;case"children":h=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:jt(e,t,S,N,s,null)}$d(e,o,d,h);return;case"option":for(H in s)s.hasOwnProperty(H)&&(o=s[H],o!=null)&&(H==="selected"?e.selected=o&&typeof o!="function"&&typeof o!="symbol":jt(e,t,H,o,s,null));return;case"dialog":ot("beforetoggle",e),ot("toggle",e),ot("cancel",e),ot("close",e);break;case"iframe":case"object":ot("load",e);break;case"video":case"audio":for(o=0;o<Jo.length;o++)ot(Jo[o],e);break;case"image":ot("error",e),ot("load",e);break;case"details":ot("toggle",e);break;case"embed":case"source":case"link":ot("error",e),ot("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(se in s)if(s.hasOwnProperty(se)&&(o=s[se],o!=null))switch(se){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:jt(e,t,se,o,s,null)}return;default:if(Dl(t)){for(pe in s)s.hasOwnProperty(pe)&&(o=s[pe],o!==void 0&&lm(e,t,pe,o,s,void 0));return}}for(N in s)s.hasOwnProperty(N)&&(o=s[N],o!=null&&jt(e,t,N,o,s,null))}function jb(e,t,s,o){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,h=null,S=null,N=null,H=null,se=null,pe=null;for(de in s){var be=s[de];if(s.hasOwnProperty(de)&&be!=null)switch(de){case"checked":break;case"value":break;case"defaultValue":H=be;default:o.hasOwnProperty(de)||jt(e,t,de,null,o,be)}}for(var re in o){var de=o[re];if(be=s[re],o.hasOwnProperty(re)&&(de!=null||be!=null))switch(re){case"type":h=de;break;case"name":d=de;break;case"checked":se=de;break;case"defaultChecked":pe=de;break;case"value":S=de;break;case"defaultValue":N=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(r(137,t));break;default:de!==be&&jt(e,t,re,de,o,be)}}Oa(e,S,N,H,se,pe,h,d);return;case"select":de=S=N=re=null;for(h in s)if(H=s[h],s.hasOwnProperty(h)&&H!=null)switch(h){case"value":break;case"multiple":de=H;default:o.hasOwnProperty(h)||jt(e,t,h,null,o,H)}for(d in o)if(h=o[d],H=s[d],o.hasOwnProperty(d)&&(h!=null||H!=null))switch(d){case"value":re=h;break;case"defaultValue":N=h;break;case"multiple":S=h;default:h!==H&&jt(e,t,d,h,o,H)}t=N,s=S,o=de,re!=null?Ti(e,!!s,re,!1):!!o!=!!s&&(t!=null?Ti(e,!!s,t,!0):Ti(e,!!s,s?[]:"",!1));return;case"textarea":de=re=null;for(N in s)if(d=s[N],s.hasOwnProperty(N)&&d!=null&&!o.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:jt(e,t,N,null,o,d)}for(S in o)if(d=o[S],h=s[S],o.hasOwnProperty(S)&&(d!=null||h!=null))switch(S){case"value":re=d;break;case"defaultValue":de=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(91));break;default:d!==h&&jt(e,t,S,d,o,h)}xr(e,re,de);return;case"option":for(var Oe in s)re=s[Oe],s.hasOwnProperty(Oe)&&re!=null&&!o.hasOwnProperty(Oe)&&(Oe==="selected"?e.selected=!1:jt(e,t,Oe,null,o,re));for(H in o)re=o[H],de=s[H],o.hasOwnProperty(H)&&re!==de&&(re!=null||de!=null)&&(H==="selected"?e.selected=re&&typeof re!="function"&&typeof re!="symbol":jt(e,t,H,re,o,de));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 qe in s)re=s[qe],s.hasOwnProperty(qe)&&re!=null&&!o.hasOwnProperty(qe)&&jt(e,t,qe,null,o,re);for(se in o)if(re=o[se],de=s[se],o.hasOwnProperty(se)&&re!==de&&(re!=null||de!=null))switch(se){case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(r(137,t));break;default:jt(e,t,se,re,o,de)}return;default:if(Dl(t)){for(var Ct in s)re=s[Ct],s.hasOwnProperty(Ct)&&re!==void 0&&!o.hasOwnProperty(Ct)&&lm(e,t,Ct,void 0,o,re);for(pe in o)re=o[pe],de=s[pe],!o.hasOwnProperty(pe)||re===de||re===void 0&&de===void 0||lm(e,t,pe,re,o,de);return}}for(var Z in s)re=s[Z],s.hasOwnProperty(Z)&&re!=null&&!o.hasOwnProperty(Z)&&jt(e,t,Z,null,o,re);for(be in o)re=o[be],de=s[be],!o.hasOwnProperty(be)||re===de||re==null&&de==null||jt(e,t,be,re,o,de)}function nv(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Cb(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,s=performance.getEntriesByType("resource"),o=0;o<s.length;o++){var d=s[o],h=d.transferSize,S=d.initiatorType,N=d.duration;if(h&&N&&nv(S)){for(S=0,N=d.responseEnd,o+=1;o<s.length;o++){var H=s[o],se=H.startTime;if(se>N)break;var pe=H.transferSize,be=H.initiatorType;pe&&nv(be)&&(H=H.responseEnd,S+=pe*(H<N?1:(N-se)/(H-se)))}if(--o,t+=8*(h+S)/(d.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 rm=null,om=null;function zu(e){return e.nodeType===9?e:e.ownerDocument}function av(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 sv(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 um=null;function kb(){var e=window.event;return e&&e.type==="popstate"?e===um?!1:(um=e,!0):(um=null,!1)}var iv=typeof setTimeout=="function"?setTimeout:void 0,Ab=typeof clearTimeout=="function"?clearTimeout:void 0,lv=typeof Promise=="function"?Promise:void 0,Mb=typeof queueMicrotask=="function"?queueMicrotask:typeof lv<"u"?function(e){return lv.resolve(null).then(e).catch(Nb)}:iv;function Nb(e){setTimeout(function(){throw e})}function fl(e){return e==="head"}function rv(e,t){var s=t,o=0;do{var d=s.nextSibling;if(e.removeChild(s),d&&d.nodeType===8)if(s=d.data,s==="/$"||s==="/&"){if(o===0){e.removeChild(d),Jr(t);return}o--}else if(s==="$"||s==="$?"||s==="$~"||s==="$!"||s==="&")o++;else if(s==="html")tc(e.ownerDocument.documentElement);else if(s==="head"){s=e.ownerDocument.head,tc(s);for(var h=s.firstChild;h;){var S=h.nextSibling,N=h.nodeName;h[dt]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&h.rel.toLowerCase()==="stylesheet"||s.removeChild(h),h=S}}else s==="body"&&tc(e.ownerDocument.body);s=d}while(s);Jr(t)}function ov(e,t){var s=e;e=0;do{var o=s.nextSibling;if(s.nodeType===1?t?(s._stashedDisplay=s.style.display,s.style.display="none"):(s.style.display=s._stashedDisplay||"",s.getAttribute("style")===""&&s.removeAttribute("style")):s.nodeType===3&&(t?(s._stashedText=s.nodeValue,s.nodeValue=""):s.nodeValue=s._stashedText||""),o&&o.nodeType===8)if(s=o.data,s==="/$"){if(e===0)break;e--}else s!=="$"&&s!=="$?"&&s!=="$~"&&s!=="$!"||e++;s=o}while(s)}function dm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var s=t;switch(t=t.nextSibling,s.nodeName){case"HTML":case"HEAD":case"BODY":dm(s),nn(s);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(s.rel.toLowerCase()==="stylesheet")continue}e.removeChild(s)}}function Tb(e,t,s,o){for(;e.nodeType===1;){var d=s;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[dt])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!==d.rel||e.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||e.getAttribute("title")!==(d.title==null?null:d.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(h=e.getAttribute("src"),(h!==(d.src==null?null:d.src)||e.getAttribute("type")!==(d.type==null?null:d.type)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&h&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var h=d.name==null?null:""+d.name;if(d.type==="hidden"&&e.getAttribute("name")===h)return e}else return e;if(e=Ka(e.nextSibling),e===null)break}return null}function Eb(e,t,s){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!s||(e=Ka(e.nextSibling),e===null))return null;return e}function cv(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=Ka(e.nextSibling),e===null))return null;return e}function fm(e){return e.data==="$?"||e.data==="$~"}function mm(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function Rb(e,t){var s=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||s.readyState!=="loading")t();else{var o=function(){t(),s.removeEventListener("DOMContentLoaded",o)};s.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Ka(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var hm=null;function uv(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="/$"||s==="/&"){if(t===0)return Ka(e.nextSibling);t--}else s!=="$"&&s!=="$!"&&s!=="$?"&&s!=="$~"&&s!=="&"||t++}e=e.nextSibling}return null}function dv(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var s=e.data;if(s==="$"||s==="$!"||s==="$?"||s==="$~"||s==="&"){if(t===0)return e;t--}else s!=="/$"&&s!=="/&"||t++}e=e.previousSibling}return null}function fv(e,t,s){switch(t=zu(s),e){case"html":if(e=t.documentElement,!e)throw Error(r(452));return e;case"head":if(e=t.head,!e)throw Error(r(453));return e;case"body":if(e=t.body,!e)throw Error(r(454));return e;default:throw Error(r(451))}}function tc(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);nn(e)}var Qa=new Map,mv=new Set;function Iu(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var ji=Q.d;Q.d={f:Db,r:Lb,D:_b,C:zb,L:Ib,m:Ob,X:Fb,S:Bb,M:Hb};function Db(){var e=ji.f(),t=Mu();return e||t}function Lb(e){var t=Tn(e);t!==null&&t.tag===5&&t.type==="form"?Ep(t):ji.r(e)}var Qr=typeof document>"u"?null:document;function hv(e,t,s){var o=Qr;if(o&&typeof t=="string"&&t){var d=Kn(t);d='link[rel="'+e+'"][href="'+d+'"]',typeof s=="string"&&(d+='[crossorigin="'+s+'"]'),mv.has(d)||(mv.add(d),e={rel:e,crossOrigin:s,href:t},o.querySelector(d)===null&&(t=o.createElement("link"),zn(t,"link",e),Dt(t),o.head.appendChild(t)))}}function _b(e){ji.D(e),hv("dns-prefetch",e,null)}function zb(e,t){ji.C(e,t),hv("preconnect",e,t)}function Ib(e,t,s){ji.L(e,t,s);var o=Qr;if(o&&e&&t){var d='link[rel="preload"][as="'+Kn(t)+'"]';t==="image"&&s&&s.imageSrcSet?(d+='[imagesrcset="'+Kn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(d+='[imagesizes="'+Kn(s.imageSizes)+'"]')):d+='[href="'+Kn(e)+'"]';var h=d;switch(t){case"style":h=Xr(e);break;case"script":h=Zr(e)}Qa.has(h)||(e=y({rel:"preload",href:t==="image"&&s&&s.imageSrcSet?void 0:e,as:t},s),Qa.set(h,e),o.querySelector(d)!==null||t==="style"&&o.querySelector(nc(h))||t==="script"&&o.querySelector(ac(h))||(t=o.createElement("link"),zn(t,"link",e),Dt(t),o.head.appendChild(t)))}}function Ob(e,t){ji.m(e,t);var s=Qr;if(s&&e){var o=t&&typeof t.as=="string"?t.as:"script",d='link[rel="modulepreload"][as="'+Kn(o)+'"][href="'+Kn(e)+'"]',h=d;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":h=Zr(e)}if(!Qa.has(h)&&(e=y({rel:"modulepreload",href:e},t),Qa.set(h,e),s.querySelector(d)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(ac(h)))return}o=s.createElement("link"),zn(o,"link",e),Dt(o),s.head.appendChild(o)}}}function Bb(e,t,s){ji.S(e,t,s);var o=Qr;if(o&&e){var d=Ht(o).hoistableStyles,h=Xr(e);t=t||"default";var S=d.get(h);if(!S){var N={loading:0,preload:null};if(S=o.querySelector(nc(h)))N.loading=5;else{e=y({rel:"stylesheet",href:e,"data-precedence":t},s),(s=Qa.get(h))&&pm(e,s);var H=S=o.createElement("link");Dt(H),zn(H,"link",e),H._p=new Promise(function(se,pe){H.onload=se,H.onerror=pe}),H.addEventListener("load",function(){N.loading|=1}),H.addEventListener("error",function(){N.loading|=2}),N.loading|=4,Ou(S,t,o)}S={type:"stylesheet",instance:S,count:1,state:N},d.set(h,S)}}}function Fb(e,t){ji.X(e,t);var s=Qr;if(s&&e){var o=Ht(s).hoistableScripts,d=Zr(e),h=o.get(d);h||(h=s.querySelector(ac(d)),h||(e=y({src:e,async:!0},t),(t=Qa.get(d))&&gm(e,t),h=s.createElement("script"),Dt(h),zn(h,"link",e),s.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(d,h))}}function Hb(e,t){ji.M(e,t);var s=Qr;if(s&&e){var o=Ht(s).hoistableScripts,d=Zr(e),h=o.get(d);h||(h=s.querySelector(ac(d)),h||(e=y({src:e,async:!0,type:"module"},t),(t=Qa.get(d))&&gm(e,t),h=s.createElement("script"),Dt(h),zn(h,"link",e),s.head.appendChild(h)),h={type:"script",instance:h,count:1,state:null},o.set(d,h))}}function pv(e,t,s,o){var d=(d=fe.current)?Iu(d):null;if(!d)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(t=Xr(s.href),s=Ht(d).hoistableStyles,o=s.get(t),o||(o={type:"style",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){e=Xr(s.href);var h=Ht(d).hoistableStyles,S=h.get(e);if(S||(d=d.ownerDocument||d,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},h.set(e,S),(h=d.querySelector(nc(e)))&&!h._p&&(S.instance=h,S.state.loading=5),Qa.has(e)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},Qa.set(e,s),h||Pb(d,e,s,S.state))),t&&o===null)throw Error(r(528,""));return S}if(t&&o!==null)throw Error(r(529,""));return null;case"script":return t=s.async,s=s.src,typeof s=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=Zr(s),s=Ht(d).hoistableScripts,o=s.get(t),o||(o={type:"script",instance:null,count:0,state:null},s.set(t,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function Xr(e){return'href="'+Kn(e)+'"'}function nc(e){return'link[rel="stylesheet"]['+e+"]"}function gv(e){return y({},e,{"data-precedence":e.precedence,precedence:null})}function Pb(e,t,s,o){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?o.loading=1:(t=e.createElement("link"),o.preload=t,t.addEventListener("load",function(){return o.loading|=1}),t.addEventListener("error",function(){return o.loading|=2}),zn(t,"link",s),Dt(t),e.head.appendChild(t))}function Zr(e){return'[src="'+Kn(e)+'"]'}function ac(e){return"script[async]"+e}function vv(e,t,s){if(t.count++,t.instance===null)switch(t.type){case"style":var o=e.querySelector('style[data-href~="'+Kn(s.href)+'"]');if(o)return t.instance=o,Dt(o),o;var d=y({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Dt(o),zn(o,"style",d),Ou(o,s.precedence,e),t.instance=o;case"stylesheet":d=Xr(s.href);var h=e.querySelector(nc(d));if(h)return t.state.loading|=4,t.instance=h,Dt(h),h;o=gv(s),(d=Qa.get(d))&&pm(o,d),h=(e.ownerDocument||e).createElement("link"),Dt(h);var S=h;return S._p=new Promise(function(N,H){S.onload=N,S.onerror=H}),zn(h,"link",o),t.state.loading|=4,Ou(h,s.precedence,e),t.instance=h;case"script":return h=Zr(s.src),(d=e.querySelector(ac(h)))?(t.instance=d,Dt(d),d):(o=s,(d=Qa.get(h))&&(o=y({},s),gm(o,d)),e=e.ownerDocument||e,d=e.createElement("script"),Dt(d),zn(d,"link",o),e.head.appendChild(d),t.instance=d);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(o=t.instance,t.state.loading|=4,Ou(o,s.precedence,e));return t.instance}function Ou(e,t,s){for(var o=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=o.length?o[o.length-1]:null,h=d,S=0;S<o.length;S++){var N=o[S];if(N.dataset.precedence===t)h=N;else if(h!==d)break}h?h.parentNode.insertBefore(e,h.nextSibling):(t=s.nodeType===9?s.head:s,t.insertBefore(e,t.firstChild))}function pm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function gm(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Bu=null;function xv(e,t,s){if(Bu===null){var o=new Map,d=Bu=new Map;d.set(s,o)}else d=Bu,o=d.get(s),o||(o=new Map,d.set(s,o));if(o.has(e))return o;for(o.set(e,null),s=s.getElementsByTagName(e),d=0;d<s.length;d++){var h=s[d];if(!(h[dt]||h[J]||e==="link"&&h.getAttribute("rel")==="stylesheet")&&h.namespaceURI!=="http://www.w3.org/2000/svg"){var S=h.getAttribute(t)||"";S=e+S;var N=o.get(S);N?N.push(h):o.set(S,[h])}}return o}function yv(e,t,s){e=e.ownerDocument||e,e.head.insertBefore(s,t==="title"?e.querySelector("head > title"):null)}function $b(e,t,s){if(s===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function wv(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Ub(e,t,s,o){if(s.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var d=Xr(o.href),h=t.querySelector(nc(d));if(h){t=h._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Fu.bind(e),t.then(e,e)),s.state.loading|=4,s.instance=h,Dt(h);return}h=t.ownerDocument||t,o=gv(o),(d=Qa.get(d))&&pm(o,d),h=h.createElement("link"),Dt(h);var S=h;S._p=new Promise(function(N,H){S.onload=N,S.onerror=H}),zn(h,"link",o),s.instance=h}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(s,t),(t=s.state.preload)&&(s.state.loading&3)===0&&(e.count++,s=Fu.bind(e),t.addEventListener("load",s),t.addEventListener("error",s))}}var vm=0;function qb(e,t){return e.stylesheets&&e.count===0&&Pu(e,e.stylesheets),0<e.count||0<e.imgCount?function(s){var o=setTimeout(function(){if(e.stylesheets&&Pu(e,e.stylesheets),e.unsuspend){var h=e.unsuspend;e.unsuspend=null,h()}},6e4+t);0<e.imgBytes&&vm===0&&(vm=62500*Cb());var d=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Pu(e,e.stylesheets),e.unsuspend)){var h=e.unsuspend;e.unsuspend=null,h()}},(e.imgBytes>vm?50:800)+t);return e.unsuspend=s,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(d)}}:null}function Fu(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Pu(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Hu=null;function Pu(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Hu=new Map,t.forEach(Gb,e),Hu=null,Fu.call(e))}function Gb(e,t){if(!(t.state.loading&4)){var s=Hu.get(e);if(s)var o=s.get(null);else{s=new Map,Hu.set(e,s);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),h=0;h<d.length;h++){var S=d[h];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(s.set(S.dataset.precedence,S),o=S)}o&&s.set(null,o)}d=t.instance,S=d.getAttribute("data-precedence"),h=s.get(S)||o,h===o&&s.set(null,d),s.set(S,d),this.count++,o=Fu.bind(this),d.addEventListener("load",o),d.addEventListener("error",o),h?h.parentNode.insertBefore(d,h.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(d,e.firstChild)),t.state.loading|=4}}var sc={$$typeof:R,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function Vb(e,t,s,o,d,h,S,N,H){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ws(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ws(0),this.hiddenUpdates=ws(null),this.identifierPrefix=o,this.onUncaughtError=d,this.onCaughtError=h,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=H,this.incompleteTransitions=new Map}function bv(e,t,s,o,d,h,S,N,H,se,pe,be){return e=new Vb(e,t,s,S,H,se,pe,be,N),t=1,h===!0&&(t|=24),h=Dn(3,null,null,t),e.current=h,h.stateNode=e,t=Ir(),t.refCount++,e.pooledCache=t,t.refCount++,h.memoizedState={element:o,isDehydrated:s,cache:t},B(h),e}function Sv(e){return e?(e=si,e):si}function jv(e,t,s,o,d,h){d=Sv(d),o.context===null?o.context=d:o.pendingContext=d,o=ge(t),o.payload={element:s},h=h===void 0?null:h,h!==null&&(o.callback=h),s=Re(e,o,t),s!==null&&(ua(s,e,t),Pe(s,e,t))}function Cv(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var s=e.retryLane;e.retryLane=s!==0&&s<t?s:t}}function xm(e,t){Cv(e,t),(e=e.alternate)&&Cv(e,t)}function kv(e){if(e.tag===13||e.tag===31){var t=ba(e,67108864);t!==null&&ua(t,e,67108864),xm(e,67108864)}}function Av(e){if(e.tag===13||e.tag===31){var t=Ta();t=Mn(t);var s=ba(e,t);s!==null&&ua(s,e,t),xm(e,t)}}var $u=!0;function Yb(e,t,s,o){var d=z.T;z.T=null;var h=Q.p;try{Q.p=2,ym(e,t,s,o)}finally{Q.p=h,z.T=d}}function Wb(e,t,s,o){var d=z.T;z.T=null;var h=Q.p;try{Q.p=8,ym(e,t,s,o)}finally{Q.p=h,z.T=d}}function ym(e,t,s,o){if($u){var d=wm(o);if(d===null)im(e,t,o,Uu,s),Nv(e,o);else if(Qb(d,e,t,s,o))o.stopPropagation();else if(Nv(e,o),t&4&&-1<Kb.indexOf(e)){for(;d!==null;){var h=Tn(d);if(h!==null)switch(h.tag){case 3:if(h=h.stateNode,h.current.memoizedState.isDehydrated){var S=Wn(h.pendingLanes);if(S!==0){var N=h;for(N.pendingLanes|=2,N.entangledLanes|=2;S;){var H=1<<31-Ne(S);N.entanglements[1]|=H,S&=~H}Hs(h),(vt&6)===0&&(ku=Ge()+500,Zo(0))}}break;case 31:case 13:N=ba(h,2),N!==null&&ua(N,h,2),Mu(),xm(h,2)}if(h=wm(o),h===null&&im(e,t,o,Uu,s),h===d)break;d=h}d!==null&&o.stopPropagation()}else im(e,t,o,null,s)}}function wm(e){return e=wr(e),bm(e)}var Uu=null;function bm(e){if(Uu=null,e=Ft(e),e!==null){var t=u(e);if(t===null)e=null;else{var s=t.tag;if(s===13){if(e=m(t),e!==null)return e;e=null}else if(s===31){if(e=p(t),e!==null)return e;e=null}else if(s===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return Uu=e,null}function Mv(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(ea()){case gn:return 2;case kn:return 8;case Yn:case Ml:return 32;case Da:return 268435456;default:return 32}default:return 32}}var Sm=!1,ml=null,hl=null,pl=null,ic=new Map,lc=new Map,gl=[],Kb="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 Nv(e,t){switch(e){case"focusin":case"focusout":ml=null;break;case"dragenter":case"dragleave":hl=null;break;case"mouseover":case"mouseout":pl=null;break;case"pointerover":case"pointerout":ic.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":lc.delete(t.pointerId)}}function rc(e,t,s,o,d,h){return e===null||e.nativeEvent!==h?(e={blockedOn:t,domEventName:s,eventSystemFlags:o,nativeEvent:h,targetContainers:[d]},t!==null&&(t=Tn(t),t!==null&&kv(t)),e):(e.eventSystemFlags|=o,t=e.targetContainers,d!==null&&t.indexOf(d)===-1&&t.push(d),e)}function Qb(e,t,s,o,d){switch(t){case"focusin":return ml=rc(ml,e,t,s,o,d),!0;case"dragenter":return hl=rc(hl,e,t,s,o,d),!0;case"mouseover":return pl=rc(pl,e,t,s,o,d),!0;case"pointerover":var h=d.pointerId;return ic.set(h,rc(ic.get(h)||null,e,t,s,o,d)),!0;case"gotpointercapture":return h=d.pointerId,lc.set(h,rc(lc.get(h)||null,e,t,s,o,d)),!0}return!1}function Tv(e){var t=Ft(e.target);if(t!==null){var s=u(t);if(s!==null){if(t=s.tag,t===13){if(t=m(s),t!==null){e.blockedOn=t,Gs(e.priority,function(){Av(s)});return}}else if(t===31){if(t=p(s),t!==null){e.blockedOn=t,Gs(e.priority,function(){Av(s)});return}}else if(t===3&&s.stateNode.current.memoizedState.isDehydrated){e.blockedOn=s.tag===3?s.stateNode.containerInfo:null;return}}}e.blockedOn=null}function qu(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var s=wm(e.nativeEvent);if(s===null){s=e.nativeEvent;var o=new s.constructor(s.type,s);yr=o,s.target.dispatchEvent(o),yr=null}else return t=Tn(s),t!==null&&kv(t),e.blockedOn=s,!1;t.shift()}return!0}function Ev(e,t,s){qu(e)&&s.delete(t)}function Xb(){Sm=!1,ml!==null&&qu(ml)&&(ml=null),hl!==null&&qu(hl)&&(hl=null),pl!==null&&qu(pl)&&(pl=null),ic.forEach(Ev),lc.forEach(Ev)}function Gu(e,t){e.blockedOn===t&&(e.blockedOn=null,Sm||(Sm=!0,n.unstable_scheduleCallback(n.unstable_NormalPriority,Xb)))}var Vu=null;function Rv(e){Vu!==e&&(Vu=e,n.unstable_scheduleCallback(n.unstable_NormalPriority,function(){Vu===e&&(Vu=null);for(var t=0;t<e.length;t+=3){var s=e[t],o=e[t+1],d=e[t+2];if(typeof o!="function"){if(bm(o||s)===null)continue;break}var h=Tn(s);h!==null&&(e.splice(t,3),t-=3,wf(h,{pending:!0,data:d,method:s.method,action:o},o,d))}}))}function Jr(e){function t(H){return Gu(H,e)}ml!==null&&Gu(ml,e),hl!==null&&Gu(hl,e),pl!==null&&Gu(pl,e),ic.forEach(t),lc.forEach(t);for(var s=0;s<gl.length;s++){var o=gl[s];o.blockedOn===e&&(o.blockedOn=null)}for(;0<gl.length&&(s=gl[0],s.blockedOn===null);)Tv(s),s.blockedOn===null&&gl.shift();if(s=(e.ownerDocument||e).$$reactFormReplay,s!=null)for(o=0;o<s.length;o+=3){var d=s[o],h=s[o+1],S=d[ke]||null;if(typeof h=="function")S||Rv(s);else if(S){var N=null;if(h&&h.hasAttribute("formAction")){if(d=h,S=h[ke]||null)N=S.formAction;else if(bm(d)!==null)continue}else N=S.action;typeof N=="function"?s[o+1]=N:(s.splice(o,3),o-=3),Rv(s)}}}function Dv(){function e(h){h.canIntercept&&h.info==="react-transition"&&h.intercept({handler:function(){return new Promise(function(S){return d=S})},focusReset:"manual",scroll:"manual"})}function t(){d!==null&&(d(),d=null),o||setTimeout(s,20)}function s(){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,d=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(s,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),d!==null&&(d(),d=null)}}}function jm(e){this._internalRoot=e}Yu.prototype.render=jm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(r(409));var s=t.current,o=Ta();jv(s,o,e,t,null,null)},Yu.prototype.unmount=jm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;jv(e.current,2,null,e,null,null),Mu(),t[_e]=null}};function Yu(e){this._internalRoot=e}Yu.prototype.unstable_scheduleHydration=function(e){if(e){var t=tn();e={blockedOn:null,target:e,priority:t};for(var s=0;s<gl.length&&t!==0&&t<gl[s].priority;s++);gl.splice(s,0,e),s===0&&Tv(e)}};var Lv=a.version;if(Lv!=="19.2.7")throw Error(r(527,Lv,"19.2.7"));Q.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(r(188)):(e=Object.keys(e).join(","),Error(r(268,e)));return e=g(t),e=e!==null?w(e):null,e=e===null?null:e.stateNode,e};var Zb={bundleType:0,version:"19.2.7",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.7"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Wu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Wu.isDisabled&&Wu.supportsFiber)try{ys=Wu.inject(Zb),mt=Wu}catch{}}return cc.createRoot=function(e,t){if(!c(e))throw Error(r(299));var s=!1,o="",d=Hp,h=Pp,S=$p;return t!=null&&(t.unstable_strictMode===!0&&(s=!0),t.identifierPrefix!==void 0&&(o=t.identifierPrefix),t.onUncaughtError!==void 0&&(d=t.onUncaughtError),t.onCaughtError!==void 0&&(h=t.onCaughtError),t.onRecoverableError!==void 0&&(S=t.onRecoverableError)),t=bv(e,1,!1,null,null,s,o,null,d,h,S,Dv),e[_e]=t.current,sm(e),new jm(t)},cc.hydrateRoot=function(e,t,s){if(!c(e))throw Error(r(299));var o=!1,d="",h=Hp,S=Pp,N=$p,H=null;return s!=null&&(s.unstable_strictMode===!0&&(o=!0),s.identifierPrefix!==void 0&&(d=s.identifierPrefix),s.onUncaughtError!==void 0&&(h=s.onUncaughtError),s.onCaughtError!==void 0&&(S=s.onCaughtError),s.onRecoverableError!==void 0&&(N=s.onRecoverableError),s.formState!==void 0&&(H=s.formState)),t=bv(e,1,!0,t,s??null,o,d,H,h,S,N,Dv),t.context=Sv(null),s=t.current,o=Ta(),o=Mn(o),d=ge(o),d.callback=null,Re(s,d,o),s=o,t.current.lanes=s,bs(t,s),Hs(t),e[_e]=t.current,sm(e),new Yu(t)},cc.version="19.2.7",cc}var Vv;function PS(){if(Vv)return Am.exports;Vv=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(),Am.exports=HS(),Am.exports}var $S=PS();const kc=5179,bn=Al(`http://127.0.0.1:${kc}`);function US(n){const a=n.split(".").map(l=>Number(l));return a.length===4&&a.every(l=>Number.isInteger(l)&&l>=0&&l<=255)?a:[]}function qS(n){const a=n.trim().toLowerCase();return a==="localhost"||a==="127.0.0.1"||a==="::1"||a==="[::1]"}function GS(n){const a=n.trim().toLowerCase();return!a||a==="0.0.0.0"||a==="::"||a==="[::]"}function VS(n){const a=US(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 YS(n){return n.includes(":")&&!n.startsWith("[")?`[${n}]`:n}function WS(n){const a=String(n||"").trim();if(!a)return null;const l=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`tcp://${a}`;try{const r=new URL(l),c=r.hostname.replace(/^\[|\]$/g,""),u=Number(r.port);return!c||!Number.isInteger(u)||u<1||u>65535||GS(c)?null:{host:c,port:u}}catch{return null}}function Al(n){const a=String(n||"").trim()||`http://127.0.0.1:${kc}`,l=/^[a-z][a-z\d+.-]*:\/\//i.test(a)?a:`http://${a}`;try{const r=new URL(l);return r.port||(r.port=String(kc)),r.hash="",r.search="",r.toString().replace(/\/+$/,"")}catch{return`http://127.0.0.1:${kc}`}}function KS(n){const a=WS(n);return a?Al(`http://${YS(a.host)}:${kc}`):""}function Yv(n){const l=[n?.endpoint,...Array.isArray(n?.endpoint_candidates)?n.endpoint_candidates:[]].map(r=>KS(String(r||""))).filter(Boolean);return[...new Set(l)]}function Ac(n=bn){if(!(typeof window>"u"||window.location.protocol!=="https:"))try{const a=new URL(n);if(a.protocol!=="http:")return;if(qS(a.hostname))return"loopback";if(VS(a.hostname))return"local"}catch{return}}function _d(n,a=bn){const l=new URL(n,Al(a));return l.protocol=l.protocol==="https:"?"wss:":"ws:",l.toString()}async function Be(n,a,l=bn){const r=Al(l),c={...a,headers:{"Content-Type":"application/json",...a?.headers||{}},cache:"no-store"},u=Ac(r);u&&(c.targetAddressSpace=u);let m;try{m=await fetch(`${r}${n}`,c)}catch(v){throw u?new Error("LiveDesk Hub is not reachable at this local network address. If Chrome shows a local network prompt, allow it; otherwise restart the Hub so port 5179 is open on the network."):v}let p=null;try{p=await m.json()}catch{p=null}if(!m.ok){const v=p&&typeof p=="object"&&"error"in p?String(p.error||""):"";throw new Error(`${m.status} ${v||m.statusText}`)}return p}function ky(n,a=120){if(typeof window>"u")return;const l=new URL(window.location.href);l.port=String(n),l.pathname="/",l.search="",l.hash="";const r=l.toString();let c=0;const u=()=>{fetch(r,{cache:"no-store",mode:"no-cors"}).then(()=>window.location.replace(r)).catch(()=>{if(c+=1,c>=a){window.location.replace(r);return}window.setTimeout(u,250)})};u()}function rh(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 ir(n){await navigator.clipboard.writeText(n)}function QS(){if(typeof window>"u")return"";const n=window.location.port;return n==="5198"||n==="5179"?window.location.origin:"http://127.0.0.1:5198"}function XS(n){if(!n)return"-";const a=Date.parse(n);return Number.isFinite(a)?new Date(a).toLocaleString():n}function ZS({ok:n}){return n?i.jsx(On,{size:17,"aria-hidden":"true"}):i.jsx(Mh,{size:17,"aria-hidden":"true"})}function xl({label:n,value:a,ok:l}){return i.jsxs("div",{className:"client-status-card",children:[i.jsx("span",{children:n}),i.jsx("strong",{children:l===void 0?a:i.jsxs(i.Fragment,{children:[i.jsx(ZS,{ok:l})," ",a]})})]})}function JS(){const[n,a]=f.useState(null),[l,r]=f.useState(""),[c,u]=f.useState(""),[m,p]=f.useState(!1),[v,g]=f.useState(!1),w=f.useMemo(QS,[]),y=async()=>{g(!0);try{const A=await fetch(`${w}/api/client/status`,{cache:"no-store"});if(!A.ok)throw new Error(`Client runtime returned HTTP ${A.status}.`);const T=await A.json();if(String(T.role||"").toLowerCase()==="hub")throw new Error("This computer is assigned to the Hub role.");a(T),r("")}catch(A){r(A instanceof Error?A.message:String(A))}finally{g(!1)}};f.useEffect(()=>{y();const A=window.setInterval(()=>{y()},5e3);return()=>window.clearInterval(A)},[w]);const b=async()=>{p(!0),u(""),r("");try{const A=await fetch(`${w}/api/client/role`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({role:"hub"})}),T=await A.json().catch(()=>({}));if(!A.ok||T?.ok===!1)throw new Error(T?.error||`Role change failed with HTTP ${A.status}.`);u("Hub role accepted. LiveDesk is restarting this computer with the Hub Wall."),ky(5179)}catch(A){r(A instanceof Error?A.message:String(A)),p(!1)}},j=!!n?.manager,C=!!n?.runtimeStarted;return i.jsxs("main",{className:"client-app-shell",children:[i.jsxs("header",{className:"client-app-header",children:[i.jsxs("div",{children:[i.jsx("p",{className:"client-eyebrow",children:"LiveDesk Client Runtime"}),i.jsx("h1",{children:n?.deviceName||"This Computer"}),i.jsx("p",{className:"client-subtitle",children:"This computer is running as a Client. The Hub Wall and management tools are available only after this computer becomes the Hub."})]}),i.jsxs("button",{className:"client-refresh-button",type:"button",onClick:()=>{y()},disabled:v,children:[i.jsx(fr,{size:16,className:v?"client-spin":""}),"Refresh"]})]}),i.jsx("nav",{className:"client-app-nav","aria-label":"Client navigation",children:i.jsxs("button",{className:"active",type:"button",onClick:()=>{b()},disabled:m,children:[i.jsx(wc,{size:17}),m?"Switching to Hub…":"Sync Server"]})}),l&&i.jsxs("aside",{className:"client-error",role:"alert",children:[i.jsx(Mh,{size:18})," ",l]}),i.jsxs("section",{className:"client-app-content",children:[i.jsxs("div",{className:"client-page-heading",children:[i.jsxs("div",{children:[i.jsx("p",{className:"client-eyebrow",children:"Client"}),i.jsx("h2",{children:"Sync Server"})]}),i.jsxs("span",{className:`client-runtime-pill ${C?"online":"offline"}`,children:[i.jsx("span",{className:"client-runtime-dot"}),n?.statusLabel||(C?"Running":"Starting")]})]}),i.jsxs("section",{className:"client-panel client-role-panel",children:[i.jsx("h3",{children:"Make this computer the Hub"}),i.jsx("p",{className:"client-muted",children:"Sync Server stops the Client runtime, registers this computer as the Hub, and restarts LiveDesk with the Hub Wall."}),i.jsxs("div",{className:"client-card-grid",children:[i.jsx(xl,{label:"Current role",value:"Client",ok:!0}),i.jsx(xl,{label:"Assigned Hub",value:n?.manager||"Not connected",ok:j}),i.jsx(xl,{label:"Client runtime",value:C?"Running":"Starting",ok:C}),i.jsx(xl,{label:"Last connected",value:XS(n?.connectedAt)})]}),c&&i.jsx("p",{className:"client-success",children:c}),i.jsx("button",{className:"client-primary-button",type:"button",onClick:()=>{b()},disabled:m,children:m?"Switching to Hub…":"Sync Server"})]}),i.jsxs("section",{className:"client-panel client-capability-panel",children:[i.jsx("h3",{children:"Client status"}),i.jsxs("div",{className:"client-card-grid",children:[i.jsx(xl,{label:"Device ID",value:n?.deviceId||"-"}),i.jsx(xl,{label:"LiveDesk version",value:n?.appVersion||"-"}),i.jsx(xl,{label:"Screen sharing",value:C?"Ready":"Starting",ok:C}),i.jsx(xl,{label:"Remote input",value:C?"Ready":"Waiting",ok:C})]})]})]})]})}const e0="https://otbyfkjxrkngvjziawki.supabase.co",t0="sb_publishable_NpUs0RDJH2YnllsqTKO6TQ_1jTdSsNQ",zt=zS(e0,t0,{auth:{autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"pkce",storageKey:"livedesk.mindexec.supabase.auth"}});function bl(n,a,l){if(l<0||a<0||a+l>n.length)throw new Error("Invalid LZO1X block: input overrun.")}function Tm(n,a,l){let r=0;for(;bl(n,a.inputIndex,1),n[a.inputIndex]===0;)r+=1,a.inputIndex+=1;const c=r*255+l+n[a.inputIndex];return a.inputIndex+=1,c}function Ku(n,a,l,r){if(bl(n,a.inputIndex,r),a.outputIndex+r>l.length)throw new Error("Invalid LZO1X block: output overrun.");l.set(n.subarray(a.inputIndex,a.inputIndex+r),a.outputIndex),a.inputIndex+=r,a.outputIndex+=r}function n0(n,a,l,r){const c=a-l;if(c<=0||r<=0)throw new Error("Invalid LZO1X block: invalid match distance.");let u=Math.min(c,r);for(n.set(n.subarray(l,l+u),a);u<r;){const m=Math.min(u,r-u);n.copyWithin(a+u,a,a+m),u+=m}return a+r}function Ay(n,a){if(!(n instanceof Uint8Array)||n.length<3||a<0)throw new Error("Invalid LZO1X block.");const l=new Uint8Array(a),r={inputIndex:0,outputIndex:0};let c=0,u=0;if(n[r.inputIndex]>=22){const m=n[r.inputIndex]-17;r.inputIndex+=1,Ku(n,r,l,m),c=4}else n[r.inputIndex]>=18&&(c=n[r.inputIndex]-17,r.inputIndex+=1,Ku(n,r,l,c));for(;;){bl(n,r.inputIndex,1);const m=n[r.inputIndex];r.inputIndex+=1;let p,v;if((m&192)!==0)bl(n,r.inputIndex,1),v=r.outputIndex-((n[r.inputIndex]<<3)+(m>>2&7)+1),r.inputIndex+=1,u=(m>>5)+1,p=m&3;else if((m&32)!==0){u=(m&31)+2,u===2&&(u+=Tm(n,r,31)),bl(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;r.inputIndex+=2,v=r.outputIndex-((g>>2)+1),p=g&3}else if((m&16)!==0){u=(m&7)+2,u===2&&(u+=Tm(n,r,7)),bl(n,r.inputIndex,2);const g=n[r.inputIndex]|n[r.inputIndex+1]<<8;if(r.inputIndex+=2,v=r.outputIndex-(((m&8)<<11)+(g>>2)),p=g&3,v===r.outputIndex)break;v-=16384}else if(c===0){let g=m+3;g===3&&(g+=Tm(n,r,15)),Ku(n,r,l,g),c=4;continue}else c!==4?(bl(n,r.inputIndex,1),p=m&3,v=r.outputIndex-((m>>2)+(n[r.inputIndex]<<2)+1),r.inputIndex+=1,u=2):(bl(n,r.inputIndex,1),p=m&3,v=r.outputIndex-((m>>2)+(n[r.inputIndex]<<2)+2049),r.inputIndex+=1,u=3);if(v<0||r.outputIndex+u+p>l.length)throw new Error("Invalid LZO1X block: lookbehind overrun.");r.outputIndex=n0(l,r.outputIndex,v,u),c=p,Ku(n,r,l,p)}if(u!==3||r.inputIndex!==n.length||r.outputIndex!==l.length)throw new Error("Invalid LZO1X block: incomplete output.");return l}const Wv=16,Kv=8,a0=24*1024*1024,My=new Uint8Array(new Uint32Array([16909060]).buffer)[0]===4,oh=new Uint32Array(65536);for(let n=0;n<oh.length;n+=1){const a=Math.round((n>>11&31)*255/31),l=Math.round((n>>5&63)*255/63),r=Math.round((n&31)*255/31);oh[n]=My?(a|l<<8|r<<16|4278190080)>>>0:(a<<24|l<<16|r<<8|255)>>>0}function yl(n,a){return n[a]|n[a+1]<<8}function s0(n,a){const l=Number(a);if(!Number.isSafeInteger(l)||l<Wv||l>a0)throw new Error(`Invalid Mode 5 packet length: ${a}.`);const r=Ay(new Uint8Array(n),l);if(r[0]!==76||r[1]!==68||r[2]!==53||r[3]!==68)throw new Error("Invalid Mode 5 packet magic.");if(r[4]!==1)throw new Error(`Unsupported Mode 5 packet version: ${r[4]}.`);const c=(r[5]&1)!==0,u=yl(r,6),m=yl(r,8),p=yl(r,10),v=yl(r,12);if(u<=0||m<=0||u>3840||m>2160)throw new Error(`Invalid Mode 5 frame size: ${u}x${m}.`);if(p<=0||p>256||v>8192)throw new Error(`Invalid Mode 5 tile header: ${p}/${v}.`);const g=[];let w=Wv;for(let y=0;y<v;y+=1){if(w+Kv>r.length)throw new Error("Mode 5 tile header is truncated.");const b=yl(r,w),j=yl(r,w+2),C=yl(r,w+4),A=yl(r,w+6);w+=Kv;const T=C*A*2;if(C<=0||A<=0||C>p||A>p||b+C>u||j+A>m||w+T>r.length)throw new Error(`Invalid Mode 5 tile ${y}.`);g.push({x:b,y:j,width:C,height:A,pixels:r.subarray(w,w+T)}),w+=T}if(w!==r.length)throw new Error(`Mode 5 packet has ${r.length-w} trailing bytes.`);return{keyFrame:c,width:u,height:m,tileSize:p,tiles:g}}function i0(n,a,l,r){if(!(n instanceof Uint8ClampedArray)||n.length!==a*l*4||r.width!==a||r.height!==l)throw new Error("Mode 5 canvas state does not match the packet dimensions.");let c=a,u=l,m=0,p=0;const v=new Uint32Array(n.buffer,n.byteOffset,n.byteLength>>>2);for(const g of r.tiles){const w=My&&(g.pixels.byteOffset&1)===0?new Uint16Array(g.pixels.buffer,g.pixels.byteOffset,g.pixels.byteLength>>>1):null;let y=0;for(let b=0;b<g.height;b+=1){let j=(g.y+b)*a+g.x;for(let C=0;C<g.width;C+=1){const A=y<<1,T=w?w[y]:g.pixels[A]|g.pixels[A+1]<<8;v[j]=oh[T],y+=1,j+=1}}c=Math.min(c,g.x),u=Math.min(u,g.y),m=Math.max(m,g.x+g.width),p=Math.max(p,g.y+g.height)}return r.tiles.length>0?{x:c,y:u,width:m-c,height:p-u}:null}const ha=new WeakMap,Rc=new WeakMap,ch=new WeakMap,Dc=new Set,lr=new Set,Cd=new WeakMap,uh=new WeakMap,dh=new WeakMap,kd=new WeakMap,Dh=32,l0=2,r0=2,o0=2,c0=18,u0=40,d0=0,f0=750,Ny=80,Qv=5,m0=150,h0=24,p0=180,g0=1200,v0=18,x0=.65,y0=2e3,w0=500,Ty=250;let Ad=!1;function b0(){return typeof navigator>"u"?!1:/mac/i.test(`${navigator.platform||""} ${navigator.userAgent||""}`)}function S0(){const n=Math.max(1,Number(navigator.hardwareConcurrency||8));return Math.max(4,Math.min(16,Math.round(n/2)))}let cr={h264DecodeAcceleration:"prefer-hardware",h264HardwareDecoderBudget:S0()};function j0(n){n.h264DecodeAcceleration&&(cr={...cr,h264DecodeAcceleration:n.h264DecodeAcceleration}),Number.isFinite(Number(n.h264HardwareDecoderBudget))&&(cr.h264HardwareDecoderBudget=Math.max(1,Math.min(64,Math.round(Number(n.h264HardwareDecoderBudget)))))}function Ey(n,a=cr.h264DecodeAcceleration){const l=Cd.get(n);return l?.requested===a?(l.actual!=="prefer-hardware"&&lr.delete(n),l.actual):(l&&Cd.delete(n),a!=="prefer-hardware"?(lr.delete(n),a):lr.has(n)?"prefer-hardware":lr.size<cr.h264HardwareDecoderBudget?(lr.add(n),"prefer-hardware"):"prefer-software")}function zd(n,a){return a!=="prefer-hardware"?!1:(Cd.set(n,{requested:a,actual:"prefer-software"}),lr.delete(n),!0)}function C0(n,a,l,r=64){try{let c=uh.get(n);c||(c={canvas:document.createElement("canvas"),lastHash:"",initialized:!1},uh.set(n,c));const u=Math.max(8,Math.min(64,Math.round(r))),m=Math.max(1,Math.round(u*Math.max(1,l)/Math.max(1,a)));(c.canvas.width!==u||c.canvas.height!==m)&&(c.canvas.width=u,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,l),0,0,u,m);const v=p.getImageData(0,0,u,m).data;let g=2166136261;for(let b=0;b<v.length;b+=4)g^=v[b],g=Math.imul(g,16777619),g^=v[b+1],g=Math.imul(g,16777619),g^=v[b+2],g=Math.imul(g,16777619);const w=(g>>>0).toString(16).padStart(8,"0"),y=!c.initialized||w!==c.lastHash;return c.initialized=!0,c.lastHash=w,{visualHash:w,visualChanged:y}}catch{return{visualHash:"",visualChanged:!0}}}function fh(n,a,l,r=Ty,c=64){let u=dh.get(n);u||(u={lastHash:"",initialized:!1,lastCanvasSampleAt:0},dh.set(n,u));const m=performance.now();if(u.initialized&&r>0&&m-u.lastCanvasSampleAt<r)return{visualHash:u.lastHash,visualChanged:!1};const p=C0(n,a,l,c);return u.initialized=!0,u.lastHash=p.visualHash,u.lastCanvasSampleAt=m,p}function k0(n,a){let l=kd.get(n);l||(l={lastHash:"",initialized:!1},kd.set(n,l));const r=String(a.contentHash||""),c=!l.initialized||!r||r!==l.lastHash;return l.initialized=!0,l.lastHash=r,{visualHash:r,visualChanged:c}}function Ry(n,a){const l=ch.get(n);if(l)return l;const r=n.getContext("2d",{alpha:!1,desynchronized:a==="interactive"});if(r){const c=r.getContextAttributes?.(),u={context:r,presentation:c?.desynchronized?"desync":"sync"};return ch.set(n,u),u}return null}function A0(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),l=String(n.compression||"").toLowerCase(),r=String(n.mimeType||"").toLowerCase();return a==="mode2-lzo"||l==="lzo1x"||r==="application/vnd.livedesk.lzo-rgb565"||a==="mode2-lz4"||String(n.compression||"").toLowerCase()==="lz4"||r==="application/vnd.livedesk.lz4-raw"}function M0(n){return String(n.frameMode||n.mode||"").toLowerCase()==="mode3-h264-hw"||String(n.codec||"").toLowerCase()==="h264"||String(n.mimeType||"").toLowerCase()==="video/h264"}function N0(n){const a=String(n.frameMode||n.mode||"").toLowerCase(),l=String(n.mimeType||"").toLowerCase();return a==="mode5-lzo-delta"||l==="application/vnd.livedesk.lzo-rgb565-delta"}function Xv(n,a,l){let r=l,c=a;if(r===15){let u=255;for(;u===255;){if(c>=n.length)throw new Error("Invalid LZ4 block: length overrun.");u=n[c],c+=1,r+=u}}return{length:r,cursor:c}}function T0(n,a){const l=new Uint8Array(a);let r=0,c=0;for(;r<n.length;){const u=n[r];r+=1;const m=Xv(n,r,u>>4);r=m.cursor;const p=m.length;if(r+p>n.length||c+p>l.length)throw new Error("Invalid LZ4 block: literal overrun.");if(l.set(n.subarray(r,r+p),c),r+=p,c+=p,r>=n.length)break;if(r+2>n.length)throw new Error("Invalid LZ4 block: missing offset.");const v=n[r]|n[r+1]<<8;if(r+=2,v<=0||v>c)throw new Error("Invalid LZ4 block: bad match offset.");const g=Xv(n,r,u&15);r=g.cursor;const w=g.length+4;if(c+w>l.length)throw new Error("Invalid LZ4 block: match overrun.");let y=c-v;for(let b=0;b<w;b+=1)l[c]=l[y],c+=1,y+=1}if(c!==l.length)throw new Error("Invalid LZ4 block: incomplete output.");return l}function E0(n){const a=Math.max(1,Math.floor(n.width||0)),l=Math.max(1,Math.floor(n.height||0)),r=String(n.compression||"").toLowerCase(),c=String(n.pixelFormat||n.codec||"").toLowerCase();if(r==="lzo1x"||String(n.frameMode||n.mode||"").toLowerCase()==="mode2-lzo"||String(n.mimeType||"").toLowerCase()==="application/vnd.livedesk.lzo-rgb565"){const w=Math.max(1,Math.floor(n.bytesPerPixel||2)),y=a*l*2,b=Math.floor(n.uncompressedByteLength||y);if(w!==2||b!==y)throw new Error(`Invalid mode2 RGB565 frame size: ${b} for ${a}x${l}.`);if(c&&c!=="rgb565le"&&c!=="rgb565")throw new Error(`Unsupported mode2 pixel format: ${c}`);const j=Ay(new Uint8Array(n.payload),y),C=new Uint8ClampedArray(a*l*4);for(let A=0,T=0;A<j.length;A+=2,T+=4){const k=j[A]|j[A+1]<<8,E=k>>11&31,R=k>>5&63,U=k&31;C[T]=E<<3|E>>2,C[T+1]=R<<2|R>>4,C[T+2]=U<<3|U>>2,C[T+3]=255}return new ImageData(C,a,l)}const m=Math.max(1,Math.floor(n.bytesPerPixel||4)),p=Math.max(a*l*m,Math.floor(n.uncompressedByteLength||0)),v=T0(new Uint8Array(n.payload),p);if(m!==4)throw new Error(`Unsupported mode2 pixel size: ${m}`);const g=new Uint8ClampedArray(a*l*4);if(c==="rgba32"||c==="rgba")g.set(v.subarray(0,g.length));else for(let w=0,y=0;y<g.length;w+=4,y+=4)g[y]=v[w+2],g[y+1]=v[w+1],g[y+2]=v[w],g[y+3]=v[w+3];return new ImageData(g,a,l)}function Zv(n,a="smooth"){const l=window.VideoDecoder;if(!l||!window.EncodedVideoChunk)throw new Error("WebCodecs H.264 decode is not supported in this browser.");const r=ha.get(n);if(r&&r.decoder.state!=="closed"&&r.latencyMode===a)return r;r&&vs(n);let c;return c={decoder:new l({output:m=>{if(ha.get(n)!==c){m.close();return}const p=Number(m.timestamp||0);c.outputSerial+=1;let v=c.pendingFrames.get(p);if(v)c.pendingFrames.delete(p);else if(c.pendingFrames.size>0){const C=c.pendingFrames.entries().next().value;C&&(c.pendingFrames.delete(C[0]),v=C[1],c.timestampFallbacks+=1)}const g=m.displayWidth||m.codedWidth||n.width||960,w=m.displayHeight||m.codedHeight||n.height||540,y=Number(v?.frame.durationUs||0),b=Number(m.duration||0),j=Math.max(16,Math.min(250,(y>0?y:b||83333)/1e3));for(c.targetPaintIntervalMs=j,c.decodedFrames.push({videoFrame:m,pending:v,decodedAt:performance.now(),width:g,height:w,durationMs:j}),c.lastOutputAt=performance.now();c.decodedFrames.length>Dy(c);)Md(c,c.decodedFrames.shift());Ly(c),c.renderTimer!==null&&c.renderScheduledAt>0&&performance.now()-c.renderScheduledAt>w0&&(typeof document>"u"||document.visibilityState==="visible")&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),c.renderTimer!==null&&c.decodedFrames.length>=Dh&&(window.cancelAnimationFrame(c.renderTimer),c.renderTimer=null,c.renderScheduledAt=0),Nd(n,c)},error:()=>{ha.get(n)===c&&(zd(n,c.hardwareAcceleration),Lh(c),Dc.delete(n),ha.delete(n))}}),configured:!1,configKey:"",codec:"",hardwareAcceleration:Ey(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},ha.set(n,c),Dc.add(n),c}function Lh(n){n.renderTimer!==null&&(window.cancelAnimationFrame(n.renderTimer),n.renderTimer=null),n.renderScheduledAt=0,n.flushTimer!==null&&(window.clearTimeout(n.flushTimer),n.flushTimer=null),n.flushInFlight=!1;for(const a of n.decodedFrames)a.videoFrame.close();n.decodedFrames=[],n.interactiveBufferPrimed=!1,n.interactiveBufferStartedAt=0}function Md(n,a){a&&(a.videoFrame.close(),n.droppedForLatency+=1)}function Dy(n){return n.latencyMode==="interactive"?r0:String(n.decodedFrames[0]?.pending?.frame.frameMode||n.decodedFrames[0]?.pending?.frame.mode||"").toLowerCase()==="mode4-h264-atlas"?l0:Dh}function Ly(n,a=performance.now()){const l=Dy(n);for(;n.decodedFrames.length>l;)Md(n,n.decodedFrames.shift());const r=n.latencyMode==="interactive"?Ny:f0;let c=n.decodedFrames[0];for(;n.decodedFrames.length>1&&c?.pending&&a-c.pending.queuedAt>r;)Md(n,n.decodedFrames.shift()),c=n.decodedFrames[0]}function _y(n,a){if(a.hardwareAcceleration!=="prefer-hardware"||a.flushTimer!==null||a.flushInFlight)return;const l=a.latencyMode==="interactive"?h0:m0,r=a.latencyMode==="interactive";a.flushTimer=window.setTimeout(async()=>{a.flushTimer=null;const c=performance.now();for(const[p,v]of a.pendingFrames.entries())c-v.queuedAt>y0&&a.pendingFrames.delete(p);if(ha.get(n)!==a||a.decoder.state!=="configured"||a.pendingFrames.size===0||a.inputSerial<=a.lastFlushInputSerial||!r&&a.lastOutputAt>0&&c-a.lastOutputAt<l)return;const u=a.inputSerial,m=performance.now();a.flushInFlight=!0,a.flushCount+=1;try{await a.decoder.flush(),a.lastFlushInputSerial=Math.max(a.lastFlushInputSerial,u)}catch{ha.get(n)===a&&gd(a)}finally{a.flushInFlight=!1;const p=performance.now()-m;if(r&&p>=p0&&a.hardwareAcceleration==="prefer-hardware"){Ad=!0,zd(n,a.hardwareAcceleration),vs(n);return}ha.get(n)===a&&a.inputSerial>u&&a.pendingFrames.size>0&&(r||performance.now()-a.lastOutputAt>=l)&&_y(n,a)}},l)}function Jv(n,a,l){const r=performance.now();try{(n.width!==l.width||n.height!==l.height)&&(n.width=l.width,n.height=l.height);const c=Ry(n,a.latencyMode);if(c?.context.drawImage(l.videoFrame,0,0,l.width,l.height),l.pending){const u=performance.now(),p=a.latencyMode==="interactive"?k0(n,l.pending.frame):fh(n,l.width,l.height,Ty,64);try{a.onPaint?.(l.pending.frame,{deviceId:l.pending.frame.deviceId,frameSeq:l.pending.frame.frameSeq,mode:l.pending.frame.frameMode||l.pending.frame.mode||l.pending.frame.codec||l.pending.frame.mimeType,width:l.width,height:l.height,byteLength:l.pending.frame.byteLength,queuedForMs:Math.max(0,r-l.pending.queuedAt),decodedForMs:Math.max(0,l.decodedAt-l.pending.queuedAt),scheduledForMs:Math.max(0,r-l.decodedAt),drawMs:Math.max(0,u-r),queueSize:l.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:u})}catch{}}a.lastPaintAt=performance.now()}finally{l.videoFrame.close()}}function Nd(n,a){if(a.renderTimer!==null||a.decodedFrames.length===0)return;const l=Math.max(16,Math.min(250,a.targetPaintIntervalMs||1e3/12)),r=()=>{if(a.renderTimer=null,a.renderScheduledAt=0,a.decodedFrames.length===0)return;const c=performance.now();if(Ly(a,c),a.decodedFrames.length===0)return;if(a.latencyMode==="interactive"){const v=a.targetPaintIntervalMs<=u0,g=a.targetPaintIntervalMs<=20;if(g&&!a.interactiveBufferPrimed){a.interactiveBufferStartedAt<=0&&(a.interactiveBufferStartedAt=c,a.interactiveBufferWaitCount+=1);const A=a.decodedFrames.length>=o0,T=c-a.interactiveBufferStartedAt>=c0;if(!A&&!T){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}a.interactiveBufferWaitMs+=Math.max(0,c-a.interactiveBufferStartedAt),a.interactiveBufferPrimed=!0}else g||(a.interactiveBufferPrimed=!0);const w=a.decodedFrames[0],y=w?.pending?Math.max(0,c-w.pending.queuedAt):0,b=a.lastPaintAt>0?a.lastPaintAt+l:c;if(!(!v||c+Qv>=b||y>=Ny)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const C=a.decodedFrames.shift();if(C)try{Jv(n,a,C)}catch{}a.decodedFrames.length===0&&(a.interactiveQueueDrainCount+=1,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0),Nd(n,a);return}const u=a.lastPaintAt>0?a.lastPaintAt+l:c+d0;if(!(c+Qv>=u||a.decodedFrames.length>=Dh-1)){a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r);return}const p=a.decodedFrames.shift();if(p)try{Jv(n,a,p)}catch{}Nd(n,a)};a.renderScheduledAt=performance.now(),a.renderTimer=window.requestAnimationFrame(r)}function zy(n,a){if(ha.get(n)!==a||a.decoder.state==="closed")return!1;for(a.renderTimer!==null&&(window.cancelAnimationFrame(a.renderTimer),a.renderTimer=null),a.renderScheduledAt=0;a.decodedFrames.length>1;)Md(a,a.decodedFrames.shift());return a.lastPaintAt=0,a.interactiveBufferPrimed=!1,a.interactiveBufferStartedAt=0,Nd(n,a),!0}function Em(){if(!(typeof document>"u"||document.visibilityState!=="visible"))for(const n of Dc){const a=ha.get(n);if(!a||a.decoder.state==="closed"){Dc.delete(n);continue}zy(n,a)}}typeof document<"u"&&typeof window<"u"&&(document.addEventListener("visibilitychange",Em),window.addEventListener("focus",Em),window.addEventListener("pageshow",Em));function vs(n){lr.delete(n),Dc.delete(n),kd.delete(n);const a=ha.get(n);if(a){ha.delete(n);try{Lh(a),a.decoder.state!=="closed"&&a.decoder.close()}catch{}}}function uc(n){n&&(Cd.delete(n),ch.delete(n),dh.delete(n),uh.delete(n),kd.delete(n),Rc.delete(n),vs(n))}function gd(n,a=1){try{n.decoder.state!=="closed"&&n.decoder.reset()}catch{}n.configured=!1,n.configKey="",n.keyFrameSeen=!1,n.pendingFrames.clear(),Lh(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 Qu(n,a,l,r){n.decoder.configure(a),n.configured=!0,n.configKey=l,n.codec=a.codec,n.hardwareAcceleration=r,n.keyFrameSeen=!1,n.nextChunkTimestampUs=0,n.lastInputFrameSeq=void 0}function R0(n,a){if(a.latencyMode!=="interactive"||a.hardwareAcceleration!=="prefer-hardware")return!1;const l=performance.now();if(l-a.healthSampleStartedAt<g0)return!1;const r=a.inputSerial-a.healthInputSerial,c=a.outputSerial-a.healthOutputSerial;return a.healthSampleStartedAt=l,a.healthInputSerial=a.inputSerial,a.healthOutputSerial=a.outputSerial,r<v0||c/Math.max(1,r)>=x0?!1:(Ad=!0,zd(n,a.hardwareAcceleration),vs(n),!0)}function Rm(n,a=1){if(!n)return!1;const l=ha.get(n);return l?(l.droppedForLatency+=Math.max(1,Math.min(1e4,Math.floor(a))),vs(n),!0):!1}function D0(n){if(!n)return!1;const a=ha.get(n);return a?zy(n,a):!1}function L0(n,a,l,r="interactive"){vs(n);const c=performance.now(),u=s0(a.payload,a.uncompressedByteLength||0),m=String(a.streamId||"mode5");let p=Rc.get(n);if(!p||p.streamId!==m||p.width!==u.width||p.height!==u.height){const A=new Uint8ClampedArray(u.width*u.height*4);for(let T=3;T<A.length;T+=4)A[T]=255;p={streamId:m,width:u.width,height:u.height,rgba:A,imageData:new ImageData(A,u.width,u.height),keyFrameSeen:!1,inputSerial:0,outputSerial:0},Rc.set(n,p)}if(!p)throw new Error("Mode 5 canvas state could not be initialized.");p.inputSerial+=1;const g=Number(a.streamFrameSeq||0);if(g>0&&(p.lastStreamFrameSeq=g),!u.keyFrame&&!p.keyFrameSeen)return;u.keyFrame&&(p.keyFrameSeen=!0);const w=i0(p.rgba,p.width,p.height,u),y=performance.now();(n.width!==p.width||n.height!==p.height)&&(n.width=p.width,n.height=p.height);const b=Ry(n,r),j=performance.now();w&&b?.context.putImageData(p.imageData,0,0,w.x,w.y,w.width,w.height);const C=performance.now();p.outputSerial+=1,l?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.mimeType,width:p.width,height:p.height,byteLength:a.byteLength,queuedForMs:Math.max(0,C-c),decodedForMs:Math.max(0,y-c),scheduledForMs:0,drawMs:Math.max(0,C-j),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:"prefer-software",decoderLabel:"lzo-rgb565-delta",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:p.inputSerial,decoderOutputCount:p.outputSerial,targetPaintIntervalMs:Math.max(1,Number(a.durationUs||0)/1e3||1e3/30),canvasPresentation:b?.presentation||"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:String(a.contentHash||""),visualChanged:Number(a.deltaVisualTileCount||0)>0,paintedAt:C})}const Dm=[{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 ex(n,a){for(let l=Math.max(0,a);l+3<n.length;l+=1)if(!(n[l]!==0||n[l+1]!==0)){if(n[l+2]===1)return{index:l,length:3};if(n[l+2]===0&&n[l+3]===1)return{index:l,length:4}}return null}function _0(n){const a=new Uint8Array(n);let l=0;for(;l<a.length;){const r=ex(a,l);if(!r)break;const c=r.index+r.length,u=ex(a,c),m=u?.index??a.length;if(c<m&&(a[c]&31)===7){const p=[];let v=0;for(let g=c+1;g<m;g+=1){const w=a[g];if(v>=2&&w===3){v=0;continue}p.push(w),v=w===0?v+1:0}if(p.length>=3)return`avc1.${p.slice(0,3).map(g=>g.toString(16).toUpperCase().padStart(2,"0")).join("")}`}l=u?u.index:a.length}return""}function z0(n,a,l,r,c=""){const u=Math.ceil(n/16)*Math.ceil(a/16),m=l>0?1e6/l:30,p=u*m,v=Dm.find(g=>u<=g.maxFrameSize&&p<=g.maxMacroblocksPerSecond)||Dm[Dm.length-1];return _0(r)||c||`avc1.42E0${v.code.toString(16).toUpperCase().padStart(2,"0")}`}function I0(n,a,l,r,c="smooth"){Rc.delete(n);const u=String(a.h264Format||"").toLowerCase()==="avc"?"avc":"annexb",m=Math.max(1,Math.floor(a.width||960)),p=Math.max(1,Math.floor(a.height||540)),v=Math.max(1,Math.floor(a.durationUs||1e6/12));let g=Zv(n,c);const w=z0(m,p,v,a.payload,g.codec),y=String(a.frameMode||a.mode||"").toLowerCase(),b=c==="interactive"&&r==="prefer-hardware"&&b0(),C=y==="mode4-h264-atlas"?"prefer-software":Ey(n,c==="interactive"&&(Ad||b)?"prefer-software":r),A=[a.streamId||"",a.commandId||"",m,p,w,u,C,c].join("|");g.onPaint=l,g.configured&&g.decoder.state!=="configured"&&(g.configured=!1,g.configKey=""),g.configured&&g.configKey!==A&&(vs(n),g=Zv(n,c),g.onPaint=l);const T={codec:w,codedWidth:m,codedHeight:p,hardwareAcceleration:C,optimizeForLatency:!0,avc:{format:u}};g.configured||Qu(g,T,A,C);const k=a.isKeyFrame===!0||String(a.chunkType||"").toLowerCase()==="key";Number(a.frameSeq||0);const E=Number(a.streamFrameSeq||0);if(E>0&&g.lastInputFrameSeq!==void 0){if(E<=g.lastInputFrameSeq){if(!k||E===g.lastInputFrameSeq)return;gd(g,g.lastInputFrameSeq-E+1),Qu(g,T,A,C)}if(E>g.lastInputFrameSeq+1){if(gd(g,E-g.lastInputFrameSeq-1),!k)return;Qu(g,T,A,C)}}if(E>0&&(g.lastInputFrameSeq=E),!k&&!g.keyFrameSeen)return;k&&(g.keyFrameSeen=!0);const R=Number(g.decoder.decodeQueueSize||0);if(R>8){if(g.latencyMode==="interactive"&&g.hardwareAcceleration==="prefer-hardware"){Ad=!0,zd(n,g.hardwareAcceleration),vs(n);return}if(gd(g),!k)return;Qu(g,T,A,C),g.keyFrameSeen=!0}const U=g.nextChunkTimestampUs;g.nextChunkTimestampUs+=v,g.pendingFrames.set(U,{frame:a,queuedAt:performance.now(),queueSize:R}),g.inputSerial+=1,g.lastInputAt=performance.now();const F=new EncodedVideoChunk({type:k?"key":"delta",timestamp:U,duration:v,data:a.payload});try{g.decoder.decode(F)}catch(V){throw vs(n),V}_y(n,g),R0(n,g)}async function Lm(n,a,l,r,c,u="smooth"){if(N0(a)){l()||L0(n,a,r,u);return}if(M0(a)){l()||I0(n,a,r,c,u);return}if(Rc.delete(n),A0(a)){vs(n);const y=E0(a);if(l())return;(n.width!==y.width||n.height!==y.height)&&(n.width=y.width,n.height=y.height);const b=n.getContext("2d"),j=performance.now();b?.putImageData(y,0,0);const C=performance.now(),A=fh(n,y.width,y.height);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:y.width,height:y.height,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,C-j),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:cr.h264DecodeAcceleration,decoderLabel:"lzo-rgb565",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:A.visualHash,visualChanged:A.visualChanged,paintedAt:C});return}vs(n);const m=new Blob([a.payload],{type:a.mimeType}),p=await createImageBitmap(m);if(l()){p.close();return}const v=a.width||p.width||960,g=a.height||p.height||540;(n.width!==v||n.height!==g)&&(n.width=v,n.height=g);const w=n.getContext("2d");if(w){const y=performance.now();w.clearRect(0,0,v,g),w.drawImage(p,0,0,v,g);const b=performance.now(),j=fh(n,v,g);r?.(a,{deviceId:a.deviceId,frameSeq:a.frameSeq,mode:a.frameMode||a.mode||a.codec||a.mimeType,width:v,height:g,byteLength:a.byteLength,queuedForMs:0,decodedForMs:0,scheduledForMs:0,drawMs:Math.max(0,b-y),queueSize:0,renderQueueSize:0,droppedForLatency:0,h264DecodeAcceleration:cr.h264DecodeAcceleration,decoderLabel:"image",decoderFlushCount:0,decoderTimestampFallbacks:0,decoderInputCount:0,decoderOutputCount:0,targetPaintIntervalMs:0,canvasPresentation:"sync",interactiveBufferWaitCount:0,interactiveBufferWaitMs:0,interactiveQueueDrainCount:0,visualHash:j.visualHash,visualChanged:j.visualChanged,paintedAt:b})}p.close()}const tx="livedesk_remote_host_targets",O0="livedesk_entitlements";function B0(n){const l=(Array.isArray(n)?n:[n||bn]).map(r=>Al(r||bn));return[...new Set(l.filter(Boolean))]}function F0(){const[n,a]=f.useState(null),[l,r]=f.useState(!0);return f.useEffect(()=>{let c=!0;zt.auth.getSession().then(({data:m})=>{c&&(a(m.session??null),r(!1))});const{data:{subscription:u}}=zt.auth.onAuthStateChange((m,p)=>{a(p),r(!1)});return()=>{c=!1,u.unsubscribe()}},[]),{session:n,loading:l}}function H0(n,a=!0){const[l,r]=f.useState(null),[c,u]=f.useState([]),[m,p]=f.useState(""),[v,g]=f.useState(""),[w,y]=f.useState(0),b=f.useRef(new Map),j=Array.isArray(n)?n.join(`
10
+ `):String(n||""),C=f.useMemo(()=>B0(n),[j]),A=f.useMemo(()=>C.find(E=>Ac(E)==="loopback")||C[0]||bn,[C]),T=f.useCallback(async()=>{if(!a){r(null),u([]),g(""),p("");return}let E=null;const R=Date.now(),U=C.filter(F=>(b.current.get(F)||0)<=R);if(U.length===0)throw new Error("No LiveDesk Hub endpoint is reachable. Retrying shortly.");for(const F of U)try{const[V,_]=await Promise.all([Be("/api/remote/status",void 0,F),Be("/api/remote/devices",void 0,F)]);if(!Array.isArray(_.devices))throw new Error("Invalid Hub devices response.");b.current.delete(F),r(V),u(_.devices),g(F),p("");return}catch(V){E=V,b.current.set(F,Date.now()+1e4)}throw g(""),E||new Error("No LiveDesk Hub endpoint is reachable.")},[a,C]),k=f.useCallback(()=>{b.current.clear(),T().catch(E=>{p(E instanceof Error?E.message:String(E))}),y(E=>E+1)},[T]);return f.useEffect(()=>{if(!a){r(null),u([]),g(""),p("");return}let E=!0;const R=async()=>{try{await T()}catch(F){E&&p(F instanceof Error?F.message:String(F))}};R();const U=window.setInterval(R,2500);return()=>{E=!1,window.clearInterval(U)}},[a,T,w]),{status:l,devices:c,error:m,refresh:k,hubBaseUrl:v||A,hubCandidates:C}}function P0(n){const[a,l]=f.useState(null),[r,c]=f.useState(""),u=n?.user?.id||"",m=f.useCallback(async()=>{if(!u){l(null);return}const{data:p,error:v}=await zt.from(tx).select("*").eq("user_id",u).maybeSingle();if(v){c(v.message);return}l(p),c("")},[u]);return f.useEffect(()=>{m()},[m]),f.useEffect(()=>{if(!u)return;const p=zt.channel(`livedesk-remote-host-targets-${u.replace(/[^a-zA-Z0-9]/g,"")}`).on("postgres_changes",{event:"*",schema:"public",table:tx,filter:`user_id=eq.${u}`},v=>l(v.new)).subscribe();return()=>{zt.removeChannel(p)}},[u]),{target:a,error:r,refresh:m}}function $0(n){const[a,l]=f.useState(null),[r,c]=f.useState(!1),[u,m]=f.useState(""),p=n?.user?.id||"",v=f.useCallback(async()=>{if(!p){l(null),m(""),c(!1);return}c(!0);const{data:w,error:y}=await zt.from(O0).select("*").eq("user_id",p).eq("product_key","livedesk").maybeSingle();if(y){m(y.message),c(!1);return}l(w),m(""),c(!1)},[p]);f.useEffect(()=>{v()},[v]);const g=f.useMemo(()=>!a||a.status!=="active"?!1:a.expires_at?new Date(a.expires_at).getTime()>Date.now():!0,[a]);return{entitlement:a,licensed:g,loading:r,error:u,refresh:v}}const Mc={totalFrames:0,totalBytes:0,framesPerSecond:0,bytesPerSecond:0,sampleMs:0,lastUpdatedAt:0},U0=2500,q0=3e4,G0=64*1024,V0=6,Y0=V0,Iy=new Map;function W0(n){return Iy.get(n)}const nx={totalSent:0,totalDropped:0,sentPerSecond:0,droppedPerSecond:0,bufferedAmount:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0,lastUpdatedAt:0};function ax(n){const a=Date.parse(String(n||""));if(!Number.isFinite(a))return 0;const l=Date.now()-a;return l>0&&l<=q0?l:0}function sx(n,a,l=bn,r={}){const[c,u]=f.useState(new Map),[m,p]=f.useState("idle"),[v,g]=f.useState(""),[w,y]=f.useState(Mc),b=f.useRef(new Map),j=f.useRef(new Map),C=f.useRef(0),A=f.useRef(new Map),T=f.useRef({enabled:!1,token:"",reason:""}),k=f.useRef(new Set),[E,R]=f.useState(0),U=f.useRef(r.onFrame),F=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),V=f.useMemo(()=>[...n].sort().join(","),[n]),_=Number.isFinite(r.fps)?Number(r.fps):2,I=Number.isFinite(r.maxWidth)?Number(r.maxWidth):640,me=Number.isFinite(r.maxHeight)?Number(r.maxHeight):360,Y=Number.isFinite(r.quality)?Number(r.quality):45,ue=String(r.frameMode||r.mode||"mode3-h264-hw").trim()||"mode3-h264-hw",K=r.streamPurpose==="control"?"control":"wall",ie=r.forceRestart===!0,ee=String(r.forceRestartToken||"").trim(),W=String(r.restartReason||"").trim();T.current={enabled:ie,token:ee,reason:W};const z=f.useMemo(()=>{const $=Object.entries(r.monitorSelections||{}).filter(([xe])=>!!xe).sort(([xe],[Se])=>xe.localeCompare(Se));return JSON.stringify(Object.fromEntries($))},[r.monitorSelections]);f.useEffect(()=>{U.current=r.onFrame},[r.onFrame]);const Q=f.useCallback(($,xe="livedesk-frame-socket-release")=>{$.disposed=!0;try{$.socket.readyState===WebSocket.CONNECTING||$.socket.readyState===WebSocket.OPEN?$.socket.close(1e3,xe):$.socket.close()}catch{}},[]),X=f.useCallback(()=>{const $=[...j.current.values()].map(xe=>xe.socket);if($.length===0){p("idle");return}if($.some(xe=>xe.readyState===WebSocket.OPEN)){p("open");return}if($.some(xe=>xe.readyState===WebSocket.CONNECTING)){p("connecting");return}p("closed")},[]),P=f.useCallback(($,xe,Se,fe)=>{if(xe.disposed||xe.socket.readyState!==WebSocket.OPEN)return!1;try{return xe.socket.send(JSON.stringify({...xe.payload,type:"restart-live",deviceIds:[$],forceRestart:!0,restartReason:Se,restartToken:fe})),!0}catch{return!1}},[]),le=f.useCallback(($,xe)=>{if(!$||$.byteLength<5)return;const Se=Date.now(),Te=new DataView($).getUint32(0,!1);if(Te<=0||Te+4>$.byteLength)return;const Ie=new Uint8Array($.slice(4,4+Te)),oe=JSON.parse(new TextDecoder().decode(Ie));if(Math.max(ax(oe.receivedAt),ax(oe.capturedAt))>U0)return;const De=$.slice(4+Te),We={deviceId:String(oe.deviceId||""),kind:oe.kind==="thumbnail"?"thumbnail":"live",frameSeq:Number(oe.frameSeq||0),streamFrameSeq:Number(oe.streamFrameSeq||0)||void 0,streamId:String(oe.streamId||""),commandId:oe.commandId?String(oe.commandId):void 0,width:Number(oe.width||0),height:Number(oe.height||0),sourceWidth:Number(oe.sourceWidth||0)||void 0,sourceHeight:Number(oe.sourceHeight||0)||void 0,mimeType:String(oe.mimeType||"image/jpeg"),mode:oe.mode?String(oe.mode):void 0,frameMode:oe.frameMode?String(oe.frameMode):void 0,frameProfile:oe.frameProfile?String(oe.frameProfile):void 0,encoding:oe.encoding?String(oe.encoding):void 0,codec:oe.codec?String(oe.codec):void 0,compression:oe.compression?String(oe.compression):void 0,pixelFormat:oe.pixelFormat?String(oe.pixelFormat):void 0,bytesPerPixel:Number(oe.bytesPerPixel||0)||0,uncompressedByteLength:Number(oe.uncompressedByteLength||0)||0,h264Format:oe.h264Format?String(oe.h264Format):void 0,isKeyFrame:oe.isKeyFrame===!0,chunkType:oe.chunkType?String(oe.chunkType):void 0,timestampUs:Number(oe.timestampUs||0)||0,durationUs:Number(oe.durationUs||0)||0,sourceGapMs:Number(oe.sourceGapMs||0)||0,agentSendGapMs:Number(oe.agentSendGapMs||0)||0,agentSendDurationMs:Number(oe.agentSendDurationMs||0)||0,agentSendDurationFrameSeq:Number(oe.agentSendDurationFrameSeq||0)||0,agentPaceMs:Number(oe.agentPaceMs||0)||0,agentQueueBeforePaceMs:Number(oe.agentQueueBeforePaceMs||0)||0,agentFrameAgeMs:Number(oe.agentFrameAgeMs||0)||0,droppedByAgent:Number(oe.droppedByAgent||0)||0,hubIngressDropped:Number(oe.hubIngressDropped||0)||0,hubClientDropped:Number(oe.hubClientDropped||0)||0,hardwareEncoder:oe.hardwareEncoder?String(oe.hardwareEncoder):void 0,platformProfile:oe.platformProfile?String(oe.platformProfile):void 0,monitorIndex:Number.isFinite(Number(oe.monitorIndex))?Number(oe.monitorIndex):void 0,monitorCount:Number.isFinite(Number(oe.monitorCount))?Number(oe.monitorCount):void 0,requestedFps:Number(oe.requestedFps||0)||0,effectiveFps:Number(oe.effectiveFps||0)||0,captureAverageMs:Number(oe.captureAverageMs||0)||0,captureP95Ms:Number(oe.captureP95Ms||0)||0,slowFrameCount:Number(oe.slowFrameCount||0)||0,captureHelperRestarts:Number(oe.captureHelperRestarts||0)||0,capturedAt:String(oe.capturedAt||""),receivedAt:String(oe.receivedAt||""),hubPacketAt:oe.hubPacketAt?String(oe.hubPacketAt):void 0,hubPacketEpochMs:Number.isFinite(Number(oe.hubPacketEpochMs))?Number(oe.hubPacketEpochMs):void 0,browserReceivedEpochMs:Se,byteLength:Number(oe.byteLength||De.byteLength),contentHash:oe.contentHash?String(oe.contentHash):void 0,captureMs:Number(oe.captureMs||0)||0,captureStageMs:Number(oe.captureStageMs||0)||0,convertMs:Number(oe.convertMs||0)||0,compressMs:Number(oe.compressMs||0)||0,captureSourceSerial:Number(oe.captureSourceSerial||0)||0,captureSourceSkipped:Number(oe.captureSourceSkipped||0)||0,deltaTileSize:Number(oe.deltaTileSize||0)||0,deltaTileCount:Number(oe.deltaTileCount||0)||0,deltaVisualTileCount:Number(oe.deltaVisualTileCount||0)||0,deltaRefreshTileCount:Number(oe.deltaRefreshTileCount||0)||0,deltaTotalTiles:Number(oe.deltaTotalTiles||0)||0,payload:De};if(!We.deviceId)return;const D={streamId:xe.lastFrameStreamId,commandId:xe.lastFrameCommandId,order:xe.lastFrameOrder},ne=Number(We.streamFrameSeq||We.frameSeq||0),je=!!D.commandId&&!!We.commandId,te=D.streamId===We.streamId&&(!je||D.commandId===We.commandId),ce=D.order;if(te&&ce>=ne&&(ce===ne||je))return;xe.lastFrameStreamId=We.streamId,xe.lastFrameCommandId=We.commandId||"",xe.lastFrameOrder=ne;const Me=F.current;Me.totalFrames+=1,Me.totalBytes+=De.byteLength,Me.sampleFrames+=1,Me.sampleBytes+=De.byteLength;const Ce=!b.current.has(We.deviceId);b.current.set(We.deviceId,We),Ce&&u(new Map(b.current)),U.current?.(We)},[]);f.useEffect(()=>{const $=window.setInterval(()=>{const xe=performance.now(),Se=F.current,fe=Math.max(1,xe-Se.sampleStartedAt);y({totalFrames:Se.totalFrames,totalBytes:Se.totalBytes,framesPerSecond:Se.sampleFrames*1e3/fe,bytesPerSecond:Se.sampleBytes*1e3/fe,sampleMs:fe,lastUpdatedAt:Date.now()}),u(new Map(b.current)),Se.sampleFrames=0,Se.sampleBytes=0,Se.sampleStartedAt=xe},2e3);return()=>{window.clearInterval($)}},[]),f.useEffect(()=>{const $=V?V.split(",").filter(Boolean):[],xe=new Set($),Se=performance.now();for(const[fe,Te]of j.current.entries())xe.has(fe)||(Q(Te,"livedesk-device-unsubscribed"),j.current.delete(fe),A.current.delete(fe),b.current.delete(fe));if($.length===0){for(const fe of j.current.values())Q(fe,"livedesk-no-devices");j.current.clear(),A.current.clear(),b.current=new Map,u(new Map),g(""),F.current={totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0},y(Mc),X();return}F.current.sampleStartedAt<=0&&(F.current.sampleStartedAt=Se,y({...Mc,lastUpdatedAt:Date.now()}));for(const fe of $){const Te=r.monitorSelections?.[fe],Ie=Number.isFinite(Number(Te))?{[fe]:Number(Te)}:{},oe={type:"subscribe",deviceIds:[fe],autoStartLive:a,fps:_,maxWidth:I,maxHeight:me,quality:Y,mode:ue,frameMode:ue,streamPurpose:K,monitorSelections:Ie},Ye=JSON.stringify(oe),De=j.current.get(fe);if(De){const je=De.socket.readyState===WebSocket.CONNECTING||De.socket.readyState===WebSocket.OPEN;if(De.payloadKey===Ye&&je&&!De.disposed)continue}const We=De&&(De.socket.readyState===WebSocket.CONNECTING||De.socket.readyState===WebSocket.OPEN)&&!De.disposed?De.handoffFrom&&!De.handoffCompleted?De.handoffFrom:De:void 0;De&&De!==We&&Q(De,"livedesk-subscription-superseded");const D=new WebSocket(_d(`/api/remote/frames/ws?devices=${encodeURIComponent(fe)}`,l));D.binaryType="arraybuffer";const ne={socket:D,payload:oe,payloadKey:Ye,generation:C.current+1,disposed:!1,handoffFrom:We,handoffCompleted:!1,lastFrameStreamId:"",lastFrameCommandId:"",lastFrameOrder:-1};C.current=ne.generation,j.current.set(fe,ne),D.addEventListener("open",()=>{if(ne.disposed||j.current.get(fe)!==ne){Q(ne,"livedesk-stale-frame-socket");return}g("");const je=T.current,te=je.enabled&&(!je.token||A.current.get(fe)!==je.token);D.send(JSON.stringify({...ne.payload,forceRestart:te,restartReason:te?je.reason:"",restartToken:te?je.token:""})),te&&je.token&&A.current.set(fe,je.token);const ce=ne.handoffFrom;ne.handoffFrom=void 0,ne.handoffCompleted=!0,ce&&!ce.disposed&&Q(ce,"livedesk-subscription-replaced"),X()}),D.addEventListener("message",je=>{if(ne.disposed||j.current.get(fe)!==ne)return;if(typeof je.data=="string"){try{const ce=JSON.parse(je.data);if(ce?.type==="RemoteFrameSubscriptionError")g(String(ce.error||"control-stream-start-failed"));else if(ce?.type==="RemoteFrameLiveAutoStart"){const Ce=(Array.isArray(ce.skipped)?ce.skipped:[]).find(it=>it?.deviceId===fe);Ce?g(String(Ce.reason||"control-stream-start-failed")):Array.isArray(ce.started)&&ce.started.some(it=>it?.deviceId===fe)&&g("")}}catch{}return}const te=je.data instanceof ArrayBuffer?je.data:null;te&&(g(""),le(te,ne))}),D.addEventListener("error",()=>{ne.disposed||j.current.get(fe)!==ne||(g("frame-socket-error"),p("error"))}),D.addEventListener("close",()=>{const je=!ne.disposed;ne.disposed=!0;const te=j.current.get(fe);let ce=!1;if(te===ne){const Me=ne.handoffFrom;ne.handoffFrom=void 0,Me&&!Me.disposed&&(Me.socket.readyState===WebSocket.CONNECTING||Me.socket.readyState===WebSocket.OPEN)?(j.current.set(fe,Me),ce=!0):j.current.delete(fe)}if(X(),je&&te===ne&&!ce){const Me=window.setTimeout(()=>{k.current.delete(Me),R(Ce=>Ce+1)},750);k.current.add(Me)}})}X()},[a,Q,V,_,ue,le,l,me,I,z,r.monitorSelections,Y,E,K,X]),f.useEffect(()=>{if(!ie||!ee)return;const $=V?V.split(",").filter(Boolean):[];for(const xe of $){if(A.current.get(xe)===ee)continue;const Se=j.current.get(xe);!Se||!P(xe,Se,W,ee)||A.current.set(xe,ee)}},[V,ie,ee,W,P]),f.useEffect(()=>()=>{for(const $ of j.current.values())Q($,"livedesk-hook-unmount");j.current.clear();for(const $ of k.current)window.clearTimeout($);k.current.clear()},[Q]);const we=f.useCallback(($,xe="browser-stale")=>{const Se=Array.isArray($)&&$.length>0?$:V.split(",").filter(Boolean);if(Se.length===0)return!1;let fe=!1;for(const Te of Se){const Ie=j.current.get(Te);!Ie||Ie.socket.readyState!==WebSocket.OPEN||(fe=P(Te,Ie,xe,`${Date.now()}-${Math.random().toString(36).slice(2)}`)||fe)}return fe},[V,P]),L=f.useCallback(($,xe="browser-reconnect")=>{const Se=Array.isArray($)&&$.length>0?$:V.split(",").filter(Boolean);if(Se.length===0)return!1;let fe=!1;for(const Te of Se){const Ie=j.current.get(Te);Ie&&(Q(Ie,`livedesk-${xe}`),j.current.delete(Te),A.current.delete(Te),b.current.delete(Te),fe=!0)}return fe&&u(new Map(b.current)),R(Te=>Te+1),X(),!0},[Q,V,X]);return{frames:c,state:m,error:v,stats:w,restartLive:we,reconnectLive:L}}function K0(n,a,l=bn,r={}){const[c,u]=f.useState(null),[m,p]=f.useState(null),[v,g]=f.useState("idle"),[w,y]=f.useState(Mc),b=f.useRef(null),j=f.useRef(r.onFrame),C=f.useRef(null),A=f.useRef(0),T=f.useRef({totalFrames:0,totalBytes:0,sampleFrames:0,sampleBytes:0,sampleStartedAt:0}),k=f.useMemo(()=>[...new Set(n.filter(Boolean))].join(","),[n]),E=f.useMemo(()=>[...new Set((r.captureDeviceIds||n).filter(Boolean))].join(","),[n,r.captureDeviceIds]),R=f.useMemo(()=>JSON.stringify(r.monitorSelections||{}),[r.monitorSelections]),U=f.useMemo(()=>({deviceIds:k.split(",").filter(Boolean),captureDeviceIds:E.split(",").filter(Boolean),fps:Number(r.fps||20),width:Number(r.width||1920),height:Number(r.height||1080),tileWidth:Number(r.tileWidth||320),tileHeight:Number(r.tileHeight||180),monitorSelections:r.monitorSelections||{}}),[E,k,R,r.fps,r.height,r.monitorSelections,r.tileHeight,r.tileWidth,r.width]),F=f.useMemo(()=>JSON.stringify(U),[U]),V=f.useRef(U);V.current=U;const _=a&&U.deviceIds.length>0,I=f.useCallback(Y=>Y.readyState!==WebSocket.OPEN?!1:(Y.send(JSON.stringify({type:"configure",...V.current})),!0),[]);f.useEffect(()=>{j.current=r.onFrame},[r.onFrame]),f.useEffect(()=>{const Y=window.setInterval(()=>{const ue=T.current,K=performance.now(),ie=Math.max(1,K-ue.sampleStartedAt);y({totalFrames:ue.totalFrames,totalBytes:ue.totalBytes,framesPerSecond:ue.sampleFrames*1e3/ie,bytesPerSecond:ue.sampleBytes*1e3/ie,sampleMs:ie,lastUpdatedAt:Date.now()});const ee=C.current;ee&&ee.frameSeq!==A.current&&(A.current=ee.frameSeq,u(ee)),ue.sampleFrames=0,ue.sampleBytes=0,ue.sampleStartedAt=K},1e3);return()=>window.clearInterval(Y)},[]),f.useEffect(()=>{if(!_){b.current?.close(),b.current=null,u(null),C.current=null,A.current=0,p(null),g("idle"),y(Mc);return}let Y=!1,ue=0;const K=()=>{if(Y)return;const ie=new WebSocket(_d("/api/remote/atlas/ws",l));ie.binaryType="arraybuffer",b.current=ie,g("connecting"),ie.addEventListener("open",()=>{T.current.sampleStartedAt=performance.now(),g("open"),I(ie)}),ie.addEventListener("message",ee=>{if(typeof ee.data=="string"){try{const z=JSON.parse(ee.data);z?.type==="Mode4AtlasLayout"&&p({layoutVersion:Number(z.layoutVersion||0),width:Number(z.width||1920),height:Number(z.height||1080),columns:Number(z.columns||1),rows:Number(z.rows||1),tiles:Array.isArray(z.tiles)?z.tiles:[]})}catch{}return}const W=ee.data instanceof ArrayBuffer?ee.data:null;if(!(!W||W.byteLength<5))try{const z=Date.now(),X=new DataView(W).getUint32(0,!1);if(X<=0||X+4>W.byteLength)return;const P=JSON.parse(new TextDecoder().decode(new Uint8Array(W,4,X))),le=W.slice(4+X),we={deviceId:String(P.deviceId||"__livedesk_mode4_atlas__"),kind:"live",frameSeq:Number(P.frameSeq||0),streamFrameSeq:Number(P.streamFrameSeq||0)||void 0,streamId:String(P.streamId||"mode4-atlas"),commandId:P.commandId?String(P.commandId):void 0,width:Number(P.width||1920),height:Number(P.height||1080),sourceWidth:Number(P.sourceWidth||P.width||1920),sourceHeight:Number(P.sourceHeight||P.height||1080),mimeType:String(P.mimeType||"video/h264"),mode:String(P.mode||"mode4-h264-atlas"),frameMode:String(P.frameMode||"mode4-h264-atlas"),frameProfile:String(P.frameProfile||"mode4-h264-atlas-v1"),encoding:String(P.encoding||"video-atlas"),codec:String(P.codec||"h264"),compression:String(P.compression||"video/h264"),h264Format:String(P.h264Format||"annexb"),isKeyFrame:P.isKeyFrame===!0,chunkType:String(P.chunkType||""),timestampUs:Number(P.timestampUs||0),durationUs:Number(P.durationUs||0),hardwareEncoder:P.hardwareEncoder?String(P.hardwareEncoder):void 0,platformProfile:P.platformProfile?String(P.platformProfile):void 0,capturedAt:String(P.capturedAt||""),receivedAt:String(P.receivedAt||""),hubPacketAt:P.hubPacketAt?String(P.hubPacketAt):void 0,hubPacketEpochMs:Number(P.hubPacketEpochMs||0)||void 0,browserReceivedEpochMs:z,byteLength:le.byteLength,layoutVersion:Number(P.layoutVersion||0),atlasComposeMs:Number(P.atlasComposeMs||0),atlasPoolStarved:Number(P.atlasPoolStarved||0),atlasReadyTiles:Number(P.atlasReadyTiles||0),atlasTileCount:Number(P.atlasTileCount||0),payload:le},L=T.current;L.totalFrames+=1,L.totalBytes+=le.byteLength,L.sampleFrames+=1,L.sampleBytes+=le.byteLength,C.current=we,A.current===0&&(A.current=we.frameSeq,u(we)),j.current?.(we)}catch{}}),ie.addEventListener("error",()=>g("error")),ie.addEventListener("close",()=>{b.current===ie&&(b.current=null),!Y&&(g("closed"),ue=window.setTimeout(K,1200))})};return K(),()=>{Y=!0,window.clearTimeout(ue),b.current?.close(),b.current=null}},[_,l,I]),f.useEffect(()=>{if(!_)return;const Y=b.current;Y&&I(Y)},[F,_,I]);const me=f.useCallback(()=>{const Y=b.current;return Y?I(Y):!1},[I]);return{frame:c,layout:m,state:v,stats:w,refreshInputs:me}}function Q0(n,a=bn){const l=f.useRef(null),r=f.useRef(0),c=f.useRef(0),u=f.useRef(new Map),[m,p]=f.useState("idle"),[v,g]=f.useState(""),[w,y]=f.useState(nx),b=f.useRef({totalSent:0,totalDropped:0,sampleSent:0,sampleDropped:0,sampleStartedAt:0,lastInputType:"",lastInputSeq:0,lastRoundTripMs:0,lastAgentApplyMs:0});f.useEffect(()=>{if(!n){l.current?.close(),l.current=null,c.current=0,p("idle"),g(""),y(nx);return}const C=new WebSocket(_d("/api/remote/input/ws",a));return l.current=C,b.current.sampleStartedAt=performance.now(),p("connecting"),g(""),C.addEventListener("open",()=>{g(""),p("open")}),C.addEventListener("message",A=>{if(typeof A.data=="string")try{const T=JSON.parse(A.data);if(T?.type==="RemoteInputError"){g(String(T.error||T.result?.error||"Remote input failed.")),p("error");return}if(T?.type!=="RemoteInputApplied")return;const k=Number(T.inputSeq||0),E=u.current.get(k);E!==void 0&&(b.current.lastRoundTripMs=Math.max(0,performance.now()-E),u.current.delete(k)),b.current.lastInputSeq=k,b.current.lastAgentApplyMs=Math.max(0,Number(T.agentApplyMs||0))}catch{}}),C.addEventListener("close",()=>p("closed")),C.addEventListener("error",()=>p("error")),()=>{C.close(),u.current.clear(),l.current===C&&(l.current=null)}},[n,a]),f.useEffect(()=>{if(!n)return;const C=window.setInterval(()=>{const A=performance.now(),T=b.current,k=Math.max(1,A-T.sampleStartedAt);y({totalSent:T.totalSent,totalDropped:T.totalDropped,sentPerSecond:T.sampleSent*1e3/k,droppedPerSecond:T.sampleDropped*1e3/k,bufferedAmount:l.current?.bufferedAmount||0,lastInputType:T.lastInputType,lastInputSeq:T.lastInputSeq,lastRoundTripMs:T.lastRoundTripMs,lastAgentApplyMs:T.lastAgentApplyMs,lastUpdatedAt:Date.now()}),T.sampleSent=0,T.sampleDropped=0,T.sampleStartedAt=A},1e3);return()=>window.clearInterval(C)},[n]);const j=f.useCallback((C,A)=>{const T=l.current;if(!T||T.readyState!==WebSocket.OPEN||!C)return!1;const k=String(A.type||"").toLowerCase(),E=k==="pointermove",U=E||k==="wheel",F=b.current;if(E&&T.bufferedAmount>G0)return F.totalDropped+=1,F.sampleDropped+=1,F.lastInputType="pointermove-drop",!1;const V=r.current+1;r.current=V;const _=Date.now(),I=!U||V-c.current>=Y0;for(I&&(u.current.set(V,performance.now()),U&&(c.current=V)),E||Iy.set(C,{inputSeq:V,inputType:k||"input",sentAt:performance.now()});u.current.size>256;){const me=u.current.keys().next().value;if(me===void 0)break;u.current.delete(me)}return T.send(JSON.stringify({type:"input",requestId:U?"":crypto.randomUUID(),fireAndForget:U,deviceId:C,input:{...A,inputSeq:V,requestAck:I,issuedAtEpochMs:_,issuedAt:new Date(_).toISOString()}})),F.totalSent+=1,F.sampleSent+=1,F.lastInputType=k||"input",!0},[]);return{state:m,sendInput:j,stats:w,error:v}}function X0(n){const a=String(n||"").toLowerCase();return a.includes("audio/pcm")||a.includes("audio/l16")||a.includes("f32le")||a.includes("s16le")}const Xu={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},Z0=.08,J0=.25,e1=.02,ix=300,t1=4,Zu=1500,_m=5e3,n1=2e3,a1=1e4,Ju=[0,1e3,3e3];function lx(n){const a=Date.parse(String(n||""));return Number.isFinite(a)?Math.max(0,Date.now()-a):0}function s1(n,a,l){const r=Math.max(1,Math.min(8,Math.floor(a.channels||2))),c=Math.max(8e3,Math.min(192e3,Math.floor(a.sampleRate||48e3))),u=String(a.mimeType||"").toLowerCase(),m=u.includes("s16le")||u.includes("audio/l16"),p=m?2:4,v=Math.floor(l.byteLength/p),g=Math.floor(v/r),w=n.createBuffer(r,g,c),y=new DataView(l);for(let b=0;b<r;b+=1){const j=w.getChannelData(b);for(let C=0;C<g;C+=1){const T=(C*r+b)*p;j[C]=m?Math.max(-1,Math.min(1,y.getInt16(T,!0)/32768)):Math.max(-1,Math.min(1,y.getFloat32(T,!0)))}}return w}function i1(n,a,l=bn){const r=f.useRef(null),c=f.useRef(0),[u,m]=f.useState("idle"),[p,v]=f.useState(null),[g,w]=f.useState(Xu),[y,b]=f.useState("");return f.useEffect(()=>{if(!a||!n){m("idle"),v(null),w(Xu),b("");return}m("connecting"),v(null),w(Xu),b("");const j=window.AudioContext||window.webkitAudioContext;if(!j){m("unsupported"),w(Xu),b("Audio playback is not supported in this browser.");return}const C=new j;r.current=C,c.current=C.currentTime;const A=new WebSocket(_d("/api/remote/audio/ws?devices="+encodeURIComponent(n),l));A.binaryType="arraybuffer";const T=new Set,k={browserAgeMs:0,captureAgeMs:0,captureStatusAgeMs:0,silentForMs:0,captureAlive:!1,helperAlive:!1,captureRestartCount:0,localProcessingAgeMs:0,lastPacketAt:0,lastAcceptedAt:0,framesReceived:0,drops:0,resyncs:0,pendingDecodes:0,lastFrameSeq:0,audioContextState:String(C.state),stalledCount:0,automaticRestarts:0,activeStreamId:"",lastCaptureStatusAt:0,lastPcmAtEpochMs:0};let E=!1,R=0,U=!1,F=0,V=0;const _=(z=!0)=>{for(const Q of T)try{Q.stop()}catch{}T.clear(),z&&(c.current=C.currentTime+Z0)},I=()=>{k.audioContextState=String(C.state),!E&&(k.audioContextState==="suspended"||k.audioContextState==="interrupted"?m("suspended"):k.audioContextState==="closed"&&(m("error"),b("The browser audio context is closed. Toggle Remote Audio off and on to recover.")))},me=async()=>{if(E||String(C.state)==="closed")return!1;try{if(String(C.state)!=="running"&&await C.resume(),k.audioContextState=String(C.state),!E&&!U&&k.audioContextState==="running"){const z=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=Zu,Q=k.lastCaptureStatusAt>0&&performance.now()-k.lastCaptureStatusAt<=_m&&k.captureAlive&&k.helperAlive;m(z?"playing":Q?"silent":"open")}return k.audioContextState==="running"}catch(z){return E||(m("suspended"),b(z instanceof Error?"Audio playback is suspended: "+z.message:"Audio playback is suspended.")),!1}},Y=async()=>{if(E||U||A.readyState!==WebSocket.OPEN)return;if(F>=Ju.length){m("error"),b("Remote audio stopped sending frames. Toggle Audio off and on to retry.");return}const z=F;F+=1,U=!0,k.stalledCount+=1,k.automaticRestarts+=1,m("reconnecting");try{const Q=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/stop",{method:"POST",body:JSON.stringify({})},l);if(Q.ok===!1)throw new Error(Q.error||"Remote audio stop failed.");if(E)return;const X=await Be("/api/remote/devices/"+encodeURIComponent(n)+"/audio/start",{method:"POST",body:JSON.stringify({streamId:"audio-restart-"+Date.now(),mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},l);if(X.ok===!1)throw new Error(X.error||"Remote audio start failed.");const P=performance.now();R=P,k.lastPacketAt=P,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,V=P+(Ju[z+1]??3e3),b(""),E||m("open")}catch(Q){E||(V=performance.now()+(Ju[z+1]??3e3),m("error"),b(Q instanceof Error?"Remote audio restart failed: "+Q.message:"Remote audio restart failed."))}finally{U=!1}},ue=()=>{k.drops+=1},K=window.setInterval(()=>{if(E)return;const z=performance.now(),Q=k.lastPacketAt>0?Math.max(0,z-k.lastPacketAt):R>0?Math.max(0,z-R):0,X=k.lastAcceptedAt>0?Math.max(0,z-k.lastAcceptedAt):0,P=k.lastCaptureStatusAt>0?Math.max(0,z-k.lastCaptureStatusAt):0,le=A.readyState===WebSocket.OPEN,we=k.lastCaptureStatusAt>0,L=we&&P<=_m,$=we&&(!k.captureAlive||!k.helperAlive)&&P>n1,xe=we&&P>_m,Se=!we&&R>0&&z-R>a1,fe=R>0&&(k.lastAcceptedAt<=0?z-R>Zu:X>Zu);le&&R>0&&($||xe||Se)?F>=Ju.length&&!U?(m("error"),b("Remote audio capture heartbeat stopped. Toggle Audio off and on to retry.")):!U&&z>=V?Y():U||m("stalled"):le&&fe&&!U&&k.audioContextState!=="suspended"&&k.audioContextState!=="interrupted"&&m(L?"silent":"open"),w({queuedMs:Math.max(0,(c.current-C.currentTime)*1e3),browserAgeMs:k.browserAgeMs,captureAgeMs:k.captureAgeMs,captureStatusAgeMs:P,silentForMs:k.silentForMs,captureAlive:k.captureAlive,helperAlive:k.helperAlive,captureRestartCount:k.captureRestartCount,localProcessingAgeMs:k.localProcessingAgeMs,lastPacketAgeMs:Q,lastAcceptedAgeMs:X,framesReceived:k.framesReceived,drops:k.drops,resyncs:k.resyncs,pendingDecodes:k.pendingDecodes,lastFrameSeq:k.lastFrameSeq,audioContextState:k.audioContextState,stalledCount:k.stalledCount,automaticRestarts:k.automaticRestarts,lastUpdatedAt:Date.now()})},250),ie=()=>{I(),(String(C.state)==="suspended"||String(C.state)==="interrupted")&&me()},ee=()=>{document.visibilityState==="visible"&&me()},W=()=>{me()};return C.addEventListener("statechange",ie),document.addEventListener("visibilitychange",ee),window.addEventListener("pageshow",W),window.addEventListener("pointerdown",W),window.addEventListener("keydown",W),m("connecting"),b(""),I(),A.addEventListener("open",()=>{E||(R=performance.now(),k.lastPacketAt=R,k.lastAcceptedAt=0,k.lastCaptureStatusAt=0,k.lastPcmAtEpochMs=0,k.captureAlive=!1,k.helperAlive=!1,k.silentForMs=0,m("open"),A.send(JSON.stringify({type:"subscribe",deviceIds:[n]})),me())}),A.addEventListener("message",z=>{if(typeof z.data=="string")return;const Q=z.data instanceof ArrayBuffer?z.data:null;if(!Q||Q.byteLength<5)return;const X=performance.now();k.lastPacketAt=X,(async()=>{try{const le=new DataView(Q).getUint32(0,!1);if(le<=0||le+4>Q.byteLength){ue();return}const we=new Uint8Array(Q.slice(4,4+le)),L=JSON.parse(new TextDecoder().decode(we)),$=Q.slice(4+le),xe=String(L.frameKind||L.kind||"").toLowerCase();if(L.type==="remote.audio.status"||xe==="audio-status"){if(k.lastCaptureStatusAt=X,k.captureAlive=L.captureAlive===!0,k.helperAlive=L.helperAlive===!0,k.captureRestartCount=Math.max(0,Number(L.restartCount||0)||0),k.lastPcmAtEpochMs=Math.max(0,Number(L.lastPcmAtEpochMs||0)||0),k.silentForMs=Math.max(0,Number(L.silentForMs||0)||0),k.captureAgeMs=k.lastPcmAtEpochMs>0?Math.max(0,Date.now()-k.lastPcmAtEpochMs):k.silentForMs,k.captureAlive&&k.helperAlive){if(F=0,V=0,!U){b("");const fe=String(C.state)==="running",Te=k.lastAcceptedAt>0&&performance.now()-k.lastAcceptedAt<=Zu;m(fe?Te?"playing":"silent":"suspended")}}else U||m("stalled");return}const Se={deviceId:String(L.deviceId||""),frameSeq:Number(L.frameSeq||0),streamId:String(L.streamId||""),mimeType:String(L.mimeType||"audio/webm;codecs=opus"),sampleRate:Number(L.sampleRate||48e3),channels:Number(L.channels||2),capturedAt:String(L.capturedAt||""),receivedAt:String(L.receivedAt||""),byteLength:Number(L.byteLength||$.byteLength),payload:$};if(!Se.deviceId||E)return;if(performance.now()-X>ix){ue();return}if(k.pendingDecodes>=t1){ue();return}k.pendingDecodes+=1;try{const fe=X0(Se.mimeType)?s1(C,Se,$):await C.decodeAudioData($.slice(0));if(k.localProcessingAgeMs=Math.max(0,performance.now()-X),E)return;if(k.localProcessingAgeMs>ix){ue();return}if(Se.frameSeq>0&&Se.frameSeq<=k.lastFrameSeq){ue();return}if(k.activeStreamId&&Se.streamId!==k.activeStreamId&&Se.frameSeq<=k.lastFrameSeq){ue();return}Se.streamId&&Se.streamId!==k.activeStreamId&&(k.activeStreamId=Se.streamId,k.lastFrameSeq=0,_());const Te=C.currentTime;Math.max(0,c.current-Te)>J0&&(_(),k.resyncs+=1);const oe=C.createBufferSource();oe.buffer=fe,oe.connect(C.destination),T.add(oe),oe.onended=()=>{T.delete(oe),oe.onended=null};const Ye=Math.max(C.currentTime+e1,c.current);oe.start(Ye),c.current=Ye+fe.duration,k.browserAgeMs=lx(Se.receivedAt),k.captureAgeMs=lx(Se.capturedAt),k.lastAcceptedAt=performance.now(),k.framesReceived+=1,k.lastFrameSeq=Se.frameSeq,F=0,V=0,v(Se),me();const De=String(C.state)==="running";De&&b(""),m(De?"playing":"suspended")}finally{k.pendingDecodes=Math.max(0,k.pendingDecodes-1)}}catch(P){E||(m("error"),b(P instanceof Error?P.message:String(P)))}})()}),A.addEventListener("error",()=>{E||(m("error"),b("Remote audio WebSocket error."))}),A.addEventListener("close",()=>{E||m("closed")}),()=>{E=!0,window.clearInterval(K),C.removeEventListener("statechange",ie),document.removeEventListener("visibilitychange",ee),window.removeEventListener("pageshow",W),window.removeEventListener("pointerdown",W),window.removeEventListener("keydown",W),_(!1),A.close(),C.close().catch(()=>{}),r.current===C&&(r.current=null)}},[n,a,l]),{state:u,lastFrame:p,stats:g,error:y}}const mh={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}}},l1=[{id:"connection",label:"Connection",icon:bc},{id:"security",label:"Security",icon:en},{id:"control",label:"Control",icon:Jt},{id:"wall",label:"Wall",icon:Ec},{id:"files-audio",label:"Files & Audio",icon:ao},{id:"agent",label:"Agent",icon:or},{id:"advanced",label:"Advanced",icon:Sd}];function er(n,a){return n?.settings?.[a]||mh.settings[a]}function tt({icon:n,title:a,description:l,children:r,disabled:c=!1,recommended:u=!1}){return i.jsxs("div",{className:`product-setting-row ${c?"disabled":""}`,children:[i.jsx("div",{className:"product-setting-control",children:r}),n&&i.jsx("span",{className:"product-setting-icon",children:i.jsx(n,{size:17})}),i.jsxs("div",{className:"product-setting-copy",children:[i.jsx("strong",{children:a}),u&&i.jsx("em",{children:"Recommended"}),i.jsx("small",{children:l})]})]})}function ft({checked:n,onChange:a,disabled:l=!1,label:r}){return i.jsxs("label",{className:"product-switch",children:[i.jsx("input",{"aria-label":r,type:"checkbox",checked:n,disabled:l,onChange:c=>a(c.target.checked)}),i.jsx("span",{})]})}function Ci({value:n,onChange:a,options:l,disabled:r=!1,label:c}){return i.jsx("select",{"aria-label":c,value:String(n),disabled:r,onChange:u=>a(u.target.value),children:l.map(([u,m])=>i.jsx("option",{value:u,children:m},u))})}function r1({hubUrl:n="",runtimeRole:a="hub",runtimeDeviceId:l="",sessionAccessToken:r="",initialTab:c="connection",pin:u,wall:m,control:p,agent:v,advancedExtras:g,captureGallery:w}){const[y,b]=f.useState(c),[j,C]=f.useState(null),[A,T]=f.useState("loading"),[k,E]=f.useState(""),[R,U]=f.useState("idle"),[F,V]=f.useState("");f.useEffect(()=>{let fe=!0;return T("loading"),Be("/api/settings",void 0,n).then(Te=>{fe&&(C({revision:Number(Te.revision||0),updatedAt:Te.updatedAt,settings:Te.settings}),T("saved"))}).catch(Te=>{fe&&(E(Te instanceof Error?Te.message:String(Te)),C(mh),T("failed"))}),()=>{fe=!1}},[n]);const _=async(fe,Te,Ie)=>{const oe=j||mh,Ye=oe,De={...oe,settings:{...oe.settings,[fe]:{...er(oe,fe),[Te]:Ie}}};C(De),T("saving"),E("");try{const We=await Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:oe.revision,[fe]:{[Te]:Ie}})},n);C({revision:We.revision,updatedAt:We.updatedAt,settings:We.settings}),T("saved")}catch(We){C(Ye),T("failed"),E(We instanceof Error?We.message:String(We))}},I=(fe,Te)=>Ie=>{_(fe,Te,Ie)},me=async()=>{if(a!=="hub"||!l||!r){U("failed"),V("Sign in to this Hub before changing its runtime role.");return}U("changing"),V("");try{await Be("/api/runtime/role",{method:"POST",headers:{Authorization:`Bearer ${r}`},body:JSON.stringify({role:"client"})},n),U("accepted"),ky(5198)}catch(fe){U("failed"),V(fe instanceof Error?fe.message:String(fe))}},Y=er(j,"security"),ue=er(j,"connection"),K=er(j,"control"),ie=er(j,"wall"),ee=er(j,"filesAudio"),W=er(j,"agent"),z=f.useMemo(()=>Y.allowInternetConnections===!1?{label:"Local only",tone:"local",detail:"Internet connections are disabled."}:Y.requireEncryptedConnections&&Y.requireNewDeviceApproval&&Y.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."},[Y]),Q=`settings-panel-${y}`,X=i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[i.jsxs("section",{className:"product-settings-hero",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"settings-eyebrow",children:[i.jsx(bc,{size:14})," Connection"]}),i.jsx("h2",{children:"Connect a device"}),i.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."})]}),i.jsxs("div",{className:"product-save-state",role:"status",children:[i.jsx(gy,{size:14})," ",A==="saving"?"Saving":A==="failed"?"Failed":A==="loading"?"Loading":"Saved"]})]}),u,i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Connection behavior"}),i.jsx("h3",{children:"New device access"})]}),i.jsx(Sc,{size:20})]}),i.jsx(tt,{icon:Sc,title:"Use PIN to add new devices",description:"Allow temporary PIN pairing from the client.",recommended:!0,children:i.jsx(ft,{checked:!!ue.usePinToAddDevices,onChange:I("connection","usePinToAddDevices"),label:"Use PIN to add new devices"})}),i.jsx(tt,{icon:en,title:"Approve new devices on this Hub",description:"Ask for approval before an unfamiliar computer becomes trusted.",children:i.jsx(ft,{checked:!!ue.approveNewDevices,onChange:I("connection","approveNewDevices"),label:"Approve new devices"})}),i.jsx(tt,{icon:Zt,title:"Show connection notifications",description:"Show a short notice when a computer connects or leaves.",children:i.jsx(ft,{checked:!!ue.showConnectionNotifications,onChange:I("connection","showConnectionNotifications"),label:"Show connection notifications"})})]}),i.jsxs("section",{className:"settings-section-card runtime-role-settings",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Runtime role"}),i.jsx("h3",{children:"Use this computer as a Client"})]}),i.jsx(Sd,{size:20})]}),i.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"?i.jsx("p",{className:"settings-help runtime-role-success",children:"Role change accepted. LiveDesk is restarting as Client."}):F?i.jsx("p",{className:"settings-help runtime-role-error",role:"alert",children:F}):null,i.jsx("button",{className:"settings-reset",onClick:()=>{me()},disabled:R==="changing"||a!=="hub",type:"button",children:R==="changing"?"Switching role…":"Switch this computer to Client"})]})]}),P=i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[i.jsxs("section",{className:`security-status-card ${z.tone}`,children:[i.jsxs("div",{children:[i.jsx("span",{children:"Security status"}),i.jsx("strong",{children:z.label}),i.jsx("small",{children:z.detail})]}),i.jsx(en,{size:28})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Access mode"}),i.jsx("h3",{children:"Who may use this Hub?"})]}),i.jsx(Ai,{size:20})]}),i.jsx(tt,{icon:en,title:"Access mode",description:"Choose the default boundary for remote sessions.",recommended:!0,children:i.jsx(Ci,{value:String(Y.accessMode),onChange:I("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"]]})}),i.jsx(tt,{icon:bc,title:"Require encrypted connections",description:"External connections cannot disable this protection.",recommended:!0,children:i.jsx(ft,{checked:!!Y.requireEncryptedConnections,onChange:I("security","requireEncryptedConnections"),label:"Require encrypted connections"})}),i.jsx(tt,{icon:bc,title:"Allow internet connections",description:"Keep off unless you intentionally expose this Hub beyond the LAN.",children:i.jsx(ft,{checked:!!Y.allowInternetConnections,onChange:I("security","allowInternetConnections"),label:"Allow internet connections"})}),i.jsx(tt,{icon:Jt,title:"Allow LAN connections",description:"Permit connections from the local network.",children:i.jsx(ft,{checked:!!Y.allowLanConnections,onChange:I("security","allowLanConnections"),label:"Allow LAN connections"})}),i.jsx(tt,{icon:en,title:"Require approval for new devices",description:"New computers must be approved before remote access is granted.",children:i.jsx(ft,{checked:!!Y.requireNewDeviceApproval,onChange:I("security","requireNewDeviceApproval"),label:"Require approval for new devices"})})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Session protection"}),i.jsx("h3",{children:"End sessions safely"})]}),i.jsx(Zt,{size:20})]}),i.jsx(tt,{icon:Jt,title:"Show an indicator while Control is active",description:"Make active remote control visible on the local computer.",children:i.jsx(ft,{checked:!!Y.visibleControlIndicator,onChange:I("security","visibleControlIndicator"),label:"Show Control indicator"})}),i.jsx(tt,{icon:Ai,title:"Lock the remote computer when Control ends",description:"Protect the local screen after a Control session.",children:i.jsx(ft,{checked:!!Y.lockOnControlEnd,onChange:I("security","lockOnControlEnd"),label:"Lock after Control ends"})}),i.jsx(tt,{icon:Zt,title:"Disconnect idle Control sessions",description:"Automatically close inactive Control sessions.",children:i.jsx(ft,{checked:!!Y.disconnectIdleControlSessions,onChange:I("security","disconnectIdleControlSessions"),label:"Disconnect idle sessions"})}),i.jsx(tt,{icon:Zt,title:"Idle timeout",description:"Time before an inactive Control session closes.",disabled:!Y.disconnectIdleControlSessions,children:i.jsx(Ci,{value:Number(Y.idleControlMinutes),onChange:fe=>I("security","idleControlMinutes")(Number(fe)),disabled:!Y.disconnectIdleControlSessions,label:"Idle timeout",options:[["5","5 minutes"],["15","15 minutes"],["30","30 minutes"],["60","1 hour"],["1440","Never"]]})})]})]}),le=i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Remote use"}),i.jsx("h3",{children:"What can a connected user do?"})]}),i.jsx(Jt,{size:20})]}),i.jsx(tt,{icon:Jt,title:"Keyboard and mouse control",description:"Allow the Hub to send keyboard and pointer input.",recommended:!0,children:i.jsx(ft,{checked:!!K.allowKeyboardMouse,onChange:I("control","allowKeyboardMouse"),label:"Keyboard and mouse control"})}),i.jsx(tt,{icon:tS,title:"System shortcuts",description:"Allow shortcut keys such as Alt-Tab and the system key.",children:i.jsx(ft,{checked:!!K.allowSystemShortcuts,onChange:I("control","allowSystemShortcuts"),label:"System shortcuts"})}),i.jsx(tt,{icon:Sc,title:"Clipboard text sharing",description:"Share plain text through the remote session.",children:i.jsx(ft,{checked:!!K.allowClipboardText,onChange:I("control","allowClipboardText"),label:"Clipboard text sharing"})}),i.jsx(tt,{icon:Zt,title:"Remote restart",description:"Allow restart requests from Control.",disabled:!K.allowKeyboardMouse,children:i.jsx(ft,{checked:!!K.allowRemoteRestart,onChange:I("control","allowRemoteRestart"),disabled:!K.allowKeyboardMouse,label:"Remote restart"})}),i.jsx(tt,{icon:Jt,title:"Switching monitors",description:"Allow the viewer to select another connected display.",children:i.jsx(ft,{checked:!!K.allowSwitchingMonitors,onChange:I("control","allowSwitchingMonitors"),label:"Switching monitors"})})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Session behavior"}),i.jsx("h3",{children:"Make Control predictable"})]}),i.jsx(On,{size:20})]}),i.jsx(tt,{icon:Jt,title:"Open Control on double-click",description:"Double-clicking a Wall tile opens its Control view.",children:i.jsx(ft,{checked:!!K.openControlOnDoubleClick,onChange:I("control","openControlOnDoubleClick"),label:"Open Control on double-click"})}),i.jsx(tt,{icon:Zt,title:"Start audio with Control",description:"Keep audio muted by default for new sessions.",children:i.jsx(ft,{checked:!!K.startRemoteAudioWithControl,onChange:I("control","startRemoteAudioWithControl"),label:"Start audio with Control"})}),i.jsx(tt,{icon:Jt,title:"Fit remote screen to window",description:"Scale the remote display to the available Control area.",children:i.jsx(ft,{checked:!!K.fitRemoteScreen,onChange:I("control","fitRemoteScreen"),label:"Fit remote screen"})}),i.jsx(tt,{icon:Zt,title:"Keep Control ready between pages",description:"Faster reconnection for 1 minute.",recommended:!0,children:i.jsx(ft,{checked:!!K.keepControlReadyBetweenPages,onChange:I("control","keepControlReadyBetweenPages"),label:"Keep Control ready between pages"})})]})]}),we=i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Performance mode"}),i.jsx("h3",{children:"Let LiveDesk choose the best path"})]}),i.jsx(Ec,{size:20})]}),i.jsx(tt,{icon:or,title:"Performance mode",description:"Automatic mode balances responsiveness and image quality.",recommended:!0,children:i.jsx(Ci,{value:String(ie.performanceMode),onChange:I("wall","performanceMode"),label:"Performance mode",options:[["auto","Auto"],["responsive","Prioritize responsiveness"],["quality","Prioritize image quality"],["custom","Custom"]]})}),i.jsx("p",{className:"settings-help",children:"Streaming details are available under Advanced for diagnostics and development."})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Wall behavior"}),i.jsx("h3",{children:"What should the Wall show?"})]}),i.jsx(Zt,{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(([fe,Te,Ie])=>i.jsx(tt,{icon:Jt,title:Te,description:Ie,children:i.jsx(ft,{checked:!!ie[fe],onChange:I("wall",fe),label:Te})},fe))]})]}),L=i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"File permissions"}),i.jsx("h3",{children:"Move files deliberately"})]}),i.jsx(ao,{size:20})]}),i.jsx(tt,{icon:ao,title:"Allow file transfer",description:"Permit Hub-to-device file delivery.",recommended:!0,children:i.jsx(ft,{checked:!!ee.allowFileTransfer,onChange:I("filesAudio","allowFileTransfer"),label:"Allow file transfer"})}),i.jsx(tt,{icon:Ec,title:"Allow folder sync",description:"Enable recurring folder synchronization.",disabled:!ee.allowFileTransfer,children:i.jsx(ft,{checked:!!ee.allowFolderSync,onChange:I("filesAudio","allowFolderSync"),disabled:!ee.allowFileTransfer,label:"Allow folder sync"})}),i.jsx(tt,{icon:en,title:"Ask before receiving files",description:"Require local confirmation before a transfer is written.",children:i.jsx(ft,{checked:!!ee.askBeforeReceivingFiles,onChange:I("filesAudio","askBeforeReceivingFiles"),label:"Ask before receiving files"})}),i.jsx(tt,{icon:ao,title:"Allow overwrite",description:"Permit replacing an existing destination file.",children:i.jsx(ft,{checked:!!ee.allowOverwrite,onChange:I("filesAudio","allowOverwrite"),label:"Allow overwrite"})})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Audio permissions"}),i.jsx("h3",{children:"Remote sound"})]}),i.jsx(Zt,{size:20})]}),i.jsx(tt,{icon:Zt,title:"Allow remote audio",description:"Permit audio capture from connected computers.",recommended:!0,children:i.jsx(ft,{checked:!!ee.allowRemoteAudio,onChange:I("filesAudio","allowRemoteAudio"),label:"Allow remote audio"})}),i.jsx(tt,{icon:Zt,title:"Start audio muted",description:"New audio sessions begin silent.",children:i.jsx(ft,{checked:!!ee.startAudioMuted,onChange:I("filesAudio","startAudioMuted"),label:"Start audio muted"})}),i.jsx(tt,{icon:Zt,title:"Automatically recover audio",description:"Recover from temporary capture or transport stalls.",children:i.jsx(ft,{checked:!!ee.automaticallyRecoverAudio,onChange:I("filesAudio","automaticallyRecoverAudio"),label:"Automatically recover audio"})})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Capture defaults"}),i.jsx("h3",{children:"Screen recording"})]}),i.jsx(Jt,{size:20})]}),i.jsx(tt,{icon:Zt,title:"Keep a Last 30s buffer",description:"Keep recent video in memory only until you explicitly save it.",children:i.jsx(ft,{checked:!!ee.rollingBufferEnabled,onChange:I("filesAudio","rollingBufferEnabled"),label:"Keep a Last 30s buffer"})}),i.jsx(tt,{icon:Zt,title:"Recording quality",description:"Choose the WebM bitrate profile.",children:i.jsx(Ci,{value:String(ee.recordingQuality),onChange:I("filesAudio","recordingQuality"),label:"Recording quality",options:[["standard","Standard"],["high","High"]]})}),i.jsx(tt,{icon:Zt,title:"Timelapse interval",description:"Capture one frame at the selected interval.",children:i.jsx(Ci,{value:Number(ee.timelapseIntervalSeconds),onChange:fe=>I("filesAudio","timelapseIntervalSeconds")(Number(fe)),label:"Timelapse interval",options:[["5","5 seconds"],["10","10 seconds"],["30","30 seconds"],["60","60 seconds"]]})}),i.jsx(tt,{icon:Jt,title:"Include remote cursor",description:"Include the cursor indicator when the source provides it.",children:i.jsx(ft,{checked:!!ee.includeRemoteCursor,onChange:I("filesAudio","includeRemoteCursor"),label:"Include remote cursor"})}),i.jsx(tt,{icon:ao,title:"Capture save location",description:"Captures are stored inside the Hub capture library.",children:i.jsx(Ci,{value:String(ee.captureSaveLocation),onChange:I("filesAudio","captureSaveLocation"),label:"Capture save location",options:[[String(ee.captureSaveLocation||"LiveDesk Captures"),"LiveDesk Captures"]]})}),i.jsx(tt,{icon:ao,title:"Automatic deletion",description:"Keep saved captures until you delete them.",children:i.jsx(Ci,{value:String(ee.captureAutoDelete),onChange:I("filesAudio","captureAutoDelete"),label:"Automatic deletion",options:[["never","Never"],["7-days","After 7 days"],["30-days","After 30 days"]]})})]}),w]}),$=i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Agent safety"}),i.jsx("h3",{children:"AI workstation operations"})]}),i.jsx(or,{size:20})]}),i.jsx(tt,{icon:or,title:"Enable AI Agent on devices",description:"Allow Agent runs to reach connected workstations.",recommended:!0,children:i.jsx(ft,{checked:!!W.enabled,onChange:I("agent","enabled"),label:"Enable AI Agent"})}),i.jsx(tt,{icon:en,title:"Default permission mode",description:"Safe Auto keeps destructive operations behind approval.",children:i.jsx(Ci,{value:String(W.defaultPermissionMode),onChange:I("agent","defaultPermissionMode"),label:"Default Agent permission mode",options:[["ask","Ask"],["safe-auto","Safe Auto"],["full-access","Full Access"],["custom","Custom"]]})}),i.jsx(tt,{icon:en,title:"Ask before destructive operations",description:"Locked on for Safe Auto and destructive actions.",disabled:!W.enabled,children:i.jsx(ft,{checked:!!W.askBeforeDestructive,onChange:I("agent","askBeforeDestructive"),disabled:!W.enabled,label:"Ask before destructive operations"})}),i.jsx(tt,{icon:Zt,title:"Keep Agent audit history",description:"Retain an inspectable record of Agent runs.",children:i.jsx(ft,{checked:!!W.keepAuditHistory,onChange:I("agent","keepAuditHistory"),label:"Keep Agent audit history"})}),i.jsx(tt,{icon:Zt,title:"Stop Agent tasks after timeout",description:"Maximum runtime for one task.",children:i.jsx(Ci,{value:Number(W.timeoutMinutes),onChange:fe=>I("agent","timeoutMinutes")(Number(fe)),label:"Agent task timeout",options:[["1","1 minute"],["5","5 minutes"],["10","10 minutes"],["30","30 minutes"],["60","1 hour"]]})})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Detailed permissions"}),i.jsx("h3",{children:"Capabilities"})]}),i.jsx(en,{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(([fe,Te])=>i.jsx(tt,{icon:en,title:Te,description:fe.includes("allowCommand")||fe.includes("Installation")||fe.includes("Power")?"Disabled by default for safety.":"Applied by the Hub and checked again by the Client.",children:i.jsx(ft,{checked:!!W[fe],onChange:I("agent",fe),label:Te})},fe))]}),i.jsx("p",{className:"settings-help",children:"The existing Codex runtime and audit controls remain available below in Advanced and the Agent diagnostics panel."})]}),Se=y==="connection"?X:y==="security"?P:y==="control"?le:y==="wall"?we:y==="files-audio"?L:y==="agent"?i.jsxs(i.Fragment,{children:[$,v]}):i.jsxs("div",{className:"settings-tab-content product-settings-content",children:[g,i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Developer controls"}),i.jsx("h3",{children:"Streaming and diagnostics"})]}),i.jsx(Sd,{size:20})]}),i.jsx("p",{className:"settings-help",children:"Codec, frame rate, resolution, quality, Atlas layout, and decoder preferences are intentionally kept here."}),m,p]})]});return i.jsxs("section",{className:"settings-page",children:[i.jsx("div",{className:"settings-page-tabs",role:"tablist","aria-label":"LiveDesk settings",children:l1.map(({id:fe,label:Te,icon:Ie})=>i.jsxs("button",{className:y===fe?"active":"",id:`settings-tab-${fe}`,role:"tab","aria-selected":y===fe,"aria-controls":`settings-panel-${fe}`,tabIndex:y===fe?0:-1,onClick:()=>b(fe),type:"button",children:[i.jsx(Ie,{size:16}),Te]},fe))}),k&&i.jsx("div",{className:"agent-settings-alert error",role:"alert",children:k}),i.jsx("section",{className:"settings-page-panel",id:Q,role:"tabpanel","aria-labelledby":`settings-tab-${y}`,tabIndex:0,children:Se})]})}function o1({children:n}){return i.jsx("div",{className:"settings-tab-content",children:n})}function c1({children:n}){return i.jsx("div",{className:"settings-tab-content",children:n})}function u1({children:n}){return i.jsx("div",{className:"settings-tab-content",children:n})}const Oy={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 rx(n){return{...Oy,...n||{}}}function d1({hubUrl:n}){const[a,l]=f.useState(Oy),[r,c]=f.useState(null),[u,m]=f.useState(""),[p,v]=f.useState(""),[g,w]=f.useState(""),[y,b]=f.useState("");f.useEffect(()=>{let I=!0;return Be("/api/settings/agent",void 0,n).then(me=>{I&&(c(me.settings),l(rx(me.settings)))}).catch(me=>{I&&b(me instanceof Error?me.message:String(me))}),()=>{I=!1}},[n]);const j=(I,me)=>l(Y=>({...Y,[I]:me})),C=I=>{c(I),l(rx(I))},A=async()=>{v("save"),b(""),w("");try{const I={...a};u.trim()&&(I.apiKey=u.trim());const me=await Be("/api/settings/agent",{method:"PUT",body:JSON.stringify(I)},n);C(me.settings),m(""),w("Agent settings saved.")}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},T=async()=>{v("reset"),b("");try{const I=await Be("/api/settings/agent/reset",{method:"POST",body:JSON.stringify({})},n);C(I.settings),w("Codex defaults restored.")}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},k=async()=>{v("test"),b(""),w("");try{const I=await Be("/api/settings/agent/test",{method:"POST",body:JSON.stringify({})},n),me=await Be("/api/settings/agent",void 0,n);C(me.settings),w(`Codex connection verified with ${I.connection?.modelName||"the configured model"}${I.connection?.latencyMs?` in ${I.connection.latencyMs} ms.`:"."}`)}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},E=async()=>{v("clear-key"),b("");try{const I=await Be("/api/settings/agent/api-key",{method:"DELETE"},n);C(I.settings),m(""),w("The optional OpenCode Go key was removed.")}catch(I){b(I instanceof Error?I.message:String(I))}finally{v("")}},R=r?.codexInstallation==="installed"&&r.codexAuth==="signed-in",U=r?.securityStatus,F=U?.state||"unavailable",V=F==="verified"?"Verified":F==="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 i.jsxs("div",{className:"settings-tab-content agent-settings-content",children:[i.jsxs("header",{className:"agent-settings-header",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"settings-eyebrow",children:[i.jsx(_v,{size:14})," Agent AI"]}),i.jsx("h2",{children:"Codex SDK"}),i.jsx("p",{children:"Codex owns the agent reasoning loop. LiveDesk keeps the existing task manager and exposes only safe, read-only workstation tools."})]}),i.jsxs("label",{className:"settings-toggle agent-enable-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.enabled,onChange:I=>j("enabled",I.target.checked)}),i.jsx("span",{children:"Enable Agent AI"})]})]}),y&&i.jsx("div",{className:"agent-settings-alert error",role:"alert",children:y}),g&&i.jsx("div",{className:"agent-settings-alert success",role:"status",children:g}),i.jsxs("div",{className:"settings-section-grid",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Provider"}),i.jsx("h3",{children:"Codex is the default"})]}),i.jsx(Sc,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Agent provider"}),i.jsxs("select",{value:a.provider,onChange:I=>j("provider",I.target.value),children:[i.jsx("option",{value:"codex",children:"Codex SDK"}),i.jsx("option",{value:"opencode-go",children:"OpenCode Go (optional legacy)"})]})]}),i.jsxs("div",{className:"agent-connection-row",children:[i.jsx("span",{className:`agent-connection-dot ${R?"connected":r?.codexAuth==="not-signed-in"?"unavailable":""}`}),i.jsx("span",{children:r?.codexInstallation==="not-installed"?"Codex SDK not installed":r?.codexAuth==="signed-in"?"Codex CLI signed in":r?.codexAuth==="not-signed-in"?"Codex CLI sign-in required":"Codex status not tested"}),i.jsxs("button",{className:"settings-reset",onClick:()=>{k()},disabled:p!==""||a.provider!=="codex",type:"button",children:[i.jsx(nS,{size:15})," ",p==="test"?"Testing":"Test connection"]})]}),i.jsxs("p",{className:"settings-help",children:[i.jsx(aS,{size:12})," Authentication is owned by the installed Codex CLI. LiveDesk never asks for or stores a ChatGPT token."]}),r?.codexPath&&i.jsxs("p",{className:"settings-help",children:["CLI: ",r.codexPath]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Codex runtime"}),i.jsx("h3",{children:"Model and reasoning"})]}),i.jsx(_v,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Model"}),i.jsx("input",{value:a.codexModelId,onChange:I=>j("codexModelId",I.target.value),placeholder:"Codex default",disabled:a.provider!=="codex"})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Reasoning effort"}),i.jsxs("select",{value:a.codexReasoningEffort,onChange:I=>j("codexReasoningEffort",I.target.value),disabled:a.provider!=="codex",children:[i.jsx("option",{value:"minimal",children:"Minimal"}),i.jsx("option",{value:"low",children:"Low"}),i.jsx("option",{value:"medium",children:"Medium"}),i.jsx("option",{value:"high",children:"High"}),i.jsx("option",{value:"xhigh",children:"Extra high"})]})]}),i.jsxs("div",{className:"settings-field-grid",children:[i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Task timeout (ms)"}),i.jsx("input",{type:"number",min:"30000",max:"1800000",step:"10000",value:a.codexTaskTimeoutMs,onChange:I=>j("codexTaskTimeoutMs",Number(I.target.value)),disabled:a.provider!=="codex"})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Max tool calls"}),i.jsx("input",{type:"number",min:"1",max:"100",value:a.codexMaxToolCalls,onChange:I=>j("codexMaxToolCalls",Number(I.target.value)),disabled:a.provider!=="codex"})]})]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Workspace"}),i.jsx("h3",{children:"Restricted execution context"})]}),i.jsx(en,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Working directory"}),i.jsx("input",{value:r?.agentWorkspacePath||a.codexWorkingDirectory,readOnly:!0})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.codexResumeSessions,onChange:I=>j("codexResumeSessions",I.target.checked),disabled:a.provider!=="codex"}),i.jsx("span",{children:"Allow session resume"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.codexShowDetailedEvents,onChange:I=>j("codexShowDetailedEvents",I.target.checked),disabled:a.provider!=="codex"}),i.jsx("span",{children:"Show detailed Codex events"})]}),i.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"&&i.jsxs("section",{className:"settings-section-card agent-legacy-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Developer fallback"}),i.jsx("h3",{children:"OpenCode Go"})]}),i.jsx(Sc,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Base URL"}),i.jsx("input",{value:a.baseUrl,onChange:I=>j("baseUrl",I.target.value)})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"API key"}),i.jsx("input",{type:"password",value:u,onChange:I=>m(I.target.value),placeholder:r?.hasApiKey?r.apiKeyPreview:"Stored only in the Hub",autoComplete:"new-password"})]}),i.jsxs("div",{className:"settings-action-row",children:[i.jsxs("button",{className:"settings-reset",onClick:()=>{E()},disabled:p!==""||!r?.hasApiKey,type:"button",children:[i.jsx(Nh,{size:15})," Clear key"]}),i.jsx("span",{className:"settings-help",children:"This provider does not run the Codex MCP tool loop."})]})]}),i.jsxs("div",{className:"settings-section-grid",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Agent behavior"}),i.jsx("h3",{children:"Predictable operation"})]}),i.jsx(On,{size:20})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.deterministicParserFirst,onChange:I=>j("deterministicParserFirst",I.target.checked)}),i.jsx("span",{children:"Use deterministic parser before Codex"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.generateSummary,onChange:I=>j("generateSummary",I.target.checked)}),i.jsx("span",{children:"Generate task summaries"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.fallbackSummary,onChange:I=>j("fallbackSummary",I.target.checked)}),i.jsx("span",{children:"Fallback to deterministic summaries"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:a.includeRawDeviceDetails,onChange:I=>j("includeRawDeviceDetails",I.target.checked)}),i.jsx("span",{children:"Include raw device details in summaries"})]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Safety"}),i.jsx("h3",{children:"Locked execution boundary"})]}),i.jsx(en,{size:20})]}),["Arbitrary shell commands","PowerShell and Bash","Filesystem writes, deletes, and installs","Reboot, shutdown, and process termination","Network access and web search"].map(I=>i.jsxs("div",{className:"agent-safety-row",children:[i.jsx(Mh,{size:15}),i.jsx("span",{children:I}),i.jsx("strong",{children:"Blocked"})]},I)),_.map(([I])=>i.jsxs("div",{className:"agent-safety-row",children:[i.jsx(en,{size:15}),i.jsx("span",{children:I}),i.jsx("strong",{className:F==="unavailable"?"agent-safety-failed":F==="configured"?"agent-safety-configured":"agent-safety-verified",children:V})]},I)),i.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."})]})]}),i.jsxs("div",{className:"settings-action-row agent-settings-actions",children:[i.jsxs("button",{className:"settings-reset",onClick:()=>{T()},disabled:p!=="",type:"button",children:[i.jsx(jc,{size:15})," Reset defaults"]}),i.jsxs("button",{className:"text-button primary",onClick:()=>{A()},disabled:p!=="",type:"button",children:[i.jsx(gy,{size:15})," ",p==="save"?"Saving":"Save Agent settings"]})]})]})}new Date().valueOf();function $s(n){const[a,l]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,l(n)}},[n]),[a,l]}function _h(n,a){return typeof n=="function"?typeof a=="object"?n(a):n():n}function co(n,a="data-id"){let l=n;for(!l.tagName&&n.target&&(l=n.target);l;){if(l.getAttribute&&l.getAttribute(a))return l;l=l.parentNode}return null}function f1(n,a="data-id"){const l=co(n,a);return l?l.getAttribute(a):null}function Lc(n,a="data-id"){const l=co(n,a);return l?Id(l,a):null}function Id(n,a="data-id"){const l=n.getAttribute(a);return l?m1(l):null}function Sn(n){return typeof n=="string"?":"+n:n}function m1(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function h1(){return{detect:()=>!0,addEvent:function(n,a,l){return n.addEventListener(a,l),()=>n.removeEventListener(a,l)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var pa=h1();function zh(n){Object.assign(pa,n)}function ox(n,a,l){function r(c){const u=co(c);if(!u)return;const m=Id(u);if(typeof a=="function")return a(m,c);let p,v=c.target;for(;v!=u;){if(p=v.dataset?v.dataset.action:null,p&&a[p]){a[p](m,c);return}v=v.parentNode}a[l]&&a[l](m,c)}pa.addEvent(n,l,r)}function uo(n,a){ox(n,a,"click"),a.dblclick&&ox(n,a.dblclick,"dblclick")}function p1(n,a){for(let l=n.length-1;l>=0;l--)if(n[l]===a){n.splice(l,1);break}}function g1(n,a,l){for(let r=0;r<Mi.length;r++){if(r===l)continue;const c=Mi[r],u=c.props.parent?.();if(u&&n.contains(u)&&c.node.contains(a))return!0}return!1}var By=new Date,Td=!1,ed=[],Mi=[],cx=n=>{const a=n.target;if(Td||!a.isConnected){Td=!1;return}for(let l=Mi.length-1;l>=0;l--){const{node:r,date:c,props:u}=Mi[l];if(!(c>By)&&!r.contains(a)&&r!==a&&(g1(r,a,l)||(u.callback&&u.callback(n),u.modal||n.defaultPrevented)))break}},v1=n=>{By=new Date,Td=!0;for(let a=Mi.length-1;a>=0;a--){const{node:l}=Mi[a];if(!l.contains(n.target)&&l!==n.target){Td=!1;break}}};function Us(n,a){ed.length||(ed=[pa.addGlobalEvent("click",cx,n),pa.addGlobalEvent("contextmenu",cx,n),pa.addGlobalEvent("mousedown",v1,n)]),typeof a!="object"&&(a={callback:a});const l={node:n,date:new Date,props:a};return Mi.push(l),{destroy(){p1(Mi,l),Mi.length||(ed.forEach(r=>r()),ed=[])}}}var td=n=>n.indexOf("bottom")!==-1,nd=n=>n.indexOf("left")!==-1,ad=n=>n.indexOf("right")!==-1,zm=n=>n.indexOf("top")!==-1,ux=n=>n.indexOf("fit")!==-1,dc=n=>n.indexOf("overlap")!==-1,x1=n=>n.split("-").every(a=>["center","fit"].indexOf(a)>-1),y1=n=>{const a=n.match(/(start|center|end)/);return a?a[0]:null};function w1(n,a){let l=0;const r=pa.getTopNode(n);for(;n&&n!==r;){const c=getComputedStyle(n).position;if((c==="absolute"||c==="relative"||c==="fixed")&&(l=parseInt(getComputedStyle(n).zIndex)||0),n=n.parentNode,n===a)break}return l}var cn,$n,fc,In;function Fy(n,a,l="bottom",r=0,c=0){if(!n)return null;cn=r,$n=c,fc="auto";let u=0,m=0,p=l;const v=Hy(n),g=dc(l)?pa.getTopNode(n):v;if(!v)return null;const w=v.getBoundingClientRect(),y=n.getBoundingClientRect(),b=g.getBoundingClientRect(),j=window.getComputedStyle(g),C={left:0,top:0,bottom:0,right:0};for(const U in C){const F=`border-${U}-width`;C[U]=parseFloat(j.getPropertyValue(F))}if(a){const U=w1(a,v);u=Math.max(U+1,20)}if(a){if(In=a.getBoundingClientRect(),ux(l)&&(fc=In.width+"px"),l!=="point")if(x1(l))ux(l)?cn=0:(cn=b.width/2,m=1),$n=(b.height-y.height)/2;else{const U=dc(l)?0:1;cn=ad(l)?In.right+U:In.left-U,$n=td(l)?In.bottom+1:In.top;const F=y1(l);F&&(ad(l)||nd(l)?F==="center"?$n-=(y.height-In.height)/2:F==="end"&&($n-=y.height-In.height):(td(l)||zm(l))&&(F==="center"?cn-=(y.width-In.width)/2:F==="end"&&(cn-=y.width-In.width),dc(l)||(cn+=1)))}}else In={left:r,right:r,top:c,bottom:c};const A=(nd(l)||ad(l))&&(td(l)||zm(l));nd(l)&&(m=2);const T=cn-y.width-b.left;a&&nd(l)&&!A&&T<0&&(cn=In.right,m=0,p=p.replace("left","right"));const k=cn+y.width*(1-m/2)-b.right;if(k>0)if(!ad(l))cn=b.right-C.right-y.width;else{const U=In.left-b.x-y.width;a&&!A&&U>=0?(cn=In.left-y.width,p=p.replace("right","left")):cn-=k+C.right}m&&(cn=Math.round(cn-y.width*m/2));const E=T<0||k>0||!A;zm(l)&&($n=In.top-y.height,a&&$n<b.y&&E&&($n=In.bottom,p=p.replace("top","bottom")));const R=$n+y.height-b.bottom;return R>0&&(a&&td(l)&&E?($n-=y.height+In.height+1,p=p.replace("bottom","top")):$n-=R+C.bottom),cn-=w.left+C.left,$n-=w.top+C.top,cn=(dc(l)?cn:Math.max(cn,0))+g.scrollLeft,$n=(dc(l)?$n:Math.max($n,0))+g.scrollTop,fc=fc||"auto",{at:p,x:cn,y:$n,z:u,width:fc}}function Hy(n){const a=pa.getTopNode(n);for(n&&(n=n.parentElement);n;){const l=getComputedStyle(n).position;if(n===a||l==="relative"||l==="absolute"||l==="fixed")return n;n=n.parentNode}return null}function b1(n){const a=[];let l=n;const r=pa.getTopNode(n);for(;l&&l!==r&&!l.getAttribute("data-wx-portal-root");)getComputedStyle(l).position==="absolute"&&a.push(l),l=l.parentNode;return a}var dx=new Date().valueOf();function Ih(){return dx+=1,dx}function qn(n){return n<10?"0"+n:n.toString()}function S1(n){const a=qn(n);return a.length==2?"0"+a:a}function Py(n){const a=Math.floor(n/11)*11;return{start:a,end:a+11}}function Im(n){const a=(n.getDay()+6)%7,l=new Date(n.valueOf());l.setDate(n.getDate()+(3-a)),l.setHours(0,0,0,0);const r=new Date(l.getFullYear(),0,1),c=Math.round((l.getTime()-r.getTime())/864e5);return 1+Math.floor(c/7)}var fx=["",""];function j1(n,a,l){switch(n){case"%d":return qn(a.getDate());case"%m":return qn(a.getMonth()+1);case"%j":return a.getDate();case"%n":return a.getMonth()+1;case"%y":return qn(a.getFullYear()%100);case"%Y":return a.getFullYear();case"%D":return l.dayShort[a.getDay()];case"%l":return l.dayFull[a.getDay()];case"%M":return l.monthShort[a.getMonth()];case"%F":return l.monthFull[a.getMonth()];case"%h":return qn((a.getHours()+11)%12+1);case"%g":return(a.getHours()+11)%12+1;case"%G":return a.getHours();case"%H":return qn(a.getHours());case"%i":return qn(a.getMinutes());case"%a":return((a.getHours()>11?l.pm:l.am)||fx)[0];case"%A":return((a.getHours()>11?l.pm:l.am)||fx)[1];case"%s":return qn(a.getSeconds());case"%S":return S1(a.getMilliseconds());case"%W":return qn(Im(a));case"%w":{const r=l.weekStart??1;if(r===1)return qn(Im(a));const c=(a.getDay()-r+7)%7,u=(1-r+7)%7,m=new Date(a.valueOf());return m.setDate(a.getDate()+(u-c)),qn(Im(m))}case"%c":{let r=a.getFullYear()+"";return r+="-"+qn(a.getMonth()+1),r+="-"+qn(a.getDate()),r+="T",r+=qn(a.getHours()),r+=":"+qn(a.getMinutes()),r+=":"+qn(a.getSeconds()),r}case"%Q":return Math.floor(a.getMonth()/3)+1;default:return n}}var C1=/%[a-zA-Z]/g;function so(n,a){return typeof n=="function"?n:function(l){return l?(l.getMonth||(l=new Date(l)),n.replace(C1,r=>j1(r,l,a))):""}}function mx(n){return n&&typeof n=="object"&&!Array.isArray(n)}function hh(n,a){for(const l in a){const r=a[l];mx(n[l])&&mx(r)?n[l]=hh({...n[l]},a[l]):n[l]=a[l]}return n}function zc(n){return{getGroup(a){const l=n[a];return r=>l&&l[r]||r},getRaw(){return n},extend(a,l){if(!a)return this;let r;return l?r=hh({...a},n):r=hh({...n},a),zc(r)}}}var k1=Cy();const A1="en-US",M1={monthFull:["January","February","March","April","May","June","July","August","September","October","November","December"],monthShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayFull:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],hours:"Hours",minutes:"Minutes",done:"Done",clear:"Clear",today:"Today",am:["am","AM"],pm:["pm","PM"],weekStart:0,clockFormat:24},N1={ok:"OK",cancel:"Cancel",select:"Select","No data":"No data","Rows per page":"Rows per page","Total pages":"Total pages"},T1={timeFormat:"%H:%i",dateFormat:"%m/%d/%Y",monthYearFormat:"%F %Y",yearFormat:"%Y"},$y={core:N1,calendar:M1,formats:T1,lang:A1},Oh=f.createContext(""),Uy=f.createContext({}),xs=f.createContext(null),qy=f.createContext(null),Cn=Object.freeze(Object.defineProperty({__proto__:null,fieldId:qy,helpers:Uy,i18n:xs,theme:Oh},Symbol.toStringTag,{value:"Module"}));function Gy(n){const a=f.useContext(qy),[l]=f.useState(()=>n||a||Ih());return l}function Nc({type:n="",css:a="",icon:l="",disabled:r=!1,title:c="",tooltip:u,text:m="",children:p,onClick:v}){const g=f.useMemo(()=>{let y=n?n.split(" ").filter(b=>b!=="").map(b=>"wx-"+b).join(" "):"";return a+(a?" ":"")+y},[n,a]),w=y=>{v&&v(y)};return i.jsxs("button",{title:c,className:`wx-2ZWgb4 wx-button ${g} ${l&&!p?"wx-icon":""}`,disabled:r,onClick:w,"data-tooltip-text":u,children:[l&&i.jsx("i",{className:"wx-2ZWgb4 "+l}),p||m||" "]})}function E1({id:n,label:a="",inputValue:l="",value:r=!1,onChange:c,disabled:u=!1,css:m=""}){const p=Gy(n),[v,g]=$s(r),w=({target:y})=>{const b=y.checked;g(b),c&&c({value:b,inputValue:l})};return i.jsxs("div",{className:`wx-2IvefP wx-checkbox ${m}`,children:[i.jsx("input",{type:"checkbox",id:p,disabled:u,className:"wx-2IvefP wx-check",checked:v,value:l,onChange:w}),i.jsxs("label",{htmlFor:p,className:"wx-2IvefP wx-label",children:[i.jsx("span",{className:"wx-2IvefP wx-before"}),a&&i.jsx("span",{className:"wx-2IvefP wx-after",children:a})]})]})}function Bh({theme:n="",target:a,children:l}){const r=f.useRef(null),c=f.useRef(null),[u,m]=f.useState(null);r.current||(r.current=document.createElement("div"));const p=f.useContext(Oh);return f.useEffect(()=>{m(a||R1(c.current)||pa.getTopNode(c.current))},[c.current]),i.jsxs(i.Fragment,{children:[i.jsx("span",{ref:c,style:{display:"none"}}),c.current&&u?k1.createPortal(i.jsx("div",{className:`wx-3ZWsT0 wx-${n||p}-theme`,children:l}),u):null]})}function R1(n){const a=pa.getTopNode(n);for(;n&&n!==a&&!n.getAttribute("data-wx-portal-root");)n=n.parentNode;return n}function D1({left:n=0,top:a=0,at:l="bottom",parent:r=null,width:c="auto",css:u="",onCancel:m,children:p,trackScroll:v=!1}){const[g,w]=f.useState(0),[y,b]=f.useState(0),[j,C]=f.useState("auto"),[A,T]=f.useState(!1),k=f.useRef(null),E=f.useRef(null),R=f.useRef(m);f.useEffect(()=>{R.current=m},[m]);function U(V){return r&&(c+"").indexOf("%")>-1?c.replace(/(\d+)%/,(_,I)=>(I=I*r.offsetWidth/100+"px",c.replace(_,I))):c&&c!=="auto"?c:V}const F=f.useCallback(()=>{if(!k.current)return;const V=Fy(k.current,r,l,n,a);V&&(w(V.x),b(V.y),C(U(V.width)))},[k,r,l,n,a,c]);return f.useLayoutEffect(()=>{const V=I=>{R.current&&I.target!==E.current&&k.current&&!k.current.contains(I.target)&&R.current(I)};let _;return requestAnimationFrame(()=>{F(),T(!0),v&&k.current&&(E.current=Hy(k.current),E.current&&E.current.addEventListener("scroll",V,!0)),r&&(_=new ResizeObserver(F),_.observe(r))}),()=>{v&&E.current&&E.current.removeEventListener("scroll",V,!0),_?.disconnect()}},[]),f.useLayoutEffect(()=>{F()},[r,l,n,a]),f.useEffect(()=>{const V=_=>{R.current&&R.current(_)};if(k.current)return Us(k.current,{callback:V,parent:()=>r}).destroy},[r]),i.jsx("div",{ref:k,className:["wx-37M6Fj","wx-popup",u].filter(Boolean).join(" "),style:{position:"absolute",visibility:A?"visible":"hidden",top:y+"px",left:g+"px",width:j},children:p})}function L1({position:n="bottom",align:a="start",autoFit:l=!0,onCancel:r=null,width:c="100%",css:u="",children:m}){const p=f.useRef(null),[v,g]=f.useState(n),[w,y]=f.useState(a),b=f.useRef(r);return f.useEffect(()=>{b.current=r},[r]),f.useEffect(()=>{if(l){const j=p.current;if(j){const C=j.getBoundingClientRect(),A=document.body.getBoundingClientRect();C.right>=A.right&&y("end"),C.bottom>=A.bottom&&g("top")}}},[]),f.useEffect(()=>{if(p.current){const j=C=>{b.current&&b.current(C)};return Us(p.current,j).destroy}},[]),i.jsx("div",{ref:p,className:["wx-dropdown",`wx-${v}-${w}`,u||"","wx-aaaVytZW"].filter(Boolean).join(" "),style:{width:c},children:m})}function Fh({position:n="bottom",align:a="start",autoFit:l=!0,inline:r=!1,onCancel:c,width:u="100%",children:m,...p}){const[v,g]=f.useState(void 0),w=f.useRef(null),y=f.useMemo(()=>`${n}-${a}`,[n,a]);return f.useLayoutEffect(()=>{w.current&&g(w.current.parentNode)},[]),i.jsxs(i.Fragment,{children:[v&&(r?i.jsx(L1,{onCancel:c,position:n,align:a,autoFit:l,width:u,...p,children:m}):i.jsx(Bh,{children:i.jsx(D1,{parent:v,at:y,onCancel:c,width:u,...p,children:m})})),i.jsx("span",{ref:w,className:"wx-portal-node wx-32GZ52"})]})}function Od(){return zc($y)}function _1(){let n=null,a=!1,l=!1,r,c,u,m;const p=(y,b,j,C,A)=>{r=y,c=b,u=j,m=C,l=A},v=y=>{n=y,a=n!==null,u(n)},g=(y,b)=>{if(!l&&y!==null&&r){const j=r.querySelectorAll(".wx-list > .wx-item")[y];j&&(j.scrollIntoView({block:"nearest"}),b&&b.preventDefault())}},w=(y,b)=>{const j=y===null?null:Math.max(0,Math.min(n+y,c.length-1));j!==n&&(v(j),r?g(j,b):requestAnimationFrame(()=>g(j,b)))};return{move:y=>{const b=Lc(y),j=c.findIndex(C=>C.id===b);j!==n&&v(j)},keydown:(y,b)=>{switch(y.code){case"Enter":a?m():v(0);break;case"Space":a||v(0);break;case"Escape":u(n=null);break;case"Tab":u(n=null);break;case"ArrowDown":w(a?1:b||0,y);break;case"ArrowUp":w(a?-1:b||0,y);break}},init:p,navigate:w}}const hx=10,z1=f.memo(function({data:n,checkboxes:a,itemTemplate:l,value:r}){return i.jsxs(i.Fragment,{children:[a&&i.jsx(E1,{id:n.id,css:"wx-list-checkbox",value:r&&r.includes(n.id)}),l?_h(l,{option:n}):n.label]})});function px({visibleItems:n,visibleRange:a,navIndex:l,checkboxes:r,itemTemplate:c,value:u,measureRefCallback:m}){return n.map((p,v)=>{const g=a.start+v;return i.jsx("div",{ref:v===0?m:void 0,className:`wx-233fr7 wx-item ${g===l?"wx-focus":""}`,"data-id":p.id,children:i.jsx(z1,{data:p,checkboxes:r,itemTemplate:c,value:u})},p.id)})}function Bd({items:n=[],children:a,onSelect:l,onReady:r,virtualized:c=!1,checkboxes:u,multiselect:m,value:p,...v}){const g=f.useRef(),w=f.useRef(!1),y=f.useRef(_1()),[b,j]=f.useState(null),C=f.useRef(b),[A,T]=f.useState(0),[k,E]=f.useState(24),R=f.useRef(!1),U=(f.useContext(xs)||Od()).getGroup("core"),F=f.useRef(n);f.useEffect(()=>{F.current=n},[n]);const V=f.useRef(p);f.useEffect(()=>{V.current=p},[p]);const _=f.useRef(0);f.useEffect(()=>{_.current=k},[k]);const I=f.useCallback(L=>{L&&L.stopPropagation();const $=F.current,xe=V.current,Se=C.current;let fe;const Te=$[Se]?.id;m?xe&&xe.includes(Te)?fe=xe.filter(Ie=>Ie!==Te):fe=[...xe||[],Te]:fe=Te,l&&l({id:fe})},[m,l]),me=f.useRef(I);f.useEffect(()=>{me.current=I},[I]);const Y=f.useCallback(L=>{if(g.current){let $=L*_.current-g.current.clientHeight+_.current;T($),g.current.scrollTop=$}},[_.current]),ue=f.useCallback(L=>{g.current=L,c&&(L&&!w.current&&C.current!==null&&requestAnimationFrame(()=>{g.current&&(Y(C.current),w.current=!0)}),L||(w.current=!1))},[Y]),K=f.useCallback(L=>{if(!L||R.current)return;const $=L.getBoundingClientRect().height;$&&(E($),_.current=$,R.current=!0)},[]);f.useEffect(()=>{y.current.init(g.current,n,L=>{j(L),C.current=L},L=>me.current(L),c)},[n,g.current,c]),f.useEffect(()=>{const L=(xe,Se)=>{y.current.navigate(xe,Se),Y(C.current)},$=(xe,Se)=>{const fe=C.current,Te=F.current;if(fe!==0&&fe!==Te.length-1&&(xe.key==="ArrowDown"||xe.key==="ArrowUp")&&xe.preventDefault(),y.current.keydown(xe,Se),g.current){const Ie=g.current.scrollTop<=C.current*_.current,oe=g.current.scrollTop+g.current.clientHeight>=C.current*_.current+_.current;Ie?oe||Y(C.current):(g.current.scrollTop=C.current*_.current,T(g.current.scrollTop))}};r&&r({navigate:c?L:y.current.navigate,keydown:c?$:y.current.keydown,move:y.current.move})},[]);const ie=f.useRef(0),ee=f.useRef(n);ee.current!==n&&(ee.current=n,ie.current+=1);const W=f.useCallback(()=>{y.current.navigate(null)},[y]),z=f.useCallback(L=>{c&&T(L.target.scrollTop)},[c]),Q=f.useMemo(()=>Math.ceil((g.current?.clientHeight||0)/k),[k,A]),X=f.useMemo(()=>{if(!c)return{start:0,end:n.length};if(!n.length)return{start:0,end:0};const L=Math.floor(A/k),$=L+Q;return{start:Math.max(0,L-hx),end:Math.min(n.length,$+hx)}},[c,n,A,k,Q]),P=f.useMemo(()=>{if(!c)return n;const{start:L,end:$}=X;return n.slice(L,$).map(xe=>({...xe}))},[c,n,X]),le=X.start*k,we=n.length*k;return f.useEffect(()=>{c&&T(0)},[n,c]),f.useEffect(()=>{b===null&&(w.current=!1)},[b]),b===null?null:i.jsx(Fh,{onCancel:W,...v,children:i.jsx("div",{className:"wx-233fr7 wx-list",ref:ue,onClick:I,onMouseMove:y.current.move,onScroll:z,children:n.length?c?i.jsx("div",{className:"wx-233fr7 wx-list-wrapper",style:{height:`${we}px`},children:i.jsx("div",{className:"wx-233fr7 wx-list-content",style:{transform:`translateY(${le}px)`},children:i.jsx(px,{visibleRange:X,visibleItems:P,navIndex:b,measureRefCallback:K,checkboxes:u,itemTemplate:a,value:p})})}):i.jsx(px,{visibleRange:X,visibleItems:P,navIndex:b,measureRefCallback:K,checkboxes:u,itemTemplate:a,value:p}):i.jsx("div",{className:"wx-233fr7 wx-no-data",children:U("No data")})})},ie.current)}function Hh({value:n="",id:a,readonly:l=!1,focus:r=!1,select:c=!1,type:u="text",placeholder:m="",disabled:p=!1,error:v=!1,title:g="",tooltip:w,css:y="",icon:b="",clear:j=!1,onChange:C}){const A=Gy(a),[T,k]=$s(n),E=f.useRef(null),R=f.useMemo(()=>b&&y.indexOf("wx-icon-left")===-1?"wx-icon-right "+y:y,[b,y]),U=f.useMemo(()=>b&&y.indexOf("wx-icon-left")!==-1,[b,y]);f.useEffect(()=>{const me=setTimeout(()=>{r&&E.current&&E.current.focus(),c&&E.current&&E.current.select()},1);return()=>clearTimeout(me)},[r,c]);const F=f.useCallback(me=>{const Y=me.target.value;k(Y),C&&C({value:Y,input:!0})},[C]),V=f.useCallback(me=>C&&C({value:me.target.value}),[C]);function _(me){me.stopPropagation(),k(""),C&&C({value:""})}let I=u;return u!=="password"&&u!=="number"&&(I="text"),f.useEffect(()=>{const me=V,Y=E.current;return Y.addEventListener("change",me),()=>{Y&&Y.removeEventListener("change",me)}},[V]),i.jsxs("div",{className:`wx-hQ64J4 wx-text ${R} ${v?"wx-error":""} ${p?"wx-disabled":""} ${j?"wx-clear":""}`,"data-tooltip-text":w,children:[i.jsx("input",{className:"wx-hQ64J4 wx-input",ref:E,id:A,readOnly:l,disabled:p,placeholder:m,type:I,title:g,value:T,onInput:F}),j&&!p&&T?i.jsxs(i.Fragment,{children:[i.jsx("i",{className:"wx-hQ64J4 wx-icon wxi-close",onClick:_}),U&&i.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`})]}):b?i.jsx("i",{className:`wx-hQ64J4 wx-icon ${b}`}):null]})}function I1({date:n,type:a,part:l,onShift:r}){const{calendar:c,formats:u}=f.useContext(xs).getRaw(),m=n.getFullYear(),p=f.useMemo(()=>{switch(a){case"month":return so(u.monthYearFormat,c)(n);case"year":return so(u.yearFormat,c)(n);case"duodecade":{const{start:g,end:w}=Py(m),y=so(u.yearFormat,c);return`${y(new Date(g,0,1))} - ${y(new Date(w,11,31))}`}default:return""}},[n,a,m,c,u]);function v(){r&&r({diff:0,type:a})}return i.jsxs("div",{className:"wx-8HQVQV wx-header",children:[l!=="right"?i.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-left",onClick:()=>r&&r({diff:-1,type:a})}):i.jsx("span",{className:"wx-8HQVQV wx-spacer"}),i.jsx("span",{className:"wx-8HQVQV wx-label",onClick:v,children:p}),l!=="left"?i.jsx("i",{className:"wx-8HQVQV wx-pager wxi-angle-right",onClick:()=>r&&r({diff:1,type:a})}):i.jsx("span",{className:"wx-8HQVQV wx-spacer"})]})}function Ph({onClick:n,children:a}){return i.jsx("button",{className:"wx-3s8W4d wx-button",onClick:n,children:a})}function O1({value:n,current:a,part:l="",markers:r=null,css:c="",onCancel:u,onChange:m}){const p=(f.useContext(xs)||Od()).getRaw().calendar,v=(p.weekStart||7)%7,g=p.dayShort.slice(v).concat(p.dayShort.slice(0,v)),w=(F,V,_)=>new Date(F.getFullYear(),F.getMonth()+(V||0),F.getDate()+(_||0));let y=l!=="normal";function b(F){const V=F.getDay();return V===0||V===6}function j(){const F=w(a,0,1-a.getDate());return F.setDate(F.getDate()-(F.getDay()-(v-7))%7),F}function C(){const F=w(a,1,-a.getDate());return F.setDate(F.getDate()+(6-F.getDay()+v)%7),F}const A=f.useRef(0);function T(F,V){V.timeStamp!==A.current&&(A.current=V.timeStamp,V.stopPropagation(),m&&m(new Date(F)),u&&u())}const k=f.useMemo(()=>l=="normal"?[n?w(n).valueOf():0]:n?[n.start?w(n.start).valueOf():0,n.end?w(n.end).valueOf():0]:[0,0],[l,n]),E=f.useMemo(()=>{const F=j(),V=C(),_=a.getMonth();let I=[];for(let me=F;me<=V;me.setDate(me.getDate()+1)){const Y={day:me.getDate(),in:me.getMonth()===_,date:me.valueOf()};let ue="";if(ue+=Y.in?"":" wx-inactive",ue+=k.indexOf(Y.date)>-1?" wx-selected":"",y){const K=Y.date==k[0],ie=Y.date==k[1];K&&!ie?ue+=" wx-left":ie&&!K&&(ue+=" wx-right"),Y.date>k[0]&&Y.date<k[1]&&(ue+=" wx-inrange")}if(ue+=b(me)?" wx-weekend":"",r){const K=r(me);K&&(ue+=" "+K)}I.push({...Y,css:ue})}return I},[a,k,y,r]),R=f.useRef(null);let U=f.useRef({});return U.current.click=T,f.useEffect(()=>{uo(R.current,U.current)},[]),i.jsxs("div",{className:`wx-398RBS wx-month ${c}`,children:[i.jsx("div",{className:"wx-398RBS wx-weekdays",children:g.map(F=>i.jsx("div",{className:"wx-398RBS wx-weekday",children:F},F))}),i.jsx("div",{className:"wx-398RBS wx-days",ref:R,children:E.map(F=>i.jsx("div",{className:`wx-398RBS wx-day ${F.css} ${F.in?"":"wx-out"}`,"data-id":F.date,children:F.day},F.date))})]})}function B1({value:n,current:a,part:l,onCancel:r,onChange:c,onShift:u}){const m=f.useRef(new Date),[p,v]=$s(n||m.current),[g,w]=$s(a||m.current),y=f.useContext(xs).getRaw().calendar,b=y.monthShort||[],j=f.useMemo(()=>g.getMonth(),[g]),C=f.useCallback((k,E)=>{if(k!=null){E.stopPropagation();const R=new Date(g);R.setMonth(k),w(R),u&&u({current:R})}l==="normal"&&v(new Date(g)),r&&r()},[g,l,u,r]),A=f.useCallback(()=>{const k=new Date(Vy(p,l)||g);k.setMonth(g.getMonth()),k.setFullYear(g.getFullYear()),c&&c(k)},[p,g,l,c]),T=f.useCallback(k=>{const E=k.target.closest("[data-id]");if(E){const R=parseInt(E.getAttribute("data-id"),10);C(R,k)}},[C]);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"wx-34U8T8 wx-months",onClick:T,children:b.map((k,E)=>i.jsx("div",{className:"wx-34U8T8 wx-month"+(j===E?" wx-current":""),"data-id":E,children:k},E))}),i.jsx("div",{className:"wx-34U8T8 wx-buttons",children:i.jsx(Ph,{onClick:A,children:y.done})})]})}const Om="wx-1XEF33",F1=({value:n,current:a,onCancel:l,onChange:r,onShift:c,part:u})=>{const m=f.useContext(xs).getRaw().calendar,[p,v]=$s(a),[g,w]=$s(n),y=f.useMemo(()=>p.getFullYear(),[p]),b=f.useMemo(()=>{const{start:k,end:E}=Py(y),R=[];for(let U=k;U<=E;++U)R.push(U);return R},[y]),j={click:C};function C(k,E){if(k){E.stopPropagation();const R=new Date(p);R.setFullYear(k),v(R),c&&c({current:R})}u==="normal"&&w(new Date(p)),l&&l()}function A(){const k=new Date(Vy(g,u)||p);k.setFullYear(p.getFullYear()),r&&r(k)}const T=f.useRef(null);return f.useEffect(()=>{T.current&&uo(T.current,j)},[]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:Om+" wx-years",ref:T,children:b.map((k,E)=>i.jsx("div",{className:Om+` wx-year ${y==k?"wx-current":""} ${E===0?"wx-prev-decade":""} ${E===11?"wx-next-decade":""}`,"data-id":k,children:k},E))}),i.jsx("div",{className:Om+" wx-buttons",children:i.jsx(Ph,{onClick:A,children:m.done})})]})},gx={month:{component:O1,next:P1,prev:H1},year:{component:B1,next:U1,prev:$1},duodecade:{component:F1,next:G1,prev:q1}};function H1(n){return n=new Date(n),n.setMonth(n.getMonth()-1),n}function P1(n){return n=new Date(n),n.setMonth(n.getMonth()+1),n}function $1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-1),n}function U1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+1),n}function q1(n){return n=new Date(n),n.setFullYear(n.getFullYear()-10),n}function G1(n){return n=new Date(n),n.setFullYear(n.getFullYear()+10),n}function Vy(n,a){let l;if(a==="normal")l=n;else{const{start:r,end:c}=n;a==="left"?l=r:a=="right"?l=c:l=r&&c}return l}const V1=["clear","today"];function Y1(n){if(n==="done")return-1;if(n==="clear")return null;if(n==="today")return new Date}function W1({value:n,current:a,onCurrentChange:l,part:r="normal",markers:c=null,buttons:u,css:m="",onShift:p,onChange:v}){const g=f.useContext(xs).getGroup("calendar"),[w,y]=f.useState("month"),b=Array.isArray(u)?u:u?V1:[],j=(E,R)=>{E.preventDefault(),v&&v({value:R})},C=()=>{w==="duodecade"?y("year"):w==="year"&&y("month")},A=E=>{const{diff:R,current:U}=E;if(R===0){w==="month"?y("year"):w==="year"&&y("duodecade");return}if(R){const F=gx[w];l(R>0?F.next(a):F.prev(a))}else U&&l(U);p&&p()},T=E=>{y("month"),v&&v({select:!0,value:E})},k=f.useMemo(()=>gx[w].component,[w]);return i.jsx("div",{className:`wx-2Gr4AS wx-calendar ${r!=="normal"&&r!=="both"?"wx-part":""} ${m}`,children:i.jsxs("div",{className:"wx-2Gr4AS wx-wrap",children:[i.jsx(I1,{date:a,part:r,type:w,onShift:A}),i.jsxs("div",{children:[i.jsx(k,{value:n,current:a,onCurrentChange:l,part:r,markers:c,onCancel:C,onChange:T,onShift:A}),w==="month"&&b.length>0&&i.jsx("div",{className:"wx-2Gr4AS wx-buttons",children:b.map(E=>i.jsx("div",{className:"wx-2Gr4AS wx-button-item",children:i.jsx(Ph,{onClick:R=>j(R,Y1(E)),children:g(E)})},E))})]})]})})}function $h(n){let{words:a=null,optional:l=!1,children:r}=n,c=f.useContext(xs);const u=f.useMemo(()=>{let m=c;return(!m||!m.extend)&&(m=zc($y)),a!==null&&(m=m.extend(a,l)),m},[a,l,c]);return i.jsx(xs.Provider,{value:u,children:r})}function vx(n,a,l,r){if(!n||r){const c=a?new Date(a):new Date;c.setDate(1),l(c)}else if(n.getDate()!==1){const c=new Date(n);c.setDate(1),l(c)}}const K1=["clear","today"];function Yy({value:n,current:a,markers:l=null,buttons:r=K1,css:c="",onChange:u}){const[m,p]=$s(n),[v,g]=$s(a);f.useEffect(()=>{vx(v,m,g,!1)},[m,v]);const w=f.useCallback(b=>{const j=b.value;j?(p(new Date(j)),vx(v,new Date(j),g,!0)):p(null),u&&u({value:j?new Date(j):null})},[u,v]),y=f.useCallback(b=>{g(b)},[g]);return v?i.jsx($h,{children:i.jsx(W1,{value:m,current:v,markers:l,buttons:r,css:c,onChange:w,onCurrentChange:y})}):null}function Q1(n){return n||(n={}),n.width||(n.width="unset"),n}const X1=["clear","today"];function Z1({value:n,id:a,disabled:l=!1,error:r=!1,placeholder:c="",format:u="",buttons:m=X1,css:p="",title:v="",tooltip:g,editable:w=!1,clear:y=!1,onChange:b,dropdown:j={}}){const{calendar:C,formats:A}=(f.useContext(xs)||Od()).getRaw(),T=u||A?.dateFormat;let k=typeof T=="function"?T:so(T,C);const[E,R]=f.useState(n),[U,F]=f.useState(!1);f.useEffect(()=>{R(n)},[n]);function V(){F(!1)}function _(Y){const ue=Y===E||Y&&E&&Y.valueOf()===E.valueOf()||!Y&&!E;R(Y),ue||b&&b({value:Y}),setTimeout(V,1)}const I=f.useMemo(()=>E?k(E):"",[E,k]);function me({value:Y,input:ue}){if(!w&&!y||ue)return;let K=typeof w=="function"?w(Y):Y?new Date(Y):null;K=isNaN(K)?E||null:K||null,_(K)}return f.useEffect(()=>{const Y=V;return window.addEventListener("scroll",Y),()=>window.removeEventListener("scroll",Y)},[]),i.jsxs("div",{className:"wx-1lKOFG wx-datepicker",onClick:()=>F(!0),children:[i.jsx(Hh,{css:`wx-date-input ${p}`,title:v,tooltip:g,value:I,id:a,readonly:!w,disabled:l,error:r,placeholder:c,onInput:V,onChange:me,icon:"wxi-calendar",clear:y}),U&&!l&&i.jsx(Fh,{onCancel:V,...Q1(j),children:i.jsx(Yy,{buttons:m,value:E,onChange:Y=>_(Y.value)})})]})}function J1({value:n="",options:a=[],textOptions:l=null,placeholder:r="",disabled:c=!1,error:u=!1,title:m="",tooltip:p,textField:v="label",clear:g=!1,css:w="",children:y,onChange:b,dropdown:j={}}){const C=f.useRef(null),A=f.useRef(null);let[T,k]=$s(n);function E(_){C.current=_.navigate,A.current=_.keydown}const R=f.useMemo(()=>T||T===0?(l||a).find(_=>_.id===T):null,[T,l,a]),U=f.useCallback(({id:_})=>{(_||_===0)&&(k(_),C.current(null),b&&b({value:_}))},[k,b]),F=f.useCallback(_=>{_.stopPropagation(),k(""),b&&b({value:""})},[k,b]),V=f.useCallback(()=>a.findIndex(_=>_.id===T),[a,T]);return i.jsxs("div",{className:`wx-2YgblL wx-richselect ${w} ${u?"wx-2YgblL wx-error":""} ${c?"wx-2YgblL wx-disabled":""} ${y?"":"wx-2YgblL wx-nowrap"}`,title:m,onClick:()=>C.current(V()),onKeyDown:_=>A.current(_,V()),tabIndex:0,"data-tooltip-text":p,children:[i.jsx("div",{className:"wx-2YgblL wx-label",children:R?y?y(R):R[v]:r?i.jsx("span",{className:"wx-2YgblL wx-placeholder",children:r}):" "}),g&&!c&&T?i.jsx("i",{className:"wx-2YgblL wx-icon wxi-close",onClick:F}):i.jsx("i",{className:"wx-2YgblL wx-icon wxi-angle-down"}),!c&&i.jsx(Bd,{items:a,onReady:E,onSelect:U,...j,children:({option:_})=>y?y(_):_[v]})]})}const ej=({options:n=[],value:a="",css:l="",children:r,onChange:c})=>{const[u,m]=f.useState(a),p=v=>{m(v),c&&c({value:v})};return f.useEffect(()=>{m(a)},[a]),i.jsx("div",{className:`wx-0hMO7P wx-segmented ${l}`,children:n.map(v=>i.jsx("button",{className:`wx-0hMO7P wx-segment ${v.css} ${v.id===u?"wx-selected":""}`,title:v.title,onClick:()=>p(v.id),"data-tooltip-text":v.tooltip,children:r?_h(r,{option:v}):i.jsxs(i.Fragment,{children:[v.icon&&i.jsx("i",{className:`wx-0hMO7P wx-icon ${v.icon} ${v.label?"":"wx-only"}`}),v.label&&i.jsx("span",{className:"wx-0hMO7P wx-label",children:v.label})]})},v.id))})};function tj({notice:n={}}){function a(){n.remove&&n.remove()}return i.jsxs("div",{className:`wx-11sNg5 wx-notice wx-${n.type?n.type:""}`,role:"status","aria-live":"polite",children:[i.jsx("div",{className:"wx-11sNg5 wx-text",children:n.text}),i.jsx("div",{className:"wx-11sNg5 wx-button",children:i.jsx("i",{className:"wx-11sNg5 wxi-close",onClick:a})})]})}function nj({data:n=[]}){return i.jsx("div",{className:"wx-3nwoO9 wx-notices",children:n.map(a=>i.jsx(tj,{notice:a},a.id))})}function ph({title:n="",buttons:a=["cancel","ok"],header:l,children:r,footer:c,css:u="",onConfirm:m,onCancel:p}){const v=(f.useContext(xs)||Od()).getGroup("core"),g=f.useRef(null);f.useEffect(()=>{g.current?.focus()},[]);function w(b){switch(b.code){case"Enter":{const j=b.target.tagName;if(j==="TEXTAREA"||j==="BUTTON")return;m&&m({event:b});break}case"Escape":p&&p({event:b});break}}function y(b,j){const C={event:b,button:j};j==="cancel"?p&&p(C):m&&m(C)}return i.jsx("div",{className:`wx-1FxkZa wx-modal ${u}`,ref:g,tabIndex:0,onKeyDown:w,children:i.jsxs("div",{className:"wx-1FxkZa wx-window",children:[l||(n?i.jsx("div",{className:"wx-1FxkZa wx-header",children:n}):null),i.jsx("div",{children:r}),c||a&&i.jsx("div",{className:"wx-1FxkZa wx-buttons",children:a.map(b=>i.jsx("div",{className:"wx-1FxkZa wx-button",children:i.jsx(Nc,{type:`block ${b==="ok"?"primary":"secondary"}`,onClick:j=>y(j,b),children:v(b)})},b))})]})})}function aj({children:n},a){const[l,r]=f.useState(null),[c,u]=f.useState([]);return f.useImperativeHandle(a,()=>({showModal:m=>{const p={...m};return r(p),new Promise((v,g)=>{p.resolve=w=>{r(null),v(w)},p.reject=w=>{r(null),g(w)}})},showNotice:m=>{m={...m},m.id=m.id||Ih(),m.remove=()=>u(p=>p.filter(v=>v.id!==m.id)),m.expire!=-1&&setTimeout(m.remove,m.expire||5100),u(p=>[...p,m])}}),[]),i.jsxs(i.Fragment,{children:[n,l&&i.jsx(ph,{title:l.title,buttons:l.buttons,onConfirm:l.resolve,onCancel:l.reject,children:l.message}),i.jsx(nj,{data:c})]})}const sj=f.forwardRef(aj);function ij(n){let{children:a}=n,l=f.useRef();const r=f.useMemo(()=>({showNotice:c=>l.current.showNotice(c),showModal:c=>l.current.showModal(c)}),[]);return i.jsx(Uy.Provider,{value:r,children:i.jsx(sj,{ref:l,children:a})})}const lj=({value:n=!1,type:a="",icon:l="",disabled:r=!1,iconActive:c="",onClick:u,title:m="",tooltip:p,css:v="",text:g="",textActive:w="",children:y,active:b,onChange:j})=>{const[C,A]=$s(n),T=f.useMemo(()=>(C?"pressed":"")+(a?" "+a:""),[C,a]),k=f.useCallback(E=>{let R=!C;u&&u(E),E.defaultPrevented||(A(R),j&&j({value:R}))},[C,u,j]);return C&&b?i.jsx(Nc,{title:m,tooltip:p,text:C&&w||g,css:v,type:T,icon:C&&c||l,onClick:k,disabled:r,children:_h(b,{value:C})}):y?i.jsx(Nc,{title:m,tooltip:p,text:C&&w||g,css:v,type:T,icon:C&&c||l,onClick:k,disabled:r,children:y}):i.jsx(Nc,{title:m,tooltip:p,text:C&&w||g,css:v,type:T,icon:C&&c||l,onClick:k,disabled:r})};function rj(){return i.jsx(i.Fragment,{})}function xx(n){const{fonts:a=!0,children:l}=n;return i.jsx(Oh.Provider,{value:"willow",children:i.jsxs(i.Fragment,{children:[l&&l&&i.jsx("div",{className:"wx-theme wx-willow-theme",children:l}),a&&i.jsxs(i.Fragment,{children:[i.jsx("link",{rel:"preconnect",href:"https://cdn.svar.dev",crossOrigin:"true"}),i.jsx(rj,{}),i.jsx("link",{rel:"stylesheet",href:"https://cdn.svar.dev/fonts/wxi/wx-icons.css"})]})]})})}zh(pa);const Uh={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 Wy=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 oj=class{constructor(n){const a={id:0,$level:0,data:[],parent:null},l=new Map;l.set(0,a),this._pool=l,n&&n.length&&this.parse(n,0)}parse(n,a){const l=this._pool;for(let c=0;c<n.length;c++){const u=n[c];u.parent=u.parent||a,u.data=null,l.set(u.id,u)}for(let c=0;c<n.length;c++){const u=n[c],m=l.get(u.parent);m&&(m.data||(m.data=[]),m.data.push(u))}const r=l.get(a);this.setLevel(r,r.$level+1,!1)}add(n,a){const l=this._pool.get(n.parent||0);n.$level=l.$level+1,this._pool.set(n.id,n),l.data?a===-1?l.data=[...l.data,n]:yx(l,a,n):l.data=[n]}addAfter(n,a){if(!a)return this.add(n,-1);const l=this.byId(a),r=this.byId(l.parent),c=sd(r,l.id)+1;n.parent=r.id,n.$level=r.$level+1,this.add(n,c)}remove(n){const a=this._pool.get(n);this._remove(a);const l=this._pool.get(a.parent);l.data=l.data.filter(r=>r.id!=n),this._clearBranch(l)}_remove(n){n.data&&n.data.forEach(a=>this._remove(a)),this._pool.delete(n.id)}update(n,a){let l=this._pool.get(n);const r=this._pool.get(l.parent),c=sd(r,l.id);l={...l,...a},r&&c>=0&&(r.data[c]=l,r.data=[...r.data]),this._pool.set(l.id,l)}move(n,a,l){const r=this._pool.get(n),c=a==="child",u=this._pool.get(l),m=u.$level+(c?1:0);if(!r||!u)return;const p=this._pool.get(r.parent),v=c?u:this._pool.get(u.parent);v.data||(v.data=[]);const g=sd(p,r.id);cj(p,g);const w=c?v.data.length:sd(v,u.id)+(a==="after"?1:0);if(yx(v,w,r),p.id===v.id&&g===w)return null;r.parent=v.id,r.$level!==m&&(r.$level=m,this.setLevel(r,m+1,!0)),this.update(r.id,r),this._clearBranch(p)}_clearBranch(n){n.data&&!n.data.length&&(n.open&&delete n.open,this.update(n.id,{data:null}))}toArray(){const n=[],a=this._pool.get(0).data;return a&&Ky(a,n),n}byId(n){return this._pool.get(n)}getBranch(n){return this._pool.get(n).data}forEach(n){this._pool.forEach((a,l)=>{l!==0&&n(a)})}eachChild(n,a){const l=this.byId(a);!l||!l.data||l.data.forEach((r,c)=>{n(this.byId(r.id),c),this.eachChild(n,r.id)})}setLevel(n,a,l){n.data&&(n.data=n.data.map(r=>(l&&(r={...r},this._pool.set(r.id,r)),r.$level=a,r.data&&this.setLevel(r,a+1,l),r)))}};function Ky(n,a){n.forEach(l=>{a.push(l),l.open===!0&&Ky(l.data,a)})}function cj(n,a){const l=[...n.data];l.splice(a,1),n.data=l}function yx(n,a,l){const r=[...n.data];r.splice(a,0,l),n.data=r}function sd(n,a){return n?.data.findIndex(l=>l.id===a)}var Qy=2,uj=class{constructor(a){a&&(this._writable=a.writable,this._async=a.async),this._values={},this._state={}}setState(a,l=0){const r={};return this._wrapProperties(a,this._state,this._values,"",r,l),r}getState(){return this._values}getReactive(){return this._state}_wrapProperties(a,l,r,c,u,m){for(const p in a){const v=l[p],g=r[p],w=a[p];if(v&&(g===w&&typeof w!="object"||w instanceof Date&&g instanceof Date&&g.getTime()===w.getTime()))continue;const y=c+(c?".":"")+p;v?(v.__parse(w,y,u,m)&&(r[p]=w),m&Qy?u[y]=v.__trigger:v.__trigger()):(w&&w.__reactive?l[p]=this._wrapNested(w,w,y,u):l[p]=this._wrapWritable(w),r[p]=w),u[y]=u[y]||null}}_wrapNested(a,l,r,c){const u=this._wrapWritable(a);return this._wrapProperties(a,u,l,r,c,0),u.__parse=(m,p,v,g)=>(this._wrapProperties(m,u,l,p,v,g),!1),u}_wrapWritable(a){const l=[],r=function(){for(let c=0;c<l.length;c++)l[c](a)};return{subscribe:c=>(l.push(c),this._async?setTimeout(c,1,a):c(a),()=>{const u=l.indexOf(c);u>=0&&l.splice(u,1)}),__trigger:()=>{l.length&&(this._async?setTimeout(r,1):r())},__parse:function(c){return a=c,!0}}}};function wx(n,a){return Object.defineProperty(n,"__reactive",{value:!0,enumerable:!1,writable:!1}),n}var dj=class{constructor(a,l,r,c){typeof a=="function"?this._setter=a:this._setter=a.setState.bind(a),this._routes=l,this._parsers=r,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(u=>{u.in.forEach(m=>{const p=this._triggers.get(m)||[];p.push(u),this._triggers.set(m,p)}),u.out.forEach(m=>{const p=this._sources.get(m)||{};u.in.forEach(v=>p[v]=!0),this._sources.set(m,p)})}),this._routes.forEach(u=>{u.length=Math.max(...u.in.map(m=>Xy(m,this._sources,1)))}),this._bus=c}init(a){const l={};for(const r in a)if(this._prev[r]!==a[r]){const c=this._parsers[r];l[r]=c?c(a[r]):a[r]}this._prev=this._prev?{...this._prev,...a}:{...a},this.setState(l),this._bus&&this._bus.exec("init-state",l)}setStateAsync(a){const l=this._setter(a,Qy);return this._async?Object.assign(this._async.signals,l):this._async={signals:l,timer:setTimeout(this._applyState.bind(this),1)},l}_applyState(){const a=this._async;if(a){this._async=null,this._triggerUpdates(a.signals,[]);for(const l in a.signals){const r=a.signals[l];r&&r()}}}setState(a,l=[]){const r=this._setter(a);return this._triggerUpdates(r,l),r}_triggerUpdates(a,l){const r=Object.keys(a),c=!l.length;l=l||[];for(let u=0;u<r.length;u++){const m=r[u],p=this._triggers.get(m);p&&p.forEach(v=>{l.indexOf(v)==-1&&l.push(v)})}c&&this._execNext(l)}_execNext(a){for(;a.length;){a.sort((r,c)=>r.length<c.length?1:-1);const l=a[a.length-1];a.splice(a.length-1),l.exec(a)}}};function Xy(n,a,l){const r=a.get(n);if(!r)return l;const c=Object.keys(r).map(u=>Xy(u,a,l+1));return Math.max(...c)}var fj=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(a,l,r){let c=this._handlers[a];c?r&&r.intercept?c.unshift(l):c.push(l):c=this._handlers[a]=[l],r&&r.tag&&this._tag.set(l,r.tag)}intercept(a,l,r){this.on(a,l,{...r,intercept:!0})}detach(a){for(const l in this._handlers){const r=this._handlers[l];for(let c=r.length-1;c>=0;c--)this._tag.get(r[c])===a&&r.splice(c,1)}}async exec(a,l){const r=this._handlers[a];if(r)for(let c=0;c<r.length;c++){const u=r[c](l);if(u===!1||u&&u.then&&await u===!1)return}return this._nextHandler&&await this._nextHandler.exec(a,l),l}setNext(a){return this._nextHandler=a}};const eo=1024;function _c(n){return n<eo?`${n} B`:n<eo**2?`${(n/eo).toFixed(1)} KB`:n<eo**3?`${(n/eo**2).toFixed(1)} MB`:`${(n/eo**3).toFixed(1)} GB`}function bx(n,a){a||(a={key:"name",order:"asc"});const l=n.filter(m=>m.type==="folder"),r=n.filter(m=>m.type!=="folder"),c=l.sort(Sx(a)),u=r.sort(Sx(a));return[...c,...u]}function mj(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 hj(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 Sx({key:n,order:a}){const l=a==="asc"?mj:hj;return(r,c)=>l(r[n],c[n])}function qh(n,a){const l=n==="/"?1:n.split("/").length;return l>=a.length?null:a[l].id}function pj(n){return n.length>1?n[n.length-2].id:null}let gj=class extends oj{constructor(a){const l={id:"/",name:"My files",open:!0,$level:1,parent:0,ext:"",type:"folder"};super([l]),this.parse(a,"/")}parse(a,l,r){!a||!a.length||(a.forEach(c=>this.parseId(c,r?l:void 0)),super.parse(a,l))}parseId(a,l){if(a.parent===0)return;const r=a.id,c=r.lastIndexOf("/");if(a.parent=l??(c===0?"/":r.slice(0,c)),a.name=r.slice(c+1),a.type=a.type||"file",a.type!=="folder"){const u=a.name.lastIndexOf("."),m=u!==-1?a.name.slice(u+1):"";a.ext=m!=="new"?m?.toLocaleLowerCase():""}}getParents(a){const l=[];let r=this.byId(a);if(!r)return l;for(;r.id!==0;)l.push(r),r=this.byId(r.parent);return l.reverse()}findFiles(a,l="/"){const r=[],c=a.toLocaleLowerCase();return this.eachChild(u=>{u.name.toLowerCase().indexOf(c)!==-1&&r.push(u)},l),r}add(a,l){const r=this.byId(a.parent||"/"),c=a.data?[...a.data]:null;a.data=null,super.add(a,l??r.data?r.data.length:0),c&&c.forEach(u=>this.add(u))}renameFiles(a,l,r){const c=this.byId(a),u=this.normalizeFile(c,l),m=[];return u.data?.forEach(p=>m.push(this.renameFiles(p.id,u.id,r))),m.length&&(u.data=m),r[a]=u.id,u}copyFiles(a,l,r){const c={};return a.forEach(u=>{const m=this.renameFiles(u,l,c);this.add(m),r&&this.remove(u),c[u]=m.id}),c}moveFiles(a,l){if(this.byId(a[0]).parent!==l)return this.copyFiles(a,l,!0)}serialize(a="/"){const l=[],r=this.byId(a);return r?(r.data?.forEach(c=>{const{id:u,date:m,type:p,size:v,lazy:g}=c,w={id:u,date:m,type:p??"file"};g&&(w.lazy=g),v&&(w.size=v),l.push(w);const y=this.serialize(u);y.length&&l.push(...y)}),l):null}normalizeFile(a,l){const r=a.name,c=r.lastIndexOf("."),u=c!==-1?r.slice(c+1):"",m=u?`.${u}`:"";let p=c!==-1?r.slice(0,c):r,v=l+(l==="/"?"":"/")+p;for(;this.byId(v+m);){const g=".new";v+=g,p+=g}return{...a,id:v+m,name:p+m,parent:l,ext:u.toLocaleLowerCase()}}},vj=class extends uj{in;_router;constructor(a){super({writable:a,async:!1});const l=[];for(let u=0;u<2;u++)l.push({in:["data",`panels.${u}.path`],out:[`panels.${u}._crumbs`],exec:m=>{const{data:p,panels:v}=this.getState(),g=[];g[u]={_crumbs:p.getParents(v[u].path)},this.setState({panels:g},m)}}),l.push({in:["data",`panels.${u}.path`,`panels.${u}._sorts`,"search"],out:[`panels.${u}._files`],exec:m=>{const{data:p,panels:v,search:g}=this.getState();let w;g?w=p.findFiles(g,v[u].path):w=p.byId(v[u].path)?.data||[];const{path:y,_sorts:b}=v[u];w=bx(w,b[y]);const j=[];j[u]={_files:w},this.setState({panels:j},m)}}),l.push({in:["data",`panels.${u}.selected`,`panels.${u}._sorts`],out:[`panels.${u}._selected`],exec:m=>{const{data:p,panels:v}=this.getState(),g=[];v[u].selected.forEach(C=>{const A=p.byId(C);A&&g.push(A)});const{path:w,_sorts:y}=v[u],b=bx(g,y[w]),j=[];j[u]={_selected:b},this.setState({panels:j},m)}});this._router=new dj(super.setState.bind(this),l,{data:u=>new gj(u)});const r=this.in=new fj;r.on("select-file",({id:u,toggle:m,range:p,panel:v,type:g})=>{const{panels:w,activePanel:y}=this.getState();typeof v>"u"&&(v=y),u||(m=p=!1);let b=[...w[v].selected];if(m){const C=b.indexOf(u);C===-1?b.push(u):b.splice(C,1)}else if(p&&w[v]._lastSelected){const C=w[v]._files;let A=C.findIndex(E=>E.id==w[v]._lastSelected),T=C.findIndex(E=>E.id==u);T<A&&([A,T]=[T,A]);const k=C.slice(A,T+1).map(E=>E.id);b=[...new Set([...b,...k])]}else b=u?[u]:[];const j=[];j[v]={selected:b,_lastSelected:u,_selectNavigation:g==="navigation"},this.setState({panels:j})}),r.on("set-path",({id:u,panel:m,selected:p})=>{const{data:v,activePanel:g}=this.getState(),w=v.byId(u);if(w){const y=[];typeof m>"u"&&(m=g),y[m]={path:u},this.setState({panels:y}),r.exec("select-file",{panel:m}),p&&p.forEach(b=>r.exec("select-file",{id:b,panel:m,toggle:!0})),w.lazy&&r.exec("request-data",{id:u})}}),r.on("provide-data",({id:u,data:m})=>{const{mode:p,data:v}=this.getState(),g=v.byId(u);g&&(g.lazy||(g.data=[]),g.lazy=!1,v.parse(m,u,p==="search"),this.setState({data:v}))}),r.on("open-tree-folder",({id:u,mode:m})=>{const{data:p}=this.getState();p.update(u,{open:m}),this.setState({data:p})}),r.on("show-preview",({mode:u})=>{this.setState({preview:u})}),r.on("rename-file",u=>{const{id:m,name:p}=u,{data:v,panels:g}=this.getState(),w=v.byId(m);if(w.name!==p){w.name=p;const y=v.normalizeFile(w,w.parent);u.newId=y.id,y.data=null,v.add(y);let b={[m]:y.id};w.data?.forEach(C=>b={...v.moveFiles([C.id],y.id),...b});const j=g.map(C=>({selected:C.selected,_crumbs:C._crumbs,_lastSelected:C._lastSelected,_sorts:C._sorts}));v.remove(m),this._updatePanels(j,b),this.setState({data:v,panels:j})}}),r.on("create-file",u=>{const{file:m,parent:p}=u,{data:v}=this.getState(),g=v.normalizeFile(m,p);g.type=m.type||"file",u.newId=g.id,v.add(g),this.setState({data:v}),r.exec("select-file",{id:g.id})}),r.on("delete-files",({ids:u})=>{const{data:m,panels:p}=this.getState(),v=p.map(g=>({selected:g.selected,_crumbs:g._crumbs,_lastSelected:g._lastSelected,_sorts:g._sorts}));u.forEach(g=>m.remove(g)),this._updatePanels(v,{}),this.setState({data:m,panels:v})}),r.on("copy-files",u=>{const{ids:m,target:p}=u;if(this._isPlacedIntoSelf(m,p)){console.error("You cannot copy a folder into itself"),u.skipProvider=!0;return}const{data:v,panels:g,activePanel:w}=this.getState(),y=v.copyFiles(m,p);u.newIds=m.map(b=>y[b]),this.setState({data:v}),g[w].path==p&&(r.exec("select-file",{}),m.forEach(b=>{r.exec("select-file",{id:y[b],toggle:!0})}))}),r.on("move-files",u=>{const{ids:m,target:p}=u;if(this._isPlacedIntoSelf(m,p)){console.error("You cannot move a folder into itself"),u.skipProvider=!0;return}const{data:v,panels:g,activePanel:w}=this.getState(),y=v.moveFiles(m,p);if(y){u.newIds=m.map(j=>y[j]);const b=g.map(j=>({selected:j.selected,_crumbs:j._crumbs,_lastSelected:j._lastSelected,_sorts:j._sorts}));this._updatePanels(b,y,!0),this.setState({data:v,panels:b}),g[w].path==p&&(r.exec("select-file",{}),m.forEach(j=>{r.exec("select-file",{id:y[j],toggle:!0})}))}});let c=null;r.on("filter-files",({text:u})=>{if(!u){c&&this.setState({...c});return}r.exec("select-file",{});const{panels:m,mode:p}=this.getState();c||(c={panels:m,mode:p,search:""}),this.setState({mode:"search",search:u})}),r.on("set-mode",({mode:u})=>{const{activePanel:m}=this.getState(),p=[];p[m]={_selectNavigation:!1};const v={mode:u,search:"",panels:p};c=null,this.setState(v)}),r.on("set-active-panel",({panel:u})=>{this.setState({activePanel:u})}),r.on("sort-files",({key:u,order:m,panel:p,path:v})=>{const{activePanel:g,panels:w}=this.getState();p=p??g,v=v??w[p].path;const y=[];y[p]={_sorts:{...w[p]._sorts,[v]:{key:u,order:m}}},this.setState({panels:y})}),this.initOnce()}initOnce(){const a=[];for(let r=0;r<2;r++)a[r]=wx({_crumbs:[],_files:[],_selected:[],_sorts:{},path:"/",selected:[],...a[r]});const l={panels:wx(a),data:[],search:""};this._router.init(l)}init(a){const l={...a};this._router.init(l)}setState(a,l){return this._router.setState(a,l)}getFile(a){const{data:l}=this.getState();return l.byId(a)||null}serialize(a){const{data:l}=this.getState();return l.serialize(a)}_updatePanels(a,l,r){const{data:c}=this.getState();a.forEach(u=>{const m=[];u.selected.forEach(g=>{c.byId(g)?m.push(g):!r&&l[g]&&m.push(l[g])}),u.selected=m,c.byId(u._lastSelected)||(u._lastSelected=r?null:l[u._lastSelected]||null);const p={};Object.keys(u._sorts).forEach(g=>{c.byId(g)?p[g]=u._sorts[g]:l[g]&&!r&&(p[l[g]]=u._sorts[g])}),u._sorts=p;const v=u._crumbs[u._crumbs.length-1];v?.id!=="/"&&(l[v.id]?u.path=l[v.id]:c.byId(v.id)||(u.path="/"))})}_isPlacedIntoSelf(a,l){return a.some(r=>r===l||this.getState().data.getParents(l).some(c=>c.id===r))}};function xj(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 yj(n,a="data-id"){let l=n;for(!l.tagName&&n.target&&(l=n.target);l;){if(l.getAttribute&&l.getAttribute(a))return l;l=l.parentNode}return null}function wj(n,a="data-id"){const l=yj(n,a);return l?l.getAttribute(a):null}new Date().valueOf();function bj(n,a){const{api:l}=a;function r(u,m){const p=a.getPanel(),v=p.selected,g=m.ctrlKey||m.metaKey,w=m.shiftKey;let y;const b=v?.[0]?l.getFile(v[0]):null;v?.length?v.length>1?y=a.menuOptions("multiselect"):y=a.menuOptions(b.type,b):y=a.menuOptions("body");const j=`${g?"ctrl+":""}${w?"shift+":""}${u}`,C=y?y.find(T=>T.hotkey?.toLowerCase()===j):!1,A=a.performAction;if(C)switch(j){case"ctrl+c":A("copy");break;case"ctrl+x":A("move");break;case"ctrl+v":A("paste",b);break;case"delete":A("delete");break;case"ctrl+r":m.preventDefault(),A("rename",b);break;case"ctrl+d":m.preventDefault(),A("download",b);break;default:C.handler?.({context:b})}switch(u){case"enter":{if(g||w)break;const{_crumbs:T,_selectNavigation:k}=p;if(k){const E=pj(T);if(E){const R=qh(E,T);l.exec("set-path",{id:E,selected:[R]})}}else if(v.length===1){const E=l.getFile(v[0]);E&&l.exec(E.type==="folder"?"set-path":"open-file",{id:E.id})}break}case"arrowup":case"arrowleft":{const{_files:T,_selected:k,path:E,_selectNavigation:R}=p;let U;if(k.length){const F=k.at(0).id,V=T.findIndex(_=>_.id===F);if(V!==-1){const _=V-1;T[_]?U=T[_].id:E!=="/"&&!(g||w)&&l.exec("select-file",{type:"navigation"})}}else{if(R)break;if(E!=="/"){l.exec("select-file",{type:"navigation"});break}U=T.at(0)?.id}U&&l.exec("select-file",{id:U,toggle:g,range:w});break}case"arrowdown":case"arrowright":{const{_files:T,_selected:k,path:E,_selectNavigation:R}=p;let U;if(k.length){const F=k.at(-1).id,V=T.findIndex(_=>_.id===F);if(V!==-1){const _=V+1;T[_]&&(U=T[_].id)}}else{if(E!=="/"&&!R){l.exec("select-file",{type:"navigation"});break}U=T.at(0)?.id}U&&l.exec("select-file",{id:U,toggle:g,range:w});break}}}function c(u){const m=u.code.replace("Key","").toLowerCase();r(m,u),m=="tab"&&setTimeout(()=>{const p=document.activeElement;p.className.indexOf("table")!=-1&&l.exec("set-active-panel",{panel:+wj(p,"data-panel")})})}return n.addEventListener("keydown",c),{destroy:()=>{n.removeEventListener("keydown",c)}}}function Sj(n,a="data-id"){let l=n;for(!l.tagName&&n.target&&(l=n.target);l;){if(l.getAttribute&&l.getAttribute(a))return l;l=l.parentNode}return null}function jj(n,a="data-id"){const l=n.getAttribute(a);return l?Cj(l):null}function Cj(n){if(n.startsWith(":"))return n.substring(1);const a=n*1;return isNaN(a)?n:a}function kj(){return{detect:()=>!0,addEvent:function(n,a,l){return n.addEventListener(a,l),()=>n.removeEventListener(a,l)},addGlobalEvent:function(n,a){return document.addEventListener(n,a),()=>document.removeEventListener(n,a)},getTopNode:function(){return window.document.body}}}var Aj=kj();new Date().valueOf();function Zy(n){const[a,l]=f.useState(n),r=f.useRef(n);return f.useEffect(()=>{if(r.current!==n){if(Array.isArray(r.current)&&Array.isArray(n)&&r.current.length===0&&n.length===0)return;r.current=n,l(n)}},[n]),[a,l]}function Mj(n,a,l){const[r,c]=f.useState(()=>a);return n||console.warn(`Writable ${l} is not defined`),f.useEffect(()=>n?n.subscribe(m=>{c(()=>m)}):void 0,[n]),r}function Ze(n,a){const l=n.getState(),r=n.getReactiveState();return Mj(r[a],l[a],a)}function Nj(n,a){const l=f.useRef(a);l.current=a;const[r,c]=f.useState(1);return f.useEffect(()=>n.subscribe(m=>{l.current=m,c(p=>p+1)}),[n]),[l.current,r]}function Za(n,a){const l=n.getState(),r=n.getReactiveState();return Nj(r[a],l[a])}function Jy(n){const a={};return n.split(";").forEach(l=>{const[r,c]=l.split(":");if(c){let u=r.trim();u.indexOf("-")&&(u=u.replace(/-([a-z])/g,(m,p)=>p.toUpperCase())),a[u]=c.trim()}}),a}function ew(n){let a=n,l=[];return{subscribe:p=>{l.push(p),p(a)},unsubscribe:p=>{l=l.filter(v=>v!==p)},set:p=>{a=p,l.forEach(v=>v(a))},update:p=>{a=p(a),l.forEach(v=>v(a))}}}function jx(n,a,l){function r(c){const u=Sj(c);if(!u)return;const m=jj(u);if(typeof a=="function")return a(m,c);let p,v=c.target;for(;v!=u;){if(p=v.dataset?v.dataset.action:null,p&&a[p]){a[p](m,c);return}v=v.parentNode}a[l]&&a[l](m,c)}return Aj.addEvent(n,l,r)}function Tj(n,a){const l=[jx(n,a,"click")];return a.dblclick&&l.push(jx(n,a.dblclick,"dblclick")),()=>{l.forEach(r=>r())}}function tw(n,a){return n.map((l,r)=>{const c=a(l,r);return l.data&&l.data.length&&(c.data=tw(l.data,a)),c}).filter(Boolean)}function nw(n,a){const l=[];return n.forEach(r=>{if(r.data){const c=nw(r.data,a);c.length&&l.push({...r,data:c})}else a(r)&&l.push(r)}),l}function Ej(n){return tw(n,(a,l)=>{const r={...a,id:a.id||Ih()};return r.type&&(r.comp=r.type),r.comp==="separator"&&n[l-1]?.comp==="separator"?null:r})}const aw={};function Rj(n){return aw[n]||n}function Dj(n,a){aw[n]=a}function Lj({onClick:n,onShow:a,option:l}){const r=f.useRef(null),c=f.useCallback(()=>{a(l.data?l.id:!1,r.current)},[a,l]),u=f.useCallback(p=>{if(l.data){p.stopPropagation(),a(l.id,r.current);return}n(p)},[n,a,l]),m=f.useMemo(()=>l&&l.comp?Rj(l.comp):null,[l]);return i.jsxs("div",{ref:r,className:`wx-cDCz9rZQ wx-option ${l.css||""} ${l.disabled?"wx-disabled":""}`,"data-id":Sn(l.id),onMouseEnter:c,onClick:u,children:[l.icon?i.jsx("i",{className:`wx-cDCz9rZQ wx-icon ${l.icon}`}):null,l.comp?m?i.jsx(m,{item:l,option:l}):null:i.jsxs("span",{className:"wx-cDCz9rZQ wx-value",children:[" ",l.text," "]}),l.subtext?i.jsx("span",{className:"wx-cDCz9rZQ wx-subtext",children:l.subtext}):null,l.data?i.jsx("i",{className:"wx-cDCz9rZQ wx-sub-icon wxi-angle-right"}):null]})}function Gh({options:n,left:a=0,top:l=0,at:r="bottom",parent:c=null,mount:u=null,context:m=null,css:p="",onClick:v,onCancel:g}){const[w,y]=f.useState(-1e4),[b,j]=f.useState(-1e4),[C,A]=f.useState(20),[T,k]=f.useState(),E=f.useRef(null),[R,U]=f.useState(!1),[F,V]=f.useState(null),_=f.useCallback(()=>{const ee=Fy(E.current,c,r,a,l);ee&&(y(ee.x),j(ee.y),k(ee.width));let W=ee?.z??20;const z=c?b1(c):[];let Q=0;for(const X of z){const P=parseInt(getComputedStyle(X).zIndex,10);P>Q&&(Q=P)}Q>=W&&(W=Q+1),A(W)},[c,r,a,l]);f.useEffect(()=>{u&&u(_)},[]);const I=f.useCallback(()=>{U(!1)},[]),me=f.useCallback((ee,W)=>{U(ee),V(W)},[]),Y=f.useMemo(()=>Ej(n),[n]);f.useEffect(()=>{_()},[c,_]);const ue=f.useRef(v),K=f.useRef(g),ie=f.useRef(c);return f.useEffect(()=>{ue.current=v},[v]),f.useEffect(()=>{K.current=g},[g]),f.useEffect(()=>{ie.current=c},[c]),f.useEffect(()=>{if(!E.current)return;function ee(W){K.current?K.current(W):ue.current&&ue.current({action:null,option:null})}return Us(E.current,{callback:ee,modal:!0,parent:()=>ie.current}).destroy},[]),i.jsx("div",{ref:E,"data-wx-menu":"true",className:`wx-XMmAGqVx wx-menu ${p}`,style:{position:"absolute",top:b+"px",left:w+"px",width:T,zIndex:C},onMouseLeave:I,children:Y.map(ee=>i.jsxs(f.Fragment,{children:[ee.comp==="separator"?i.jsx("div",{className:"wx-XMmAGqVx wx-separator"}):i.jsx(Lj,{option:ee,onShow:me,onClick:W=>{if(!ee.data&&!W.defaultPrevented){const z={context:m,action:ee,option:ee,event:W};ee.handler&&ee.handler(z),v&&v(z),W.stopPropagation()}}}),ee.data&&R===ee.id?i.jsx(Gh,{css:p,options:ee.data,at:"right-overlap",parent:F,context:m,onClick:v,onCancel:g}):null]},ee.id))})}const sw=f.forwardRef(function(n,a){const{options:l,at:r="bottom",resolver:c=null,dataKey:u="contextId",filter:m=null,css:p="",children:v,onClick:g}=n,[w,y]=f.useState(null),[b,j]=f.useState(null),[C,A]=f.useState(0),[T,k]=f.useState(0),E=f.useRef(null),R=f.useMemo(()=>`data-${u.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`,[u]),U=f.useMemo(()=>w!==null&&m?nw(l,I=>m(I,w)):l,[w,m,l]);function F(I){j(null),g&&g(I)}function V(I){if(E.current===I){E.current=null;return}j(null),g&&g({action:null,option:null})}const _=f.useCallback((I,me)=>{if(!I){j(null);return}if(I.defaultPrevented)return;const Y=I.target;if(Y&&Y.dataset&&Y.dataset.menuIgnore)return;if(b&&b===Y){j(null),I.preventDefault();return}A(I.clientX+1),k(I.clientY+1);let ue=typeof me<"u"?me:Lc(Y,R);c&&(ue=c(ue,I),!ue)||(y(ue),j(Y),E.current=I.nativeEvent||I,I.preventDefault())},[b,R,c]);return f.useImperativeHandle(a,()=>({show:_}),[_]),i.jsxs(i.Fragment,{children:[v?i.jsx("span",{onClick:_,"data-menu-ignore":"true",children:typeof v=="function"?v():v}):null,b?i.jsx(Bh,{children:i.jsx(Gh,{css:p,at:r,top:T,left:C,parent:b,context:w,onClick:F,onCancel:V,options:U},b)}):null]})}),_j=f.forwardRef(function(n,a){const{options:l,at:r="bottom",css:c="",children:u,onClick:m}=n,[p,v]=f.useState(null),g=f.useRef(null);function w(C){v(null),m&&m(C)}function y(C){if(g.current===C){g.current=null;return}v(null),m&&m({action:null,option:null})}const b=f.useCallback(C=>{v(C.target),g.current=C.nativeEvent||C,C.preventDefault()},[]);f.useImperativeHandle(a,()=>({show:b}),[b]);function j(C){let A=C.target;for(;!A.dataset.menuIgnore;)v(A),A=A.parentNode}return i.jsxs(i.Fragment,{children:[i.jsx("span",{onClick:j,"data-menu-ignore":"true",children:u}),p?i.jsx(Bh,{children:i.jsx(Gh,{css:c,at:r,parent:p,options:l,onClick:w,onCancel:y})}):null]})}),zj=f.forwardRef(function(n,a){const{options:l,at:r="bottom",resolver:c=null,dataKey:u="contextId",filter:m=null,css:p="",children:v,onClick:g}=n,w=f.useRef(null),y=f.useCallback((b,j)=>{w.current.show(b,j)},[]);return f.useImperativeHandle(a,()=>({show:y}),[y]),i.jsxs(i.Fragment,{children:[v?i.jsx("span",{onContextMenu:y,"data-menu-ignore":"true",children:v}):null,i.jsx(sw,{css:p,at:r,options:l,resolver:c,dataKey:u,filter:m,ref:w,onClick:g})]})}),Ij={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 Oj=class{constructor(a,l,r,c,u){this.setFiles=a,this.setReady=l,this.setSignal=r,this.setDrag=c,u&&u.length&&this.setFiles(u)}open(a){this.setSignal(["click",a||{}])}getState(){let a="server";const l=this.files;for(let r=0;r<l.length;r++){if(l[r].status==="client")return"client";l[r].status==="error"&&(a="error")}return a}droparea(a,l){l=l||{};const r=()=>{l.dragEnter&&l.dragEnter(),this.setDrag(!0)},c=()=>{l.dragLeave&&l.dragLeave(),this.setDrag(!1)},u=p=>{p.preventDefault()},m=p=>{p.preventDefault(),this.setDrag(!1),this.setSignal(["drop",l,p]),l.dragLeave&&l.dragLeave(),l.drop&&l.drop()};return a.addEventListener("dragenter",r),a.addEventListener("dragleave",c),a.addEventListener("dragover",u,!0),a.addEventListener("drop",m,!0),()=>{a.removeEventListener("dragenter",r),a.removeEventListener("dragleave",c),a.removeEventListener("dragover",u,!0),a.removeEventListener("drop",m,!0)}}updateFile(a,l){const r=this.files.findIndex(u=>u.id===a);if(r===-1)return;const c=[...this.files];return c[r]={...c[r],...l},this.files=c,this.setFiles(this.files),this.files[r]}deleteFile(a){this.files=this.files.filter(l=>l.id!==a),this.setFiles(this.files)}addFile(a,l){l?this.files=[...this.files,a]:this.files=[a],this.setFiles(this.files)}deleteAll(){this.files=[],this.setFiles(this.files)}};function iw(n){const[a,l]=f.useState([]),[r,c]=f.useState(Promise.resolve(null)),[u,m]=f.useState(null),[p,v]=f.useState(!1),g=f.useRef();return g.current||(g.current=new Oj(l,c,m,v,n)),g.current.files=a,g.current.ready=r,g.current.signal=u,g.current.drag=p,g.current}function Bj(n,a){{if(n){const l=n.getGroup(a);if(l)return l}return zc(Ij).getGroup(a)}}const Fj=()=>Math.random().toString(36).substr(2,9),Hj=({data:n,accept:a="",multiple:l=!0,folder:r=!1,uploadURL:c="",apiOnly:u=!1,disabled:m=!1,children:p,onChange:v,onUpload:g})=>{const w=f.useRef(null),y=f.useRef(null),[b,j]=f.useState({}),C=iw(),A=n||C,T=f.useContext(Cn.i18n),k=Bj(T,"uploader");f.useEffect(()=>{w.current&&r&&(w.current.webkitdirectory=!0)},[r]),f.useEffect(()=>{if(!u&&y.current&&!m)return A.droparea(y.current)},[u,m,y]);const E=Y=>{const ue=new FormData;return ue.append("upload",Y.file),fetch(c,{method:"POST",body:ue}).then(K=>K.json()).then(K=>({id:Y.id,...K}),()=>({id:Y.id,status:"error"})).catch(K=>(console.log(K),{id:Y.id,status:"error"}))},R=(Y,ue)=>{const K=A.updateFile(Y,ue),ie={...K,status:A.getState()};K&&K.uploaded&&K.uploaded(ie),g&&g(ie),K.temp&&A.deleteFile(K.id)},U=Y=>{if(!Y)return;const ue=typeof c=="function"?c(Y):E(Y);A.setReady(ue.then(K=>{K.status=K.status||"server",R(Y.id,K)}).catch(K=>{R(Y.id,{status:"error",error:K})}))},F=(Y,ue)=>{const K={...ue||b,id:Fj(),status:"client",name:Y.name,file:Y};K.selected&&K.selected(K),v&&v(K),A.addFile(K,l),U(K),w.current&&(w.current.value="")},V=(Y,ue,K)=>{Y.isFile?Y.file(ie=>{F(ie,K)}):Y.isDirectory&&Y.createReader().readEntries(ie=>{ie.forEach(ee=>{V(ee,ue+ee.name+"/",K)})})},_=Y=>{Array.from(Y.target.files).forEach(ue=>F(ue))},I=(Y,ue)=>{Array.from(Y.dataTransfer.items).forEach(K=>{const ie=K.webkitGetAsEntry();ie&&V(ie,"",ue)})},me=()=>{w.current&&w.current.click()};return f.useEffect(()=>{if(A.signal){const[Y,ue,K]=A.signal;j(ue),Y==="click"?me():Y==="drop"&&I(K,ue),A.setSignal(null)}},[A.signal]),u?i.jsxs(i.Fragment,{children:[i.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:_,accept:a,multiple:l,disabled:m}),p]}):i.jsxs("div",{className:`wx-at1A8tb8 wx-label ${A.drag?"wx-active":""} ${m?"wx-disabled":""}`,ref:y,children:[i.jsx("input",{type:"file",className:"wx-at1A8tb8 wx-input",ref:w,onChange:_,accept:a,multiple:l,disabled:m}),p||i.jsx("div",{className:"wx-at1A8tb8 wx-dropzone",children:i.jsxs("span",{children:[k("Drop files here or")," ",i.jsx("span",{className:"wx-at1A8tb8 wx-action",onClick:me,children:k("select files")})]})})]})};new Date().valueOf();function Pj(n,a){if(Object.keys(n).length!==Object.keys(a).length)return!1;for(const l in a){const r=n[l],c=a[l];if(!Fd(r,c))return!1}return!0}function Fd(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 l=n.length-1;l>=0;l--)if(!Fd(n[l],a[l]))return!1;return!0}else return Pj(n,a);return n===a}function gh(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(n instanceof Array)return n.map(gh);const a={};for(const l in n)a[l]=gh(n[l]);return a}var lw=2,$j=class{constructor(n){n&&(this._writable=n.writable,this._async=n.async),this._values={},this._state={}}setState(n,a=0){const l={};return this._wrapProperties(n,this._state,this._values,"",l,a),l}getState(){return this._values}getReactive(){return this._state}_wrapProperties(n,a,l,r,c,u){for(const m in n){const p=a[m],v=l[m],g=n[m];if(p&&(v===g&&typeof g!="object"||g instanceof Date&&v instanceof Date&&v.getTime()===g.getTime()))continue;const w=r+(r?".":"")+m;p?(p.__parse(g,w,c,u)&&(l[m]=g),u&lw?c[w]=p.__trigger:p.__trigger()):(g&&g.__reactive?a[m]=this._wrapNested(g,g,w,c):a[m]=this._wrapWritable(g),l[m]=g),c[w]=c[w]||null}}_wrapNested(n,a,l,r){const c=this._wrapWritable(n);return this._wrapProperties(n,c,a,l,r,0),c.__parse=(u,m,p,v)=>(this._wrapProperties(u,c,a,m,p,v),!1),c}_wrapWritable(n){const a=[],l=function(){for(let r=0;r<a.length;r++)a[r](n)};return{subscribe:r=>(a.push(r),this._async?setTimeout(r,1,n):r(n),()=>{const c=a.indexOf(r);c>=0&&a.splice(c,1)}),__trigger:()=>{a.length&&(this._async?setTimeout(l,1):l())},__parse:function(r){return n=r,!0}}}},Uj=class{constructor(n,a,l,r){typeof n=="function"?this._setter=n:this._setter=n.setState.bind(n),this._routes=a,this._parsers=l,this._prev={},this._triggers=new Map,this._sources=new Map,this._routes.forEach(c=>{c.in.forEach(u=>{const m=this._triggers.get(u)||[];m.push(c),this._triggers.set(u,m)}),c.out.forEach(u=>{const m=this._sources.get(u)||{};c.in.forEach(p=>m[p]=!0),this._sources.set(u,m)})}),this._routes.forEach(c=>{c.length=Math.max(...c.in.map(u=>rw(u,this._sources,1)))}),this._bus=r}init(n){const a={};for(const l in n)if(this._prev[l]!==n[l]){const r=this._parsers[l];a[l]=r?r(n[l]):n[l]}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,lw);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 l=n.signals[a];l&&l()}}}setState(n,a=[]){const l=this._setter(n);return this._triggerUpdates(l,a),l}_triggerUpdates(n,a){const l=Object.keys(n),r=!a.length;a=a||[];for(let c=0;c<l.length;c++){const u=l[c],m=this._triggers.get(u);m&&m.forEach(p=>{a.indexOf(p)==-1&&a.push(p)})}r&&this._execNext(a)}_execNext(n){for(;n.length;){n.sort((l,r)=>l.length<r.length?1:-1);const a=n[n.length-1];n.splice(n.length-1),a.exec(n)}}};function rw(n,a,l){const r=a.get(n);if(!r)return l;const c=Object.keys(r).map(u=>rw(u,a,l+1));return Math.max(...c)}var qj=class{constructor(){this._nextHandler=null,this._handlers={},this._tag=new WeakMap,this.exec=this.exec.bind(this)}on(n,a,l){let r=this._handlers[n];r?l&&l.intercept?r.unshift(a):r.push(a):r=this._handlers[n]=[a],l&&l.tag&&this._tag.set(a,l.tag)}intercept(n,a,l){this.on(n,a,{...l,intercept:!0})}detach(n){for(const a in this._handlers){const l=this._handlers[a];for(let r=l.length-1;r>=0;r--)this._tag.get(l[r])===n&&l.splice(r,1)}}async exec(n,a){const l=this._handlers[n];if(l)for(let r=0;r<l.length;r++){const c=l[r](a);if(c===!1||c&&c.then&&await c===!1)return}return this._nextHandler&&await this._nextHandler.exec(n,a),a}setNext(n){return this._nextHandler=n}};function Gj(n){return a=>a[n]}function Vj(n){return(a,l)=>a[n]=l}function kl(n,a){return(a.getter||Gj(a.id))(n)}function Bm(n,a,l){return(a.setter||Vj(a.id))(n,l)}function Yj(n,a){const l=document.createElement("a");l.href=URL.createObjectURL(n),l.download=a,document.body.appendChild(l),l.click(),document.body.removeChild(l)}function Cl(n,a){let l=kl(n,a)??"";return a.template?l=a.template(l,n,a):a.optionsMap&&(Array.isArray(l)?l=l.map(r=>a.optionsMap.get(r)).join(", "):l=a.optionsMap.get(l)),typeof l>"u"?"":l+""}function Wj(n,a){const l=/\n|"|;|,/;let r="";const c=a.rows||`
11
+ `,u=a.cols||" ",m=n._columns,p=n.flatData;a.header!==!1&&m[0].header&&(r=Cx("header",m,r,u,c));for(let v=0;v<p.length;v++){const g=[];for(let w=0;w<m.length;w++){let y=Cl(p[v],m[w]);l.test(y)&&(y='"'+y.replace(/"/g,'""')+'"'),g.push(y)}r+=(r?c:"")+g.join(u)}return a.footer!==!1&&m[0].footer&&(r=Cx("footer",m,r,u,c)),r}function Cx(n,a,l,r,c){const u=/\n|"|;|,/;for(let m=0;m<a[0][n].length;m++){const p=[];for(let v=0;v<a.length;v++){let g=(a[v][n][m].text||"")+"";u.test(g)&&(g='"'+g.replace(/"/g,'""')+'"'),p.push(g)}l+=(l?c:"")+p.join(r)}return l}const Kj="portrait",Qj=100,Xj="a4",Zj={a3:{width:11.7,height:16.5},a4:{width:8.27,height:11.7},letter:{width:8.5,height:11}};function Jj(n,a){const l=[];let r=[],c=0;const u=n.filter(p=>!p.hidden),m=eC(a);return u.forEach((p,v)=>{c+p.width<=m?(c+=p.width,r.push(p)):(r.length&&l.push(r),r=[p],c=p.width),v===u.length-1&&r.length&&l.push(r)}),l}function kx(n,a,l){const r=[];return n.forEach((c,u)=>{const m=c[a];for(let p=0;p<l.length;p++){r[p]||(r[p]=[]);const v={...m[p]};if(r[p][u]!==null){if(!u&&!v.rowspan&&!v.colspan){let g=1,w=n[u+g][a][p],y=v.width;for(;!w.rowspan&&!w.colspan;)g++,w=n[u+g][a][p],y+=w.width;v.colspan=g,v.width=y,v.height=l[p]}if(r[p].push(v),!v.collapsed&&v.colspan>1){let g=v.colspan-1;if(v.colspan+u>n.length){const w=v.colspan-(v.colspan+u-n.length);v.colspan=w,v.width=n.slice(u,u+g+1).reduce((y,b)=>y+b.width,0),w>1&&(g=w-1)}for(let w=0;w<g;w++)r[p].push(null)}if(v.rowspan>1){const g=v.rowspan;for(let w=1;w<g;w++)r[p+w]||(r[p+w]=[]),r[p+w].push(null)}}}if(c.collapsed)for(let p=0;p<r.length;p++){const v=r[p],g=v[u];if(g&&g.collapsed){if(v[u]=null,!p)break}else{const w=g||v.findLast(y=>y?.colspan>=1);w&&(w.colspan=w.colspan-1,w.width=w.width-c.width)}}}),r.map(c=>c.filter(u=>u&&u.colspan!==0))}function eC(n){const{mode:a,ppi:l,paper:r}=n,{width:c,height:u}=Zj[r];return tC(a==="portrait"?c:u,l)}function tC(n,a){return n*a}function nC(n={}){const{mode:a,ppi:l,paper:r}=n;return{mode:a||Kj,ppi:l||Qj,paper:r||Xj}}function ow(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 aC(n,a,l){let r=n[l.id];if(l.filter.type==="richselect"&&r){const c=l.filter.config?.options||a.find(({id:u})=>u==l.id).options;c&&(r=c.find(({id:u})=>u==r).label)}return r??""}const Ax=["resize-column","hide-column","update-cell"],sC=["delete-row","update-row","update-cell"],iC=["move-item"],lC=["resize-column","move-item"];class rC{undo=[];redo=[];progress={};in;getState;setState;_previousValues={};constructor(a,l,r){this.in=a,this.getState=l,this.setState=r,this.setHandlers(),this.resetStateHistory()}getHandlers(){return{"add-row":{handler:a=>({action:"delete-row",data:{id:a.id},source:{action:"add-row",data:a}})},"delete-row":{handler:a=>{const{id:l}=a,{data:r}=this.getPrev(),c=r.findIndex(u=>u.id===l);return{action:"add-row",data:{id:l,row:r[c],before:c<r.length-1?r[c+1].id:void 0},source:{action:"delete-row",data:a}}}},"update-cell":{handler:a=>{const{id:l,column:r}=a,c=this.getRow(l),u=this.getColumn(r),m=kl(c,u);return Fd(m,a.value)?null:{action:"update-cell",data:{id:l,column:r,value:m},source:{action:"update-cell",data:a}}}},"update-row":{handler:a=>{const{id:l,row:r}=a,c=this.getRow(l);for(const u in r)Object.keys(c).includes(u)||(c[u]=void 0);return{action:"update-row",data:{id:l,row:c},source:{action:"update-row",data:a}}}},"copy-row":{handler:a=>{const{id:l}=a,{data:r}=this.getState(),c=r.findIndex(m=>m.id===l),u=r[c];return{action:"delete-row",data:{id:l},source:{action:"add-row",data:{id:l,row:u,before:c<r.length-1?r[c+1].id:void 0}}}}},"resize-column":{handler:a=>{const{id:l,width:r}=a,c=this.getColumn(l),{_sizes:u}=this.getState();return{action:"resize-column",data:{id:l,width:c.width??u.columnWidth},source:{action:"resize-column",data:{id:l,width:r}}}}},"hide-column":{handler:a=>{const{id:l}=a,r=this.getColumn(l);return{action:"hide-column",data:{id:l,mode:r.hidden},source:{action:"hide-column",data:a}}}},"collapse-column":{handler:a=>{const{id:l,row:r,mode:c}=a;return{action:"collapse-column",data:{id:l,row:r,mode:typeof c=="boolean"?!c:c},source:{action:"collapse-column",data:a}}}},"move-item":{handler:a=>{const{id:l,target:r,mode:c}=a,{flatData:u}=this.getPrev(),m=u.findIndex(p=>p.id===l);return{action:"move-item",data:{id:l,target:u[m+(m?-1:1)].id,mode:m?"after":"before"},source:{action:"move-item",data:{id:l,target:r,mode:c}}}}},"open-row":{handler:a=>{const{id:l,nested:r}=a;return{action:"close-row",data:{id:l,nested:r},source:{action:"open-row",data:a}}}},"close-row":{handler:a=>{const{id:l,nested:r}=a;return{action:"open-row",data:{id:l,nested:r},source:{action:"close-row",data:a}}}}}}resetHistory(){this.undo=[],this.redo=[],this.progress={},this.resetStateHistory()}getPrev(){return this._previousValues}setHandlers(){const a=this.getHandlers();for(const l in a)this.in.intercept(l,r=>{if(!(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo)){if(lC.includes(l)){(r.inProgress&&!this.progress[l]||typeof r.inProgress!="boolean")&&(iC.includes(l)&&this.setPrev("flatData"),Ax.includes(l)&&this.setPrev("columns")),this.progress[l]=r.inProgress;return}sC.includes(l)&&this.setPrev("data"),Ax.includes(l)&&this.setPrev("columns")}}),this.in.on(l,r=>{if(r.eventSource==="undo"||r.eventSource==="redo"||r.skipUndo||r.inProgress)return;const c=a[l].handler(r);c&&this.addToHistory(c)})}setPrev(a){this._previousValues[a]=gh(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:l}=this.getPrev();return this.getState().tree?this.getTreeRow(l,a):l.find(r=>r.id===a)}getTreeRow(a,l){for(let r=0;r<a.length;r++){if(a[r].id===l)return a[r];if(a[r].data){const c=this.getTreeRow(a[r].data,l);if(c)return c}}return null}getColumn(a){const{columns:l}=this.getPrev();return l.find(r=>r.id===a)}}function cw(n,a){return typeof n>"u"||n===null?-1:typeof a>"u"||a===null?1:n===a?0:n>a?1:-1}function oC(n,a){return-cw(n,a)}function cC(n,a){if(typeof a.sort=="function")return function(r,c){const u=a.sort(r,c);return n==="asc"?u:-u};const l=n==="asc"?cw:oC;return function(r,c){return l(kl(r,a),kl(c,a))}}function uC(n,a){if(!n||!n.length)return;const l=n.map(r=>{const c=a.find(u=>u.id==r.key);return cC(r.order,c)});return n.length===1?l[0]:function(r,c){for(let u=0;u<l.length;u++){const m=l[u](r,c);if(m!==0)return m}return 0}}const id=28,dC=20;function fC(){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 Ed(n,a,l,r,c){const u=document.createElement("div"),m=document.createElement("div"),p=document.body;c=c?`${c}px`:"auto";let v,g;m.className=a,u.classList.add(`wx-${l}-theme`),u.style.cssText=`height:auto;position:absolute;top:0px;left:100px;overflow:hidden;width=${c};white-space:nowrap;`,u.appendChild(m),p.appendChild(u),typeof n!="object"&&(n=[n]);for(let w=0;w<n.length;w++){m.innerText=n[w]+"";const y=u.getBoundingClientRect(),b=Math.ceil(y.width)+(r&&r.length?r[w]:0),j=Math.ceil(y.height);v=Math.max(v||0,b),g=Math.max(g||0,j)}return u.remove(),{width:v,height:g}}function Mx(n,a,l,r,c){const u=[];for(let m=0;m<n.length;m++){const p=n[m][a],v=p.length;for(let g=0;g<v;g++){const{text:w,vertical:y,collapsed:b,rowspan:j,css:C}=p[g];if(!w){u[g]=Math.max(u[g]||0,r);continue}let A=0;if(y&&!b){let T=`wx-measure-cell-${a}`;if(T+=C?` ${C}`:"",A=Ed(w,T,c).width,(j>1||!p[g+1])&&l>g+1){const k=j||l-g,E=u.slice(g,g+k).reduce((R,U)=>R+U,0);if(E<A){const R=Math.ceil((A-E)/k);for(let U=g;U<g+k;U++)u[U]=(u[U]||r)+R}continue}}u[g]=Math.max(u[g]||r,A)}}return u}function mC(n,a,l){const r=[],c=[];let u="wx-measure-cell-body";u+=n.css?` ${n.css}`:"";for(let m=0;m<a.length;m++){const p=a[m],v=Cl(p,n);v&&(r.push(v),n.treetoggle?c.push(a[m].$level*id+(a[m].$count?id:0)+(n.draggable?id:0)):n.draggable&&c.push(id))}return Ed(r,u,l,c).width}function hC(n,a){const l="wx-measure-cell-header",r=n.sort?dC:0;let c=n.header;if(typeof c=="string")return Ed(c,l,a).width+r;let u;Array.isArray(c)||(c=[c]);for(let m=0;m<c.length;m++){const p=c[m],v=typeof p=="string"?p:p.text,g=l+(typeof p=="string"?"":` ${p.css}`);let w=Ed(v,g,a).width;m===c.length-1&&(w+=r),u=Math.max(u||0,w)}return u}const pC={text:(n,a)=>n?n.toString().toLowerCase().indexOf(a.toLowerCase())!==-1:!a,richselect:(n,a)=>typeof a!="number"&&!a?!0:n==a,datepicker:(n,a)=>a?n&&vC(n,a):!0,multiselect:(n,a)=>!a||a?.length===0?!0:Array.isArray(n)?n?.some(l=>a.includes(l)):n&&a.includes(n)};function uw(n){return pC[n]}function gC(n,a){const l=[];for(const r in n){const c=a.find(v=>v.id==r),{config:u,type:m}=c.header.find(v=>v.filter).filter,p=n[r];l.push(v=>{const g=kl(v,c);return u?.handler?u.handler(g,p):uw(m)(g,p)})}return r=>{for(let c=0;c<l.length;c++)if(!l[c](r))return!1;return!0}}function vC(n,a){return n.getFullYear()===a.getFullYear()&&n.getMonth()===a.getMonth()&&n.getDate()===a.getDate()}let xC=class extends $j{in;_router;_branches;_xlsxWorker;_historyManager;constructor(a){super({writable:a,async:!1});const l={rowHeight:37,columnWidth:160,headerHeight:36,footerHeight:36};this._router=new Uj(super.setState.bind(this),[{in:["columns","sizes","_skin"],out:["_columns","_sizes"],exec:c=>{const{columns:u,sizes:m,_skin:p}=this.getState(),v=this.copyColumns(u),g=v.reduce((b,j)=>Math.max(j.header.length,b),0),w=v.reduce((b,j)=>Math.max(j.footer.length,b),0);v.forEach(this.setCollapsibleColumns);const y=this.normalizeSizes(v,m,g,w,p);for(let b=0;b<v.length;b++)this.normalizeColumns(v,b,"header",g,y),this.normalizeColumns(v,b,"footer",w,y);this.setState({_columns:v,_sizes:y},c)}},{in:["data","tree","_filterIds"],out:["flatData","_rowHeightFromData"],exec:c=>{const{data:u,tree:m,dynamic:p,_filterIds:v}=this.getState(),g=v&&new Set(v),w=m?this.flattenRows(u,[],v):g?u.filter(b=>g.has(b.id)):u,y=!p&&w.some(b=>b.rowHeight);this.setState({flatData:w,_rowHeightFromData:y},c)}}],{sizes:c=>({...l,...c})});const r=this.in=new qj;r.on("close-editor",({ignore:c})=>{const{editor:u}=this.getState();u&&(c||r.exec("update-cell",u),this.setState({editor:null}))}),r.on("open-editor",({id:c,column:u})=>{let m=this.getState().editor;m&&r.exec("close-editor",{});const p=this.getRow(c),v=u?this.getColumn(u):this.getNextEditor(p);if(v?.editor){let g=v.editor;if(typeof g=="function"&&(g=g(p,v)),!g)return;m={column:v.id,id:c,value:kl(p,v)??"",renderedValue:Cl(p,v),type:g.type||g},typeof g=="object"&&g.config&&(m.config=g.config,g.config.options&&(m.options=g.config.options)),v.options&&!m.options&&(m.options=v.options),this.setState({editor:m})}}),r.on("editor",({value:c})=>{let u=this.getState().editor;if(u){u={...u},u.value=c;const m=this.getColumn(u.column),p={...this.getRow(u.id)};Bm(p,m,c),u.renderedValue=Cl(p,m),this.setState({editor:u})}}),r.on("add-row",c=>{const u=this.getState();let{data:m}=u;const{select:p,_filterIds:v}=u,{row:g,before:w,after:y,select:b}=c;if(c.id=g.id=c.id||g.id||ld(),w||y){const C=w||y,A=m.findIndex(T=>T.id===C);m=[...m],m.splice(A+(y?1:0),0,c.row)}else m=[...m,c.row];const j={data:m};v&&(j._filterIds=[...v,c.id]),this.setState(j),!(typeof b=="boolean"&&!b)&&(b||p)&&r.exec("select-row",{id:g.id,show:!0})}),r.on("delete-row",c=>{const{data:u,selectedRows:m,focusCell:p,editor:v}=this.getState(),{id:g}=c,w={data:u.filter(y=>y.id!==g)};this.isSelected(g)&&(w.selectedRows=m.filter(y=>y!==g)),v?.id===g&&(w.editor=null),this.setState(w),p?.row===g&&this.in.exec("focus-cell",{eventSource:"delete-row"})}),r.on("update-cell",c=>{const u=this.getState();let{data:m}=u;m=[...m];const{tree:p}=u,{id:v,column:g,value:w}=c,y=this.getColumn(g);if(p){const b={...this._branches[v]};Bm(b,y,w);const j=this.updateTreeRow(b);b.$parent===0&&(m=j)}else{const b=m.findIndex(C=>C.id===v),j={...m[b]};Bm(j,y,w),m[b]=j}this.setState({data:m})}),r.on("update-row",c=>{let{data:u}=this.getState();const{id:m,row:p}=c,v=u.findIndex(g=>g.id===m);u=[...u],u[v]={...u[v],...p},this.setState({data:u})}),r.on("select-row",({id:c,toggle:u,range:m,mode:p,show:v,column:g})=>{const w=this.getState(),{focusCell:y}=w;let{selectedRows:b}=w;if(b.length||(m=u=!1),m){const{data:j}=this.getState();let C=j.findIndex(T=>T.id===b[b.length-1]),A=j.findIndex(T=>T.id===c);C>A&&([C,A]=[A,C]),j.slice(C,A+1).forEach(T=>{this.isSelected(T.id)||b.push(T.id)})}else if(u&&this.isSelected(c)){if(p===!0)return;b=b.filter(j=>j!==c)}else if(u){if(p===!1)return;b.push(c)}else b=[c];this.setState({selectedRows:[...b]}),y?.row!==c&&this.in.exec("focus-cell",{eventSource:"select-row"}),v&&this.in.exec("scroll",{row:c,column:g})}),this.in.on("focus-cell",c=>{const{row:u,column:m,eventSource:p}=c,{_columns:v,split:g}=this.getState();u&&m?(this.setState({focusCell:{row:u,column:m}}),p!=="click"&&((!g.left||v.findIndex(w=>w.id===c.column)>=g.left)&&(!g.right||v.findIndex(w=>w.id===c.column)<v.length-g.right)?this.in.exec("scroll",{row:u,column:m}):this.in.exec("scroll",{row:u}))):this.setState({focusCell:null})}),r.on("resize-column",c=>{const{id:u,auto:m,maxRows:p,inProgress:v}=c;if(v===!1)return;let g=c.width||0;const w=[...this.getState().columns],y=this.getColumn(u);if(m){if(m==="data"||m===!0){const{flatData:b,_skin:j}=this.getState();let C=b.length;p&&(C=Math.min(p,C));const A=b.slice(0,C);g=mC(y,A,j)}if(m==="header"||m===!0){const{_skin:b}=this.getState();g=Math.max(hC(y,b),g)}}y.width=Math.max(17,g),delete y.flexgrow,this.setState({columns:w})}),r.on("hide-column",c=>{const{id:u,mode:m}=c,p=[...this.getState().columns],v=this.getColumn(u),g=p.reduce((w,y)=>w+(y.hidden?0:1),0);!m||g>1?(v.hidden=!v.hidden,this.setState({columns:p})):c.skipUndo=!0}),r.on("sort-rows",c=>{const{key:u,add:m,sort:p}=c,v=this.getState(),{columns:g,data:w,tree:y}=v;if(p){const E=[...w];E.sort(p),this.setState({data:E});return}const{order:b="asc"}=c;let j=v.sortMarks;const C=Object.keys(j),A=C.length;!m||!A||A===1&&j[u]?j={[u]:{order:b}}:(A===1&&(j[C[0]]={...j[C[0]],index:0}),j={...j,[u]:{order:b,index:typeof m=="number"?m:j[u]?.index??A}});const T=Object.keys(j).sort((E,R)=>j[E].index-j[R].index).map(E=>({key:E,order:j[E].order}));this.setState({sortMarks:j});const k=uC(T,g);if(k){const E=[...w];y?this.sortTree(E,k):E.sort(k),this.setState({data:E})}}),r.on("filter-rows",c=>{const{value:u,key:m,filter:p}=c;if(!Object.keys(c).length){this.setState({filterValues:{},_filterIds:null});return}const v=this.getState(),{data:g,tree:w,_columns:y}=v;let b=v.filterValues;const j={};m&&(b={...b,[m]:u},j.filterValues=b);const C=p??gC(b,y);let A=[];w?A=this.filterTree(g,C,A):g.forEach(T=>{C(T)&&A.push(T.id)}),j._filterIds=A,this.setState(j)}),r.on("collapse-column",c=>{const{id:u,row:m,mode:p}=c,v=[...this.getState().columns],g=this.getColumn(u).header,w=Array.isArray(g)?g[m]:g;typeof w=="object"&&(w.collapsed=p??!w.collapsed,this.setState({columns:v}))}),r.on("move-item",c=>{const{id:u,inProgress:m}=c;let{target:p,mode:v="after"}=c;const{data:g,flatData:w,tree:y}=this.getState(),b=w.findIndex(A=>A.id===u);let j;if(v==="up"||v==="down"){if(v==="up"){if(b===0)return;j=b-1,v="before"}else if(v==="down"){if(b===w.length-1)return;j=b+1,v="after"}p=w[j]&&w[j].id}else j=w.findIndex(A=>A.id===p);if(b===-1||j===-1||m===!1)return;let C;y||(C=this.moveItem(u,p,g,v)),this.setState({data:y?this.normalizeTreeRows(C):C})}),r.on("copy-row",c=>{const{id:u,target:m,mode:p="after"}=c,v=this.getState(),{flatData:g,_filterIds:w}=v;let{data:y}=v;const b=this.getRow(u);if(!b)return;const j={...b,id:ld()};c.id=j.id;const C=g.findIndex(T=>T.id===m);if(C===-1)return;y.splice(C+(p==="after"?1:0),0,j),y=[...y];const A={data:y};w&&(A._filterIds=[...w,j.id]),this.setState(A)}),r.on("open-row",c=>{const{id:u,nested:m}=c;this.toggleBranch(u,!0,m)}),r.on("close-row",c=>{const{id:u,nested:m}=c;this.toggleBranch(u,!1,m)}),r.on("export-data",c=>new Promise((u,m)=>{const p=c.format||"csv",v=`${c.fileName||"data"}.${p}`;if(p==="csv"){const g=Wj(this.getState(),c.csv||{});c.download!==!1?Yj(new Blob(["\uFEFF"+g],{type:"text/csv"}),v):c.result=g,u(!0)}else m()})),r.on("hotkey",({key:c,event:u,isInput:m})=>{switch(c){case"arrowup":{const{flatData:p,focusCell:v,select:g}=this.getState();if(u.preventDefault(),m)return;const w=v?v.column:this._getFirstVisibleColumn()?.id,y=v?this.getPrevRow(v.row)?.id:p[p.length-1]?.id;w&&y&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:y}));break}case"arrowdown":{const{flatData:p,focusCell:v,select:g}=this.getState();if(u.preventDefault(),m)return;const w=v?v.column:this._getFirstVisibleColumn()?.id,y=v?this.getNextRow(v.row)?.id:p[0]?.id;w&&y&&(this.in.exec("focus-cell",{row:y,column:w,eventSource:"key"}),g&&this.in.exec("select-row",{id:y}));break}case"arrowright":{const{focusCell:p}=this.getState();if(m)return;if(u.preventDefault(),p){const v=this.getNextColumn(p.column,!0)?.id;v&&this.in.exec("focus-cell",{row:p.row,column:v,eventSource:"key"})}break}case"arrowleft":{const{focusCell:p}=this.getState();if(m)return;if(u.preventDefault(),p){const v=this.getPrevColumn(p.column,!0)?.id;v&&this.in.exec("focus-cell",{row:p.row,column:v,eventSource:"key"})}break}case"tab":{const{editor:p,focusCell:v,select:g}=this.getState();if(p){u.preventDefault();const w=p.column;let y=p.id,b=this.getNextEditor(this.getRow(y),this.getColumn(w));if(!b){const j=this.getNextRow(y);j&&(y=j.id,b=this.getNextEditor(j))}b&&(this.in.exec("open-editor",{id:y,column:b.id}),this.in.exec("focus-cell",{row:y,column:b.id,eventSource:"key"}),g&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else v&&this.in.exec("focus-cell",{eventSource:"key"});break}case"shift+tab":{const{editor:p,focusCell:v,select:g}=this.getState();if(p){u.preventDefault();const w=p.column;let y=p.id,b=this.getPrevEditor(this.getRow(y),this.getColumn(w));if(!b){const j=this.getPrevRow(y);j&&(y=j.id,b=this.getPrevEditor(j))}b&&(this.in.exec("open-editor",{id:y,column:b.id}),this.in.exec("focus-cell",{row:y,column:b.id,eventSource:"key"}),g&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}else v&&this.in.exec("focus-cell",{eventSource:"key"});break}case"escape":{const{editor:p}=this.getState();p&&(this.in.exec("close-editor",{ignore:p.type!="multiselect"}),this.in.exec("focus-cell",{row:p.id,column:p.column,eventSource:"key"}));break}case"f2":{const{editor:p,focusCell:v}=this.getState();!p&&v&&this.in.exec("open-editor",{id:v.row,column:v.column});break}case"enter":{const{focusCell:p,tree:v}=this.getState();if(!m&&v&&p&&this.getColumn(p.column).treetoggle){const g=this.getRow(p.row);if(!g.data)return;this.in.exec(g.open?"close-row":"open-row",{id:p.row,nested:!0})}break}case"home":{const{editor:p,focusCell:v}=this.getState();if(!p&&v){u.preventDefault();const g=this._getFirstVisibleColumn()?.id;this.in.exec("focus-cell",{row:v.row,column:g,eventSource:"key"})}break}case"ctrl+home":{const{editor:p,focusCell:v,flatData:g,select:w}=this.getState();if(!p&&v){u.preventDefault();const y=g[0]?.id,b=this._getFirstVisibleColumn()?.id;y&&b&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),w&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"end":{const{editor:p,focusCell:v}=this.getState();if(!p&&v){u.preventDefault();const g=this._getLastVisibleColumn()?.id,w=v.row;this.in.exec("focus-cell",{row:w,column:g,eventSource:"key"})}break}case"ctrl+end":{const{editor:p,focusCell:v,flatData:g,select:w}=this.getState();if(!p&&v){u.preventDefault();const y=g.at(-1).id,b=this._getLastVisibleColumn()?.id;y&&b&&(this.in.exec("focus-cell",{row:y,column:b,eventSource:"key"}),w&&!this.isSelected(y)&&this.in.exec("select-row",{id:y}))}break}case"ctrl+z":{this.in.exec("undo",{});break}case"ctrl+y":{this.in.exec("redo",{});break}}}),r.on("scroll",c=>{const{_columns:u,split:m,_sizes:p,flatData:v,dynamic:g,_rowHeightFromData:w}=this.getState();let y=-1,b=-1,j=0,C=0;if(c.column){y=0;const A=u.findIndex(T=>T.id===c.column);j=u[A].width;for(let T=m.left??0;T<A;T++){const k=u[T];k.hidden||(y+=k.width)}}if(c.row&&!g){const A=v.findIndex(T=>T.id===c.row);A>=0&&(w?(b=v.slice(0,A).reduce((T,k)=>T+(k.rowHeight||p.rowHeight),0),C=v[A].rowHeight):b=p.rowHeight*A)}this.setState({scroll:{top:b,left:y,width:j,height:C||p.rowHeight}})}),r.on("scroll-to",c=>{const u={};c.top!==void 0&&(u.scrollTop=c.top),c.left!==void 0&&(u.scrollLeft=c.left),Object.keys(u).length&&this.setState(u)}),r.on("print",c=>{const u=nC(c);this.setState({_print:u}),this.setStateAsync({_print:null})}),r.on("undo",()=>{this._historyManager?.handleUndo()}),r.on("redo",()=>{this._historyManager?.handleRedo()}),this.initOnce()}getXlsxWorker(a){if(!this._xlsxWorker){const l=window.URL.createObjectURL(new Blob([`importScripts('${a}');`],{type:"text/javascript"}));this._xlsxWorker=new Promise(r=>{const c=new Worker(l);c.addEventListener("message",u=>{u.data.type==="init"&&r(c)})})}return this._xlsxWorker}initOnce(){const a={sortMarks:{},_filterIds:null,data:[],filterValues:{},scroll:null,scrollLeft:0,scrollTop:0,editor:null,focusCell:null,_print:null,history:{undo:0,redo:0},search:null};this._router.init(a)}init(a){a.hasOwnProperty("_skin")&&!a._skin&&(a._skin=fC()),a.columns&&a.columns.forEach(l=>{l.options&&(l.optionsMap=new Map(l.options.map(r=>[r.id,r.label])))}),Fd(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 rC(this.in,this.getState.bind(this),this.setState.bind(this))),this._router.init({...a})}setState(a,l){return this._router.setState(a,l)}setStateAsync(a){this._router.setStateAsync(a)}getRow(a){const{tree:l}=this.getState();return l?this._branches[a]:this.getState().data.find(r=>r.id===a)}getRowIndex(a,l){return l||(l=this.getState().flatData),l.findIndex(r=>r.id===a)}getNextRow(a){const l=this.getState().flatData,r=this.getRowIndex(a,l);return l[r+1]}getPrevRow(a){const l=this.getState().flatData,r=this.getRowIndex(a,l);return l[r-1]}getColumn(a){return this.getState().columns.find(l=>l.id===a)}getNextColumn(a,l){const r=this.getState()._columns,c=r.findIndex(u=>u.id===a);return l?this._getFirstVisibleColumn(c+1):r[c+1]}getPrevColumn(a,l){const r=this.getState()._columns,c=r.findIndex(u=>u.id===a);return l?this._getLastVisibleColumn(c-1):r[c-1]}_getFirstVisibleColumn(a){const l=this.getState()._columns;let r=a??0;for(;r<l.length&&(l[r]?.hidden||l[r]?.collapsed);)r++;return l[r]}_getLastVisibleColumn(a){const l=this.getState()._columns;let r=a??l.length-1;for(;r<l.length&&(l[r]?.hidden||l[r]?.collapsed);)r--;return l[r]}isCellEditable(a,l){const{editor:r,hidden:c}=l;return!r||c?!1:typeof r=="function"?r(a,l):!0}getNextEditor(a,l){let r=this.getState().columns;if(l){const c=r.findIndex(u=>u.id===l.id);r=r.slice(c+1)}return r.find(c=>this.isCellEditable(a,c))}getPrevEditor(a,l){let r=this.getState().columns;if(l){const c=r.findLastIndex(u=>u.id===l.id);r=r.slice(0,c)}return r.findLast(c=>this.isCellEditable(a,c))}toggleBranch(a,l,r){let c=this._branches[a],{data:u}=this.getState();if(u=[...u],a!==0){c={...c,open:l};const m=this.updateTreeRow(c);c.$parent===0&&(u=m)}r&&c.data?.length&&c.data.forEach(m=>{const p=this.toggleKids(m,l,r);a===0&&(u=p)}),this.setState({data:u})}toggleKids(a,l,r){a={...a,open:l};const c=this.updateTreeRow(a);return r&&a.data?.length&&a.data.forEach(u=>{this.toggleKids(u,l,r)}),c}updateTreeRow(a){const l=a.id;this._branches[l]=a;const r=this._branches[a.$parent],c=r.data.findIndex(u=>u.id===l);return r.data=[...r.data],r.data[c]=a,r.data}isSelected(a){return this.getState().selectedRows.indexOf(a)!==-1}findAndRemove(a,l){for(let r=0;r<a.length;r++){if(a[r].id===l)return a.splice(r,1)[0];if(a[r].data){const c=[...a[r].data],u=this.findAndRemove(c,l);if(u)return a[r]={...a[r],data:c},u}}return null}insertItem(a,l,r,c){for(let u=0;u<a.length;u++){if(a[u].id===l){const m=a[u],p=c==="before"?u:u+1;if(m.data){if(c==="before"){const v=u>0?a[u-1]:null;return v?.data&&v.open?a[u-1]={...v,data:[...v.data,r]}:a.splice(p,0,r),!0}else if(m.open)return a[u]={...m,data:[r,...m.data]},!0}return a.splice(p,0,r),!0}if(a[u].data&&(a[u]={...a[u],data:[...a[u].data]},this.insertItem(a[u].data,l,r,c)))return!0}return!1}moveItem(a,l,r,c){const u=[...r],m=this.findAndRemove(u,a);return this.insertItem(u,l,m,c),u}copyColumns(a){const l=[];for(let r=0;r<a.length;r++){const c={...a[r]};this.copyHeaderFooter(c,"header"),this.copyHeaderFooter(c,"footer"),l[r]=c}return l}copyHeaderFooter(a,l){let r=a[l];r=Array.isArray(r)?[...r]:[r],r.forEach((c,u)=>{r[u]=typeof c=="string"?{text:c}:{...c}}),a[l]=r}setCollapsibleColumns(a,l,r){let c=a.header;for(let u=0;u<c.length;u++){const m=c[u];if(m.collapsible&&m.collapsed){if(m.collapsible!=="first"){a.collapsed=!0,a.width=36,m.vertical=!0;const v=c.length-u;c=c.slice(0,u+1),c[u].rowspan=v}const p=m.colspan;if(p){const v=c[u+1];let g=1;v&&v.colspan&&!v.collapsed&&(g=v.colspan);for(let w=g;w<p;w++){const y=r[l+w];y&&(y.hidden=!0)}}}}}normalizeColumns(a,l,r,c,u){const m=a[l];m.width||(m.width=m.flexgrow?17:u.columnWidth),m._colindex=l+1;const p=m[r],v=u[`${r}RowHeights`];for(let g=0;g<c;g++){const w=p[g];w.id=m.id,g===p.length-1&&(w.rowspan=w.rowspan?Math.min(w.rowspan,c-g):c-g);for(let y=1;y<w.rowspan;y++){p.splice(g+y,0,{_hidden:!0});for(let b=1;b<w.colspan;b++)a[l+b][r].splice(g+y,0,{})}if(w.rowspan){const y=(w.rowspan===c?v:v.slice(g,w.rowspan+g)).reduce((b,j)=>b+j,0);w.height=y,g+w.rowspan!=c&&w.height--}if(w.colspan){let y=m.width,b=m.flexgrow||0;const j=w.colspan;for(let C=1;C<j;C++){const A=a[l+C];A&&(A.hidden?w.colspan-=1:A.flexgrow?b+=A.flexgrow:y+=A.width||u.columnWidth),b?w.flexgrow=b:w.width=y}}else w.width=m.width,w.flexgrow=m.flexgrow;r==="header"&&w.filter&&typeof w.filter=="string"&&(w.filter={type:w.filter})}p.length>c&&(p.length=c),m[r]=p}normalizeRows(a){for(let l=0;l<a.length;l++)a[l].id||(a[l].id=ld());return a}normalizeTreeRows(a,l,r){return!l&&!r&&(this._branches={0:{data:a}}),a.forEach(c=>{c.id||(c.id=ld()),c.$level=l||0,c.$parent=r||0,this._branches[c.id]=c,c.data&&(c.data.length?(c.$count=c.data.length,this.normalizeTreeRows(c.data,c.$level+1,c.id)):(delete c.data,delete c.$count,delete c.open))}),a}sortTree(a,l){a.sort(l),a.forEach(r=>{r.data&&this.sortTree(r.data,l)})}filterTree(a,l,r){return a.forEach(c=>{l(c)&&r.push(c.id),c.data&&this.filterTree(c.data,l,r)}),r}flattenRows(a,l,r){const c=l;return a.forEach(u=>{(!r||r.includes(u.id))&&c.push(u),u.data?.length&&u.open!==!1&&this.flattenRows(u.data,c,r)}),c}createFilter(a){const{_columns:l}=this.getState(),r=[];for(const c in a){const u=l.find(g=>g.id==c),{config:m,type:p}=u.header.find(g=>g.filter).filter,v=a[c];r.push(g=>{const w=kl(g,u);return m?.handler?m.handler(w,v):uw(p)(w,v)})}return c=>{for(let u=0;u<r.length;u++)if(!r[u](c))return!1;return!0}}searchRows(a,l){a=a.trim().toLowerCase();const r={};if(!a)return r;const{flatData:c,columns:u}=this.getState(),m=l?u.filter(p=>l[p.id]):u;return c.forEach(p=>{const v={};m.forEach(g=>{const w=Cl(p,g);String(w).toLowerCase().includes(a)&&(v[g.id]=!0)}),Object.keys(v).length&&(r[p.id]=v)}),r}normalizeSizes(a,l,r,c,u){const m=Mx(a,"header",r,l.headerHeight,u),p=Mx(a,"footer",c,l.footerHeight,u),v=m.reduce((w,y)=>w+y,0),g=p.reduce((w,y)=>w+y,0);return{...l,headerRowHeights:m,footerRowHeights:p,headerHeight:v,footerHeight:g}}},yC=new Date().valueOf();function ld(){return"temp://"+yC++}function wC(n,a="data-id"){let l=n;for(!l.tagName&&n.target&&(l=n.target);l;){if(l.getAttribute&&l.getAttribute(a))return l;l=l.parentNode}return null}new Date().valueOf();var bC=class{constructor(){this.store=new Map}configure(n,a){this.node=a;for(const l in n)if(n[l]){const r=l.toLowerCase().replace(/[ ]/g,""),c=n[l];this.store.set(r,c)}}},io=[],SC={subscribe:n=>{jC();const a=new bC;return io.push(a),n(a),()=>{const l=io.findIndex(r=>r===a);l>=0&&io.splice(l,1)}}},Nx=!1;function jC(){Nx||(Nx=!0,document.addEventListener("keydown",n=>{if(io.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 l=n.code.replace("Key","").toLocaleLowerCase();n.key===" "&&(l="space"),a.push(l);const r=a.join("+");for(let c=io.length-1;c>=0;c--){const u=io[c],m=u.store.get(r)||u.store.get(l);m&&u.node.contains(n.target)&&m(n,{key:r,evKey:l})}}}))}const CC={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 kC(n,{keys:a,exec:l}){if(!a)return;function r(m){const p=m.target;return p.tagName==="INPUT"||p.tagName==="TEXTAREA"||wC(p,"data-header-id")?.classList.contains("wx-filter")||!!p.closest(".wx-cell.wx-editor")}const c={};for(const m in a){const p=a[m];typeof p<"u"&&(typeof p=="function"?c[m]=p:p&&(c[m]=v=>{const g=r(v);l({key:m,event:v,isInput:g})}))}const u=SC.subscribe(m=>{m.configure(c,n)});return{destroy:()=>{u()}}}function AC(n,a){let l=null;a.scroll.subscribe(r=>{if(!r||r===l)return;l=r;const{left:c,top:u,height:m,width:p}=r,v=a.getHeight(),g=a.getWidth(),w=a.getScrollMargin();if(u>=0){const y=n.scrollTop;u<y?n.scrollTop=u:u+m>y+v&&(n.scrollTop=u-v+m)}if(c>=0){const y=n.scrollLeft;c<y?n.scrollLeft=c:c+p>y+g-w&&(n.scrollLeft=c-g+p+w)}}),a.scrollLeft?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollLeft-r)>1&&(n.scrollLeft=r)})}),a.scrollTop?.subscribe?.(r=>{requestAnimationFrame(()=>{Math.abs(n.scrollTop-r)>1&&(n.scrollTop=r)})})}const Ra=f.createContext(null);function MC(n,a){const l=new ResizeObserver(r=>{requestAnimationFrame(()=>a(r[0].contentRect))});return l.observe(n.parentNode),{destroy(){l.disconnect()}}}const Tx=5,NC=700;function vd(n){const a=n.getBoundingClientRect(),l=document.body,r=a.top+l.scrollTop-l.clientTop||0,c=a.left+l.scrollLeft-l.clientLeft||0;return{y:Math.round(r),x:Math.round(c),width:n.offsetWidth,height:n.offsetHeight}}function vh(n,a){const l=vd(a);return{x:n.clientX-l.x,y:n.clientY-l.y}}function TC(n,a){const l=a.current;let r=null,c,u,m=!1,p=!1;const v=document.createElement("DIV");v.className="wx-drag-zone",v.setAttribute("tabindex",-1);function g(){clearTimeout(c),c=null}function w(_){const I=co(_);I&&(r={container:v,sourceNode:_.target,from:Id(I),pos:vh(_,n)},u=r.pos,y(_))}function y(_){if(!r)return;const I=r.pos=vh(_,n);if(!m){if(!p&&!_?.target?.getAttribute("draggable-data")&&Math.abs(u.x-I.x)<Tx&&Math.abs(u.y-I.y)<Tx)return;if(F(_)===!1)return V()}if(p){const me=window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft,Y=window.scrollY||document.documentElement.scrollTop||document.body.scrollTop;r.targetNode=document.elementFromPoint(_.pageX-me,_.pageY-Y)}else r.targetNode=_.target;l.move&&l.move(_,r),v.style.left=-(r.offset?r.offset.x:0)+"px",v.style.top=r.pos.y+(r.offset?r.offset.y:0)+"px"}function b(_){v.parentNode&&v.parentNode.removeChild(v),v.innerHTML="",m&&l.end&&l.end(_,r),r=u=null,V()}function j(_){l.getReorder&&!l.getReorder()||_.button===0&&(U(_),window.addEventListener("mousemove",C),window.addEventListener("mouseup",A),w(_))}function C(_){y(_)}function A(_){b(_)}function T(_){if(l.getReorder&&!l.getReorder())return;c=setTimeout(()=>{p=!0,w(_.touches[0])},NC),U(_);function I(){c&&g(),_.target.removeEventListener("touchmove",k),_.target.removeEventListener("touchend",I),b(_)}_.target.addEventListener("touchmove",k),_.target.addEventListener("touchend",I),n.addEventListener("contextmenu",E)}function k(_){m?(_.preventDefault(),y(_.touches[0])):c&&g()}function E(_){if(m||c)return _.preventDefault(),!1}function R(_){_.preventDefault()}function U(_){if(!l.getDraggableInfo)return;const{hasDraggable:I}=l.getDraggableInfo();(!I||_.target.getAttribute("draggable-data"))&&(document.body.style.userSelect="none",document.body.style.webkitUserSelect="none")}function F(_){if(m=!0,l.start){if(l.start(_,r)===!1)return!1;n.appendChild(v),document.body.style.cursor="move"}}function V(_){m=p=!1,document.body.style.cursor="",document.body.style.userSelect="",document.body.style.webkitUserSelect="",window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",A),_&&(n.removeEventListener("mousedown",j),n.removeEventListener("touchstart",T),n.removeEventListener("dragstart",R))}return n.addEventListener("mousedown",j),n.addEventListener("touchstart",T),n.addEventListener("dragstart",R),{destroy(){V(!0)}}}const EC=.004;function RC(){return{dirX:0,dirY:0,scrollSpeedFactor:1}}function DC(n,a,l,r){const{node:c,left:u,top:m,bottom:p,sense:v,xScroll:g,yScroll:w}=r,y=vh(n,c);l.scrollState||(l.scrollState=RC());let b=0,j=0;y.x<u+v?b=-1:y.x>a.width-v&&(b=1),y.y<m+Math.round(v/2)?j=-1:y.y>a.height-p-Math.round(v/2)&&(j=1),(l.scrollState.dirX!==b||l.scrollState.dirY!==j)&&(dw(l),l.scrollState.dirX=b,l.scrollState.dirY=j),(g&&l.scrollState.dirX!==0||w&&l.scrollState.dirY!==0)&&LC(l,r,{x:l.scrollState.dirX,y:l.scrollState.dirY})}function LC(n,a,l){n.autoScrollTimer||(n.autoScrollTimer=setTimeout(()=>{n.activeAutoScroll=setInterval(_C,15,n,a,l)},250))}function dw(n){n.scrollSpeedFactor=1,n.autoScrollTimer&&(n.autoScrollTimer=clearTimeout(n.autoScrollTimer),n.activeAutoScroll=clearInterval(n.activeAutoScroll))}function _C(n,a,l){const{x:r,y:c}=l;n.scrollSpeedFactor+=EC,r!==0&&IC(n,a,r),c!==0&&zC(n,a,c)}function zC(n,a,l){const r=a.node.scrollTop;fw(r+Math.round(a.sense/3)*n.scrollSpeedFactor*l,"scrollTop",a)}function IC(n,a,l){const r=a.node.scrollLeft;fw(r+Math.round(a.sense/3)*n.scrollSpeedFactor*l,"scrollLeft",a)}function fw(n,a,l){l.node[a]=n}function Hd(n,a,l,r,c,u){const m={};return n&&(m.width=`${n}px`,m.minWidth=`${n}px`),a&&(m.flexGrow=a),u&&(m.height=`${u}px`),l&&(m.position="sticky",l.left&&(m.left=`${r}px`),l.right&&(m.right=`${c}px`)),m}function mw(n,a,l){let r="";if(n.fixed)for(const c in n.fixed){let u=n.fixed[c]===-1;!u&&n.fixed.leftSize&&a.colspan&&(u=a.colspan+n._colindex-1===n.fixed.leftSize),r+=u?"wx-shadow ":"wx-fixed "}return r+=a.rowspan>1?"wx-rowspan ":"",r+=a.colspan>1?"wx-colspan ":"",r+=a.vertical?"wx-vertical ":"",r+=l?l(n)+" ":"",r}function OC(n){const{row:a,column:l,cellStyle:r=null,columnStyle:c=null,children:u,focusable:m}=n,p=f.useContext(Ra),v=Ze(p,"focusCell"),g=Ze(p,"search"),w=Ze(p,"reorder"),y=f.useMemo(()=>g?.rows[a.id]&&g.rows[a.id][l.id],[g,a.id,l.id]),b=f.useMemo(()=>Hd(l.width,l.flexgrow,l.fixed,l.left,l.right),[l.width,l.flexgrow,l.fixed,l.left,l.right]);function j(F,V){let _="wx-cell";return _+=l.fixed?" "+(l.fixed===-1?"wx-shadow":"wx-fixed"):"",_+=F?" "+F(l):"",_+=V?" "+V(a,l):"",_+=l.treetoggle?" wx-tree-cell":"",_}const C=f.useMemo(()=>j(c,r),[c,r,l,a]),A=f.useMemo(()=>typeof l.draggable=="function"?l.draggable(a,l)!==!1:l.draggable,[l,a]),T=f.useRef(null);f.useEffect(()=>{T.current&&m&&v?.row===a.id&&v?.column===l.id&&T.current.focus()},[v,m,a.id,l.id]);const k=f.useCallback(()=>{m&&!v&&p.exec("focus-cell",{row:a.id,column:l.id,eventSource:"focus"})},[p,m,v,a.id,l.id]);function E(F){const V=new RegExp(`(${g.value.trim()})`,"gi");return String(F).split(V).map(_=>({text:_,highlight:V.test(_)}))}const R=f.useMemo(()=>{const F=l.fixed&&l.fixed.left===-1||l.fixed.right===-1,V=l.fixed&&l.fixed.right;return[C,F?"wx-shadow":"",V?"wx-fixed-right":""].filter(Boolean).join(" ")},[C,l]),U=l.cell;return i.jsxs("div",{className:"wx-TSCaXsGV "+R,ref:T,onFocus:k,style:b,"data-row-id":Sn(a.id),"data-col-id":Sn(l.id),tabIndex:m?"0":"-1",role:"gridcell","aria-colindex":l._colindex,"aria-readonly":l.editor?void 0:!0,children:[w&&l.draggable?A?i.jsx("i",{"draggable-data":"true",className:"wx-TSCaXsGV wx-draggable wxi-drag"}):i.jsx("i",{className:"wx-TSCaXsGV wx-draggable-stub"}):null,l.treetoggle?i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{marginLeft:`${a.$level*28}px`}}),a.$count?i.jsx("i",{"data-action":"toggle-row",className:`wx-TSCaXsGV wx-table-tree-toggle wxi-menu-${a.open!==!1?"down":"right"}`}):null]}):null,U?i.jsx(U,{api:p,row:a,column:l,onAction:({action:F,data:V})=>p.exec(F,V)}):u?u():y?i.jsx("span",{children:E(Cl(a,l)).map(({highlight:F,text:V},_)=>F?i.jsx("mark",{className:"wx-TSCaXsGV wx-search",children:V},_):i.jsx("span",{children:V},_))}):Cl(a,l)]})}function Ex(n,a){let l,r;function c(p){l=p.clientX,n.style.opacity=1,document.body.style.cursor="ew-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",u),window.addEventListener("mouseup",m),a&&a.down&&a.down(n)}function u(p){r=p.clientX-l,a&&a.move&&a.move(r)}function m(){n.style.opacity="",document.body.style.cursor="",document.body.style.userSelect="",a&&a.up&&a.up(r),window.removeEventListener("mousemove",u),window.removeEventListener("mouseup",m)}return n.addEventListener("mousedown",c),{destroy(){n.removeEventListener("mousedown",c)}}}function BC({filter:n,column:a,action:l,filterValue:r}){function c({value:u}){l({value:u,key:a.id})}return i.jsx(Hh,{...n.config??{},value:r,onChange:c})}function FC({filter:n,column:a,action:l,filterValue:r}){const c=f.useContext(Ra),u=Ze(c,"flatData"),m=f.useMemo(()=>n?.config?.options||a?.options||v(),[n,a,u]),p=f.useMemo(()=>n?.config?.template,[n]);function v(){const y=[];return u.forEach(b=>{const j=kl(b,a);y.includes(j)||y.push(j)}),y.map(b=>({id:b,label:b}))}function g({value:y}){l({value:y,key:a.id})}function w(y){y.key!=="Tab"&&y.preventDefault()}return i.jsx("div",{style:{width:"100%"},onKeyDown:w,children:i.jsx(J1,{placeholder:"",clear:!0,...n?.config??{},options:m,value:r,onChange:g,children:y=>p?p(y):y.label})})}function HC({filter:n,column:a,action:l,filterValue:r}){function c({value:u}){l({value:u,key:a.id})}return i.jsx("div",{className:"wx-aaaK5VYO",style:{width:"100%"},children:i.jsx(Z1,{placeholder:"",clear:!0,...n?.config??{},value:r,onChange:c})})}function hw(n){const{value:a,options:l=[],placeholder:r="",clear:c=!1,text:u=null,template:m=null,cell:p=null,dropdown:v={},autoOpen:g=!1,onChange:w,onAction:y}=n,[b,j]=Zy(a||[]),C=f.useMemo(()=>(b||[]).map(Y=>l.find(ue=>ue.id===Y)).filter(Boolean),[b,l]),A=f.useRef(null),T=f.useRef(null),[k,E]=f.useState(null),R=()=>{const Y=b||[];if(!Y.length)return 0;const ue=l.find(K=>Y.includes(K.id));return ue?l.indexOf(ue):0};function U(Y){T.current=Y.navigate,E(()=>Y.keydown),g&&Y.navigate(R())}f.useEffect(()=>{g&&(A.current?.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges())},[]);function F({id:Y}){j(Y),w&&w({value:Y})}function V(Y){Y.stopPropagation(),j([]),w&&w({value:[]})}function _(){T.current?.(R())}function I(){T.current?.(null)}function me(Y){k?.(Y,R())}return i.jsxs("div",{ref:A,className:"wx-multiselect wx-aadNNOwy",onClick:_,onKeyDown:me,tabIndex:0,children:[i.jsx("div",{className:"wx-label wx-aadNNOwy",children:m?m(C):p?i.jsx(p,{data:C,onAction:y}):u?i.jsx("span",{className:"wx-text wx-aadNNOwy",children:u}):C.length?i.jsx("span",{className:"wx-text wx-aadNNOwy",children:C.map(Y=>Y.label).join(", ")}):r?i.jsx("span",{className:"wx-placeholder wx-aadNNOwy",children:r}):" "}),c&&b?.length?i.jsx("i",{className:"wx-icon wxi-close wx-aadNNOwy",onClick:V}):i.jsx("i",{className:"wx-icon wxi-angle-down wx-aadNNOwy"}),i.jsx(Bd,{items:l,onReady:U,onSelect:F,multiselect:!0,checkboxes:!0,value:b||[],onCancel:I,...v,children:({option:Y})=>i.jsx("div",{className:"wx-option wx-aadNNOwy",children:m?m(Y):p?i.jsx(p,{data:Y,onAction:y}):Y.label})})]})}function PC({filter:n,column:a,action:l,filterValue:r}){const c=f.useContext(Cn.i18n)?.getGroup("grid")||zc(Uh).getGroup("grid"),u=f.useMemo(()=>({clear:!0,...n?.config||{}}),[n]),m=f.useMemo(()=>u.options||a.options,[u,a]),p=f.useMemo(()=>{const w=r?.length;return w?w<3?r.map(y=>a.optionsMap.get(y)).join(", "):w+" "+c("selected"):""},[r,a,c]);function v({value:w}){l({value:w,key:a.id})}function g(w){w.key!=="Tab"&&w.preventDefault()}return i.jsx("div",{style:{width:"100%"},onKeyDown:g,children:i.jsx(hw,{placeholder:"",...u,options:m,value:r||[],text:p,onChange:v})})}const $C={text:BC,richselect:FC,datepicker:HC,multiselect:PC};function UC({filter:n,column:a}){const l=f.useContext(Ra),r=Ze(l,"filterValues");function c(m){l.exec("filter-rows",m)}const u=f.useMemo(()=>$C[n.type],[n.type]);return i.jsx(u,{filter:n,column:a,action:c,filterValue:r[a.id]})}function qC(n){const{cell:a,column:l,row:r,lastRow:c,sortRow:u,columnStyle:m,bodyHeight:p,hasSplit:v}=n,g=f.useContext(Ra),w=Ze(g,"sortMarks"),y=f.useMemo(()=>w?w[l.id]:void 0,[w,l.id]),b=f.useRef(),j=f.useCallback(ee=>{b.current=a.flexgrow?ee.parentNode.clientWidth:a.width},[a.flexgrow,a.width]),C=f.useCallback((ee,W)=>{g.exec("resize-column",{id:a.id,width:Math.max(1,(b.current||0)+ee),inProgress:W})},[g,a.id]),A=f.useCallback(ee=>C(ee,!0),[C]),T=f.useCallback(ee=>C(ee,!1),[C]),k=f.useCallback(ee=>{if(!l.sort||a.filter)return;let W=y?.order;W&&(W=W==="asc"?"desc":"asc"),g.exec("sort-rows",{key:a.id,add:ee.ctrlKey||ee.metaKey,order:W})},[g,a.id,a.filter,l.sort,y?.order]),E=f.useCallback(ee=>{ee&&ee.stopPropagation(),g.exec("collapse-column",{id:a.id,row:r})},[g,a.id,r]),R=f.useCallback(ee=>{ee.key==="Enter"&&E()},[E]),U=f.useCallback(ee=>{ee.key==="Enter"&&!a.filter&&k(ee)},[k,a.filter]),F=f.useMemo(()=>a.collapsed&&l.collapsed,[a.collapsed,l.collapsed]),V=f.useMemo(()=>F&&!v&&a.collapsible!=="header",[F,v,a.collapsible]),_=f.useMemo(()=>V?{top:-p/2,position:"absolute"}:{},[V,p]),I=f.useMemo(()=>Hd(a.width,a.flexgrow,l.fixed,l.left,a.right??l.right,a.height+(F&&V?p:0)),[a.width,a.flexgrow,l.fixed,l.left,a.right,l.right,a.height,F,V,p]),me=f.useMemo(()=>mw(l,a,m),[l,a,m]),Y=f.useCallback(()=>Object.fromEntries(Object.entries(a).filter(([ee])=>ee!=="cell")),[a]),ue=`wx-cell ${me} ${a.css||""} wx-collapsed`,K=["wx-cell",me,a.css||"",a.filter?"wx-filter":"",l.fixed&&l.fixed.right?"wx-fixed-right":""].filter(Boolean).join(" "),ie=f.useRef(null);return f.useEffect(()=>{const ee=ie.current;if(!ee)return;const W=Ex(ee,{down:j,move:A,up:T});return()=>{typeof W=="function"&&W()}},[j,A,T,Ex]),F?i.jsx("div",{className:"wx-RsQD74qC "+ue,style:I,role:"button","aria-label":`Expand column ${a.text||""}`,"aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:E,"data-header-id":Sn(l.id),children:i.jsx("div",{className:"wx-RsQD74qC wx-text",style:_,children:a.text||""})}):i.jsxs("div",{className:"wx-RsQD74qC "+K,style:I,onClick:k,"data-header-id":Sn(l.id),tabIndex:!a._hidden&&l.sort&&!a.filter?0:void 0,role:"columnheader","aria-colindex":l._colindex,"aria-colspan":a.colspan>1?a.colspan:void 0,"aria-rowspan":a.rowspan>1?a.rowspan:void 0,"aria-sort":!y?.order||a.filter?"none":y?.order==="asc"?"ascending":"descending",onKeyDown:U,children:[a.collapsible?i.jsx("div",{className:"wx-RsQD74qC wx-collapse",role:"button","aria-label":a.collapsed?"Expand column":"Collapse column","aria-expanded":!a.collapsed,tabIndex:0,onKeyDown:R,onClick:E,children:i.jsx("i",{className:`wx-RsQD74qC wxi-angle-${a.collapsed?"down":"right"}`})}):null,a.cell?(()=>{const ee=a.cell;return i.jsx(ee,{api:g,cell:Y(),column:l,row:r,onAction:({action:W,data:z})=>g.exec(W,z)})})():a.filter?i.jsx(UC,{filter:a.filter,column:l}):i.jsx("div",{className:"wx-RsQD74qC wx-text",children:a.text||""}),l.resize&&c&&!a._hidden?i.jsx("div",{className:"wx-RsQD74qC wx-grip",role:"presentation","aria-label":"Resize column",ref:ie,onClick:ee=>ee.stopPropagation(),children:i.jsx("div",{})}):null,u?i.jsx("div",{className:"wx-RsQD74qC wx-sort",children:y?i.jsxs(i.Fragment,{children:[typeof y.index<"u"?i.jsx("div",{className:"wx-RsQD74qC wx-order",children:y.index+1}):null,i.jsx("i",{className:`wx-RsQD74qC wxi-arrow-${y.order==="asc"?"up":"down"}`})]}):null}):null]})}function GC({cell:n,column:a,row:l,columnStyle:r}){const c=f.useContext(Ra),u=f.useMemo(()=>Hd(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=f.useMemo(()=>mw(a,n,r),[a,n,r]),p=f.useCallback(()=>Object.fromEntries(Object.entries(n||{}).filter(([g])=>g!=="cell")),[n]),v=`wx-6Sdi3Dfd wx-cell ${m||""} ${n?.css||""}`+(a?.fixed&&a?.fixed.right?" wx-fixed-right":"");return i.jsx("div",{className:v,style:u,children:!a?.collapsed&&!n?.collapsed?n?.cell?Th.createElement(n.cell,{api:c,cell:p(),column:a,row:l,onAction:({action:g,data:w})=>c.exec(g,w)}):i.jsx("div",{className:"wx-6Sdi3Dfd wx-text",children:n?.text||""}):null})}function Rx({deltaLeft:n,contentWidth:a,columns:l,type:r="header",columnStyle:c,bodyHeight:u}){const m=f.useContext(Ra),p=Ze(m,"_sizes"),v=Ze(m,"split"),g=f.useMemo(()=>p?.[`${r}RowHeights`],[p,r]),w=f.useMemo(()=>{let A=[];if(l&&l.length){const T=l[0][r].length;for(let k=0;k<T;k++){let E=0;A.push([]),l.forEach((R,U)=>{const F={...R[r][k]};E||A[k].push(F),F.colspan>1?E=F.colspan-1:E&&E--})}}return A},[l,r]),y=f.useMemo(()=>v?.left||v?.right,[v]);function b(A){return l.find(T=>T.id===A)}function j(A,T){let k=T;return A.rowspan&&(k+=A.rowspan-1),k===w.length-1}function C(A,T,k){if(!k.sort)return!1;for(let E=w.length-1;E>=0;E--){const R=k.header[E];if(!R.filter&&!R._hidden)return T===E}return j(A,T)}return i.jsx("div",{className:`wx-sAsPVaUK wx-${r}`,style:{paddingLeft:`${n}px`,width:`${a}px`},role:"rowgroup",children:w.map((A,T)=>i.jsx("div",{className:r==="header"?"wx-sAsPVaUK wx-h-row":"wx-sAsPVaUK wx-f-row",style:{height:`${g?.[T]}px`,display:"flex"},role:"row",children:A.map(k=>{const E=b(k.id);return r==="header"?i.jsx(qC,{cell:k,columnStyle:c,column:E,row:T,lastRow:j(k,T),bodyHeight:u,sortRow:C(k,T,E),hasSplit:y},k.id):i.jsx(GC,{cell:k,columnStyle:c,column:b(k.id),row:T},k.id)})},T))})}function VC({overlay:n}){const a=f.useContext(Ra);function l(c){return typeof c=="function"}const r=n;return i.jsx("div",{className:"wx-1ty666CQ wx-overlay",children:l(n)?i.jsx(r,{onAction:({action:c,data:u})=>a.exec(c,u)}):n})}function YC(n){const{editor:a,onSave:l,onApply:r}=n,[c,u]=f.useState(a?.value||""),{type:m="text"}=f.useMemo(()=>a?.config||{},[a]),p=f.useRef(null);f.useEffect(()=>{p.current&&p.current.focus()},[]),f.useEffect(()=>{if(!p.current)return;const w=Us(p.current,()=>l(!0));return()=>w.destroy()},[l]);function v(){p.current&&(u(p.current.value),r(p.current.value))}function g({key:w}){w==="Enter"&&l()}return i.jsx("input",{className:"wx-e7Ao5ejY wx-text",onInput:v,onKeyDown:g,ref:p,type:m,value:c})}function WC({editor:n,onAction:a,onSave:l,onApply:r,onCancel:c}){const[u,m]=f.useState(n?.value),[p,v]=f.useState(n?.renderedValue),[g,w]=f.useState(n?.options||[]),y=f.useMemo(()=>n?.config?.template,[n]),b=f.useMemo(()=>n?.config?.cell,[n]),j=f.useMemo(()=>n?.config?.dropdown||{},[n]),C=f.useMemo(()=>({trackScroll:!0,...j}),[j]),A=f.useMemo(()=>(g||[]).findIndex(_=>_.id===u),[g,u]),T=f.useRef(null),k=f.useRef(null),E=f.useCallback(_=>{T.current=_.navigate,k.current=_.keydown,T.current(A)},[A,T]),R=f.useCallback(_=>{const I=_?.target?.value??"";v(I);const me=I?(n?.options||[]).filter(Y=>(Y.label||"").toLowerCase().includes(I.toLowerCase())):n?.options||[];w(me),me.length?T.current(-1/0):T.current(null)},[n]),U=f.useRef(null);f.useEffect(()=>{U.current&&U.current.focus()},[]);const F=f.useRef(l);f.useEffect(()=>{F.current=l},[l]),f.useEffect(()=>{if(!U.current)return;const _=Us(U.current,()=>F.current(!0));return()=>_.destroy()},[]),f.useEffect(()=>{m(n?.value),v(n?.renderedValue),w(n?.options||[])},[n]);const V=f.useCallback(({id:_})=>{r(_),l()},[r,l]);return i.jsxs(i.Fragment,{children:[i.jsx("input",{className:"wx-0UYfSd1x wx-input",ref:U,value:p??"",onChange:R,onKeyDown:_=>k.current?k.current(_,A):void 0}),i.jsx(Bd,{items:g,onReady:E,onSelect:V,...C,onCancel:c,children:({option:_})=>y?y(_):b?i.jsx(b,{data:_,onAction:a}):_.label})]})}function KC({editor:n,onAction:a,onSave:l,onApply:r,onCancel:c}){const[u]=f.useState(()=>n.value||new Date),{template:m,cell:p,dropdown:v={}}=n?.config||{},g=f.useMemo(()=>({trackScroll:!0,width:"auto",...v}),[v]);function w({value:C}){r(C),l()}const y=f.useRef(null),[b,j]=f.useState(null);return f.useEffect(()=>{y.current&&y.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!b)return;const C=Us(b,()=>l(!0));return()=>C.destroy()},[b,l]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"wx-lNWNYUb6 wx-value",ref:y,tabIndex:0,onClick:c,onKeyDown:C=>C.preventDefault(),children:m?m(u):p?i.jsx(p,{data:n.value,onAction:a}):i.jsx("span",{className:"wx-lNWNYUb6 wx-text",children:n.renderedValue})}),i.jsx(Fh,{...g,onCancel:c,children:i.jsx("div",{ref:j,className:"wx-lNWNYUb6",children:i.jsx(Yy,{value:u,onChange:w,buttons:n.config?.buttons})})})]})}function QC(n){const{editor:a}=n,l=n.onAction??n.onaction,r=n.onSave??n.onsave,c=n.onApply??n.onapply,u=n.onCancel??n.oncancel,m=a.config||{},{dropdown:p={}}=m,v=f.useMemo(()=>({trackScroll:!0,...p}),[p]),[g]=f.useState(a.options.find(R=>R.id===a.value)),[w]=f.useState(a.value),[y]=f.useState(a.options),b=f.useMemo(()=>y.findIndex(R=>R.id===w),[y,w]);function j({id:R}){c(R),r()}let C;const[A,T]=f.useState();function k(R){C=R.navigate,T(()=>R.keydown),C(b)}const E=f.useRef(null);return f.useEffect(()=>{E.current&&E.current.focus(),typeof window<"u"&&window.getSelection&&window.getSelection().removeAllRanges()},[]),f.useEffect(()=>{if(!E.current)return;const R=Us(E.current,()=>r(!0));return()=>R.destroy()},[r]),i.jsxs(i.Fragment,{children:[i.jsx("div",{ref:E,className:"wx-ywGRk611 wx-value",tabIndex:0,onClick:u,onKeyDown:R=>{A(R,b),R.preventDefault()},children:m.template?m.template(g):m.cell?(()=>{const R=m.cell;return i.jsx(R,{data:g,onAction:l})})():i.jsx("span",{className:"wx-ywGRk611 wx-text",children:a.renderedValue})}),i.jsx(Bd,{items:y,onReady:k,onSelect:j,...v,onCancel:u,children:({option:R})=>m.template?m.template(R):m.cell?(()=>{const U=m.cell;return i.jsx(U,{data:R,onAction:l})})():R.label})]})}function XC(n){const{editor:a,onAction:l,onSave:r,onApply:c}=n,u=a?.config||{},m=a?.options??[],p=a?.value||[],v=a?.renderedValue,g=f.useMemo(()=>({trackScroll:!0,...u.dropdown||{}}),[u]);function w({value:b}){c(b)}const y=f.useRef(null);return f.useEffect(()=>{if(!y.current)return;const b=Us(y.current,()=>r(!0));return()=>b.destroy()},[r]),i.jsx("div",{ref:y,className:"wx-value wx-aacZ4gNU",onClick:()=>r(!0),children:i.jsx(hw,{value:p,options:m,text:v,template:u.template,cell:u.cell,clear:u.clear,dropdown:g,autoOpen:!0,onChange:w,onAction:l})})}const ZC={text:YC,combo:WC,datepicker:KC,richselect:QC,multiselect:XC};function JC({column:n,row:a}){const l=f.useContext(Ra),r=Ze(l,"editor"),c=f.useCallback((C,A)=>{l.exec("close-editor",{ignore:C}),A&&l.exec("focus-cell",{...A,eventSource:"click"})},[l]),u=f.useCallback(C=>{const A=C?null:{row:r?.id,column:r?.column};c(!1,A)},[r,c]),m=f.useCallback(()=>{c(!0,{row:r?.id,column:r?.column})},[r,c]),p=f.useCallback(C=>{l.exec("editor",{value:C})},[l]),v=f.useCallback(C=>{C.key==="Enter"&&r&&(n.editor.type==="multiselect"?p(r.value):m())},[r,n.editor,m,p]),g=f.useMemo(()=>Hd(n.width,n.flexgrow,n.fixed,n.left,n.right),[n.width,n.flexgrow,n.fixed,n.left,n.right]),w=f.useMemo(()=>{let C=n.editor;if(typeof C=="function"&&(C=C(a,n)),!C)return null;let A=typeof C=="string"?C:C.type;return ZC[A]},[n,a]),y=f.useRef(null);f.useEffect(()=>{y.current&&typeof g=="string"&&y.current.setAttribute("style",g)},[g]);const b=typeof a.$parent<"u"?"gridcell":"cell",j=typeof a.$parent<"u"?!n.editor:void 0;return i.jsx("div",{className:"wx-8l724t2g wx-cell wx-editor",ref:y,style:typeof g=="object"&&g!==null?g:void 0,role:b,"aria-readonly":j,tabIndex:-1,onClick:C=>C.stopPropagation(),onDoubleClick:C=>C.stopPropagation(),onKeyDown:v,children:w?i.jsx(w,{editor:r,onSave:u,onApply:p,onCancel:m,onAction:({action:C,data:A})=>l.exec(C,A)}):null})}function Dx(n){const{columns:a,type:l,columnStyle:r}=n,c=f.useContext(Ra),{filterValues:u,_columns:m,_sizes:p}=c.getState();function v(g){return r?" "+r(g):""}return i.jsx(i.Fragment,{children:a.map((g,w)=>i.jsx("tr",{children:g.map(y=>{const b=m.find(A=>A.id===y.id),j=`wx-print-cell-${l}${v(b)}${y.filter?" wx-print-cell-filter":""}${y.vertical?" wx-vertical":""}`,C=y.cell;return i.jsx("th",{style:Jy(ow(y,p.columnWidth)),className:"wx-Gy81xq2u "+j,rowSpan:y.rowspan,colSpan:y.colspan,children:C?i.jsx(C,{api:c,cell:Object.fromEntries(Object.entries(y).filter(([A])=>A!=="cell")),column:b,row:w}):y.filter?i.jsx("div",{className:"wx-Gy81xq2u wx-print-filter",children:aC(u,m,y)}):i.jsx("div",{className:"wx-Gy81xq2u wx-text",children:y.text??""})},y.id)})},w))})}function ek(n){const{columns:a,rowStyle:l,columnStyle:r,cellStyle:c,header:u,footer:m,reorder:p}=n,v=f.useContext(Ra),{flatData:g,_sizes:w}=v.getState(),y=u&&kx(a,"header",w.headerRowHeights),b=m&&kx(a,"footer",w.footerRowHeights);function j(A,T){let k="";return k+=r?" "+r(T):"",k+=c?" "+c(A,T):"",k}function C(A,T){return typeof T.draggable=="function"?T.draggable(A,T)!==!1:T.draggable}return i.jsxs("table",{className:`wx-8NTMLH0z wx-print-grid ${a.some(A=>A.flexgrow)?"wx-flex-columns":""}`,children:[u?i.jsx("thead",{children:i.jsx(Dx,{columns:y,type:"header",columnStyle:r})}):null,i.jsx("tbody",{children:g.map((A,T)=>i.jsx("tr",{className:"wx-8NTMLH0z wx-row"+(l?" "+l(A):""),style:{height:`${A.rowHeight||w.rowHeight}px`},children:a.map(k=>k.collapsed?null:i.jsxs("td",{className:`wx-8NTMLH0z wx-print-cell wx-cell ${j(A,k)}`,style:Jy(ow(k,w.columnWidth)),children:[p&&k.draggable?i.jsx("span",{className:"wx-8NTMLH0z wx-print-draggable",children:C(A,k)?i.jsx("i",{className:"wx-8NTMLH0z wxi-drag"}):null}):null,k.treetoggle?i.jsxs(i.Fragment,{children:[i.jsx("span",{style:{marginLeft:A.$level*28+"px"}}),A.$count?i.jsx("i",{className:`wx-8NTMLH0z wx-print-grid-tree-toggle wxi-menu-${A.open!==!1?"down":"right"}`}):null]}):null,k.cell?(()=>{const E=k.cell;return i.jsx(E,{api:v,row:A,column:k})})():i.jsx("span",{children:Cl(A,k)})]},k.id))},T))}),m?i.jsx("tfoot",{children:i.jsx(Dx,{columns:b,type:"footer",columnStyle:r})}):null]})}function tk(n){const{config:a,...l}=n,r=f.useContext(Ra),{_skin:c,_columns:u}=r.getState(),m=f.useMemo(()=>Jj(u,a),[]),p=f.useRef(null);return f.useEffect(()=>{const v=document.body;v.classList.add("wx-print");const g=p.current;if(!g)return;const w=g.cloneNode(!0);v.appendChild(w);const y=`@media print { @page { size: ${a.paper} ${a.mode}; }`,b=document.createElement("style");b.setAttribute("type","text/css"),b.setAttribute("media","print"),document.getElementsByTagName("head")[0].appendChild(b),b.appendChild(document.createTextNode(y)),window.print(),b.remove(),v.classList.remove("wx-print"),w.remove()},[]),i.jsx("div",{className:`wx-4zwCKA7C wx-${c}-theme wx-print-container`,ref:p,children:m.map((v,g)=>i.jsx("div",{className:"wx-4zwCKA7C wx-print-grid-wrapper",children:i.jsx(ek,{columns:v,...l})},g))})}function nk(n){const{header:a,footer:l,overlay:r,multiselect:c,onreorder:u,rowStyle:m,columnStyle:p,cellStyle:v,autoRowHeight:g,resize:w,clientWidth:y,clientHeight:b,responsiveLevel:j,hotkeys:C}=n,A=f.useContext(Ra),T=Ze(A,"dynamic"),k=Ze(A,"_columns"),E=Ze(A,"flatData"),R=Ze(A,"split"),U=Ze(A,"_sizes"),[F,V]=Za(A,"selectedRows"),_=Ze(A,"select"),I=Ze(A,"editor"),me=Ze(A,"scrollLeft"),Y=Ze(A,"scrollTop"),ue=Ze(A,"tree"),K=Ze(A,"focusCell"),ie=Ze(A,"_print"),ee=Ze(A,"undo"),W=Ze(A,"reorder"),z=Ze(A,"_rowHeightFromData"),[Q,X]=f.useState(0);f.useEffect(()=>{X(ws())},[]);const[P,le]=f.useState(0),we=f.useMemo(()=>(k||[]).some(J=>!J.hidden&&J.flexgrow),[k]),L=f.useMemo(()=>U?.rowHeight||0,[U]),$=f.useRef(null),[xe,Se]=f.useState(null),[fe,Te]=f.useState(null),Ie=f.useMemo(()=>{let J=[],ke=0;return R&&R.left&&(J=(k||[]).slice(0,R.left).filter(_e=>!_e.hidden).map(_e=>({..._e})),J.forEach(_e=>{_e.fixed={left:1,leftSize:R.left},_e.left=ke,ke+=_e.width}),J.length&&(J[J.length-1].fixed.left=-1)),{columns:J,width:ke}},[R,k]),oe=f.useMemo(()=>{let J=[],ke=0;if(R&&R.right){J=(k||[]).slice(R.right*-1).filter(_e=>!_e.hidden).map(_e=>({..._e}));for(let _e=J.length-1;_e>=0;_e--){const Ke=J[_e];Ke.fixed={right:1},Ke.right=ke,ke+=Ke.width}J.length&&(J[0].fixed={right:-1})}return{columns:J,width:ke}},[R,k]),Ye=f.useMemo(()=>{const J=(k||[]).slice(R?.left||0,(k||[]).length-(R?.right??0)).filter(ke=>!ke.hidden);return J.forEach(ke=>{ke.fixed=0}),J},[k,R]),De=f.useMemo(()=>(k||[]).reduce((J,ke)=>(ke.hidden||(J+=ke.width),J),0),[k]),We=1;function D(J,ke,_e){let Ke=ke,xt=J;if(Ye.length){let gt=Ye.length;for(let $e=J;$e>=0;$e--)Ye[$e][_e].forEach(dt=>{dt.colspan>1&&$e>J-dt.colspan&&$e<gt&&(gt=$e)});if(gt!==Ye.length&&gt<J){for(let $e=gt;$e<J;$e++)Ke-=Ye[$e].width;xt=gt}}return{index:xt,delta:Ke}}const ne=f.useMemo(()=>{let J,ke,_e;const Ke=me||0,xt=(me||0)+(y||0);let gt=0,$e=0,dt=0,nn=0;Ye.forEach((Yt,bt)=>{Ke>dt&&(gt=bt,nn=dt),dt=dt+Yt.width,xt>dt&&($e=bt+We)});const Ft={header:0,footer:0};for(let Yt=$e;Yt>=gt;Yt--)["header","footer"].forEach(bt=>{Ye[Yt]&&Ye[Yt][bt].forEach(Ia=>{const Ja=Ia.colspan;if(Ja&&Ja>1){const es=Ja-($e-Yt+1);es>0&&(Ft[bt]=Math.max(Ft[bt],es))}})});const Tn=D(gt,nn,"header"),At=D(gt,nn,"footer"),Ht=Tn.delta,Dt=Tn.index,js=At.delta,vn=At.index;return we&&De>(y||0)?J=ke=_e=[...Ie.columns,...Ye,...oe.columns]:(J=[...Ie.columns,...Ye.slice(gt,$e+1),...oe.columns],ke=[...Ie.columns,...Ye.slice(Dt,$e+Ft.header+1),...oe.columns],_e=[...Ie.columns,...Ye.slice(vn,$e+Ft.footer+1),...oe.columns]),{data:J||[],header:ke||[],footer:_e||[],d:nn,df:js,dh:Ht}},[Ye,Ie,oe,me,y,we,De]),je=f.useMemo(()=>a&&U?.headerHeight||0,[a,U]),te=f.useMemo(()=>l&&U?.footerHeight||0,[l,U]),ce=f.useMemo(()=>y&&b?De>=y:!1,[y,b,De]),[Me,Ce]=f.useState(!1),it=f.useMemo(()=>(b||0)-je-te-(ce?Q:0),[b,je,te,ce,Q]),he=f.useMemo(()=>Math.ceil((it||0)/(L||1))+1,[it,L]),Fe=f.useRef([]),[Le,Ge]=f.useState(0),[ea,gn]=f.useState(void 0),kn=f.useMemo(()=>{let J=0,ke=0;const _e=2,Ke=Y||0;if(g){let $e=Ke;for(;$e>0;)$e-=Fe.current[J]||L,J++;ke=Ke-$e;for(let dt=Math.max(0,J-_e-1);dt<J;dt++)ke-=Fe.current[J-dt]||L;J=Math.max(0,J-_e)}else{if(z){let $e=0,dt=0;for(let At=0;At<(E||[]).length;At++){const Ht=E[At].rowHeight||L;if(dt+Ht>Ke){$e=At;break}dt+=Ht}J=Math.max(0,$e-_e);for(let At=0;At<J;At++)ke+=E[At].rowHeight||L;let nn=0,Ft=0;for(let At=$e+1;At<(E||[]).length;At++){const Ht=E[At].rowHeight||L;if(nn++,Ft+Ht>it)break;Ft+=Ht}const Tn=Math.min(T?T.rowCount:(E||[]).length,$e+nn+_e);return{d:ke,start:J,end:Tn}}J=Math.floor(Ke/(L||1)),J=Math.max(0,J-_e),ke=J*(L||0)}const xt=T?T.rowCount:(E||[]).length,gt=Math.min(xt,J+(he||0)+_e);return{d:ke,start:J,end:gt}},[g,z,Y,L,T,E,he,it]),Yn=f.useMemo(()=>{const J=T?T.rowCount:(E||[]).length;if(g)return Le+kn.d+(J-(ea||0))*(L||0);if(!z)return J*(L||0);let ke=0;for(let _e=0;_e<J;_e++)ke+=E[_e]?.rowHeight||L;return ke},[T,E,L,g,z,Le,kn.d,ea]),Ml=f.useRef({});Ml.current={clientWidth:y,clientHeight:b,fullHeight:Yn,headerHeight:je,footerHeight:te,fullWidth:De,SCROLLSIZE:Q};const Da=f.useCallback(()=>{const J=Ml.current;Ce(J.clientWidth&&J.clientHeight?J.fullHeight+J.headerHeight+J.footerHeight>=J.clientHeight-(J.fullWidth>=J.clientWidth?J.SCROLLSIZE:0):!1)},[]);f.useEffect(()=>{const J=requestAnimationFrame(Da);return()=>window.cancelAnimationFrame(J)},[P,Da]),f.useEffect(()=>{Da()},[b,Da]);const Bn=f.useMemo(()=>we&&De<=(y||0)?(y||0)-0-(Me?Q:0):De,[we,De,y,Me,Q,ce]),mr=f.useMemo(()=>we&&De<=(y||0)?y||0:Bn<(y||0)?De+(Me?Q:0):-1,[we,De,y,Bn,Me,Q]),ys=f.useRef({});f.useEffect(()=>{if(T&&(ys.current.start!==kn.start||ys.current.end!==kn.end)){const{start:J,end:ke}=kn;ys.current={start:J,end:ke},A&&A.exec&&A.exec("request-data",{row:{start:J,end:ke}})}},[T,kn,A]);const mt=f.useMemo(()=>T?E||[]:(E||[]).slice(kn.start,kn.end),[T,E,kn]),An=f.useMemo(()=>(F||[]).filter(J=>(mt||[]).some(ke=>ke.id===J)),[V,mt]),Ne=f.useMemo(()=>kn.start,[kn.start]),Nl=f.useRef({top:Y,left:me});Nl.current={top:Y,left:me};const Je=f.useCallback(J=>{const ke=J.target.scrollTop,_e=J.target.scrollLeft,Ke=Nl.current;(ke!==Ke.top||_e!==Ke.left)&&A.exec("scroll-to",{top:ke,left:_e})},[A]),hr=f.useCallback(J=>{J.shiftKey&&J.preventDefault(),$.current&&$.current.focus&&$.current.focus()},[]),kt=f.useCallback(()=>!!(k||[]).find(J=>!!J.draggable),[k]),La=f.useRef(null),Gt=f.useRef(null),Wn=f.useRef({dblclick:(J,ke)=>{const _e={id:J,column:Lc(ke,"data-col-id")};A.exec("open-editor",_e)},click:(J,ke)=>{if(ke.target.closest("input")||La.current)return;const _e=Lc(ke,"data-col-id");if(K?.id!==J&&A.exec("focus-cell",{row:J,column:_e,eventSource:"click"}),_===!1)return;const Ke=c&&(ke.ctrlKey||ke.metaKey),xt=c&&ke.shiftKey;(Ke||F.length>1||!F.includes(J))&&A.exec("select-row",{id:J,toggle:Ke,range:xt})},"toggle-row":J=>{const ke=A.getRow(J);A.exec(ke.open!==!1?"close-row":"open-row",{id:J})},"ignore-click":()=>!1}),ga=f.useMemo(()=>({top:je,bottom:te,left:Ie.width,xScroll:ce,yScroll:Me,sense:g&&fe?fe.offsetHeight:Math.max(U?.rowHeight||0,40),node:$.current&&$.current.firstElementChild}),[je,te,Ie.width,ce,Me,g,fe,U]);function _a(J,ke){const{container:_e,sourceNode:Ke,from:xt}=ke;if(kt()&&!Ke.getAttribute("draggable-data"))return!1;Se(xt),ue&&A.getRow(xt).open&&A.exec("close-row",{id:xt,nested:!0});const gt=co(Ke),$e=gt.cloneNode(!0);$e.classList.remove("wx-selected"),$e.querySelectorAll("[tabindex]").forEach(Tn=>Tn.setAttribute("tabindex","-1")),_e.appendChild($e),Te($e);const dt=(me||0)-ne.d,nn=Me?Q:0;_e.style.width=Math.min((y||0)-nn,we&&De<=(y||0)?Bn:Bn-nn)+dt+"px";const Ft=vd(gt);ke.offset={x:dt,y:-Math.round(Ft.height/2)},Gt.current||(Gt.current=J.clientY)}function Vt(J,ke){const{from:_e}=ke,Ke=ke.pos,xt=vd($.current);Ke.x=xt.x;const gt=ga.top;if(Ke.y<gt)Ke.y=gt;else{const $e=xt.height-(ce&&Q>0?Q:Math.round(ga.sense/2))-ga.bottom;Ke.y>$e&&(Ke.y=$e)}if($.current.contains(ke.targetNode)){const $e=co(ke.targetNode),dt=$e&&Id($e);if(dt&&dt!==_e){ke.to=dt;const nn=g?fe?.offsetHeight:U?.rowHeight;if(fe&&((Y||0)===0||Ke.y>gt+nn-1)){const Ft=$e.getBoundingClientRect(),Tn=vd(fe).y,At=Ft.y,Ht=Tn>At?-1:1,Dt=Ht===1?"after":"before",js=A.getState().flatData,vn=Math.abs(js.findIndex(bt=>bt.id===_e)-js.findIndex(bt=>bt.id===dt)),Yt=vn!==1?Dt==="before"?"after":"before":Dt;if(vn===1&&(Ht===-1&&J.clientY>Gt.current||Ht===1&&J.clientY<Gt.current))return;Gt.current=J.clientY,A.exec("move-item",{id:_e,target:dt,mode:Yt,inProgress:!0})}}u&&u({event:J,context:ke})}DC(J,xt,ke,ga)}function qs(J,ke){const{from:_e,to:Ke}=ke;A.exec("move-item",{id:_e,target:Ke,inProgress:!1}),La.current=setTimeout(()=>{La.current=0},1),Se(null),Te(null),Gt.current=null,dw(ke)}function ws(){const J=document.createElement("div");J.style.cssText="position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;min-height:100px;overflow-y:scroll;",document.body.appendChild(J);const ke=J.offsetWidth-J.clientWidth;return document.body.removeChild(J),ke}const bs=f.useMemo(()=>mr>0?{width:`${mr}px`}:void 0,[mr]),pr=f.useRef(null);function gr(){Promise.resolve().then(()=>{let J=0,ke=Ne;const _e=pr.current;_e&&(Array.from(_e.children).forEach((Ke,xt)=>{Fe.current[Ne+xt]=Ke.offsetHeight,J+=Ke.offsetHeight,ke++}),Ge(J),gn(ke))})}f.useEffect(()=>{mt&&g&&gr()},[mt,g,Ne]);let[za,Ss]=f.useState();f.useEffect(()=>{if(K&&(!_||!An.length||An.includes(K.row)))Ss({...K});else if(mt.length&&ne.data.length){if(!za||An.length&&!An.includes(za.row)||mt.findIndex(J=>J.id===za.row)===-1||ne.data.findIndex(J=>J.id===za.column&&!J.collapsed)===-1){const J=An[0]||mt[0].id,ke=ne.data.findIndex(_e=>!_e.collapsed);Ss(ke!==-1?{row:J,column:ne.data[ke].id}:null)}}else Ss(null)},[K]);const Mn=f.useRef(null);f.useEffect(()=>{const J=$.current;if(!J)return;const ke=MC(J,w);return()=>{typeof ke=="function"&&ke()}},[w]);const ta=f.useRef({});Object.assign(ta.current,{start:_a,move:Vt,end:qs,getReorder:()=>W,getDraggableInfo:()=>({hasDraggable:kt()})}),f.useEffect(()=>{const J=$.current;return J?TC(J,ta).destroy:void 0},[W,$.current]),f.useEffect(()=>{const J=$.current;return J?kC(J,{keys:C!==!1&&{...CC,"ctrl+z":ee,"ctrl+y":ee,...C},exec:ke=>A.exec("hotkey",ke)}).destroy:void 0},[A,ee,C]);const tn=f.useRef({scroll:A.getReactiveState().scroll,scrollLeft:A.getReactiveState().scrollLeft,scrollTop:A.getReactiveState().scrollTop});tn.current.getWidth=()=>(y||0)-(Me?Q:0),tn.current.getHeight=()=>it,tn.current.getScrollMargin=()=>Ie.width+oe.width,f.useEffect(()=>{AC(Mn.current,tn.current)},[]);const Gs=f.useRef(null);f.useEffect(()=>{const J=Gs.current;if(!J)return;const ke=[];ke.push(Us(J,()=>K&&A.exec("focus-cell",{eventSource:"click"})).destroy),ke.push(Tj(J,Wn.current)),le(J.clientHeight);const _e=new ResizeObserver(()=>{le(J.clientHeight)});return _e.observe(J),ke.push(()=>_e.disconnect()),()=>ke.forEach(Ke=>Ke())},[]);const Nn=`wx-grid ${j?`wx-responsive-${j}`:""}`;return f.useEffect(()=>{K&&(mt.some(J=>J.id===K.row)&&ne.data.some(J=>J.id===K.column&&!J.collapsed)||A.exec("focus-cell",{eventSource:"destroy"}))},[K,mt,ne.data,A]),i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"wx-4VuBwK2D "+Nn,style:{"--header-height":`${je}px`,"--footer-height":`${te}px`,"--split-left-width":`${Ie.width}px`,"--split-right-width":`${oe.width}px`},children:i.jsx("div",{ref:$,className:"wx-4VuBwK2D wx-table-box",style:bs,role:ue?"treegrid":"grid","aria-colcount":ne.data.length,"aria-rowcount":mt.length,"aria-multiselectable":ue&&c?!0:void 0,tabIndex:-1,children:i.jsxs("div",{ref:Mn,className:"wx-4VuBwK2D wx-scroll",style:{overflowX:ce?"scroll":"hidden",overflowY:Me?"scroll":"hidden"},onScroll:Je,children:[a?i.jsx("div",{className:"wx-4VuBwK2D wx-header-wrapper",children:i.jsx(Rx,{contentWidth:Bn,deltaLeft:ne.dh,columns:ne.header,columnStyle:p,bodyHeight:it-+l})}):null,i.jsxs("div",{ref:Gs,className:"wx-4VuBwK2D wx-body",style:{width:`${Bn}px`,height:`${Yn}px`},onMouseDown:J=>hr(J),children:[r?i.jsx(VC,{overlay:r}):null,i.jsx("div",{ref:pr,className:"wx-4VuBwK2D wx-data",style:{paddingTop:`${kn.d}px`,paddingLeft:`${ne.d}px`},children:mt.map((J,ke)=>{const _e=F.indexOf(J.id)!==-1,Ke=xe===J.id,xt="wx-row"+(g?" wx-autoheight":"")+(m?" "+m(J):"")+(_e?" wx-selected":"")+(Ke?" wx-inactive":""),gt=g?{minHeight:`${J.rowHeight||L}px`}:{height:`${J.rowHeight||L}px`};return i.jsx("div",{className:"wx-4VuBwK2D "+xt,"data-id":Sn(J.id),"data-context-id":Sn(J.id),style:gt,role:"row","aria-rowindex":ke,"aria-expanded":J.open,"aria-level":ue?J.$level+1:void 0,"aria-selected":ue?_e:void 0,tabIndex:-1,children:ne.data.map($e=>$e.collapsed?i.jsx("div",{className:"wx-4VuBwK2D wx-cell wx-collapsed"},$e.id):I?.id===J.id&&I.column===$e.id?i.jsx(JC,{row:J,column:$e},$e.id):i.jsx(OC,{row:J,column:$e,columnStyle:p,cellStyle:v,reorder:W,focusable:za?.row===J.id&&za?.column===$e.id},$e.id))},J.id)})})]}),l&&(E||[]).length?i.jsx(Rx,{type:"footer",contentWidth:Bn,deltaLeft:ne.df,columns:ne.footer,columnStyle:p}):null]})})}),ie?i.jsx(tk,{config:ie,rowStyle:m,columnStyle:p,cellStyle:v,header:a,footer:l,reorder:W}):null]})}const ak=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join(""),sk=f.forwardRef(function({data:n=[],columns:a=[],rowStyle:l=null,columnStyle:r=null,cellStyle:c=null,selectedRows:u,select:m=!0,multiselect:p=!1,header:v=!0,footer:g=!1,dynamic:w=null,overlay:y=null,reorder:b=!1,onReorder:j=null,autoRowHeight:C=!1,sizes:A,split:T,tree:k=!1,autoConfig:E=!1,init:R=null,responsive:U=null,sortMarks:F,undo:V=!1,hotkeys:_=null,filterValues:I,...me},Y){const ue=f.useRef();ue.current=me;const K=f.useMemo(()=>new xC(ew),[]),ie=f.useMemo(()=>K.in,[K]),ee=f.useRef(null);ee.current===null&&(ee.current=new Wy((oe,Ye)=>{const De="on"+ak(oe);ue.current&&ue.current[De]&&ue.current[De](Ye)}),ie.setNext(ee.current));const W=f.useMemo(()=>({getState:K.getState.bind(K),getReactiveState:K.getReactive.bind(K),getStores:()=>({data:K}),exec:ie.exec,setNext:oe=>(ee.current=ee.current.setNext(oe),ee.current),intercept:ie.intercept.bind(ie),on:ie.on.bind(ie),detach:ie.detach.bind(ie),getRow:K.getRow.bind(K),getColumn:K.getColumn.bind(K)}),[K,ie]),[z,Q]=f.useState(0),[X,P]=f.useState(0),[le,we]=f.useState(null),[L,$]=f.useState(null),xe=f.useMemo(()=>{if(E&&!a.length&&n.length){const oe=n[0],Ye=[];for(let De in oe)if(De!=="id"&&De[0]!=="$"){let We={id:De,header:De[0].toUpperCase()+De.slice(1)};typeof E=="object"&&(We={...We,...E}),Ye.push(We)}return Ye}return(L&&L.columns)??a},[E,a,n,L]),Se=f.useMemo(()=>(L&&L.sizes)??A,[L,A]),fe=f.useCallback(oe=>{if(Q(oe.width),P(oe.height),U){const Ye=Object.keys(U).map(Number).sort((De,We)=>De-We).find(De=>oe.width<=De)??null;Ye!==le&&($(U[Ye]),we(Ye))}},[U,le]),Te=f.useContext(Cn.theme),Ie=f.useRef(0);return f.useEffect(()=>{if(!Ie.current)R&&R(W);else{const oe=K.getState();K.init({data:n,columns:xe,split:T||oe.split,sizes:Se||oe.sizes,selectedRows:u||oe.selectedRows,dynamic:w,tree:k,sortMarks:F||oe.sortMarks,filterValues:I||oe.filterValues,undo:V,reorder:b,_skin:Te,_select:m})}Ie.current++},[K,n,xe,T,Se,u,w,k,F,I,V,b,Te,m,R,W]),Ie.current===0&&K.init({data:n,columns:xe,split:T||{left:0},sizes:Se||{},selectedRows:u||[],dynamic:w,tree:k,sortMarks:F||{},filterValues:I||{},undo:V,reorder:b,_skin:Te,select:m}),f.useImperativeHandle(Y,()=>({...W}),[W]),i.jsx(Ra.Provider,{value:W,children:i.jsx($h,{words:Uh,optional:!0,children:i.jsx(nk,{header:v,footer:g,overlay:y,rowStyle:l,columnStyle:r,cellStyle:c,onReorder:j,multiselect:p,autoRowHeight:C,clientWidth:z,clientHeight:X,responsiveLevel:le,resize:fe,hotkeys:_})})})});zh(pa);const jn=f.createContext(null),Vh=f.createContext(null),Yh=f.createContext(null);function ik({children:n}){const a=f.useContext(Cn.i18n),l=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=f.useContext(jn),[c]=Za(r,"panels"),u=Ze(r,"activePanel"),m=c[u].path,[p,v]=f.useState(null),[g,w]=f.useState(null),[y,b]=f.useState(""),[j,C]=f.useState(""),[A,T]=f.useState(!1);function k(){const F=y.trim();if(!F){T(!0);return}p.add?r.exec("create-file",{file:{...p.item,name:F},parent:m}):j!==F&&r.exec("rename-file",{id:p.item.id,name:F}),E()}function E(){v(null),T(null),C(""),b("")}function R(){r.exec("delete-files",{ids:g.selected}),w(null)}const U=f.useMemo(()=>({showPrompt(F){const V=F.item.name||(F.item.type==="folder"?l("New folder"):`${l("New file")}.txt`);C(V),b(V),v({...F})},showConfirm(F){w({...F})}}),[l]);return i.jsxs(Vh.Provider,{value:U,children:[i.jsx(ij,{children:n}),p?i.jsx(ph,{title:l(`Enter ${p.item.type} name`),onConfirm:k,onCancel:E,children:i.jsx(Hh,{error:A,select:!0,focus:!0,value:y,onChange:({value:F})=>b(F)})}):null,g?i.jsx(ph,{title:l("Are you sure you want to delete these items:"),onConfirm:R,onCancel:()=>w(null),children:g.selected?i.jsx("ul",{className:"wx-gq7BMzEP wx-list",children:g.selected.map((F,V)=>i.jsx("li",{children:F},V))}):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 lk(n){const a=n.lastIndexOf("."),l=a>0&&a<n.length-1?Math.min(10,n.length-a):Math.min(5,n.length),r=n.slice(0,-l),c=n.slice(-l);return[r,c]}function rk({item:n}){const a=f.useContext(jn),l=f.useContext(Cn.i18n).getGroup("filemanager"),r=f.useContext(jn).templates,[c]=Za(a,"panels"),u=Ze(a,"activePanel"),m=Ze(a,"mode"),p=c[u].selected,v=f.useMemo(()=>r.preview(n,214,163),[r,n]),g=f.useMemo(()=>r.icon(n,"big"),[r,n]),[w,y]=f.useMemo(()=>lk(n.name),[n.name]);return i.jsx(i.Fragment,{children:n.id==="/wx-filemanager-parent-link"?m!=="search"?i.jsx("div",{className:"wx-GAOa4kDV wx-back-item",children:i.jsxs("div",{className:`wx-GAOa4kDV wx-back ${n.navigation?"wx-selected":""}`,"data-id":Sn("/wx-filemanager-parent-link"),children:[i.jsx("i",{className:"wx-GAOa4kDV wxi-arrow-left"}),i.jsx("span",{children:l("Back to parent folder")})]})}):null:i.jsxs("div",{className:`wx-GAOa4kDV wx-item ${p?.length&&p.indexOf(n.id)>=0?"wx-selected":""}`,"data-id":Sn(n.id),children:[v?i.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-preview",children:i.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:l("A miniature file preview"),src:v})}):g?i.jsx("div",{className:"wx-GAOa4kDV wx-preview wx-file-icon",children:i.jsx("img",{className:"wx-GAOa4kDV wx-card-preview",alt:"",src:g})}):i.jsx("div",{className:"wx-GAOa4kDV wx-preview",children:i.jsx("i",{className:`wx-GAOa4kDV wxi-${n.type}`})}),n.type==="folder"?i.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[i.jsxs("div",{className:"wx-GAOa4kDV wx-folder-name",children:[i.jsx("span",{className:"wx-GAOa4kDV wx-type",children:l("Folder")}),i.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[i.jsx("span",{children:w}),i.jsx("span",{children:y})]})]}),i.jsx("div",{"data-action-id":Sn(n.id),className:"wx-GAOa4kDV wx-more",children:i.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]}):i.jsxs("div",{className:"wx-GAOa4kDV wx-info",children:[i.jsx("div",{className:"wx-GAOa4kDV wx-file-name",children:i.jsxs("span",{className:"wx-GAOa4kDV wx-name",children:[i.jsx("span",{children:w}),i.jsx("span",{children:y})]})}),i.jsx("div",{"data-action-id":Sn(n.id),className:"wx-GAOa4kDV wx-more",children:i.jsx("i",{className:"wx-GAOa4kDV wxi-dots-v"})})]})]})})}function pw(){const n=f.useContext(jn),a=f.useContext(Cn.i18n),l=f.useMemo(()=>a.getGroup("filemanager"),[a]),[r]=Za(n,"panels"),c=Ze(n,"activePanel"),u=Ze(n,"mode"),m=r[c]._files,p=r[c].selected,v=r[c].path,g=r[c]._crumbs,w=r[c]._selectNavigation,y=f.useCallback((E,R)=>{const U=R&&(R.ctrlKey||R.metaKey),F=R&&R.shiftKey;if(E==="/wx-filemanager-parent-link"){if(p.length&&(U||F))return;n.exec("select-file",{type:"navigation"});return}let V=E==="body"&&R?null:E;const _=R.target.className.indexOf("wx-more")!==-1||R.target.className.indexOf("wxi-dots-v")!==-1;setTimeout(()=>{n.exec("select-file",{id:V,toggle:U&&!_,range:F&&!_,panel:c})},1)},[n,p,c]),b=f.useCallback(()=>{g.length>1&&n.exec("set-path",{id:g[g.length-2].id,panel:c,selected:[g[g.length-1].id]})},[n,g,c]),j=f.useCallback(E=>{if(E==="/wx-filemanager-parent-link")return b();u==="search"&&n.exec("filter-files",{text:""});const R=m.find(U=>U.id===E);R&&(R.type=="folder"?n.exec("set-path",{id:R.id,panel:c}):n.exec("open-file",{id:R.id}))},[n,b,u,m,c]),C=f.useCallback((E,R)=>{(!p?.length||!p.filter(U=>U?.id===E).length>0)&&y(E,R)},[p,y]),A=f.useMemo(()=>v!=="/"?[{id:"/wx-filemanager-parent-link",name:l("Back to parent folder"),navigation:w},...m]:m,[v,l,w,m]),T=f.useRef(null),k=f.useRef();return f.useEffect(()=>{T.current&&(k.current?(k.current.click=y,k.current._dblclick=j,k.current.context=C):(k.current={click:y,dblclick:E=>k.current._dblclick(E),_dblclick:j,context:C},uo(T.current,k.current)))},[y,j,C]),u=="search"&&!A.length?i.jsx("div",{className:"wx-iyjASZCY wx-not-found",children:i.jsx("div",{className:"wx-iyjASZCY wx-not-found-text",children:l("Looks like nothing is here")})}):i.jsx("div",{tabIndex:0,className:"wx-iyjASZCY "+("wx-cards"+(v!=="/"&&u!=="search"?" wx-has-back-link":"")),"data-id":Sn("body"),ref:T,children:A.map(E=>i.jsx(rk,{item:E},E.id))})}function ur({name:n="",spin:a=!1,onClick:l}){return i.jsx("i",{"data-menu-ignore":"true",className:`wx-uwcvNSAG wx-icon wxi-${n} ${a?"wx-spin":""} ${l?"wx-clickable":""}`,onClick:()=>{l&&l()}})}function ok(){const n=f.useContext(Cn.i18n).getGroup("filemanager"),a=f.useContext(jn),l=Ze(a,"activePanel"),[r]=Za(a,"panels"),c=f.useMemo(()=>r[l]._crumbs,[r,l]);function u(){a.exec("filter-files",{text:""})}return i.jsxs("div",{className:"wx-GDJvtROw wx-search",children:[i.jsxs("div",{className:"wx-GDJvtROw wx-toolbar",children:[i.jsx("div",{className:"wx-GDJvtROw wx-back-icon",children:i.jsx(ur,{name:"angle-left",onClick:u})}),i.jsxs("div",{className:"wx-GDJvtROw wx-text",children:[n("Search results in")," ",Array.isArray(c)&&c.map((m,p)=>i.jsxs(f.Fragment,{children:[p?"/":null,m.id=="/"?n(m.name):m.name]},p))]})]}),i.jsx(pw,{})]})}function Fm({narrowMode:n,extraInfo:a}){const l=f.useContext(jn),{preview:r,icon:c}=l.templates,u=f.useContext(Cn.i18n),m=f.useMemo(()=>u.getGroup("filemanager"),[u]),p=f.useMemo(()=>so("%D, %d %F %Y, %H:%i",u.getRaw().calendar),[u]),[v,g]=Za(l,"panels"),w=Ze(l,"activePanel"),y=Ze(l,"preview"),b=Ze(l,"search"),j=f.useMemo(()=>{const _=v&&w!=null&&v[w]?._selected?.length||0;return b&&!_},[b,g,w]),C=f.useMemo(()=>{const _=v&&w!=null?v[w]:null;return _?j?_._files:_._selected:[]},[j,g,w]),A=f.useCallback((_,I)=>(_?`${_} ${m(_>1?"folders":"folder")} `:"")+(I?`${I} ${m(I>1?"files":"file")}`:""),[m]),T=f.useCallback(()=>{l.exec("show-preview",{mode:!y})},[l,y]),k=f.useCallback(_=>_.type==="folder"?m("Folder"):_.ext||m("Unknown file"),[m]),E=f.useMemo(()=>{let _,I,me,Y,ue,K,ie,ee;if(C.length===1&&!j){I=C[0],_=I.name;const W=r(I,400,500);W?(me=W,Y=""):(Y=c(I,"big"),me=""),ue=I.type!=="folder"}else{if(I=ue=null,_="",C.length){let W=0,z=0,Q=0,X=[],P;C.forEach(we=>{typeof we.size>"u"&&(P=!0,W=void 0),P||(W+=we.size),X.push(k(we)),we.type==="folder"?z++:Q++});const le=new Set(X);K=le.size>1?m("multiple"):[...le][0],ie=A(z,Q),ee=W,j||(_=m("Multiple files"))}Y=c({type:j?"search":C.length?"multiple":"none"},"big"),me=""}return{name:_,item:I,previewSrc:me,iconSrc:Y,showDownloadIcon:ue,type:K,totalCount:ie,totalSize:ee}},[C,j,r,c,m,k,A]),R=f.useCallback(()=>{l.exec("download-file",{id:C[0].id})},[l,C]),U=f.useCallback(async _=>{if(!a||!_)return null;try{return await a(_)}catch(I){return console.log(I),null}},[a]),[F,V]=f.useState(null);return f.useEffect(()=>{let _=!1;return V(null),Promise.resolve(U(E.item)).then(I=>{_||V(I)}).catch(()=>{_||V(null)}),()=>{_=!0}},[U,E.item]),i.jsx("div",{className:"wx-O0BTtRrH wx-wrapper",children:C&&C.length?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"wx-O0BTtRrH wx-preview",children:[i.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[i.jsx("div",{className:"wx-O0BTtRrH wx-name",children:E.name}),i.jsxs("div",{className:"wx-O0BTtRrH wx-icons",children:[E.showDownloadIcon?i.jsx(ur,{name:"download",onClick:R}):null,n?i.jsx(ur,{name:"close",onClick:T}):null]})]}),E.previewSrc?i.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:i.jsx("img",{src:E.previewSrc,alt:m("A miniature file preview")})}):E.iconSrc?i.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:i.jsx("img",{src:E.iconSrc,alt:m("A miniature file preview")})}):i.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:E.item?i.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${E.item.type}`}):i.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${j?"search":"file-multiple-outline"}`})})]}),i.jsxs("div",{className:"wx-O0BTtRrH wx-info-panel",children:[i.jsx("div",{className:"wx-O0BTtRrH wx-title",children:m(j?"Found":"Information")}),i.jsxs("div",{className:"wx-O0BTtRrH wx-list",children:[E.item?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),i.jsx("span",{className:"wx-O0BTtRrH wx-value",children:k(E.item)}),typeof E.item.size<"u"?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Size")}),i.jsx("span",{className:"wx-O0BTtRrH wx-value",children:_c(E.item.size)})]}):null,i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Date")}),i.jsxs("span",{className:"wx-O0BTtRrH wx-value",children:[p(E.item.date)," "]})]}):i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Count")}),i.jsx("span",{className:"wx-O0BTtRrH wx-value",children:E.totalCount}),i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Type")}),i.jsx("span",{className:"wx-O0BTtRrH wx-value",children:E.type}),typeof E.totalSize<"u"?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:m("Size")}),i.jsx("span",{className:"wx-O0BTtRrH wx-value",children:_c(E.totalSize)})]}):null]}),F?Object.entries(F).map(([_,I])=>i.jsxs(Th.Fragment,{children:[i.jsx("span",{className:"wx-O0BTtRrH wx-name",children:_}),i.jsx("span",{className:"wx-O0BTtRrH wx-value",children:I})]},_)):null]})]})]}):i.jsxs("div",{className:"wx-O0BTtRrH wx-no-info-panel",children:[i.jsxs("div",{className:"wx-O0BTtRrH wx-toolbar",children:[i.jsx("div",{className:"wx-O0BTtRrH wx-name",children:E.name}),i.jsx("div",{className:"wx-O0BTtRrH wx-icons",children:n?i.jsx(ur,{name:"close",onClick:T}):null})]}),i.jsx("div",{className:"wx-O0BTtRrH wx-no-info-wrapper",children:i.jsxs("div",{className:"wx-O0BTtRrH wx-no-info",children:[E.previewSrc?i.jsx("div",{className:"wx-O0BTtRrH wx-img-wrapper",children:i.jsx("img",{src:E.previewSrc,alt:m("A miniature file preview")})}):E.iconSrc?i.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:i.jsx("img",{src:E.iconSrc,alt:m("A miniature file preview")})}):i.jsx("div",{className:"wx-O0BTtRrH wx-icon-wrapper",children:i.jsx("i",{className:`wx-O0BTtRrH wx-icon wxi-${j?"search":"message-question-outline"}`})}),i.jsx("span",{className:"wx-O0BTtRrH wx-text",children:j?"":m("Select file or folder to view details")})]})})]})})}function gw({panel:n}){const a=f.useContext(jn),l=f.useContext(Cn.i18n),r=f.useMemo(()=>l.getGroup("filemanager"),[l]),[c,u]=Za(a,"panels"),m=f.useMemo(()=>c[n]._files,[u,n]),p=f.useMemo(()=>c[n]._crumbs||[],[u,n]);function v(C){const A=qh(C,p);a.exec("set-path",{id:C,panel:n,...A&&{selected:[A]}})}const[g,w]=f.useState(null);f.useEffect(()=>{m&&w(null)},[m]);function y(){w(!0),a.exec("request-data",{id:p[p.length-1].id}),setTimeout(()=>{w(null)},5e3)}const b=f.useRef(null),j=f.useRef();return f.useEffect(()=>{j.current?j.current.click=v:(j.current={click:v},uo(b.current,j.current))},[v]),i.jsxs("div",{className:"wx-SNY5LTYx wx-breadcrumbs","data-menu-ignore":"true",ref:b,children:[i.jsx("div",{className:"wx-SNY5LTYx wx-refresh-icon",children:i.jsx(ur,{name:"refresh",spin:!!g,onClick:y})}),p.map((C,A)=>i.jsxs(Th.Fragment,{children:[A?i.jsx(ur,{name:"angle-right"}):null,i.jsx("div",{className:"wx-SNY5LTYx wx-item","data-id":Sn(C.id),"data-menu-ignore":"true",children:C.id=="/"?r(C.name):C.name})]},A))]})}function ck({row:n}){const a=f.useContext(Cn.i18n),[l]=f.useState(()=>a.getGroup("filemanager")),r=f.useContext(jn).templates,[c]=f.useState(()=>r.icon(n,"small"));return i.jsx("div",{className:"wx-qgAqG6sL wx-name-cell",children:n.id==="/wx-filemanager-parent-link"?i.jsxs(i.Fragment,{children:[i.jsx("i",{className:"wx-qgAqG6sL wxi-arrow-left"}),i.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",l("Back to parent folder")]})]}):i.jsxs(i.Fragment,{children:[c?i.jsx("img",{className:"wx-qgAqG6sL wx-icon",alt:"",src:c,height:"24px",width:"24px"}):i.jsx("i",{className:`wx-qgAqG6sL wxi-${n.type}`}),i.jsxs("span",{className:"wx-qgAqG6sL wx-name",children:[" ",n.name," "]})]})})}function vw({children:n}){const a=f.useContext(jn),l=Ze(a,"activePanel"),r=f.useContext(Yh),c=f.useRef(null);let u=f.useRef({});return u.current.drop=()=>{const m=c.current,p=f1(m,"data-panel");p&&p!=l&&a.exec("set-active-panel",{panel:p*1})},u.current.dragEnter=()=>{const m=c.current;m&&m.classList.toggle("wx-active")},u.current.dragLeave=()=>{const m=c.current;m&&m.classList.toggle("wx-active")},f.useEffect(()=>{const m=c.current;return r.droparea(m,u.current)},[]),i.jsx("div",{className:"wx-LT9X7tb7 wx-upload-area",ref:c,children:n})}function xh({panel:n,active:a=!1,onClick:l,onContextMenu:r}){const c=f.useContext(jn),u=f.useContext(Cn.i18n),m=f.useMemo(()=>u.getGroup("filemanager"),[u]),p=f.useMemo(()=>so("%d %M %Y",u.getRaw().calendar),[u]),[v]=Za(c,"panels"),g=v[n].selected,w=v[n].path,y=v[n]._crumbs,b=v[n]._sorts,j=v[n]._selectNavigation,C=v[n]._files,A=f.useMemo(()=>[{id:"name",header:m("Name"),flexgrow:3,sort:!0,resize:!0,cell:ck},{id:"size",header:m("Size"),width:100,sort:!0,resize:!0,template:K=>typeof K=="number"?_c(K):""},{id:"date",header:m("Date"),width:120,sort:!0,resize:!0,template:K=>K?p(K):""}],[m,p]),T=f.useRef(null),k=f.useRef(null),E=f.useMemo(()=>j?["/wx-filemanager-parent-link"]:[...g],[j,g]);function R(K,ie){if(ie&&ie.target&&ie.target.className&&ie.target.className.indexOf("wx-grip")!==-1)return;const ee=ie&&(ie.ctrlKey||ie.metaKey),W=ie&&ie.shiftKey;if(K==="/wx-filemanager-parent-link"){if(g.length&&(ee||W))return;c.exec("select-file",{type:"navigation"});return}let z=K==="body"&&ie?null:K;!T.current&&!k.current?c.exec("select-file",{id:z,toggle:ee,range:W,panel:n}):(T.current=null,k.current=null)}function U(){y.length>1&&c.exec("set-path",{id:y[y.length-2].id,panel:n,selected:[y[y.length-1].id]})}function F(K){if(K==="/wx-filemanager-parent-link")return U();const ie=C.find(ee=>ee.id===K);ie&&(ie.type==="folder"?c.exec("set-path",{id:ie.id,panel:n}):c.exec("open-file",{id:ie.id}))}function V(K){const ie=K.key,ee=b[w];let W=ee?"asc":"desc";ee&&ee.key===ie&&(W=ee.order==="asc"?"desc":"asc"),c.exec("sort-files",{key:ie,order:W,panel:n,path:w})}function _(K){K.intercept("sort-rows",ie=>(T.current=!0,V(ie),!1)),K.intercept("select-row",()=>!1),K.on("resize-column",()=>k.current=!0),K.intercept("hotkey",()=>!1)}const I=f.useMemo(()=>w!=="/"?[{id:"/wx-filemanager-parent-link",name:m("Back to parent folder")},...C]:C,[w,C,m]),me=f.useMemo(()=>{if(I&&b&&b[w]){const{key:K,order:ie}=b[w];return{[K]:{order:ie}}}},[I,b,w]),Y=f.useRef(null),ue=f.useRef();return f.useEffect(()=>{ue.current?(ue.current.click=R,ue.current._dblclick=F):(ue.current={click:R,dblclick:K=>ue.current._dblclick(K),_dblclick:F},uo(Y.current,ue.current))},[R,F]),i.jsxs("div",{onClick:l,onContextMenu:r,className:"wx-SSaVhET7 wx-wrapper",children:[i.jsx(gw,{panel:n}),i.jsx("div",{"data-id":Sn("body"),className:`wx-SSaVhET7 wx-list ${a?"wx-active":""}`,ref:Y,children:i.jsx(vw,{children:i.jsx(sk,{init:_,data:I,columns:A,selectedRows:E,columnStyle:()=>"wx-SSaVhET7 wx-each-cell",sizes:{rowHeight:42,headerHeight:42},sortMarks:me})})})]})}function uk(){const n=f.useContext(jn),a=Ze(n,"activePanel");function l(r){n.exec("set-active-panel",{panel:r})}return i.jsxs("div",{className:"wx-L55BfJa2 wx-panels","data-id":Sn("body"),children:[i.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":0,children:i.jsx(xh,{panel:0,active:a==0,onClick:()=>l(0),onContextMenu:()=>l(0)})}),i.jsx("div",{className:"wx-L55BfJa2 wx-item","data-panel":1,children:i.jsx(xh,{panel:1,active:a==1,onClick:()=>l(1),onContextMenu:()=>l(1)})})]})}function xw({folderIcon:n=!1,folder:a={}}){const l=f.useContext(jn),[r,c]=Za(l,"panels"),u=Ze(l,"activePanel"),m=f.useMemo(()=>r[u].path,[c,u]),p=f.useContext(Cn.i18n),v=f.useMemo(()=>p.getGroup("filemanager"),[p]),g=f.useMemo(()=>!!a.data?.find(j=>j.type==="folder"),[a]),w=f.useMemo(()=>a.id=="/"?v(a.name):a.name,[a,v]),y=f.useMemo(()=>a.$level>1?(a.$level-1)*20:0,[a]),b=a.open;return i.jsxs(i.Fragment,{children:[i.jsxs("li",{"data-id":Sn(a.id),className:`wx-NYfhvGIt wx-folder${m===a.id?" wx-selected":""}`,style:{paddingLeft:`${y}px`},children:[g?i.jsx("i",{className:`wx-NYfhvGIt wx-toggle wxi-${b?"angle-down":"angle-right"}`,"data-action":"toggle"}):i.jsx("span",{className:"wx-NYfhvGIt wx-toggle-placeholder"}),i.jsx("i",{className:"wx-NYfhvGIt "+(n||"wxi-folder")}),i.jsxs("span",{className:"wx-NYfhvGIt wx-name",children:[" ",w," "]})]}),b&&a.data&&a.data.length&&g?i.jsx(i.Fragment,{children:a.data.map(j=>j.type==="folder"?i.jsx(xw,{folder:j},j.id):null)}):null]})}function dk(){const n=f.useContext(jn),[a,l]=Za(n,"data"),[r,c]=Za(n,"panels"),u=Ze(n,"activePanel"),m=f.useMemo(()=>r[u]._crumbs,[c,u]),p=f.useCallback(j=>{n.exec("open-tree-folder",{id:j,mode:!a.byId(j).open})},[n,l]),v=f.useCallback(j=>{const C=qh(j,m);n.exec("set-path",{id:j,panel:u,...C&&{selected:[C]}})},[n,m,u]),[g,w]=f.useState([]);f.useEffect(()=>{w(a.byId(0).data)},[l]);const y=f.useRef(null),b=f.useRef();return f.useEffect(()=>{b.current?(b.current.click=v,b.current.toggle=p):(b.current={click:v,toggle:p},uo(y.current,b.current))},[v,p]),i.jsx("ul",{ref:y,className:"wx-LyHJ6R6A",children:g.map(j=>j.type==="folder"?i.jsx(xw,{folder:j},j.id):null)})}function fk(){const n=f.useContext(jn),a=f.useContext(Cn.i18n),l=f.useMemo(()=>a.getGroup("filemanager"),[a]),r=Ze(n,"drive"),c=r?r.used:"",u=r?r.total:"";return c&&u?i.jsxs("div",{className:"wx-DetSyKGG wx-drive",children:[i.jsx("progress",{value:c,max:u,className:"wx-DetSyKGG wx-progress"}),i.jsxs("p",{children:[_c(c)," ",l("of")," ",_c(u)," ",l("used")]})]}):null}function mk({option:n}){const a=f.useContext(Cn.i18n).getGroup("filemanager"),l=f.useContext(Yh),r=f.useCallback(()=>{l.open({})},[l]);return i.jsx("div",{className:"wx-9XiKcxq5 wx-upload-button",onClick:r,children:i.jsx("span",{children:a(n.text)})})}function hk({readonly:n,menuOptions:a}){const l=f.useContext(Cn.i18n).getGroup("filemanager"),{showPrompt:r}=f.useContext(Vh);f.useEffect(()=>{Dj("upload",mk)},[]);function c({action:m}){m&&(m.id==="add-file"?r({item:{type:"file",size:0,date:new Date},add:!0}):m.id==="add-folder"&&r({item:{type:"folder",date:new Date},add:!0}))}const u=f.useMemo(()=>a("add").map(m=>(m.text=l(m.text),m)),[a,l]);return i.jsxs("div",{className:"wx-FlucfALM wx-wrapper",children:[!n&&i.jsx("div",{className:"wx-FlucfALM wx-button",children:i.jsx(_j,{options:u,at:"bottom-fit",onClick:c,children:i.jsx(Nc,{type:"primary block",children:l("Add New")})})}),i.jsx("div",{className:"wx-FlucfALM wx-tree",children:i.jsx(dk,{})}),i.jsx(fk,{})]})}function pk({value:n="",onSearch:a}){const[l,r]=Zy(n),c=f.useContext(Cn.i18n).getGroup("filemanager"),u=f.useRef(null),m=f.useMemo(()=>l!==""?"wxi-close":"wxi-search",[l]);function p(g){const w=g.target.value;r(w),a&&a({value:w})}function v(){r(""),u.current&&u.current.focus(),a&&a({value:""})}return i.jsxs("div",{className:"wx-lUZMtgT1 wx-search-input",children:[i.jsx("i",{className:`wx-lUZMtgT1 wx-icon ${m}`,onClick:v}),i.jsx("input",{type:"text",className:"wx-lUZMtgT1 wx-text",ref:u,value:l,onInput:p,placeholder:c("Search")})]})}function gk({narrowMode:n=!1,onShowTree:a}){const l=f.useContext(jn),r=f.useContext(Cn.i18n).getGroup("filemanager"),c=Ze(l,"mode"),u=Ze(l,"preview"),m=Ze(l,"search"),p=[{icon:"wxi-view-sequential",id:"table"},{icon:"wxi-view-grid",id:"cards"},{icon:"wxi-view-column",id:"panels"}];function v({value:y}){l.exec("set-mode",{mode:y})}function g(y){y.preventDefault(),l.exec("show-preview",{mode:!u})}function w(y){l.exec("filter-files",{text:y.value})}return i.jsxs("div",{className:"wx-5PZQQztG wx-toolbar",children:[i.jsxs("div",{className:"wx-5PZQQztG wx-left "+(n?"wx-left-narrow":""),children:[n?c==="panels"||c==="search"?null:i.jsx("div",{className:"wx-5PZQQztG wx-sidebar-icon","data-id":Sn("toggle-tree"),children:i.jsx(ur,{onClick:()=>a&&a(),name:"subtask"})}):i.jsx("div",{className:"wx-5PZQQztG wx-name",children:r("Files")}),i.jsx(pk,{onSearch:w,value:m})]}),i.jsxs("div",{className:"wx-5PZQQztG wx-right",children:[n?null:i.jsx("div",{className:"wx-5PZQQztG wx-preview-icon",children:i.jsx(lj,{onClick:g,value:u,children:i.jsx("i",{className:"wx-5PZQQztG wxi-eye"})})}),i.jsx("div",{className:"wx-5PZQQztG wx-modes",children:i.jsx(ej,{value:c,options:p,onChange:v})})]})]})}function vk(){const n=f.useContext(jn),a=Ze(n,"activePanel");return i.jsxs("div",{className:"wx-NwohNJzN wx-wrapper",children:[i.jsx(gw,{panel:a}),i.jsx(vw,{children:i.jsx(pw,{})})]})}function xk({readonly:n=!1,menuOptions:a,extraInfo:l}){const r=f.useRef(null),c=f.useRef(null),[u,m]=f.useState(void 0),[p,v]=f.useState(void 0),[g,w]=f.useState(!1),y=iw(),b=f.useContext(jn),{showPrompt:j,showConfirm:C}=f.useContext(Vh),A=f.useContext(Cn.i18n),T=f.useMemo(()=>A.getGroup("filemanager"),[A]),k=Ze(b,"mode"),E=Ze(b,"preview"),R=Ze(b,"activePanel"),[U,F]=Za(b,"panels"),V=f.useMemo(()=>(U&&R!=null?U[R]:null)?.selected??[],[F,R]),_=f.useMemo(()=>(U&&R!=null?U[R]:null)?.path,[F,R]),[I,me]=f.useState([]);f.useEffect(()=>{const le=r.current;if(!le)return;const we=new ResizeObserver(L=>{const $=L[0]?.borderBoxSize?.[0]?.inlineSize;typeof $=="number"&&v($<768)});return we.observe(le),()=>{we.disconnect()}},[]);const Y=f.useCallback(()=>{w(le=>!le)},[]),ue=f.useCallback(le=>{p&&Lc(le)!=="toggle-tree"&&w(!1)},[p]);f.useEffect(()=>{const le=c.current;if(le)return Us(le,ue).destroy},[ue]),f.useEffect(()=>{const le=c.current;if(!le)return;const we=new ResizeObserver(()=>{le&&m(le.clientWidth)});return we.observe(le),le&&m(le.clientWidth),()=>{we.disconnect()}},[]);const K=f.useMemo(()=>({icon:"wxi-eye",text:"Preview",id:"preview"}),[]),ie=f.useCallback(le=>{let we=p?[K]:[];return le==="file"&&(we=[...we,...a().filter(L=>L.id==="download")]),we},[p,K,a]),ee=f.useRef(null),W=f.useCallback((le,we,L)=>{const $=L?[we.id]:V;switch(le){case"download":b.exec("download-file",{id:we.id});break;case"copy":case"move":ee.current={action:le,ids:$};break;case"paste":ee.current&&b.exec(ee.current.action==="copy"?"copy-files":"move-files",{ids:ee.current.ids,target:we?.type==="folder"?we.id:_});break;case"rename":j({item:we});break;case"delete":C({selected:$});break;case"preview":b.exec("show-preview",{mode:!E});break}},[b,V,_,j,C,E]),z=f.useCallback(()=>U?.[R],[U,R]);f.useEffect(()=>{const le=r.current;if(!le)return;const we=bj(le,{api:b,menuOptions:n?ie:a,performAction:W,getPanel:z});return()=>{typeof we=="function"?we():we&&typeof we.destroy=="function"&&we.destroy()}},[b,n,ie,a,W,z]);const Q=f.useCallback((le,we)=>{const L=le?b.getFile(le):null,$=we.target.closest(".tree-item.folder");let xe;if(n)xe=ie(L?.type);else{switch(le){case"body":xe=a(le);break;default:if(L)if(!$&&V.length>1)xe=p?[K,...a("multiselect")]:a("multiselect");else if(le==="/")xe=a("folder",L).filter(Se=>Se.id==="paste");else{const Se=a(L.type,L);Se&&(xe=p?[K,...Se]:Se)}}k==="search"&&(xe=xe?.filter(Se=>Se.id!=="paste"))}if(L?.id&&(!V.length||!V.some(Se=>Se===L.id))&&!$&&b.exec("select-file",{id:L.id}),xe?.length)return xe.forEach(Se=>{$&&(Se.hotkey=""),Se.text&&(Se.text=T(Se.text)),Se.hotkey&&(Se.subtext=Se.hotkey)}),me(xe),L||{}},[b,n,ie,a,V,p,K,k,T]),X=f.useCallback(le=>{const{action:we,context:L}=le;we&&W(we.id,L,!we.hotkey)},[W]);async function P(le){await Promise.resolve();const{name:we,size:L}=le.file;b.exec("create-file",{file:{name:we,size:L,date:new Date,file:le.file},parent:_})}return i.jsx("div",{className:"wx-RJbNonjJ wx-filemanager wx-flex",ref:r,"data-menu-ignore":"false",children:p&&E?i.jsx("div",{className:"wx-RJbNonjJ wx-info-narrow",children:i.jsx(Fm,{narrowMode:p,extraInfo:l})}):i.jsxs(i.Fragment,{children:[i.jsx(gk,{narrowMode:p,onShowTree:Y}),i.jsx(zj,{dataKey:"id",at:"point",options:I,resolver:Q,onClick:X,children:i.jsxs(sw,{dataKey:"actionId",options:I,resolver:Q,onClick:X,children:[i.jsx(Hj,{data:y,apiOnly:!0,uploadURL:P}),i.jsx(Yh.Provider,{value:y,children:i.jsx("div",{className:"wx-RJbNonjJ wx-content-wrapper wx-flex",children:k!=="panels"&&k!=="search"?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"wx-RJbNonjJ "+["wx-sidebar",p?"wx-sidebar-narrow":"",g?"wx-sidebar-visible":""].filter(Boolean).join(" "),ref:c,children:i.jsx(hk,{readonly:n,menuOptions:a})}),i.jsxs("div",{className:"wx-RJbNonjJ wx-content",style:{width:`calc(100% - ${u||0}px - 10px)`},children:[i.jsx("div",{className:`wx-RJbNonjJ wx-content-item${E?"":"-fit"}`,"data-id":Sn("body"),children:k==="table"?i.jsx(xh,{panel:R}):i.jsx(vk,{})}),E?i.jsx("div",{className:"wx-RJbNonjJ wx-info",children:i.jsx(Fm,{extraInfo:l})}):null]})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:`wx-RJbNonjJ wx-content-item${E?"":"-fit"}`,children:k==="panels"?i.jsx(uk,{}):i.jsx(ok,{})}),E?i.jsx("div",{className:"wx-RJbNonjJ wx-info",children:i.jsx(Fm,{extraInfo:l})}):null]})})})]})})]})})}const yk=n=>n.split("-").map(a=>a?a.charAt(0).toUpperCase()+a.slice(1):"").join("");function wk(n,a){const{type:l,ext:r}=n;if(l==="folder")return!1;let c;return l&&l!=="file"&&Lx[l]?c=l:r?c=Lx[r]?r:"file":c="unknown",`https://cdn.svar.dev/icons/filemanager/vivid/${a}/${c}.svg`}const bk=f.forwardRef(function(n,a){const{data:l=[],mode:r="cards",drive:c=null,preview:u=!1,panels:m=null,activePanel:p=0,readonly:v=!1,menuOptions:g=xj,extraInfo:w=null,init:y=null,icons:b=wk,previews:j=null,...C}=n,A=f.useRef();A.current=C;const T=f.useMemo(()=>new vj(ew),[]),k=f.useMemo(()=>T.in,[T]),E=f.useRef(null);E.current===null&&(E.current=new Wy((F,V)=>{const _="on"+yk(F);A.current&&A.current[_]&&A.current[_](V)}),k.setNext(E.current));const R=f.useMemo(()=>({getState:T.getState.bind(T),getReactiveState:T.getReactive.bind(T),getStores:()=>({data:T}),exec:k.exec,setNext:F=>(E.current=E.current.setNext(F),E.current),intercept:k.intercept.bind(k),on:k.on.bind(k),detach:k.detach.bind(k),getFile:T.getFile.bind(T),serialize:T.serialize.bind(T),templates:{preview:j||(()=>null),icon:b==="simple"?(()=>null):b}}),[T,k]),U=f.useRef(0);return f.useEffect(()=>{if(!U.current)y&&y(R);else{const F=T.getState();T.init({data:l,mode:r,drive:c,preview:u,panels:m||F.panels||[],activePanel:p})}U.current++},[T,l,r,c,u,m,p,y,R]),U.current===0&&T.init({data:l,mode:r,drive:c,preview:u,panels:m||[],activePanel:p}),f.useImperativeHandle(a,()=>({...R}),[R]),i.jsx(jn.Provider,{value:R,children:i.jsx($h,{words:Uh,optional:!0,children:i.jsx(ik,{children:i.jsx(xk,{readonly:v,menuOptions:g,extraInfo:w})})})})});function Sk({fonts:n=!0,children:a}){return a?i.jsx(xx,{fonts:n,children:a}):i.jsx(xx,{fonts:n})}zh(pa);function Wh(n,a){if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`Invalid Hub ${a} response.`);return n}function Ic(n,a,l){const r=Wh(n,l);if(!Array.isArray(r[a]))throw new Error(`Invalid Hub ${l} response: ${a} must be an array.`);return r[a]}function jk(n,a,l){const r=Wh(n,l);if(!r[a]||typeof r[a]!="object"||Array.isArray(r[a]))throw new Error(`Invalid Hub ${l} response: ${a} must be an object.`);return r[a]}async function Ck(n,a=!1){return Ic(await Be(`/api/remote/filesystem/roots${a?"?refresh=1":""}`,void 0,n),"roots","filesystem roots")}async function Hm(n,a){const l=await Be(`/api/remote/filesystem/entries?id=${encodeURIComponent(n)}`,void 0,a);return{folder:jk(l,"folder","filesystem entries"),entries:Ic(l,"entries","filesystem entries")}}async function kk(n,a){return Be("/api/remote/filesystem/selection/scan",{method:"POST",body:JSON.stringify({itemIds:n})},a)}async function Ak(n,a,l,r){return Be("/api/remote/files/from-hub",{method:"POST",body:JSON.stringify({itemIds:n,deviceIds:a,remoteDirectory:l})},r)}async function Mk(n,a=!1){const l=await Be(`/api/remote/files/jobs?active=${a?"1":"0"}`,void 0,n);return{jobs:Ic(l,"jobs","file transfer jobs")}}async function Nk(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}`,void 0,a)}async function Tk(n,a){return Be(`/api/remote/files/jobs/${encodeURIComponent(n)}/cancel`,{method:"POST"},a)}async function _x(n){return Ic(await Be("/api/remote/filesystem/shared-folders",void 0,n),"folders","shared folders")}async function Ek(n,a){return Be("/api/remote/filesystem/shared-folders",{method:"POST",body:JSON.stringify({sourceId:n})},a)}async function Rk(n,a,l){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"PATCH",body:JSON.stringify(a)},l)}async function Dk(n,a){return Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function Lk(n,a,l,r){const c=await Be(`/api/remote/filesystem/shared-folders/${encodeURIComponent(n)}/sync`,{method:"POST",body:JSON.stringify({deviceIds:a,remoteDirectory:l})},r),u=Wh(c,"shared folder sync");return{ok:u.ok===!0,jobs:Ic(c,"jobs","shared folder sync"),files:Number(u.files||0),totalBytes:Number(u.totalBytes||0)}}function _k(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 zx(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let l=n,r=0;for(;l>=1024&&r<a.length-1;)l/=1024,r+=1;return`${l.toFixed(r===0||l>=100?0:1)} ${a[r]}`}function xd(n){return n.driveType==="network"?"network":n.driveType==="removable"?"removable":"local"}function zk(n){const a=n.filter(l=>xd(l)==="local");return a.find(l=>/\bC:/i.test(`${l.name} ${l.displayPath||""}`))||a[0]||n[0]||null}function Ik({hubUrl:n,roots:a,loading:l,error:r,onRefreshRoots:c,onImportFiles:u,onImportFolder:m,onSelectionChange:p,onShareItem:v,onAddSyncFolder:g,onNotice:w}){const y=f.useRef(null),b=f.useRef("/"),j=f.useRef(0),C=f.useRef([]),A=f.useRef(new Map),[T,k]=f.useState(null),[E,R]=f.useState([]),[U,F]=f.useState([]),[V,_]=f.useState(0),[I,me]=f.useState(null),[Y,ue]=f.useState(!1),[K,ie]=f.useState(""),[ee,W]=f.useState(new Set),z=a.find(D=>D.id===T)||null,Q=E[E.length-1]||null,X=z?Q?.svarPath||`/${z.name}`:null,P=X;f.useEffect(()=>{C.current=E,b.current=P||"/"},[P,E]);const le=f.useMemo(()=>(A.current.clear(),!z||!P||E.length===0?[]:(E.forEach(D=>A.current.set(D.svarPath,D.hubId)),[...E.map((D,ne)=>({id:D.svarPath,parent:ne===0?"/":E[ne-1].svarPath,type:"folder",name:D.name,date:D.modifiedAt?new Date(D.modifiedAt):void 0,lazy:!1})),...U.map(D=>{const ne=`${P}/${D.name}`;return A.current.set(ne,D.id),{id:ne,parent:P,name:D.name,type:D.type==="file"?"file":"folder",...D.type==="file"?{size:D.size}:{},date:D.modifiedAt?new Date(D.modifiedAt):void 0,lazy:D.type!=="file"&&D.hasChildren===!0,displayPath:D.displayPath,locked:D.locked,driveType:D.driveType,totalBytes:D.totalBytes,freeBytes:D.freeBytes}})])),[z,U,P,E]),we=D=>A.current.get(String(D))||String(D),L=D=>_k({...D,id:we(String(D.id)),parent:we(String(D.parent))}),$=async(D,ne)=>{const je=D[D.length-1];if(!je)return;const te=++j.current;ue(!0),ie("");try{const ce=await Hm(je.hubId,n);if(te!==j.current)return;if(!Array.isArray(ce.entries))throw new Error("Invalid Hub filesystem entries response.");const Me={...je,displayPath:ce.folder.displayPath||je.displayPath,modifiedAt:ce.folder.modifiedAt||je.modifiedAt},Ce=[...D.slice(0,-1),Me];C.current=Ce,R(Ce),F(ce.entries),_(it=>it+1)}catch(ce){if(te!==j.current)return;console.error("[LiveDesk FS] folder navigation failed",{folderId:je.hubId,error:ce}),ie(ce instanceof Error?`${ne}: ${ce.message}`:`${ne}: Unable to read this folder.`)}finally{te===j.current&&ue(!1)}},xe=async D=>{const ne={svarPath:`/${D.name}`,hubId:D.id,name:D.name,displayPath:D.displayPath,modifiedAt:D.modifiedAt},je=++j.current;k(D.id),C.current=[ne],R([ne]),b.current=ne.svarPath,F([]),ie(""),ue(!0),me(D.id),W(te=>{const ce=new Set(te);return ce.delete(D.id),ce});try{const te=await Hm(D.id,n);if(je!==j.current)return;if(!Array.isArray(te.entries))throw new Error("Invalid Hub filesystem entries response.");const ce={...ne,displayPath:te.folder.displayPath||ne.displayPath,modifiedAt:te.folder.modifiedAt||ne.modifiedAt};C.current=[ce],R([ce]),F(te.entries),_(Me=>Me+1)}catch(te){if(je!==j.current)return;console.error("[LiveDesk FS] getEntries failed",{rootId:D.id,error:te}),W(ce=>new Set(ce).add(D.id)),ie(te instanceof Error?`${D.name}: ${te.message}`:`${D.name}: Unable to read this drive.`),w(te instanceof Error?`${D.name}: ${te.message}`:`${D.name}: Unable to read this drive.`)}finally{je===j.current&&(me(null),ue(!1))}},Se=D=>{const ne=C.current;D<0||D>=ne.length||D===ne.length-1||$(ne.slice(0,D+1),ne[D].name)},fe=(D,ne)=>{if(D.type!=="folder")return;const je=C.current,te=je.findIndex(Me=>Me.svarPath===ne);if(te<0)return;const ce={svarPath:`${ne}/${D.name}`,hubId:D.id,name:D.name,displayPath:D.displayPath,modifiedAt:D.modifiedAt};$([...je.slice(0,te+1),ce],D.name)},Te=()=>Se(C.current.length-2),Ie=D=>{if(D.key!=="Enter"&&D.code!=="Enter"&&D.code!=="NumpadEnter"||D.target?.closest('button, input, textarea, [contenteditable="true"]'))return;const je=y.current;if(!je)return;const te=je.getState().panels?.flatMap(Me=>Me.selected||[])||[];if(te.length!==1)return;const ce=je.getFile(String(te[0]));ce?.type==="folder"&&(D.preventDefault(),D.stopPropagation(),fe(L(ce),String(ce.parent||b.current)))};f.useEffect(()=>{const D=a.find(ne=>ne.id===T)||zk(a);if(W(ne=>new Set([...ne].filter(je=>a.some(te=>te.id===je)))),!D){k(null),C.current=[],R([]),F([]);return}xe(D)},[a]);const oe=D=>{y.current=D,D.on("request-data",async({id:ne})=>{const je=String(ne),te=we(je);try{const ce=await Hm(te,n);if(!Array.isArray(ce.entries))throw new Error("Invalid Hub filesystem entries response.");const Me=ce.entries.map(Ce=>{const it=`${je}/${Ce.name}`;return A.current.set(it,Ce.id),{id:it,parent:je,name:Ce.name,type:Ce.type==="file"?"file":"folder",...Ce.type==="file"?{size:Ce.size}:{},date:Ce.modifiedAt?new Date(Ce.modifiedAt):void 0,lazy:Ce.type!=="file"&&Ce.hasChildren===!0,displayPath:Ce.displayPath,locked:Ce.locked,driveType:Ce.driveType,totalBytes:Ce.totalBytes,freeBytes:Ce.freeBytes}});await D.exec("provide-data",{id:je,data:Me})}catch(ce){console.error("[LiveDesk FS] nested getEntries failed",{id:te,error:ce}),w(ce instanceof Error?ce.message:"Unable to read this folder.")}}),D.intercept("set-path",({id:ne})=>{const je=String(ne),te=C.current.findIndex(Me=>Me.svarPath===je);if(te>=0)return Se(te),!1;const ce=D.getFile(je);if(ce?.type==="folder")return fe(L(ce),String(ce.parent||b.current)),!1}),D.intercept("open-file",()=>!1),D.on("select-file",()=>{window.setTimeout(()=>{const te=(D.getState().panels?.flatMap(ce=>ce.selected||[])||[]).map(ce=>D.getFile(ce)).filter(Boolean).map(ce=>L(ce));p(te.map(ce=>ce.id),te)},0)})},Ye=(D,ne)=>{const je=ne?L(ne):null,te=()=>{const ce=je?.type==="file"?String(ne?.parent||b.current):String(ne?.id||b.current);y.current?.exec("request-data",{id:ce})};return D==="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.")}]:D==="multiselect"?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>{(y.current?.getState().panels?.flatMap(Me=>Me.selected||[])||[]).forEach(Me=>{const Ce=y.current?.getFile(Me);Ce&&v(L(Ce))})}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:te}]:je?[{id:"share",text:"Share to workstations",icon:"mdi mdi-share-variant",handler:()=>v(je)},...je.type==="folder"?[{id:"sync",text:"Add folder to Sync",icon:"mdi mdi-folder-sync-outline",handler:()=>g(je)}]:[],{id:"copy-path",text:"Copy path",icon:"mdi mdi-content-copy",handler:()=>{ir(je.displayPath||je.name)}},{id:"refresh",text:"Refresh",icon:"mdi mdi-refresh",handler:te},{id:"properties",text:"Properties",icon:"mdi mdi-information-outline",handler:()=>w(`${je.name}
12
+ ${je.displayPath||""}`)}]:[]},De=async()=>{try{await c()}catch(D){w(D instanceof Error?D.message:"Unable to refresh Hub drives.")}},We=[{id:"local",label:"Local drives",icon:mc,roots:a.filter(D=>xd(D)==="local")},{id:"removable",label:"Removable drives",icon:sS,roots:a.filter(D=>xd(D)==="removable")},{id:"network",label:"Network drives",icon:Eh,roots:a.filter(D=>xd(D)==="network")}];return i.jsxs("section",{className:"hub-file-explorer-panel","aria-label":"Hub file explorer",children:[i.jsxs("div",{className:"hub-file-explorer-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Hub file explorer"}),i.jsxs("strong",{children:[i.jsx(mc,{size:16})," Browse files on this Hub"]})]}),i.jsxs("div",{className:"hub-file-explorer-heading-actions",children:[i.jsx("button",{className:"icon-button",onClick:u,title:"Import files from this browser",type:"button",children:i.jsx(vy,{size:16})}),i.jsx("button",{className:"icon-button",onClick:m,title:"Import folder from this browser",type:"button",children:i.jsx(iS,{size:16})}),i.jsx("button",{className:"icon-button",onClick:()=>{De()},title:"Refresh drives",type:"button",children:i.jsx(fr,{size:16})})]})]}),l?i.jsxs("div",{className:"hub-file-explorer-state",children:[i.jsx(mc,{size:24}),i.jsx("strong",{children:"Connecting to LiveDesk Hub file system..."})]}):r?i.jsxs("div",{className:"hub-file-explorer-state error",role:"alert",children:[i.jsx(Ai,{size:24}),i.jsx("strong",{children:r})]}):i.jsxs("div",{className:"hub-file-explorer-content",children:[i.jsxs("aside",{className:"hub-file-explorer-drive-sidebar","aria-label":"Hub drives",children:[i.jsxs("div",{className:"hub-drive-sidebar-title",children:[i.jsx(mc,{size:15}),i.jsx("strong",{children:"This PC"})]}),We.map(D=>D.roots.length>0&&i.jsxs("section",{className:"hub-drive-group",children:[i.jsxs("h3",{children:[i.jsx(D.icon,{size:13}),D.label]}),i.jsx("div",{className:"hub-drive-list",children:D.roots.map(ne=>{const je=D.icon,te=ee.has(ne.id)||ne.locked===!0;return i.jsxs("button",{className:`hub-drive-item ${T===ne.id?"active":""} ${te?"unavailable":""}`,onClick:()=>{xe(ne)},"aria-pressed":T===ne.id,type:"button",children:[i.jsx("span",{className:"hub-drive-item-icon",children:i.jsx(je,{size:16})}),i.jsxs("span",{className:"hub-drive-item-copy",children:[i.jsx("strong",{children:ne.name}),i.jsx("small",{children:ne.displayPath||ne.name}),i.jsxs("em",{children:[zx(ne.freeBytes||0)," free / ",zx(ne.totalBytes||0)]})]}),I===ne.id?i.jsx(jd,{className:"hub-drive-item-status spin",size:15}):te?i.jsx(zv,{className:"hub-drive-item-status",size:15}):null]},ne.id)})})]},D.id)),a.length===0&&i.jsxs("div",{className:"hub-drive-sidebar-empty",children:[i.jsx(Ai,{size:17}),i.jsx("span",{children:"No drives available."})]})]}),i.jsxs("div",{className:"hub-file-explorer-browser",children:[i.jsxs("div",{className:"hub-file-explorer-navigation",children:[i.jsx("nav",{className:"hub-file-explorer-breadcrumbs","aria-label":"Current Hub folder",children:E.map((D,ne)=>i.jsxs("span",{className:"hub-file-explorer-breadcrumb-item",children:[ne>0&&i.jsx(Rh,{size:13,"aria-hidden":"true"}),i.jsx("button",{className:`hub-file-explorer-breadcrumb ${ne===E.length-1?"current":""}`,onClick:()=>Se(ne),"aria-current":ne===E.length-1?"location":void 0,type:"button",children:D.name})]},D.svarPath))}),i.jsxs("div",{className:"hub-file-explorer-navigation-actions",children:[Y&&i.jsx(jd,{className:"hub-file-explorer-loading-icon spin",size:15,"aria-label":"Loading folder"}),i.jsx("button",{className:"icon-button",onClick:Te,disabled:E.length<=1||Y,title:"Back to parent folder",type:"button",children:i.jsx(xy,{size:16})})]})]}),K&&i.jsxs("div",{className:"hub-file-explorer-folder-error",role:"alert",children:[i.jsx(zv,{size:15}),i.jsx("span",{children:K})]}),i.jsx("div",{className:"hub-file-explorer-svar",onKeyDownCapture:Ie,children:i.jsx(Sk,{fonts:!1,children:i.jsx(bk,{data:le,panels:X?[{path:X,selected:[]}]:void 0,readonly:!0,mode:"table",preview:!1,init:oe,icons:"simple",menuOptions:Ye},`${z?.id||"no-root"}:${V}`)})})]})]})]})}class Ok extends f.Component{state={error:null};static getDerivedStateFromError(a){return{error:a}}componentDidCatch(a,l){console.error("[LiveDesk] Share Files runtime error",a,l.componentStack)}render(){return this.state.error?i.jsxs("section",{className:"file-share-error-boundary",role:"alert",children:[i.jsx(Ld,{size:24}),i.jsx("strong",{children:"Share Files could not be opened."}),i.jsx("span",{children:this.state.error.message||"An unexpected file explorer error occurred."}),i.jsxs("button",{className:"text-button",onClick:this.props.onRetry,type:"button",children:[i.jsx(fr,{size:15})," Retry"]})]}):this.props.children}}function Bk(n){return n.deviceName||n.hostname||n.deviceId}function Fk({devices:n,mode:a,selectedIds:l,onModeChange:r,onToggle:c}){const u=new Set(l);return i.jsxs("section",{className:"distribution-targets",children:[i.jsxs("div",{className:"file-share-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Target"}),i.jsx("strong",{children:a==="all"?`${n.length} connected`:`${l.length} selected`})]}),i.jsxs("div",{className:"file-share-tabs compact","aria-label":"File transfer targets",children:[i.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[i.jsx(yy,{size:14})," All connected"]}),i.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[i.jsx(Jt,{size:14})," Selected"]})]})]}),i.jsx("div",{className:"file-share-device-list","aria-label":"Connected workstation targets",children:n.length===0?i.jsx("div",{className:"file-share-empty-inline",children:"No connected workstations."}):n.map(m=>{const p=a==="all"||u.has(m.deviceId);return i.jsxs("label",{className:`file-share-device-option ${p?"selected":""}`,children:[i.jsx("input",{type:"checkbox",checked:p,disabled:a==="all",onChange:()=>c(m.deviceId)}),i.jsx(Jt,{size:20,"aria-hidden":"true"}),i.jsxs("span",{children:[i.jsx("strong",{children:Bk(m)}),i.jsxs("small",{children:["Slot ",m.slotNumber?String(m.slotNumber).padStart(3,"0"):"-"," / ",m.platform||"unknown OS"]})]}),i.jsx(On,{size:17,"aria-hidden":"true"})]},m.deviceId)})})]})}function Hk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let l=n,r=0;for(;l>=1024&&r<a.length-1;)l/=1024,r+=1;return`${l.toFixed(r===0||l>=100?0:1)} ${a[r]}`}function Pk({folders:n,loading:a,busy:l,canSync:r,onSyncAll:c,onSync:u,onToggleAuto:m,onRemove:p,onAdd:v}){return i.jsxs("section",{className:"file-share-sync-panel",children:[i.jsxs("div",{className:"file-share-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Hub folders"}),i.jsx("strong",{children:"Continuous sync"})]}),i.jsxs("button",{className:"text-button compact",onClick:c,disabled:l||!r||n.length===0,type:"button",children:[i.jsx(hd,{size:15})," ",l?"Syncing":"Sync all"]})]}),a?i.jsx("div",{className:"file-share-empty-state",children:"Loading Hub sync folders..."}):n.length===0?i.jsxs("button",{className:"file-share-empty-state interactive",onClick:v,type:"button",children:[i.jsx(hd,{size:28}),i.jsx("strong",{children:"Add a selected Hub folder"}),i.jsx("span",{children:"Hub keeps the manifest and can sync while this browser is closed."})]}):i.jsx("div",{className:"file-share-sync-list",children:n.map(g=>i.jsxs("article",{className:`file-share-sync-row state-${g.status}`,children:[i.jsx("div",{className:"file-share-sync-icon",children:i.jsx(hd,{size:19})}),i.jsxs("div",{className:"file-share-sync-info",children:[i.jsx("strong",{children:g.name}),i.jsx("span",{children:g.displayPath}),i.jsxs("small",{children:[g.fileCount," files / ",Hk(g.totalBytes)," · ",g.lastSyncedAt?`Last sync ${rh(g.lastSyncedAt)} ago`:g.message||"Not synced yet"]})]}),i.jsxs("label",{className:"file-share-auto-sync",children:[i.jsx("input",{type:"checkbox",checked:g.autoSync,onChange:()=>m(g)}),i.jsx("span",{children:"Auto"})]}),i.jsxs("button",{className:"text-button compact",onClick:()=>u(g),disabled:l||!r||g.status==="syncing",type:"button",children:[i.jsx(fr,{size:14})," Sync now"]}),i.jsx("button",{className:"icon-button",onClick:()=>p(g),title:"Remove sync folder",type:"button",children:i.jsx(Nh,{size:15})})]},g.id))})]})}function $k(n){const l=(n.targetMode==="all"?n.devices.map(r=>r.deviceId):n.selectedTargetIds).length>0;return i.jsxs("aside",{className:"file-share-distribution-panel",children:[i.jsxs("div",{className:"file-share-distribution-head",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Distribution"}),i.jsx("strong",{children:"Hub → workstations"})]}),i.jsx(ro,{size:18})]}),i.jsxs("div",{className:"file-share-tabs",role:"tablist","aria-label":"Distribution mode",children:[i.jsx("button",{className:n.tab==="send"?"active":"",onClick:()=>n.onTabChange("send"),role:"tab","aria-selected":n.tab==="send",type:"button",children:"Send"}),i.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"?i.jsxs(i.Fragment,{children:[i.jsx(Fk,{devices:n.devices,mode:n.targetMode,selectedIds:n.selectedTargetIds,onModeChange:n.onTargetModeChange,onToggle:n.onTargetToggle}),i.jsxs("label",{className:"file-share-destination",children:[i.jsx("span",{children:"Destination folder"}),i.jsxs("div",{children:[i.jsx(Cc,{size:15}),i.jsx("input",{value:n.remoteDirectory,onChange:r=>n.onRemoteDirectoryChange(r.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),i.jsx("small",{children:"Blank uses Desktop/LiveDeskFiles."})]}),i.jsxs("div",{className:"file-share-selection-summary",children:[i.jsx("span",{children:"Selected"}),i.jsx("strong",{children:n.selectedSummary})]}),i.jsxs("button",{className:"file-share-share-button",onClick:n.onShare,disabled:!n.canShare,type:"button",children:[i.jsx(ro,{size:17})," Share selected"]}),i.jsxs("button",{className:"file-share-secondary-button",onClick:n.onAddSync,disabled:!n.canAddSync,type:"button",children:[i.jsx(Cc,{size:16})," Add selected folder to Sync"]})]}):i.jsx(Pk,{folders:n.folders,loading:n.foldersLoading,busy:n.syncBusy,canSync:l,onSyncAll:n.onSyncAll,onSync:n.onSync,onToggleAuto:n.onToggleAuto,onRemove:n.onRemove,onAdd:n.onAddFolder})]})}function Uk(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let l=n,r=0;for(;l>=1024&&r<a.length-1;)l/=1024,r+=1;return`${l.toFixed(r===0||l>=100?0:1)} ${a[r]}`}function Ix(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 Ox(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 Bx(n){return["completed","partially-failed","failed","cancelled"].includes(n)}function qk({hubUrl:n,devices:a,localFeatureAccess:l,upgradeNotice:r,remoteDirectory:c,onRemoteDirectoryChange:u,targetMode:m,selectedTargetIds:p,onTargetModeChange:v,onTargetToggle:g,filePickerRef:w,folderPickerRef:y,onBrowserFileImport:b,onBrowserFolderImport:j,onNotice:C,onTransferChange:A}){const T=Array.isArray(a)?a:[],[k,E]=f.useState([]),[R,U]=f.useState(!0),[F,V]=f.useState(""),[_,I]=f.useState([]),[me,Y]=f.useState([]),[ue,K]=f.useState(null),[ie,ee]=f.useState(!1),[W,z]=f.useState([]),[Q,X]=f.useState(!0),[P,le]=f.useState(!1),[we,L]=f.useState("send"),[$,xe]=f.useState([]),Se=f.useRef(new Set),fe=f.useMemo(()=>m==="all"?T.map(he=>he.deviceId):p.filter(he=>T.some(Fe=>Fe.deviceId===he)),[T,p,m]),Te=$.find(he=>!Bx(he.state)),Ie=me.length===1&&me[0].type==="folder"?me[0]:null,oe=me.length===0?"Select files or folders from the Hub explorer.":ie?"Calculating selection size...":ue?`${ue.files} files, ${ue.folders} folders · ${Uk(ue.totalBytes)}`:`${me.length} item${me.length===1?"":"s"} selected`,Ye=he=>{A({id:he.jobId,state:he.state,progress:Ix(he),message:Ox(he)})},De=f.useCallback(async()=>{const he=await Ck(n,!0);return E(he),V(""),he},[n]),We=async()=>{try{const Fe=(await Mk(n,!0)).jobs||[],Le=await Promise.all([...Se.current].map(async gn=>{try{return await Nk(gn,n)}catch{return null}})),Ge=[...Fe,...Le.filter(Boolean)],ea=[...new Map(Ge.map(gn=>[gn.jobId,gn])).values()];xe(ea),ea.forEach(Ye),ea.filter(gn=>Bx(gn.state)).forEach(gn=>Se.current.delete(gn.jobId))}catch{}};f.useEffect(()=>{let he=!0;U(!0),V(""),Promise.all([De(),_x(n).then(Le=>{he&&z(Le)})]).catch(Le=>{he&&(V(Le instanceof Error?"Hub file system is unavailable. Make sure LiveDesk Hub is running on this computer.":"Hub file system is unavailable."),C(Le instanceof Error?Le.message:"Hub file system is unavailable."))}).finally(()=>{he&&(U(!1),X(!1))}),We();const Fe=window.setInterval(()=>{We()},800);return()=>{he=!1,window.clearInterval(Fe)}},[n,De]),f.useEffect(()=>{if(_.length===0){K(null);return}let he=!1;return ee(!0),kk(_,n).then(Fe=>{he||K(Fe)}).catch(Fe=>{he||C(Fe instanceof Error?Fe.message:"Unable to calculate selected size.")}).finally(()=>{he||ee(!1)}),()=>{he=!0}},[n,_.join("|")]);const D=(he,Fe)=>{I(he),Y(Fe)},ne=he=>{he.forEach(Fe=>Se.current.add(Fe.jobId)),xe(Fe=>[...new Map([...Fe,...he].map(Le=>[Le.jobId,Le])).values()]),he.forEach(Ye)},je=async()=>{if(!l){C(r);return}if(_.length===0){C("Select files or folders from the Hub explorer.");return}if(fe.length===0){C("Choose at least one connected workstation.");return}if(Te){C("A Hub transfer is already running.");return}try{const he=await Ak(_,fe,c.trim(),n);Se.current.add(he.jobId),C("Hub transfer queued."),await We()}catch(he){C(he instanceof Error?he.message:"Unable to start Hub transfer.")}},te=async he=>{const Fe=he||Ie;if(!Fe||Fe.type!=="folder"){C("Select one folder to add it to Sync.");return}try{const Le=await Ek(Fe.id,n);z(Ge=>[...Ge.filter(ea=>ea.id!==Le.folder.id),Le.folder]),L("sync"),C(`${Fe.name} is ready for Hub sync.`)}catch(Le){C(Le instanceof Error?Le.message:"Unable to add the Hub folder to Sync.")}},ce=async he=>{if(fe.length===0){C("Choose at least one connected workstation.");return}le(!0),z(Fe=>Fe.map(Le=>Le.id===he.id?{...Le,status:"syncing"}:Le));try{const Fe=await Lk(he.id,fe,c.trim(),n);ne(Fe.jobs||[]),C(Fe.jobs?.length?"Hub sync queued.":"No changed files to sync.");const Le=await _x(n);z(Le)}catch(Fe){C(Fe instanceof Error?Fe.message:"Unable to sync the Hub folder."),z(Le=>Le.map(Ge=>Ge.id===he.id?{...Ge,status:"error",message:"Sync failed"}:Ge))}finally{le(!1)}},Me=async()=>{le(!0);try{for(const he of W)await ce(he)}finally{le(!1)}},Ce=async he=>{try{const Fe=await Rk(he.id,{autoSync:!he.autoSync},n);z(Le=>Le.map(Ge=>Ge.id===he.id?Fe.folder:Ge))}catch(Fe){C(Fe instanceof Error?Fe.message:"Unable to update auto sync.")}},it=async he=>{try{await Dk(he.id,n),z(Fe=>Fe.filter(Le=>Le.id!==he.id))}catch(Fe){C(Fe instanceof Error?Fe.message:"Unable to remove the sync folder.")}};return i.jsxs("section",{className:"livedesk-file-explorer",children:[i.jsx("input",{ref:w,className:"hidden-file-input",type:"file",multiple:!0,onChange:he=>{he.currentTarget.files&&b(he.currentTarget.files),he.currentTarget.value=""}}),i.jsx("input",{ref:y,className:"hidden-file-input",type:"file",multiple:!0,webkitdirectory:"",directory:"",onChange:he=>{he.currentTarget.files&&j(he.currentTarget.files),he.currentTarget.value=""}}),i.jsx("div",{className:"file-share-workspace",children:i.jsxs(Ok,{onRetry:()=>window.location.reload(),children:[i.jsx(Ik,{hubUrl:n,roots:k,loading:R,error:F,onRefreshRoots:De,onImportFiles:()=>w.current?.click(),onImportFolder:()=>y.current?.click(),onSelectionChange:D,onShareItem:he=>{I([he.id]),Y([he]),L("send")},onAddSyncFolder:he=>{I([he.id]),Y([he]),te(he)},onNotice:C}),i.jsx($k,{devices:T,targetMode:m,selectedTargetIds:p,onTargetModeChange:v,onTargetToggle:g,remoteDirectory:c,onRemoteDirectoryChange:u,selectedEntries:me,selectedSummary:oe,canShare:l&&!Te&&_.length>0&&fe.length>0&&!ie,onShare:()=>{je()},canAddSync:!!Ie,onAddSync:()=>{te()},tab:we,onTabChange:L,folders:W,foldersLoading:Q,syncBusy:P,onSyncAll:()=>{Me()},onSync:he=>{ce(he)},onToggleAuto:he=>{Ce(he)},onRemove:he=>{it(he)},onAddFolder:()=>{te()}})]})}),Te&&i.jsx("footer",{className:"file-share-workspace-footer",children:i.jsxs("span",{children:[Ox(Te)," · ",Ix(Te),"% ",i.jsx("button",{className:"icon-button",onClick:()=>{Tk(Te.jobId,n).then(he=>{xe(Fe=>Fe.map(Le=>Le.jobId===he.jobId?he:Le)),Ye(he)})},title:"Cancel transfer",type:"button",children:i.jsx(Ps,{size:14})})]})})]})}const Gk=f.forwardRef(function({value:a,onChange:l,onSubmit:r,onOpenSuggestedTasks:c,suggestedOpen:u=!1,suggestedTaskCount:m,disabled:p=!1},v){return i.jsxs("form",{className:"agents-composer",onSubmit:g=>{g.preventDefault(),r()},children:[i.jsxs("button",{className:`agents-suggested-trigger ${u?"active":""}`,type:"button","aria-label":m===void 0?"Open Suggested tasks":`Open Suggested tasks (${m} available)`,"aria-expanded":u,onClick:c,disabled:p,children:[i.jsx(lS,{size:17}),m!==void 0&&i.jsx("span",{className:"agents-suggested-count","aria-hidden":"true",children:m})]}),i.jsx("textarea",{ref:v,value:a,onChange:g=>l(g.target.value.slice(0,4e3)),placeholder:"Ask LiveDesk to work across your machines...","aria-label":"Ask LiveDesk",rows:2,disabled:p}),i.jsxs("button",{className:"agents-run-button",type:"submit",disabled:p||!a.trim(),children:[p?i.jsx(jd,{className:"spin",size:16}):i.jsx(ro,{size:16}),p?"Running":"Run"]})]})}),Vk=["read","processControl","serviceControl","applicationControl","fileRead","fileWrite","fileDelete","shell","script","softwareInstall","network","systemPower","systemConfiguration","userAccount"];function yw(n){return n.deviceName?.trim()||n.hostname?.trim()||n.deviceId}function Yk(n){return n==="running"||n==="completed"||n==="failed"||n==="cancelled"?n:"queued"}function Wk(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 Kk(n){const a=n.match(/\[([^\]]+)\]/)?.[1]?.trim();if(a)return a;if(n.includes("comfyui"))return"comfyui";if(n.includes("ollama"))return"ollama";const l=n.match(/process(?:\s+(?:named|called))?\s+([a-z0-9._-]+)/i)?.[1];return l&&!["is","running","process"].includes(l)?l:void 0}function Qk(n){const a=n.trim().toLowerCase();return!a||/(stop|restart|kill|terminate|start|launch|close|delete|write|edit|run command|execute|install|shutdown|reboot|sleep|power|file|folder|script|application)/i.test(a)?null:/(process|프로세스|실행 중|실행중|comfyui|running|processes)/i.test(a)?{operation:"process.list",query:Kk(a)}:/(gpu|그래픽|vram|gpu 상태)/i.test(a)?{operation:"gpu.status"}:/(disk|디스크|storage|저장 공간)/i.test(a)?{operation:"disk.status"}:/(service|서비스)/i.test(a)?{operation:"service.status"}:/(diagnostic|진단|로그)/i.test(a)?{operation:"diagnostics.collect"}:/(health|system|시스템|상태)/i.test(a)?{operation:"system.health"}:null}const Xk=["이 작업은 아직 지원되지 않습니다.","","현재 지원:","• 시스템 상태 확인","• GPU 상태 확인","• 디스크 상태 확인","• 프로세스 조회","• 서비스 상태 조회","• 진단 로그 수집"].join(`
13
+ `);function Zk(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:null}function Ea(n){return typeof n=="number"&&Number.isFinite(n)?n:null}function rd(n){const a=Ea(n);return a===null?"":a<1024**2?`${Math.round(a/1024)}K`:a<1024**3?`${(a/1024**2).toFixed(0)}M`:`${(a/1024**3).toFixed(1)}G`}function Jk(n){const a=Ea(n);return a===null?"":`${Math.round((a<=1?a:a/100)*100)}%`}function eA(n){return!n||/^(?:[\w .-]+ )?collected(?:\.)?$/i.test(n.trim())?"":n.trim()}function Rd(n,a){if(a.error)return a.error;const l=Zk(a.data),r=eA(a.result||"");if(!l)return r||a.stage||a.status;if(n==="system.health"){const c=typeof l.machine=="string"?l.machine:"",u=rd(l.freeMemoryBytes),m=rd(l.totalMemoryBytes),p=Ea(l.totalMemoryBytes)&&Ea(l.freeMemoryBytes)!==null?`${Math.round(Ea(l.freeMemoryBytes)/Ea(l.totalMemoryBytes)*100)}% RAM free`:"";return[c,u&&m?`RAM ${u}/${m}`:"",p,typeof l.platform=="string"?l.platform:""].filter(Boolean).join(" · ")||r||a.status}if(n==="disk.status"){const c=typeof l.root=="string"?l.root:"",u=rd(l.freeBytes),m=Ea(l.totalBytes)&&Ea(l.freeBytes)!==null?`${Math.round(Ea(l.freeBytes)/Ea(l.totalBytes)*100)}% free`:"";return[c,u&&`${u} free`,m].filter(Boolean).join(" · ")||r||a.status}if(n==="gpu.status"){const c=typeof l.name=="string"&&l.name?l.name:"No GPU provider",u=Jk(l.usageRatio),m=Ea(l.temperatureC)!==null?`${Math.round(Ea(l.temperatureC))}°C`:"",p=rd(l.freeMemoryBytes);return[c,u&&`GPU ${u}`,m,p&&`${p} free`].filter(Boolean).join(" · ")||r||a.status}if(n==="process.list"){const c=Ea(l.count);return c!==null?`${c} matching process${c===1?"":"es"}`:r||a.status}if(n==="network.status"){const c=Array.isArray(l.adapters)?l.adapters.length:null;return c!==null?`${c} active adapter${c===1?"":"s"}`:r||a.status}return r||a.stage||a.status}function Fx(n,a){const l=Rd(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||""} ${l}`)}function tA({state:n,operation:a}){const l=n.status==="completed"?oo:n.status==="failed"||n.status==="cancelled"?Ps:n.status==="running"?jd:wy,r=n.status==="running"?n.stage||"Working":n.status==="completed"?a?Rd(a,n):n.result||"Completed":n.status==="failed"?n.error||"Failed":n.status==="cancelled"?"Cancelled":"Queued";return i.jsxs("div",{className:`agent-target-row status-${n.status}`,"data-agent-target-id":n.deviceId,children:[i.jsx("span",{className:"agent-target-status","aria-hidden":"true",children:i.jsx(l,{size:15})}),i.jsx("strong",{children:n.deviceName}),i.jsx("span",{className:"agent-target-state",children:n.status[0].toUpperCase()+n.status.slice(1)}),i.jsx("small",{children:r})]})}function nA({operation:n,states:a,status:l,onCancel:r,onRetry:c,busy:u=!1}){const m=["running","queued"].includes(l),[p,v]=f.useState(!1),[g,w]=f.useState("all"),y=f.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)),j=b.filter(R=>R.status==="completed").length,C=y.failed>0,A=b.length>0,T=a.filter(R=>g==="issues"?Fx(n,R):g==="running"?R.status==="running"||R.status==="queued":g==="completed"?R.status==="completed":g==="failed"?R.status==="failed":!0),k=A&&!m||l==="completed-with-failures"?"Completed with issues":l[0]?.toUpperCase()+l.slice(1),E=a.filter(R=>R.status==="completed").map(R=>Rd(n,R)).filter(Boolean).filter((R,U,F)=>F.indexOf(R)===U).slice(0,2);return i.jsxs("section",{className:"agent-task-block","aria-label":"Task execution",children:[i.jsxs("div",{className:"agent-task-head",children:[i.jsxs("div",{children:[i.jsx("span",{children:"LiveDesk Agent"}),i.jsx("strong",{children:Wk(n)})]}),i.jsx("span",{className:`agent-task-status status-${A?"completed-with-failures":l}`,children:k})]}),i.jsxs("div",{className:"agent-task-summary","aria-label":"Task summary",children:[i.jsxs("strong",{children:[y.total," targets"]}),i.jsxs("span",{className:"summary-completed",children:[y.completed," completed"]}),y.running>0&&i.jsxs("span",{className:"summary-running",children:[y.running," running"]}),y.queued>0&&i.jsxs("span",{children:[y.queued," queued"]}),C&&i.jsxs("span",{className:"summary-failed",children:[y.failed," failed"]}),j>0&&i.jsxs("span",{className:"summary-cancelled",children:[j," warning"]}),y.cancelled>0&&i.jsxs("span",{className:"summary-cancelled",children:[y.cancelled," cancelled"]})]}),E.length>0&&i.jsxs("div",{className:"agent-task-result-preview",title:E.join(" · "),children:[i.jsx("span",{children:"Result"}),E.join(" · ")]}),i.jsx("div",{className:"agent-target-chips","aria-label":"Target status overview",children:a.map((R,U)=>{const F=R.status==="completed"?"✓":R.status==="failed"?"×":R.status==="cancelled"?"!":R.status==="running"?"…":"·";return i.jsxs("span",{className:`agent-target-chip status-${R.status}`,title:`${R.deviceName}: ${Rd(n,R)}`,"aria-label":`${U+1}. ${R.deviceName}: ${R.status}`,children:[i.jsx("b",{children:String(U+1).padStart(2,"0")}),i.jsx("span",{children:F})]},R.deviceId)})}),a.length>0&&i.jsx("div",{className:"agent-task-details-toggle",children:i.jsxs("button",{type:"button",onClick:()=>v(R=>!R),"aria-expanded":p,children:[p?i.jsx(rS,{size:14}):i.jsx(by,{size:14}),p?"Hide details":"Show details"]})}),p&&i.jsxs("div",{className:"agent-task-details",children:[i.jsx("div",{className:"agent-task-filters",role:"tablist","aria-label":"Task result filter",children:["all","issues","running","completed","failed"].map(R=>i.jsx("button",{className:g===R?"active":"",onClick:()=>w(R),role:"tab","aria-selected":g===R,type:"button",children:R==="all"?"All":R==="issues"?"Issues only":R[0].toUpperCase()+R.slice(1)},R))}),i.jsx("div",{className:"agent-task-rows",children:T.length>0?T.map(R=>i.jsx(tA,{operation:n,state:R},R.deviceId)):i.jsx("small",{className:"agent-task-no-results",children:"No targets match this filter."})})]}),(m||C)&&i.jsxs("div",{className:"agent-task-actions",children:[m&&r&&i.jsxs("button",{onClick:r,disabled:u,type:"button",children:[i.jsx(oS,{size:14})," Cancel"]}),!m&&C&&c&&i.jsxs("button",{onClick:c,disabled:u,type:"button",children:[i.jsx(jc,{size:14})," Retry failed"]})]})]})}function aA(n){try{return JSON.stringify(n,null,2).slice(0,6e3)}catch{return"{}"}}function sA({approval:n,busy:a=!1,onApprove:l,onReject:r}){return i.jsxs("article",{className:"agent-approval-card","aria-label":"Agent approval required",children:[i.jsxs("div",{className:"agent-approval-head",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Approval required"}),i.jsx("strong",{children:n.toolName})]}),i.jsx("span",{className:`agent-approval-risk risk-${n.risk}`,children:n.risk})]}),i.jsx("p",{children:n.description}),i.jsx("pre",{children:aA(n.arguments)}),i.jsxs("small",{children:["Permission: ",n.permissionMode," · Scope: selected devices only · Expires in 5 minutes"]}),i.jsxs("div",{className:"agent-approval-actions",children:[i.jsxs("button",{className:"reject",disabled:a,onClick:r,type:"button",children:[i.jsx(Ps,{size:14})," Reject"]}),i.jsxs("button",{disabled:a,onClick:()=>l("once"),type:"button",children:[i.jsx(oo,{size:14})," Once"]}),i.jsx("button",{disabled:a,onClick:()=>l("same-action-this-run"),type:"button",children:"Allow same action"}),i.jsx("button",{disabled:a,onClick:()=>l("category-this-run"),type:"button",children:"Allow category"})]}),i.jsxs("div",{className:"agent-approval-scope",children:[i.jsx(Ld,{size:13})," Approval is bound to this run, tool, arguments, selected devices, and policy hash."]})]})}function iA({items:n,onCancel:a,onRetry:l,busyBatchId:r,approvals:c,onApprove:u,onReject:m,busyApprovalId:p}){return i.jsxs("section",{className:"agents-conversation","aria-live":"polite",children:[c.filter(v=>v.status==="pending").map(v=>i.jsx(sA,{approval:v,busy:p===v.approvalId,onApprove:g=>u(v,g),onReject:()=>m(v)},v.approvalId)),n.length===0&&i.jsxs("div",{className:"agents-empty-conversation",children:[i.jsx("strong",{children:"Ask LiveDesk to work across your machines."}),i.jsx("span",{children:"Start with a read-only request such as “모든 PC에서 ComfyUI가 실행 중인지 확인해줘”."})]}),n.map(v=>{if(v.type==="task"){const g=v;return i.jsx(nA,{operation:g.operation,states:g.states,status:g.status,onCancel:()=>a(g.batchId,g.agentRunId),onRetry:()=>l(g.batchId),busy:r===g.batchId},g.id)}return i.jsxs("article",{className:`agents-message ${v.type}`,children:[i.jsx("span",{children:v.type==="user"?"You":"LiveDesk Agent"}),i.jsx("p",{children:v.text})]},v.id)})]})}const Hx=["Recommended","Health & capacity","Processes & services","AI workloads","Files & configuration","Software & automation","Network & connectivity","Power & maintenance","Troubleshooting & recovery"],Xt=["windows","macos","linux"],Sl={"system.health":{label:"system health",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt},"gpu.status":{label:"GPU status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt},"disk.status":{label:"disk status",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt},"process.list":{label:"process inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt},"service.status":{label:"service inspection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt},"diagnostics.collect":{label:"diagnostics collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt},"process.control":{label:"process control",permissionCategory:"processControl",readOnly:!1,risk:"high",supportedPlatforms:Xt},"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:Xt},"application.close":{label:"application close",permissionCategory:"applicationControl",readOnly:!1,risk:"medium",supportedPlatforms:Xt},"file.read":{label:"file reading",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:Xt},"file.write":{label:"file writing",permissionCategory:"fileWrite",readOnly:!1,risk:"high",supportedPlatforms:Xt},"file.delete":{label:"file deletion",permissionCategory:"fileDelete",readOnly:!1,risk:"critical",supportedPlatforms:Xt},"file.list":{label:"directory listing",permissionCategory:"fileRead",readOnly:!0,risk:"low",supportedPlatforms:Xt},"command.run":{label:"command execution",permissionCategory:"shell",readOnly:!1,risk:"critical",supportedPlatforms:Xt},"script.run":{label:"script execution",permissionCategory:"script",readOnly:!1,risk:"high",supportedPlatforms:Xt},"software.install":{label:"software installation",permissionCategory:"softwareInstall",readOnly:!1,risk:"high",supportedPlatforms:Xt},"network.status":{label:"network inspection",permissionCategory:"network",readOnly:!0,risk:"low",supportedPlatforms:Xt},"system.power":{label:"power control",permissionCategory:"systemPower",readOnly:!1,risk:"critical",supportedPlatforms:Xt},"system.configure":{label:"system configuration",permissionCategory:"systemConfiguration",readOnly:!1,risk:"critical",supportedPlatforms:Xt},"logs.collect":{label:"log collection",permissionCategory:"read",readOnly:!0,risk:"low",supportedPlatforms:Xt}};new Set(Object.keys(Sl));const lA={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 rA(n){return n.reduce((a,l)=>{const r=Sl[l].risk;return Px.indexOf(r)>Px.indexOf(a)?r:a},"low")}function oA(n){return Xt.filter(a=>n.every(l=>Sl[l].supportedPlatforms.includes(a)))}function ze(n,a,l,r,c,u,m={}){const p=m.description||r,v=c.flatMap(w=>w.split(".")),g=[...new Set([...lA[a],...u,...v])];return{id:n,category:a,title:l,prompt:r,description:p,requiredOperations:c,risk:m.risk||rA(c),targetSupport:m.targetSupport||"single-or-multiple",supportedPlatforms:m.supportedPlatforms||oA(c),keywords:g,recommended:m.recommended??!1,enabled:!0}}const ww=[ze("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}),ze("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}),ze("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}),ze("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}),ze("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}),ze("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}),ze("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}),ze("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}),ze("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","높은 사용량"]),ze("health-uptime","Health & capacity","Review workstation uptime","Show uptime, boot time, and current system health for the target workstations.",["system.health"],["uptime","boot","가동시간"]),ze("health-gpu-temperature","Health & capacity","Check GPU temperature","Check GPU temperature and thermal warnings on the current targets.",["gpu.status"],["thermal","temperature","발열"]),ze("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"]),ze("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","디스크"]),ze("health-gpu-compare","Health & capacity","Compare GPU capacity","Compare GPU model, memory, temperature, and utilization across the current targets.",["gpu.status"],["compare","graphics","capacity"]),ze("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","경고"]),ze("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"]),ze("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","실행 중"]),ze("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"]),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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","서비스 상태"]),ze("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"}),ze("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"]),ze("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"}),ze("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"}),ze("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"]),ze("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"]),ze("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"}),ze("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"]),ze("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"}),ze("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"}),ze("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","구성"]),ze("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"]),ze("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"}),ze("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"}),ze("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"]),ze("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"}),ze("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"}),ze("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"]}),ze("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"]}),ze("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"]}),ze("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"}),ze("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"}),ze("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"}),ze("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"]),ze("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"}),ze("network-adapter-status","Network & connectivity","Check network adapters","Show adapter state, address, and link information for the current targets.",["network.status"],["adapter","ethernet","wifi","네트워크 상태"]),ze("network-disconnected","Network & connectivity","Find disconnected targets","Find current targets with disconnected or degraded network adapters.",["network.status"],["disconnected","offline","연결 끊김"]),ze("network-link-speed","Network & connectivity","Check link speed","Report network link speed and duplex information for the current targets.",["network.status"],["speed","bandwidth","duplex"]),ze("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"]),ze("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"]),ze("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"]),ze("network-compare","Network & connectivity","Compare target connectivity","Compare adapter state, addresses, and link speed across the current targets.",["network.status"],["compare","inventory","connectivity"]),ze("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"]),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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"}),ze("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","장애 보고서"])],Pm={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 cA(n,a){return n==="safe-auto"?Pm:n==="full-access"?{...Pm,processControl:"allow",serviceControl:"allow",applicationControl:"allow",fileDelete:"allow",shell:"allow",script:"allow",softwareInstall:"allow",systemPower:"allow",systemConfiguration:"allow"}:n==="custom"&&a?a:{...Pm,processControl:"ask",serviceControl:"ask",applicationControl:"ask",fileWrite:"ask",network:"ask"}}function uA(n,a,l){const r=cA(a,l),c=n.requiredOperations.map(u=>r[Sl[u].permissionCategory]);if(c.includes("deny")){const u=n.requiredOperations.find(m=>r[Sl[m].permissionCategory]==="deny");return{state:"blocked",label:"Blocked",reason:`This task requires ${Sl[u].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(u=>Sl[u].readOnly)?{state:"read-only",label:"Read only"}:a==="full-access"?{state:"full-access",label:"Full Access"}:{state:"auto",label:"Auto allowed"}}function dA(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 fA(n,a,l){const r=new Set(l);return n.filter(c=>c.connected&&(a==="all"||r.has(c.deviceId)))}function mA(n,a){const l=dA(n.platform);if(!l||!a.supportedPlatforms.includes(l))return!1;const r=n.capabilities?.agentTools;return!Array.isArray(r)||r.length===0?a.requiredOperations.every(c=>Sl[c].readOnly):a.requiredOperations.every(c=>r.includes(c))}function bw(n,a,l,r,c,u){const m=uA(n,c,u),p=fA(a,l,r),v=p.map(j=>j.deviceId),g={...m,available:!1,availableDeviceIds:[],unsupportedDeviceIds:v,risk:n.risk,supportedPlatforms:n.supportedPlatforms};if(p.length===0)return{...g,reason:"Select at least one connected workstation."};if(n.targetSupport==="single"&&p.length!==1)return{...g,reason:"This task supports one workstation at a time."};if(m.state==="blocked")return g;const w=p.filter(j=>mA(j,n)),y=w.map(j=>j.deviceId),b=v.filter(j=>!y.includes(j));return w.length===0?{...g,unsupportedDeviceIds:b,reason:"No current target supports the required platform and client capabilities."}:{...g,available:!0,availableDeviceIds:y,unsupportedDeviceIds:b}}function hA(n,a,l,r,c,u){return n.filter(m=>m.enabled&&bw(m,a,l,r,c,u).available).length}const $m="livedesk.agentPromptRecent",Um="livedesk.agentPromptFavorites",pA={Recommended:or,"Health & capacity":Zt,"Processes & services":pS,"AI workloads":hS,"Files & configuration":mS,"Software & automation":Sd,"Network & connectivity":Eh,"Power & maintenance":en,"Troubleshooting & recovery":fS};function $x(n){if(typeof window>"u")return[];try{const a=JSON.parse(window.localStorage.getItem(n)||"[]");return Array.isArray(a)?a.filter(l=>typeof l=="string"):[]}catch{return[]}}function od(n,a){try{window.localStorage.setItem(n,JSON.stringify(a))}catch{}}function qm(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 gA(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 vA(n,a,l){if(!l.trim())return!0;const r=l.trim().toLowerCase();return[n.title,n.prompt,n.description,n.category,n.risk,a.label,...n.keywords,...n.requiredOperations,...n.supportedPlatforms].join(" ").toLowerCase().includes(r)}function xA(n){return`permission-${n}`}function yA(n){return n==="low"?"Low risk":n==="medium"?"Medium risk":n==="high"?"High risk":"Critical risk"}function wA(n){return n==="windows"?"Windows":n==="macos"?"macOS":"Linux"}function bA({devices:n,targetMode:a,selectedIds:l,permissionMode:r,customCategories:c,onSelectPrompt:u,onClose:m}){const[p,v]=f.useState(""),[g,w]=f.useState("all"),[y,b]=f.useState(()=>$x($m)),[j,C]=f.useState(()=>$x(Um)),[A,T]=f.useState(0),[k,E]=f.useState(""),R=f.useRef(null),U=f.useRef(null),F=f.useMemo(()=>ww.filter(W=>W.enabled),[]),V=f.useMemo(()=>new Map(F.map(W=>[W.id,bw(W,n,a,l,r,c)])),[c,n,r,l,a,F]),_=f.useMemo(()=>[...V.values()].filter(W=>W.available).length,[V]),I=f.useMemo(()=>n.filter(W=>W.connected&&(a==="all"||l.includes(W.deviceId))).length,[n,l,a]),me=f.useMemo(()=>{const W=F.filter(z=>vA(z,V.get(z.id),p));return g==="recent"?y.map(z=>W.find(Q=>Q.id===z)).filter(z=>!!z):g==="favorites"?j.map(z=>W.find(Q=>Q.id===z)).filter(z=>!!z):g==="all"?W:W.filter(z=>{const Q=V.get(z.id);return g==="read-only"?Q.state==="read-only":g==="auto"?Q.state==="auto":g==="approval"?Q.state==="approval":g==="full-access"?Q.state==="full-access":g==="available"?Q.available:g==="unavailable"?!Q.available:z.category===g})},[V,j,g,y,p,F]),Y=f.useMemo(()=>g!=="all"?[{category:qm(g),templates:me}]:Hx.map(W=>({category:W,templates:me.filter(z=>z.category===W)})).filter(W=>W.templates.length>0),[g,me]);f.useEffect(()=>{T(W=>Math.min(W,Math.max(0,me.length-1)))},[me.length]),f.useEffect(()=>{od($m,y)},[y]),f.useEffect(()=>{od(Um,j)},[j]),f.useEffect(()=>{U.current?.focus();const W=Q=>{Q.target instanceof Node&&!R.current?.contains(Q.target)&&m()},z=Q=>{Q.key==="Escape"&&(Q.preventDefault(),m())};return document.addEventListener("pointerdown",W),document.addEventListener("keydown",z),()=>{document.removeEventListener("pointerdown",W),document.removeEventListener("keydown",z)}},[m]);const ue=W=>{const z=V.get(W.id);if(!z.available){E(z.reason||"This task is not available for the current targets and permission policy.");return}const Q=[W.id,...y.filter(X=>X!==W.id)].slice(0,10);b(Q),od($m,Q),u(W.prompt),m()},K=W=>{C(z=>{const Q=z.includes(W)?z.filter(X=>X!==W):[W,...z];return od(Um,Q),Q})},ie=W=>{W.key==="ArrowDown"?(W.preventDefault(),T(z=>Math.min(z+1,Math.max(0,me.length-1)))):W.key==="ArrowUp"?(W.preventDefault(),T(z=>Math.max(z-1,0))):W.key==="Enter"&&me[A]&&(W.preventDefault(),ue(me[A]))};let ee=-1;return i.jsxs("section",{className:"agents-suggested-tasks",ref:R,"aria-label":"Suggested tasks",children:[i.jsxs("header",{className:"agents-suggested-header",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"agents-suggested-title",children:[i.jsx(or,{size:15})," Suggested tasks"]}),i.jsxs("small",{children:[_," available · ",F.length," total. Choose a task, edit it, then run it."]})]}),i.jsx("button",{className:"agents-suggested-close",type:"button","aria-label":"Close suggested tasks",onClick:m,children:i.jsx(Ps,{size:16})})]}),i.jsxs("label",{className:"agents-suggested-search",children:[i.jsx(cS,{size:15,"aria-hidden":"true"}),i.jsx("input",{ref:U,value:p,onChange:W=>v(W.target.value),onKeyDown:ie,placeholder:"Search tasks...","aria-label":"Search suggested tasks"})]}),i.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(W=>{const z=W==="recent"?uS:W==="favorites"?ih:W==="all"?or:W==="available"?On:W==="unavailable"?dS:W==="read-only"||W==="auto"||W==="approval"||W==="full-access"?en:pA[W];return i.jsxs("button",{className:g===W?"active":"",type:"button",title:qm(W),"aria-label":qm(W),"aria-pressed":g===W,onClick:()=>{w(W),T(0),E("")},children:[i.jsx(z,{size:12})," ",gA(W)]},W)})}),k&&i.jsx("div",{className:"agents-suggested-notice",role:"status",children:k}),i.jsxs("div",{className:"agents-suggested-list",role:"listbox","aria-label":"Suggested tasks",children:[Y.map(W=>i.jsxs("div",{className:"agents-suggested-group",children:[i.jsx("strong",{children:W.category}),W.templates.map(z=>{ee+=1;const Q=ee===A,X=j.includes(z.id),P=V.get(z.id),le=P.availableDeviceIds.length+P.unsupportedDeviceIds.length||I,we=P.available?`Available on ${P.availableDeviceIds.length} of ${le} target${le===1?"":"s"}`:`Unavailable: ${P.reason||"not supported by the current targets"}`;return i.jsxs("div",{className:`agents-suggested-item ${Q?"active":""} ${P.available?"":"unavailable"}`,children:[i.jsxs("button",{className:"agents-suggested-prompt",type:"button",role:"option","aria-selected":Q,"aria-disabled":!P.available,onClick:()=>ue(z),children:[i.jsx("span",{children:z.title}),i.jsx("small",{className:"agents-suggested-description",children:z.description}),i.jsxs("span",{className:"agents-suggested-meta",children:[i.jsx("em",{children:z.category}),i.jsx("em",{className:xA(P.state),children:P.label}),i.jsx("em",{className:`risk-${z.risk}`,children:yA(z.risk)}),i.jsx("em",{children:z.supportedPlatforms.map(wA).join(" · ")}),i.jsx("em",{className:P.available?"availability-ok":"availability-unavailable",children:we}),P.available&&P.unsupportedDeviceIds.length>0&&i.jsxs("em",{className:"availability-warning",children:["Unsupported on ",P.unsupportedDeviceIds.length]})]})]}),i.jsx("button",{className:`agents-suggested-favorite ${X?"favorite":""}`,type:"button","aria-label":X?`Remove ${z.title} from favorites`:`Add ${z.title} to favorites`,"aria-pressed":X,onClick:()=>K(z.id),children:i.jsx(ih,{size:14,fill:X?"currentColor":"none"})})]},z.id)})]},W.category)),me.length===0&&i.jsx("p",{className:"agents-suggested-empty",children:"No tasks match this search or current filter."})]})]})}function SA({devices:n,mode:a,selectedIds:l,onModeChange:r,onToggle:c,permissionMode:u,onPermissionModeChange:m}){const p=n.filter(g=>g.connected),v=l.filter(g=>p.some(w=>w.deviceId===g)).length;return i.jsxs("section",{className:"agents-target-picker","aria-label":"Agent targets",children:[i.jsxs("div",{className:"agents-target-toolbar",children:[i.jsx("span",{className:"agents-section-label",children:"Targets"}),i.jsxs("div",{className:"agents-target-modes",children:[i.jsxs("button",{className:a==="all"?"active":"",onClick:()=>r("all"),type:"button",children:[i.jsx(yy,{size:14})," All connected ",i.jsx("small",{children:p.length})]}),i.jsxs("button",{className:a==="selected"?"active":"",onClick:()=>r("selected"),type:"button",children:[i.jsx(oo,{size:14})," Selected ",v]})]}),i.jsxs("label",{className:`agents-permission-picker permission-${u}`,children:[i.jsx(Ld,{size:14}),i.jsx("span",{children:"Permission"}),i.jsxs("select",{value:u,onChange:g=>m(g.target.value),"aria-label":"Agent permission mode",children:[i.jsx("option",{value:"ask",children:"Ask"}),i.jsx("option",{value:"safe-auto",children:"Safe Auto"}),i.jsx("option",{value:"full-access",children:"Full Access"}),i.jsx("option",{value:"custom",children:"Custom"})]}),i.jsx(by,{size:13,"aria-hidden":"true"})]})]}),i.jsx("div",{className:"agents-target-list",children:n.length===0?i.jsx("span",{className:"agents-target-empty",children:"No workstations discovered."}):n.map(g=>{const w=a==="all"?g.connected:l.includes(g.deviceId);return i.jsxs("label",{className:`agents-target-option ${w?"selected":""} ${g.connected?"":"offline"}`,children:[i.jsx("input",{type:"checkbox",checked:w,disabled:!g.connected||a==="all",onChange:()=>c(g.deviceId)}),i.jsx("span",{className:"agents-target-icon",children:i.jsx(Jt,{size:15})}),i.jsxs("span",{children:[i.jsx("strong",{children:yw(g)}),i.jsx("small",{children:g.connected?"Connected":"Offline"})]}),w&&i.jsx(oo,{className:"agents-target-check",size:15,"aria-hidden":"true"})]},g.deviceId)})})]})}async function jA(n,a){return Be("/api/settings/agent/plan",{method:"POST",body:JSON.stringify({instruction:a})},n)}async function CA(n,a){return Be("/api/settings/agent/run",{method:"POST",body:JSON.stringify(a)},n)}async function kA(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}`,void 0,n)}async function AA(n,a){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function MA(n){return Be("/api/settings/agent/runs/cancel-all",{method:"POST",body:JSON.stringify({})},n)}async function NA(n,a,l,r){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(l)}/approve`,{method:"POST",body:JSON.stringify({scope:r})},n)}async function TA(n,a,l,r="User rejected this action."){return Be(`/api/settings/agent/runs/${encodeURIComponent(a)}/approvals/${encodeURIComponent(l)}/reject`,{method:"POST",body:JSON.stringify({reason:r})},n)}async function EA(n,a,l){return Be(`/api/settings/agent/policies/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify({categories:l})},n)}async function RA(n,a){return Be("/api/settings/agent/summary",{method:"POST",body:JSON.stringify(a)},n)}async function DA(n,a){return Be("/api/remote/tasks",{method:"POST",body:JSON.stringify({instruction:a.instruction,deviceIds:a.deviceIds,operation:a.operation,targetQuery:a.targetQuery,approvalLevel:"read-only"})},n)}async function LA(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}`,void 0,n)}async function _A(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/cancel`,{method:"POST",body:JSON.stringify({})},n)}async function zA(n,a){return Be(`/api/remote/tasks/${encodeURIComponent(a)}/retry`,{method:"POST",body:JSON.stringify({failedOnly:!0})},n)}function tr(n){return`${n}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function cd(n,a){const l=new Map(a.map(r=>[r.deviceId,yw(r)]));return n.results.map(r=>({deviceId:r.deviceId,deviceName:r.deviceName||l.get(r.deviceId)||r.deviceId,status:Yk(r.status),stage:r.stage||(r.status==="running"?"Checking processes":void 0),result:r.result,data:r.data,error:r.error,sequence:Number.isSafeInteger(r.sequence)?r.sequence:0}))}function IA(n,a){const l=new Map(a.map(r=>[r.deviceId,r]));return n.map(r=>{const c=l.get(r.deviceId);return!c||c.sequence<=r.sequence?r:c})}function OA(n,a){const l=a.filter(u=>u.status==="completed"),r=a.filter(u=>u.status==="failed");if(n.operation==="process.list"){const m=`${l.filter(p=>{const v=p.result||"";return!/not running|no process/i.test(v)&&/running|online|found/i.test(v)}).length}대에서 요청한 프로세스가 실행 중입니다.`;return r.length>0?`${m}
14
+ ${r.map(p=>`${p.deviceName}는 ${p.error||"응답하지 않았습니다."}`).join(`
15
+ `)}`:m}return r.length>0?`${l.length}대 완료, ${r.length}대 실패했습니다.`:`${l.length}대 작업이 완료되었습니다.`}const BA={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 FA(n){return n==="safe-auto"?"Safe Auto":n==="full-access"?"Full Access":n==="custom"?"Custom":"Ask"}function HA(n){return n.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase())}function PA({hubUrl:n,devices:a}){const[l,r]=f.useState("all"),[c,u]=f.useState([]),[m,p]=f.useState(""),[v,g]=f.useState([]),[w,y]=f.useState(""),[b,j]=f.useState(""),[C,A]=f.useState(""),[T,k]=f.useState("safe-auto"),[E]=f.useState("custom-default"),[R,U]=f.useState(BA),[F,V]=f.useState([]),[_,I]=f.useState(""),[me,Y]=f.useState(!1),[ue,K]=f.useState(null),[ie,ee]=f.useState(!1),[W,z]=f.useState(""),[Q,X]=f.useState(!1),P=f.useRef(null),le=f.useRef(new Set),we=f.useRef(new Set),L=f.useRef(new Set),$=f.useMemo(()=>a.filter(te=>te.connected).map(te=>te.deviceId),[a]),xe=f.useMemo(()=>hA(ww,a,l,c,T,R),[R,a,T,c,l]),Se=f.useCallback(te=>{const ce=cd(te,a);if(g(Me=>Me.map(Ce=>Ce.type==="task"&&Ce.batchId===te.batchId?{...Ce,states:IA(Ce.states,ce),status:te.status}:Ce)),!["running","queued"].includes(te.status)&&!le.current.has(te.batchId)){le.current.add(te.batchId);const Me=tr("agent-summary");g(Ce=>[...Ce,{type:"agent",id:Me,text:OA(te,ce)}]),te.operation&&RA(n,{instruction:te.instructionPreview,operation:te.operation,total:ce.length,completed:ce.filter(Ce=>Ce.status==="completed").length,failed:ce.filter(Ce=>Ce.status==="failed").length,results:ce.map(Ce=>({deviceName:Ce.deviceName,status:Ce.status,result:Ce.result,error:Ce.error}))}).then(Ce=>{!Ce.ok||!Ce.summary||g(it=>it.map(he=>he.type==="agent"&&he.id===Me?{...he,text:Ce.summary}:he))}).catch(()=>{}),y(Ce=>Ce===te.batchId?"":Ce)}},[a,n]),fe=f.useCallback(async te=>{const ce=await LA(n,te);return Se(ce),ce},[n,Se]),Te=f.useCallback((te,ce)=>{L.current.has(te.batchId)||(L.current.add(te.batchId),g(Me=>[...Me,{type:"task",id:tr("task"),batchId:te.batchId,agentRunId:ce,operation:te.operation||"diagnostics.collect",instruction:te.instructionPreview,states:cd(te,a),status:te.status}])),Se(te)},[a,Se]),Ie=f.useCallback(async te=>{const ce=await kA(n,te);for(const Me of ce.taskBatches||[])Te(Me,te);if(V(ce.approvals||[]),!["running","queued","waiting-approval"].includes(ce.status)&&!we.current.has(te)){we.current.add(te);const Me=ce.finalResponse?.trim()||(ce.status==="cancelled"?"Codex 작업을 취소했습니다.":ce.error?`Codex 작업이 완료되지 않았습니다: ${ce.error}`:"Codex 작업이 완료되었습니다.");g(Ce=>[...Ce,{type:ce.status==="failed"?"error":"agent",id:tr("agent-run-result"),text:Me}])}return ce},[Te,n]);f.useEffect(()=>{if(!w)return;let te=!0;const ce=async()=>{try{const Ce=await fe(w);te&&!["running","queued"].includes(Ce.status)&&y("")}catch(Ce){te&&z(Ce instanceof Error?Ce.message:String(Ce))}};ce();const Me=window.setInterval(()=>{ce()},800);return()=>{te=!1,window.clearInterval(Me)}},[w,fe]),f.useEffect(()=>{if(!b)return;let te=!0;const ce=async()=>{try{const Ce=await Ie(b);te&&!["running","queued","waiting-approval"].includes(Ce.status)&&(j(""),ee(!1))}catch(Ce){te&&z(Ce instanceof Error?Ce.message:String(Ce))}};ce();const Me=window.setInterval(()=>{ce()},800);return()=>{te=!1,window.clearInterval(Me)}},[b,Ie]);const oe=async(te="",ce,Me=!1)=>{const Ce=(te||m).trim();if(!Ce||w||b)return;let it=Qk(Ce);const he=ce||(l==="all"?$:c.filter(Le=>$.includes(Le)));if(he.length===0){z("Select at least one connected workstation.");return}if(T==="full-access"&&!ie&&!Me){K({instruction:Ce,targetIds:he});return}if(g(Le=>[...Le,{type:"user",id:tr("user"),text:Ce}]),p(""),X(!1),z(""),(l==="all"?$:c.filter(Le=>$.includes(Le))).length===0){g(Le=>[...Le,{type:"error",id:tr("no-targets"),text:"연결된 대상 장비를 하나 이상 선택해 주세요."}]);return}if(!it){try{if(T==="custom"){const Ge=await EA(n,E,R);if(!Ge.ok)throw new Error(Ge.error||"Custom Agent policy could not be saved.")}const Le=await CA(n,{instruction:Ce,deviceIds:he,permissionMode:T,customPolicyId:E});if(!Le.ok||!Le.runId)throw new Error(Le.error||"Codex Agent run could not be started.");V(Le.approvals||[]),j(Le.runId);return}catch(Le){try{const Ge=await jA(n,Ce);Ge.ok&&Ge.plan&&(it={operation:Ge.plan.operation,query:Ge.plan.targetQuery})}catch{g(Ge=>[...Ge,{type:"error",id:tr("unsupported"),text:Le instanceof Error?Le.message:Xk}])}}if(!it)return}try{const Le=await DA(n,{instruction:Ce,deviceIds:he,operation:it.operation,targetQuery:it.query});if(!Le.ok||!Le.batch||!Le.batchId)throw new Error(Le.error||"작업을 만들지 못했습니다.");const Ge={type:"task",id:tr("task"),batchId:Le.batchId,operation:it.operation,instruction:Ce,states:cd(Le.batch,a),status:Le.batch.status};L.current.add(Le.batchId),g(ea=>[...ea,Ge]),y(Le.batchId)}catch(Le){z(Le instanceof Error?Le.message:String(Le))}},Ye=async(te,ce)=>{I(te.approvalId);try{const Me=await NA(n,te.runId,te.approvalId,ce);if(!Me.ok)throw new Error(Me.error||"Agent approval could not be applied.");await Ie(te.runId)}catch(Me){z(Me instanceof Error?Me.message:String(Me))}finally{I("")}},De=async te=>{I(te.approvalId);try{const ce=await TA(n,te.runId,te.approvalId);if(!ce.ok)throw new Error(ce.error||"Agent approval could not be rejected.");await Ie(te.runId)}catch(ce){z(ce instanceof Error?ce.message:String(ce))}finally{I("")}},We=async(te,ce)=>{A(te);try{if(ce){const Ce=await AA(n,ce);for(const it of Ce.taskBatches||[])Se(it);j(it=>it===ce?"":it);return}const Me=await _A(n,te);Se(Me),y(Ce=>Ce===te?"":Ce)}catch(Me){z(Me instanceof Error?Me.message:String(Me))}finally{A("")}},D=async()=>{if(!(me||!w&&!b)){Y(!0);try{const te=await MA(n);if(!te.ok)throw new Error(te.error||"모든 Agent 작업을 취소하지 못했습니다.");y(""),j(""),V([]),g(ce=>ce.map(Me=>Me.type==="task"&&["queued","running"].includes(Me.status)?{...Me,status:"cancelled",states:Me.states.map(Ce=>["queued","running"].includes(Ce.status)?{...Ce,status:"cancelled",stage:"Cancelled",error:"Cancelled by user."}:Ce)}:Me))}catch(te){z(te instanceof Error?te.message:String(te))}finally{Y(!1)}}},ne=async te=>{A(te);try{const ce=await zA(n,te);if(!ce.ok||!ce.batch||!ce.batchId)throw new Error(ce.error||"재시도하지 못했습니다.");le.current.delete(ce.batchId),g(Me=>Me.map(Ce=>Ce.type==="task"&&Ce.batchId===te?{...Ce,batchId:ce.batchId,states:cd(ce.batch,a),status:ce.batch.status}:Ce)),y(ce.batchId)}catch(ce){z(ce instanceof Error?ce.message:String(ce))}finally{A("")}},je=te=>{p(te),X(!1),window.requestAnimationFrame(()=>P.current?.focus())};return i.jsxs("section",{className:"agents-page",children:[i.jsxs("div",{className:"agents-workspace",children:[(w||b)&&i.jsxs("div",{className:"agents-page-status",children:[i.jsxs("span",{children:[$.length," workstations · ",FA(T)]}),i.jsx("button",{type:"button",className:"agents-stop-all",onClick:()=>{D()},disabled:me,children:me?"Stopping…":"Stop all"})]}),ue&&i.jsx("div",{className:"agents-permission-modal-backdrop",role:"presentation",children:i.jsxs("section",{className:"agents-permission-modal",role:"dialog","aria-modal":"true","aria-labelledby":"full-access-title",children:[i.jsx("span",{className:"agents-permission-modal-icon",children:i.jsx(Ld,{size:20})}),i.jsx("h3",{id:"full-access-title",children:"Confirm Full Access"}),i.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."}),i.jsxs("div",{className:"agents-permission-modal-actions",children:[i.jsx("button",{type:"button",onClick:()=>K(null),children:"Cancel"}),i.jsx("button",{type:"button",className:"danger",onClick:()=>{const te=ue;K(null),ee(!0),oe(te.instruction,te.targetIds,!0)},children:"Run with Full Access"})]})]})}),W&&i.jsx("div",{className:"agents-error",role:"alert",children:W}),i.jsx(iA,{items:v,onCancel:We,onRetry:ne,busyBatchId:C,approvals:F,onApprove:Ye,onReject:De,busyApprovalId:_}),i.jsxs("div",{className:"agents-composer-shell",children:[Q&&i.jsx(bA,{devices:a,targetMode:l,selectedIds:c,permissionMode:T,customCategories:R,onSelectPrompt:je,onClose:()=>X(!1)}),i.jsx(Gk,{ref:P,value:m,onChange:p,onSubmit:()=>{oe()},onOpenSuggestedTasks:()=>X(te=>!te),suggestedOpen:Q,suggestedTaskCount:xe,disabled:!!w||!!b})]})]}),i.jsxs("aside",{className:"agents-target-sidebar","aria-label":"Agent targets and permissions",children:[i.jsx(SA,{devices:a,mode:l,selectedIds:c,onModeChange:r,onToggle:te=>u(ce=>ce.includes(te)?ce.filter(Me=>Me!==te):[...ce,te]),permissionMode:T,onPermissionModeChange:te=>{k(te),te!=="full-access"&&ee(!1)}}),T==="custom"&&i.jsxs("section",{className:"agents-custom-policy","aria-label":"Custom Agent permissions",children:[i.jsxs("div",{className:"agents-custom-policy-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"agents-section-label",children:"Custom policy"}),i.jsx("strong",{children:"Choose what Codex may do automatically."})]}),i.jsx("span",{children:"Denied actions never reach a device."})]}),i.jsx("div",{className:"agents-custom-policy-grid",children:Vk.map(te=>i.jsxs("label",{children:[i.jsx("span",{children:HA(te)}),i.jsxs("select",{value:R[te],onChange:ce=>U(Me=>({...Me,[te]:ce.target.value})),children:[i.jsx("option",{value:"allow",children:"Allow automatically"}),i.jsx("option",{value:"ask",children:"Ask every time"}),i.jsx("option",{value:"deny",children:"Deny"})]})]},te))})]})]})]})}function $A(n,a="Support request failed."){if(n&&typeof n=="object"&&"message"in n){const l=String(n.message||"").trim();if(l)return l.replace(/^.*Support request failed:\s*/i,"")}return n instanceof Error?n.message:a}function UA(){return typeof navigator>"u"?{}:{browserLanguage:navigator.language||"",platform:navigator.platform||"",online:navigator.onLine,viewport:typeof window>"u"?void 0:{width:window.innerWidth,height:window.innerHeight}}}async function qA(n,a="livedesk"){const{data:l,error:r}=await zt.from("app_admins").select("role").eq("user_id",n).limit(1);if(r)throw r;const c=l?.[0]?.role||"user";if(c!=="owner"){const{error:j}=await zt.rpc("register_product_access",{p_product_key:a,p_access_type:"free"});if(j)throw j}const[u,m,p]=await Promise.all([zt.from("products").select("id, product_key, name, description, sort_order").order("sort_order"),zt.from("product_admins").select("product_id, role").eq("user_id",n),zt.from("user_products").select("product_id").eq("user_id",n).eq("is_active",!0)]);if(u.error)throw u.error;if(m.error)throw m.error;if(p.error)throw p.error;const v=u.data||[],g=(m.data||[]).map(j=>String(j.product_id)),w=(p.data||[]).map(j=>String(j.product_id)),y=c==="owner",b=y?v.map(j=>j.id):[...new Set([...g,...w])];return{products:v,access:{userId:n,globalRole:c,accessibleProductIds:b,managedProductIds:y?v.map(j=>j.id):g,canViewAllProducts:y,canViewAllPrivatePosts:y,canManageAllProducts:y,canCreateAnnouncements:y||g.length>0}}}async function GA(){const{data:n,error:a}=await zt.from("support_posts").select("*").order("is_pinned",{ascending:!1}).order("updated_at",{ascending:!1}).limit(250);if(a)throw a;return n||[]}async function Ux(n){const{data:a,error:l}=await zt.from("support_comments").select("*").eq("post_id",n).order("created_at");if(l)throw l;return a||[]}async function VA(n){const{data:a,error:l}=await zt.from("support_votes").select("post_id").eq("user_id",n);if(l)throw l;return new Set((a||[]).map(r=>String(r.post_id)))}async function YA(n){const{data:a,error:l}=await zt.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?UA():{}});if(l)throw l;const r=Array.isArray(a)?a[0]?.post_id:a?.post_id;if(!r)throw new Error("Support post was not created.");return String(r)}async function WA(n,a,l,r){const{error:c}=await zt.rpc("update_support_post",{p_post_id:n,p_title:a,p_body:l,p_visibility:r});if(c)throw c}async function KA(n,a){const{error:l}=await zt.rpc("add_support_comment",{p_post_id:n,p_body:a});if(l)throw l}async function QA(n){const{data:a,error:l}=await zt.rpc("toggle_support_vote",{p_post_id:n});if(l)throw l;const r=Array.isArray(a)?a[0]:a;return{voted:!!r?.voted,totalVotes:Number(r?.total_votes||0)}}async function XA(n,a){const{error:l}=await zt.rpc("change_support_post_status",{p_post_id:n,p_target_status:a});if(l)throw l}async function ZA(n){const{error:a}=await zt.rpc("hide_support_post",{p_post_id:n});if(a)throw a}const yh=[{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"}],JA=[{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"}],eM={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"]},tM={type:"all",product:"",status:"all",visibility:"all",sort:"recent"};function qx(){if(typeof window>"u")return tM;const n=new URLSearchParams(window.location.search),a=window.location.pathname.match(/^\/support\/(questions|issues|features|announcements)$/)?.[1],l=n.get("type")||a||"",r=l==="questions"||l==="question"?"question":l==="issues"||l==="issue"?"issue":l==="features"||l==="feature"?"feature":l==="announcements"||l==="announcement"?"announcement":"all",c=n.get("visibility"),u=n.get("sort");return{type:r,product:n.get("product")||"",status:n.get("status")||"all",visibility:c==="public"||c==="private"?c:"all",sort:u==="votes"||u==="newest"?u:"recent"}}function nM(n){return n==="all"?"":n==="question"?"questions":n==="issue"?"issues":n==="feature"?"features":"announcements"}function aM(n,a){const l={...n,...a},r=new URLSearchParams;l.product&&r.set("product",l.product),l.status!=="all"&&r.set("status",l.status),l.visibility!=="all"&&r.set("visibility",l.visibility),l.sort!=="recent"&&r.set("sort",l.sort);const c=nM(l.type),u=r.toString();return`/support${c?`/${c}`:""}${u?`?${u}`:""}`}function Gm(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 Gx(n){return n==="question"?wS:n==="issue"?bS:n==="feature"?SS:jS}function Vx(n){return yh.find(a=>a.id===n)?.shortLabel||n}function ud(n,a){return n.find(l=>l.id===a)?.name||"Product"}function wl(n){const a=$A(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 sM({session:n,currentProductKey:a="livedesk",appVersion:l="",onSignIn:r}){const[c,u]=f.useState(()=>qx()),[m,p]=f.useState(null),[v,g]=f.useState([]),[w,y]=f.useState([]),[b,j]=f.useState(""),[C,A]=f.useState([]),[T,k]=f.useState(()=>new Set),[E,R]=f.useState(!0),[U,F]=f.useState(""),[V,_]=f.useState(""),[I,me]=f.useState(!1),[Y,ue]=f.useState(!1),[K,ie]=f.useState(""),[ee,W]=f.useState({productId:"",postType:"question",title:"",body:"",visibility:"public",includeEnvironment:!0}),z=f.useCallback(D=>{const ne={...c,...D};u(ne),typeof window<"u"&&window.history.pushState({},"",aM(c,D))},[c]);f.useEffect(()=>{const D=()=>u(qx());return window.addEventListener("popstate",D),()=>window.removeEventListener("popstate",D)},[]);const Q=f.useCallback(async()=>{const D=await GA();return y(D),n?.user.id&&k(await VA(n.user.id)),D},[n?.user.id]),X=f.useCallback(async()=>{if(!n?.user.id){p(null),g([]),y([]),j(""),R(!1);return}R(!0),_("");try{const D=await qA(n.user.id,a);p(D.access),g(D.products),await Q()}catch(D){_(wl(D))}finally{R(!1)}},[a,Q,n?.user.id]);f.useEffect(()=>{X()},[X]);const P=f.useMemo(()=>m?m.canViewAllProducts?v:v.filter(D=>m.accessibleProductIds.includes(D.id)):[],[m,v]),le=f.useMemo(()=>{const D=P.find(ne=>ne.product_key===c.product);return m?.canViewAllProducts&&!c.product||c.product==="all"&&m?.canViewAllProducts?"all":D?D.product_key:P.some(ne=>ne.product_key===a)?a:P[0]?.product_key||""},[m?.canViewAllProducts,P,a,c.product]),we=le==="all"?"":P.find(D=>D.product_key===le)?.id||"",L=f.useMemo(()=>{const D=new Map(v.map(je=>[je.id,je.product_key]));return[...w.filter(je=>c.type!=="all"&&je.post_type!==c.type||le!=="all"&&we&&je.product_id!==we||c.status==="needs-response"&&!["open","needs-info"].includes(je.status)||c.status!=="all"&&c.status!=="needs-response"&&je.status!==c.status||c.visibility!=="all"&&je.visibility!==c.visibility?!1:D.has(je.product_id))].sort((je,te)=>c.sort==="votes"?te.vote_count-je.vote_count||te.updated_at.localeCompare(je.updated_at):c.sort==="newest"?te.created_at.localeCompare(je.created_at):Number(te.is_pinned)-Number(je.is_pinned)||te.updated_at.localeCompare(je.updated_at))},[w,v,c.sort,c.status,c.type,c.visibility,we,le]),$=L.find(D=>D.id===b)||L[0]||null,xe=!!($&&m&&(m.canViewAllProducts||m.managedProductIds.includes($.product_id))),Se=!!($&&n?.user.id===$.author_id)||xe;f.useEffect(()=>{if(!$){j(""),A([]),ue(!1);return}$.id!==b&&j($.id)},[$,b]),f.useEffect(()=>{let D=!0;return b?(Ux(b).then(ne=>{D&&A(ne)}).catch(ne=>{D&&_(wl(ne))}),()=>{D=!1}):(A([]),()=>{D=!1})},[b]),f.useEffect(()=>{!ee.productId&&P[0]&&W(D=>({...D,productId:we||P[0].id}))},[P,ee.productId,we]);const fe=D=>{$&&y(ne=>ne.map(je=>je.id===$.id?{...je,...D}:je))},Te=async D=>{if(D.preventDefault(),!(!n||!ee.productId)){F("create"),_("");try{const ne=await YA({productId:ee.productId,postType:ee.postType,title:ee.title,body:ee.body,visibility:ee.postType==="announcement"?"public":ee.visibility,appVersion:l,includeEnvironment:ee.postType==="issue"&&ee.includeEnvironment}),je=await Q();me(!1),W(te=>({...te,title:"",body:""})),j(ne),je.some(te=>te.id===ne)||await X()}catch(ne){_(wl(ne))}finally{F("")}}},Ie=async D=>{if(D.preventDefault(),!!$){F("edit"),_("");try{await WA($.id,$.title,$.body,$.visibility),ue(!1),await Q()}catch(ne){_(wl(ne))}finally{F("")}}},oe=async D=>{if(D.preventDefault(),!(!$||!K.trim())){F("comment"),_("");try{await KA($.id,K),ie(""),A(await Ux($.id)),await Q()}catch(ne){_(wl(ne))}finally{F("")}}},Ye=async()=>{if(!(!$||$.post_type!=="feature")){F("vote"),_("");try{const D=await QA($.id);k(ne=>{const je=new Set(ne);return D.voted?je.add($.id):je.delete($.id),je}),fe({vote_count:D.totalVotes})}catch(D){_(wl(D))}finally{F("")}}},De=async D=>{if($){F("status"),_("");try{await XA($.id,D),fe({status:D}),await Q()}catch(ne){_(wl(ne))}finally{F("")}}},We=async()=>{if(!(!$||!window.confirm("Hide this Support post from the board?"))){F("hide"),_("");try{await ZA($.id),j(""),await Q()}catch(D){_(wl(D))}finally{F("")}}};return n?E&&!m?i.jsxs("section",{className:"support-page support-loading",children:[i.jsx(fr,{className:"support-spin",size:23})," Loading Support Board..."]}):i.jsxs("section",{className:"support-page",children:[i.jsxs("header",{className:"support-page-header",children:[i.jsxs("div",{children:[i.jsxs("p",{className:"support-eyebrow",children:[i.jsx(hc,{size:15})," ",m?.canViewAllProducts?"Support Admin":"LiveDesk Support"]}),i.jsx("h2",{children:m?.canViewAllProducts?"Support Board":`${ud(P,we)||"LiveDesk"} Support`}),i.jsx("p",{children:"Questions, reproducible issues, and focused feature requests across the products you can access."})]}),i.jsxs("div",{className:"support-header-actions",children:[i.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>{X()},disabled:E,children:[i.jsx(fr,{size:16,className:E?"support-spin":""})," Refresh"]}),i.jsxs("button",{className:"support-primary-button",type:"button",onClick:()=>me(!0),disabled:P.length===0,children:[i.jsx(Iv,{size:17})," New request"]})]})]}),V&&i.jsxs("div",{className:"support-error",role:"alert",children:[i.jsx(Ps,{size:17})," ",i.jsx("span",{children:V}),i.jsx("button",{type:"button",onClick:()=>_(""),"aria-label":"Dismiss error",children:i.jsx(Ps,{size:15})})]}),I&&i.jsxs("form",{className:"support-composer",onSubmit:D=>{Te(D)},children:[i.jsxs("div",{className:"support-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"New Support request"}),i.jsx("strong",{children:"Describe one actionable problem or idea."})]}),i.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>me(!1),"aria-label":"Close composer",children:i.jsx(Ps,{size:18})})]}),i.jsxs("div",{className:"support-form-grid",children:[i.jsxs("label",{children:[i.jsx("span",{children:"Product"}),i.jsx("select",{value:ee.productId,onChange:D=>W(ne=>({...ne,productId:D.target.value})),children:P.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Type"}),i.jsx("select",{value:ee.postType,onChange:D=>W(ne=>({...ne,postType:D.target.value})),children:yh.filter(D=>D.id!=="announcement"||m?.canCreateAnnouncements).map(D=>i.jsx("option",{value:D.id,children:D.label},D.id))})]}),i.jsxs("label",{className:"support-form-wide",children:[i.jsx("span",{children:"Title"}),i.jsx("input",{required:!0,minLength:3,maxLength:180,value:ee.title,onChange:D=>W(ne=>({...ne,title:D.target.value})),placeholder:"A short, searchable summary"})]}),i.jsxs("label",{className:"support-form-wide",children:[i.jsx("span",{children:ee.postType==="issue"?"What happened?":ee.postType==="feature"?"Describe the desired behavior":ee.postType==="announcement"?"Announcement":"Question"}),i.jsx("textarea",{required:!0,value:ee.body,onChange:D=>W(ne=>({...ne,body:D.target.value})),placeholder:"Include the context another person needs to respond.",rows:6})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Visibility"}),i.jsxs("select",{value:ee.visibility,disabled:ee.postType==="announcement",onChange:D=>W(ne=>({...ne,visibility:D.target.value})),children:[i.jsx("option",{value:"public",children:"Public"}),i.jsx("option",{value:"private",children:"Private"})]})]}),ee.postType==="issue"&&i.jsxs("label",{className:"support-checkbox",children:[i.jsx("input",{type:"checkbox",checked:ee.includeEnvironment,onChange:D=>W(ne=>({...ne,includeEnvironment:D.target.checked}))}),i.jsx("span",{children:"Attach safe browser/runtime details"})]})]}),i.jsxs("div",{className:"support-composer-footer",children:[i.jsx("span",{children:"Private posts are visible only to you and the product support staff."}),i.jsxs("button",{className:"support-primary-button",type:"submit",disabled:U==="create",children:[i.jsx(ro,{size:16})," ",U==="create"?"Submitting...":"Submit request"]})]})]}),i.jsxs("div",{className:"support-tabs",role:"tablist","aria-label":"Support post type",children:[i.jsx("button",{className:c.type==="all"?"active":"",type:"button",onClick:()=>z({type:"all"}),children:"All"}),yh.map(D=>{const ne=Gx(D.id);return i.jsxs("button",{className:c.type===D.id?"active":"",type:"button",onClick:()=>z({type:D.id}),children:[i.jsx(ne,{size:15})," ",D.label]},D.id)})]}),i.jsxs("div",{className:"support-filter-bar",children:[i.jsxs("div",{className:"support-filter-title",children:[i.jsx(gS,{size:16}),i.jsx("span",{children:"Filter"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Product"}),i.jsxs("select",{value:le,onChange:D=>z({product:D.target.value}),disabled:!m?.canViewAllProducts&&P.length<=1,children:[i.jsx("option",{value:"all",children:"All products"}),P.map(D=>i.jsx("option",{value:D.product_key,children:D.name},D.id))]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Status"}),i.jsx("select",{value:c.status,onChange:D=>z({status:D.target.value}),children:JA.map(D=>i.jsx("option",{value:D.id,children:D.label},D.id))})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Visibility"}),i.jsxs("select",{value:c.visibility,onChange:D=>z({visibility:D.target.value}),children:[i.jsx("option",{value:"all",children:"All visibility"}),i.jsx("option",{value:"public",children:"Public"}),i.jsx("option",{value:"private",children:"Private"})]})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Sort"}),i.jsxs("select",{value:c.sort,onChange:D=>z({sort:D.target.value}),children:[i.jsx("option",{value:"recent",children:"Recently updated"}),i.jsx("option",{value:"newest",children:"Newest"}),i.jsx("option",{value:"votes",children:"Most votes"})]})]})]}),m?.canViewAllProducts&&i.jsxs("div",{className:"support-admin-shortcuts",children:[i.jsxs("span",{children:[i.jsx(en,{size:15})," Owner view"]}),i.jsx("button",{type:"button",onClick:()=>z({status:"needs-response"}),children:"Needs response"}),i.jsx("button",{type:"button",onClick:()=>z({visibility:"private"}),children:"Private requests"}),i.jsx("button",{type:"button",onClick:()=>z({type:"feature",status:"all",sort:"votes"}),children:"High-vote features"})]}),i.jsxs("div",{className:"support-board-layout",children:[i.jsxs("section",{className:"support-post-list","aria-label":"Support posts",children:[i.jsxs("div",{className:"support-list-heading",children:[i.jsxs("span",{children:[L.length," request",L.length===1?"":"s"]}),i.jsx("small",{children:le==="all"?"All products":ud(P,we)})]}),L.length===0?i.jsxs("div",{className:"support-list-empty",children:[i.jsx(hc,{size:25}),i.jsx("strong",{children:"No posts match these filters."}),i.jsx("span",{children:"Start with a focused question, issue report, or feature request."}),P.length>0&&i.jsxs("button",{className:"support-secondary-button",type:"button",onClick:()=>me(!0),children:[i.jsx(Iv,{size:16})," Create the first request"]})]}):L.map(D=>{const ne=Gx(D.post_type);return i.jsxs("button",{type:"button",className:`support-post-row ${D.id===$?.id?"active":""}`,onClick:()=>{j(D.id),ue(!1)},children:[i.jsx("span",{className:"support-post-row-icon",children:i.jsx(ne,{size:17})}),i.jsxs("span",{className:"support-post-row-copy",children:[i.jsxs("span",{className:"support-post-row-meta",children:[i.jsx("b",{children:ud(v,D.product_id)}),i.jsx("em",{children:Vx(D.post_type)}),D.visibility==="private"&&i.jsx(Ai,{size:13})]}),i.jsx("strong",{children:D.title}),i.jsxs("small",{children:[Vm(D.status)," · ",Gm(D.updated_at)," · ",D.comment_count," comments"]})]}),D.post_type==="feature"&&i.jsxs("span",{className:"support-vote-count",children:[i.jsx(xy,{size:14})," ",D.vote_count]})]},D.id)})]}),i.jsx("section",{className:"support-post-detail","aria-label":"Support post detail",children:$?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"support-detail-head",children:[i.jsxs("div",{className:"support-detail-badges",children:[i.jsx("span",{className:"support-product-badge",children:ud(v,$.product_id)}),i.jsx("span",{className:"support-type-badge",children:Vx($.post_type)}),i.jsx("span",{className:`support-status-badge status-${$.status}`,children:Vm($.status)}),$.visibility==="private"&&i.jsxs("span",{className:"support-private-badge",children:[i.jsx(Ai,{size:13})," Private"]})]}),i.jsxs("div",{className:"support-detail-actions",children:[Se&&i.jsx("button",{className:"support-icon-button",type:"button",onClick:()=>ue(D=>!D),title:"Edit post",children:i.jsx(vS,{size:16})}),xe&&i.jsx("button",{className:"support-icon-button danger",type:"button",onClick:()=>{We()},disabled:U==="hide",title:"Hide post",children:i.jsx(xS,{size:16})})]})]}),Y?i.jsxs("form",{className:"support-edit-form",onSubmit:D=>{Ie(D)},children:[i.jsx("input",{value:$.title,onChange:D=>fe({title:D.target.value}),minLength:3,maxLength:180,required:!0}),i.jsx("textarea",{value:$.body,onChange:D=>fe({body:D.target.value}),rows:9,required:!0}),i.jsxs("div",{className:"support-edit-actions",children:[i.jsxs("select",{value:$.visibility,onChange:D=>fe({visibility:D.target.value}),children:[i.jsx("option",{value:"public",children:"Public"}),i.jsx("option",{value:"private",children:"Private"})]}),i.jsxs("button",{className:"support-primary-button",type:"submit",disabled:U==="edit",children:[i.jsx(oo,{size:16})," Save changes"]})]})]}):i.jsxs(i.Fragment,{children:[i.jsx("h3",{children:$.title}),i.jsx("div",{className:"support-detail-body",children:$.body.split(`
16
+ `).map((D,ne)=>i.jsx("p",{children:D||" "},`${$.id}-body-${ne}`))})]}),i.jsxs("div",{className:"support-detail-meta",children:[i.jsxs("span",{children:["Opened ",Gm($.created_at)]}),$.app_version&&i.jsxs("span",{children:["Version ",$.app_version]}),$.platform&&i.jsx("span",{children:$.platform}),$.is_locked&&i.jsxs("span",{children:[i.jsx(Ai,{size:13})," Locked"]})]}),i.jsxs("div",{className:"support-detail-controls",children:[$.post_type==="feature"&&i.jsxs("button",{className:`support-vote-button ${T.has($.id)?"voted":""}`,type:"button",onClick:()=>{Ye()},disabled:U==="vote",children:[i.jsx(yS,{size:16})," ",T.has($.id)?"Voted":"Vote"," ",i.jsx("b",{children:$.vote_count})]}),xe&&i.jsxs("label",{className:"support-status-control",children:[i.jsx("span",{children:"Change status"}),i.jsx("select",{value:$.status,onChange:D=>{De(D.target.value)},disabled:U==="status",children:(eM[$.post_type]||[]).map(D=>i.jsx("option",{value:D,children:Vm(D)},D))})]})]}),i.jsxs("div",{className:"support-comments",children:[i.jsxs("div",{className:"support-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Discussion"}),i.jsxs("strong",{children:[C.length," comment",C.length===1?"":"s"]})]}),$.is_locked&&i.jsxs("span",{className:"support-locked-label",children:[i.jsx(Ai,{size:14})," Locked"]})]}),C.length===0?i.jsx("p",{className:"support-muted",children:"No response yet. Keep the conversation focused on this request."}):i.jsx("div",{className:"support-comment-list",children:C.map(D=>i.jsxs("article",{className:`support-comment ${D.is_staff_answer?"staff":""}`,children:[i.jsxs("div",{className:"support-comment-head",children:[i.jsx("strong",{children:D.is_staff_answer?"LiveDesk Support":D.author_id===n.user.id?"You":"Support user"}),D.is_staff_answer&&i.jsxs("span",{children:[i.jsx(en,{size:13})," Staff answer"]}),i.jsx("time",{children:Gm(D.created_at)})]}),i.jsx("p",{children:D.body})]},D.id))}),!$.is_locked&&i.jsxs("form",{className:"support-comment-form",onSubmit:D=>{oe(D)},children:[i.jsx("textarea",{value:K,onChange:D=>ie(D.target.value),placeholder:"Add a focused reply...",rows:3}),i.jsxs("button",{className:"support-primary-button",type:"submit",disabled:U==="comment"||!K.trim(),children:[i.jsx(ro,{size:15})," Reply"]})]})]})]}):i.jsxs("div",{className:"support-detail-empty",children:[i.jsx(hc,{size:28}),i.jsx("strong",{children:"Select a Support request"}),i.jsx("span",{children:"Its discussion and staff actions will appear here."})]})})]})]}):i.jsx("section",{className:"support-page support-auth-page",children:i.jsxs("div",{className:"support-empty-hero",children:[i.jsx("span",{className:"support-hero-icon",children:i.jsx(hc,{size:28})}),i.jsx("p",{className:"support-eyebrow",children:"LiveDesk Support"}),i.jsx("h2",{children:"Get help, report issues, and shape the product."}),i.jsx("p",{children:"Sign in to see the products attached to your account and submit a private or public request."}),i.jsxs("button",{className:"support-primary-button",type:"button",onClick:r,children:[i.jsx(en,{size:17})," Sign in with Google"]})]})})}function Sw(n){return{type:n.type,deviceIds:n.deviceIds,monitorIndex:n.monitorIndex,label:n.label}}async function jw(n){try{return(await n.json()).error||`${n.status} ${n.statusText}`}catch{return`${n.status} ${n.statusText}`}}async function Cw(n,a,l){const r=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(`${Al(l)}/api/captures?metadata=${r}`,{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream"},body:n,cache:"no-store"});if(!c.ok)throw new Error(await jw(c));return await c.json()}async function iM(n,a){return await Be("/api/capture-sessions",{method:"POST",body:JSON.stringify({...n,target:Sw(n.target)})},a)}async function lM(n,a,l,r){const c=await fetch(`${Al(r)}/api/capture-sessions/${encodeURIComponent(n)}/chunks/${a}`,{method:"PUT",headers:{"Content-Type":l.type||"application/octet-stream"},body:l,cache:"no-store"});if(!c.ok)throw new Error(await jw(c));return await c.json()}async function rM(n,a,l){return await Be(`/api/capture-sessions/${encodeURIComponent(n)}/finalize`,{method:"POST",body:JSON.stringify({durationMs:a})},l)}async function Yx(n,a){await Be(`/api/capture-sessions/${encodeURIComponent(n)}`,{method:"DELETE"},a)}async function oM(n){return await Be("/api/captures",void 0,n)}function Wx(n,a){return`${Al(a)}/api/captures/${encodeURIComponent(n)}/content`}async function cM(n,a){return await Be(`/api/captures/${encodeURIComponent(n)}`,{method:"DELETE"},a)}function uM({hubUrl:n,onToast:a}){const[l,r]=f.useState([]),[c,u]=f.useState(!0),m=f.useCallback(async()=>{u(!0);try{r((await oM(n)).captures||[])}catch(v){a(v instanceof Error?v.message:String(v))}finally{u(!1)}},[n,a]);f.useEffect(()=>{m()},[m]);const p=async v=>{const g=Wx(v.id,n);if(navigator.share)try{await navigator.share({title:v.fileName,url:g});return}catch{}window.open(g,"_blank","noopener,noreferrer")};return i.jsxs("section",{className:"capture-gallery",children:[i.jsxs("header",{children:[i.jsxs("div",{children:[i.jsx("span",{className:"settings-eyebrow",children:"Capture Gallery"}),i.jsx("h2",{children:"Saved captures"})]}),i.jsxs("button",{className:"text-button",onClick:()=>{m()},type:"button",children:[i.jsx(fr,{size:15})," Refresh"]})]}),c?i.jsx("p",{className:"settings-help",children:"Loading captures..."}):l.length===0?i.jsx("p",{className:"settings-help",children:"No captures saved yet."}):i.jsx("div",{className:"capture-gallery-grid",children:l.map(v=>{const g=Wx(v.id,n);return i.jsxs("article",{className:"capture-gallery-card",children:[v.mimeType.startsWith("image/")?i.jsx("img",{src:g,alt:v.target.label}):i.jsx("video",{src:g,controls:!0,preload:"metadata"}),i.jsxs("div",{className:"capture-gallery-card-body",children:[i.jsx("strong",{children:v.fileName}),i.jsxs("small",{children:[v.target.label," · ",new Date(v.createdAt).toLocaleString()," · ",Math.ceil(v.sizeBytes/1024)," KB"]}),i.jsxs("div",{children:[i.jsx("button",{className:"icon-button",title:"Open","aria-label":"Open",onClick:()=>window.open(g,"_blank","noopener,noreferrer"),type:"button",children:i.jsx(CS,{size:15})}),i.jsx("a",{className:"icon-button",title:"Download","aria-label":"Download",href:`${g}?download=1`,download:v.fileName,children:i.jsx(Sy,{size:15})}),i.jsx("button",{className:"icon-button",title:"Share","aria-label":"Share",onClick:()=>{p(v)},type:"button",children:i.jsx(kS,{size:15})}),i.jsx("button",{className:"icon-button danger",title:"Delete","aria-label":"Delete",onClick:()=>{window.confirm(`Delete ${v.fileName}?`)&&cM(v.id,n).then(()=>m()).catch(w=>a(w instanceof Error?w.message:String(w)))},type:"button",children:i.jsx(Nh,{size:15})})]})]})]},v.id)})})]})}function dd(n){if(!n)return"";const a=Math.max(0,Math.floor((Date.now()-n)/1e3)),l=Math.floor(a/3600),r=Math.floor(a%3600/60),c=a%60;return l>0?`${String(l).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`:`${String(r).padStart(2,"0")}:${String(c).padStart(2,"0")}`}function Kx({controller:n,compact:a=!1,onFirstRollingUse:l,onError:r}){const{state:c,settings:u,videoSupported:m}=n,p=async y=>{try{await y()}catch(b){r?.(b instanceof Error?b.message:String(b))}},v=async()=>{if(u.rollingEnabled){n.setRollingEnabled(!1);return}(l?await l():window.confirm(`Keep the most recent 30 seconds in memory temporarily?
17
+ Nothing is saved until you press Save Last 30s.`))&&n.setRollingEnabled(!0)},g=c.recording?`Stop recording · ${dd(c.recordingStartedAt)}`:`Start recording · ${c.targetLabel}`,w=c.timelapse?`Stop timelapse · ${dd(c.timelapseStartedAt)}`:`Start timelapse · ${u.timelapseIntervalSeconds}s interval`;return i.jsxs("div",{className:`capture-toolbar ${a?"compact":""} ${c.recording?"recording-active":""}`,"aria-label":"Capture actions",children:[i.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:i.jsx(AS,{size:17})}),i.jsx("button",{className:`capture-action ${c.recording?"active":""}`,"aria-label":g,title:g,disabled:!m||c.busy||c.timelapse,onClick:()=>{p(c.recording?n.stopRecording:n.startRecording)},type:"button",children:c.recording?i.jsxs(i.Fragment,{children:[i.jsx(Ov,{size:14,fill:"currentColor"}),i.jsx("span",{children:dd(c.recordingStartedAt)})]}):i.jsx(wy,{size:18})}),i.jsxs("button",{className:"capture-action","aria-label":c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",title:c.bufferEnabled?`Save last 30 seconds · ${c.bufferSeconds}s ready`:"Enable Last 30s memory buffer",disabled:!m||c.recording||c.timelapse||c.busy||c.bufferEnabled&&c.bufferSeconds<1,onClick:()=>c.bufferEnabled?void p(n.saveLast30Seconds):void v(),type:"button",children:[i.jsx(MS,{size:17}),i.jsx("small",{children:"30s"})]}),i.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?i.jsxs(i.Fragment,{children:[i.jsx(Ov,{size:14,fill:"currentColor"}),i.jsx("span",{children:dd(c.timelapseStartedAt)})]}):i.jsx(NS,{size:17})})]})}async function dM(n,a={}){const l=n.filter(y=>y.canvas&&y.canvas.width>0&&y.canvas.height>0),r=Math.max(320,a.maxWidth||1920),c=Math.max(180,a.maxHeight||1080),u=l.length<=1?1:l.length<=4?2:l.length<=9?3:4,m=Math.max(1,Math.ceil(Math.max(1,l.length)/u)),p=Math.floor(r/u),v=Math.floor(c/m),g=document.createElement("canvas");g.width=Math.max(320,p*u),g.height=Math.max(180,v*m);const w=g.getContext("2d",{alpha:!1});if(!w)return g;w.fillStyle="#0b1220",w.fillRect(0,0,g.width,g.height),w.font="600 14px system-ui, sans-serif",w.textBaseline="bottom";for(let y=0;y<l.length;y+=1){const b=l[y],j=y%u,C=Math.floor(y/u),A=j*p,T=C*v,k=b.canvas,E=Math.min(p/k.width,v/k.height),R=Math.max(1,Math.floor(k.width*E)),U=Math.max(1,Math.floor(k.height*E)),F=A+Math.floor((p-R)/2),V=T+Math.floor((v-U)/2);w.drawImage(k,F,V,R,U),a.includeLabels!==!1&&(w.fillStyle="rgba(4, 10, 20, .74)",w.fillRect(A,T+v-28,p,28),w.fillStyle="#f8fafc",w.fillText(b.label,A+9,T+v-9))}return g}function fM(n){return n?.signature||"none"}function mM(n){return n?.label||"No capture target"}function Qx(n){return{...n,deviceIds:[...n.deviceIds],sourceCanvas:n.sourceCanvas||null}}function hM(){const n=new Date,a=l=>String(l).padStart(2,"0");return`${n.getFullYear()}${a(n.getMonth()+1)}${a(n.getDate())}_${a(n.getHours())}${a(n.getMinutes())}${a(n.getSeconds())}`}function pM(n){return n.replace(/[^a-zA-Z0-9._-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"Wall"}function gM(n){return`LiveDesk_${n.type==="wall"||n.type==="selection"?"Wall":`${pM(n.label)}_Monitor-${Number(n.monitorIndex||0)+1}`}_${hM()}.png`}async function vM(n,a,l){const r=await new Promise((u,m)=>n.toBlob(p=>p?u(p):m(new Error("Screenshot could not be encoded.")),"image/png")),c=await Cw(r,{kind:"screenshot",fileName:gM(a),target:a},l);try{await navigator.clipboard.write([new ClipboardItem({"image/png":r})])}catch{}return c.capture}function kw(){return["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"].find(a=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(a))||""}function xM(n,a){const l=new Date().toISOString().replace(/[-:]/g,"").replace(/\.\d{3}Z$/,"").replace("T","_"),r=a.label.replace(/[^a-zA-Z0-9._-]+/g,"-").slice(0,70)||"Wall";return n==="timelapse"?`LiveDesk_Timelapse_${r}_${l}.webm`:`LiveDesk_Recording_${r}_${l}.webm`}async function Aw(n){if(typeof MediaRecorder>"u"||typeof n.canvas.captureStream!="function")throw new Error("This browser does not support video recording.");const a=kw();if(!a)throw new Error("This browser does not support WebM recording.");const l=n.kind||"recording",r=await iM({kind:l,fileName:xM(l,n.target),mimeType:a,target:n.target},n.hubUrl),c=n.canvas.captureStream(n.frameRequests?0:n.fps),u=new MediaRecorder(c,{mimeType:a,videoBitsPerSecond:l==="timelapse"?2e6:4e6}),m=performance.now();let p=0,v=!1,g=null,w=Promise.resolve();return u.ondataavailable=y=>{if(!y.data||y.data.size===0)return;const b=p++;w=w.then(()=>lM(r.sessionId,b,y.data,n.hubUrl).then(()=>{})).catch(j=>{g=g||(j instanceof Error?j:new Error(String(j))),n.onError?.(g)})},u.onerror=()=>{g=new Error("Video recording stopped unexpectedly."),n.onError?.(g)},u.start(1e3),{requestFrame:()=>{c.getVideoTracks()[0]?.requestFrame?.()},stop:async()=>{if(!v){if(v=!0,await new Promise(y=>{u.addEventListener("stop",()=>y(),{once:!0}),u.stop()}),c.getTracks().forEach(y=>y.stop()),await w,g)throw await Yx(r.sessionId,n.hubUrl).catch(()=>{}),g;await rM(r.sessionId,Math.max(0,performance.now()-m),n.hubUrl)}},cancel:async()=>{v||(v=!0,u.stop(),c.getTracks().forEach(y=>y.stop()),await Yx(r.sessionId,n.hubUrl).catch(()=>{}))}}}class yM{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,l){if(this.recorder&&this.targetSignature===l.signature)return;if(this.stop(),typeof MediaRecorder>"u"||typeof a.captureStream!="function")throw new Error("This browser does not support Last 30s.");const r=kw();if(!r)throw new Error("This browser does not support WebM recording.");this.targetSignature=l.signature,this.stream=a.captureStream(20),this.recorder=new MediaRecorder(this.stream,{mimeType:r,videoBitsPerSecond:3e6}),this.startedAt=performance.now(),this.recorder.ondataavailable=c=>{if(!c.data.size)return;const u=performance.now();for(this.segments.push({blob:c.data,at:u}),this.totalBytes+=c.data.size;this.segments.length>1&&(u-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(l=>l.stop()),this.stream=null,this.segments=[],this.totalBytes=0,this.startedAt=0}async save(a,l){if(this.segments.length===0)throw new Error("The Last 30s buffer is not ready yet.");const r=new Blob(this.segments.map(m=>m.blob),{type:this.segments[0].blob.type||"video/webm"}),u=`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 Cw(r,{kind:"last-30s",fileName:u,target:a,durationMs:Math.min(3e4,this.segments.length*1e3)},l)}}async function wM(n,a,l,r,c){const u=await Aw({canvas:n,target:a,kind:"timelapse",fps:30,frameRequests:!0,hubUrl:r,onError:c});u.requestFrame?.();const m=window.setInterval(()=>u.requestFrame?.(),Math.max(5,l)*1e3);return{stop:async()=>{window.clearInterval(m),await u.stop()},cancel:async()=>{window.clearInterval(m),await u.cancel()}}}const Mw="livedesk.captureSettings";function bM(){const n={rollingEnabled:!1,recordingQuality:"standard",timelapseIntervalSeconds:10,includeRemoteCursor:!0};try{const a=JSON.parse(localStorage.getItem(Mw)||"null");return{...n,...a&&typeof a=="object"?a:{}}}catch{return n}}function SM(n){const[a,l]=f.useState(bM),[r,c]=f.useState(0),[u,m]=f.useState(0),[p,v]=f.useState(0),[g,w]=f.useState(!1),y=f.useRef(void 0),b=f.useRef(!1),j=f.useRef(""),C=f.useRef(null),A=f.useRef(null),T=f.useRef(null),k=f.useRef(null),E=f.useRef(new yM),R=n.sourceRegistry.resolveCurrentTarget(),U=fM(R),F=mM(R),V=typeof MediaRecorder<"u"&&typeof HTMLCanvasElement<"u"&&"captureStream"in HTMLCanvasElement.prototype;f.useEffect(()=>{if(localStorage.setItem(Mw,JSON.stringify(a)),!b.current)return;const X=JSON.stringify(a);X!==j.current&&(j.current=X,Be("/api/settings",{method:"PATCH",body:JSON.stringify({revision:y.current,filesAudio:{rollingBufferEnabled:a.rollingEnabled,recordingQuality:a.recordingQuality,timelapseIntervalSeconds:a.timelapseIntervalSeconds,includeRemoteCursor:a.includeRemoteCursor}})},n.hubUrl).then(P=>{y.current=Number(P.revision||y.current||0)}).catch(()=>{}))},[n.hubUrl,a]),f.useEffect(()=>{let X=!0;return Be("/api/settings",void 0,n.hubUrl).then(P=>{if(!X)return;const le=P.settings?.filesAudio||{},we=typeof le.rollingBufferEnabled=="boolean"?le.rollingBufferEnabled:a.rollingEnabled,L=le.recordingQuality==="high"?"high":"standard",$=[5,10,30,60].includes(Number(le.timelapseIntervalSeconds))?Number(le.timelapseIntervalSeconds):a.timelapseIntervalSeconds,xe=typeof le.includeRemoteCursor=="boolean"?le.includeRemoteCursor:a.includeRemoteCursor,Se={rollingEnabled:we,recordingQuality:L,timelapseIntervalSeconds:$,includeRemoteCursor:xe};y.current=Number(P.revision||0),j.current=JSON.stringify(Se),b.current=!0,l(Se)}).catch(()=>{b.current=!0}),()=>{X=!1}},[n.hubUrl]);const _=f.useCallback(async X=>{if(X.sourceCanvas&&X.sourceCanvas.width>0&&X.sourceCanvas.height>0)return{target:Qx(X),canvas:X.sourceCanvas,cleanup:()=>{}};const P=await n.sourceRegistry.composeWall(X.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0});let le=!1;const we=window.setInterval(async()=>{if(le)return;const L=await n.sourceRegistry.composeWall(X.deviceIds,{maxWidth:1920,maxHeight:1080,includeLabels:!0}).catch(()=>null);!L||le||((P.width!==L.width||P.height!==L.height)&&(P.width=L.width,P.height=L.height),P.getContext("2d")?.drawImage(L,0,0))},100);return{target:Qx(X),canvas:P,cleanup:()=>{le=!0,window.clearInterval(we)}}},[n.sourceRegistry]);f.useEffect(()=>{const X=E.current;if(!a.rollingEnabled||!R||!V){X.stop(),v(0);return}let P=!1,le=null;return(async()=>{try{if(le=await _(R),P)return;await X.start(le.canvas,le.target);const L=window.setInterval(()=>v(Math.round(X.seconds)),500),$=()=>{window.clearInterval(L),le?.cleanup()};X.__cleanup=$}catch(L){P||n.onToast(L instanceof Error?L.message:String(L))}})(),()=>{P=!0,X.stop(),X.__cleanup?.(),X.__cleanup=void 0,v(0)}},[_,n.onToast,a.rollingEnabled,U,V]);const I=f.useCallback(X=>l(P=>({...P,rollingEnabled:X})),[]),me=f.useCallback(X=>l(P=>({...P,recordingQuality:X})),[]),Y=f.useCallback(X=>l(P=>({...P,timelapseIntervalSeconds:X})),[]),ue=f.useCallback(async()=>{const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);let P=null;try{P=await _(X),await vM(P.canvas,P.target,n.hubUrl),n.onToast("Screenshot saved")}finally{P?.cleanup(),w(!1)}},[_,n.hubUrl,n.onToast,n.sourceRegistry]),K=f.useCallback(async()=>{if(T.current)throw new Error("Stop the timelapse before recording.");const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");const P=await _(X),le=await Aw({canvas:P.canvas,target:P.target,fps:X.type==="control"?30:15,hubUrl:n.hubUrl,onError:we=>n.onToast(we.message)});A.current=P.cleanup,C.current=le,c(Date.now()),n.onToast("Recording started")},[_,n.hubUrl,n.onToast,n.sourceRegistry]),ie=f.useCallback(async()=>{const X=C.current;if(X){w(!0);try{await X.stop(),n.onToast("Recording saved")}finally{C.current=null,A.current?.(),A.current=null,c(0),w(!1)}}},[n.onToast]),ee=f.useCallback(async()=>{if(C.current||T.current)throw new Error("Last 30s is unavailable during a recording.");const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");w(!0);try{await E.current.save(X,n.hubUrl),n.onToast("Last 30 seconds saved")}finally{w(!1)}},[n.hubUrl,n.onToast,n.sourceRegistry]),W=f.useCallback(async()=>{if(C.current)throw new Error("Stop the recording before starting a timelapse.");const X=n.sourceRegistry.resolveCurrentTarget();if(!X)throw new Error("화면이 준비된 후 다시 시도하세요.");const P=await _(X),le=await wM(P.canvas,P.target,a.timelapseIntervalSeconds,n.hubUrl,we=>n.onToast(we.message));k.current=P.cleanup,T.current=le,m(Date.now()),n.onToast("Timelapse started")},[_,n.hubUrl,n.onToast,n.sourceRegistry,a.timelapseIntervalSeconds]),z=f.useCallback(async()=>{const X=T.current;if(X){w(!0);try{await X.stop(),n.onToast("Timelapse saved")}finally{T.current=null,k.current?.(),k.current=null,m(0),w(!1)}}},[n.onToast]);return f.useEffect(()=>{const X=P=>{!C.current&&!T.current||(P.preventDefault(),P.returnValue="")};return window.addEventListener("beforeunload",X),()=>window.removeEventListener("beforeunload",X)},[]),f.useEffect(()=>()=>{E.current.stop(),C.current?.cancel(),T.current?.cancel(),A.current?.(),k.current?.()},[]),{state:f.useMemo(()=>({recording:!!C.current,recordingStartedAt:r,timelapse:!!T.current,timelapseStartedAt:u,bufferSeconds:p,bufferEnabled:a.rollingEnabled,busy:g,targetLabel:F}),[p,g,r,a.rollingEnabled,F,u]),settings:a,videoSupported:V,targetKey:U,setRollingEnabled:I,setRecordingQuality:me,setTimelapseInterval:Y,takeScreenshot:ue,startRecording:K,stopRecording:ie,saveLast30Seconds:ee,startTimelapse:W,stopTimelapse:z}}const jM=120,CM=999,vc=5,xc=30,kM=Number.POSITIVE_INFINITY,Nw="livedesk.remoteDirectory",wh="livedesk.localHubAccessEnabled",Tw="livedesk.streamSettings",Ew=15,Rw="livedesk.controlStreamSettings",bh=6,Dw="livedesk.wallMonitorSelections",Lw=1,Ym=512*1024,Sh="".trim(),_w="".trim(),Xx="livedesk-adsense-script",Wm=!!Sh&&!!_w,AM=1e3/60,Km=1500,MM=650,NM=1800,TM=650,EM=2500,Zx=1500,Jx=15e3,RM=6e4,ey=240,DM=1024,LM=480,_M=270,ty="LiveDesk clients are updating. Hub will restart after every client reconnects.",Qm="LiveDesk is restarting with the latest Hub.";function zM(n,a){if(a.deviceId!==n.deviceId)return!1;const l=Number(a.browserReceivedEpochMs);if(!Number.isFinite(l)||l<n.startedAtEpochMs)return!1;const r=Number(a.monitorIndex);if(Number.isFinite(r)&&Math.floor(r)!==n.monitorIndex)return!1;const c=String(a.frameMode||a.mode||"").trim().toLowerCase();return!c||c===n.frameMode?!0:(n.frameMode==="mode3-h264-hw"||n.frameMode==="mode5-lzo-delta")&&(c==="mode2-lzo"||c==="mode3-h264-hw")}const nr={free:{name:"Free",price:"$0",limit:vc,audience:"Personal trial",note:"5 devices with a standard ad banner."},ltd:{name:"Plus",price:"$79 LTD",ltd:"$79 LTD",limit:xc,audience:"Creators and homelabs",note:"30 devices, no ads, personal use."},pro:{name:"Pro",price:"$199 LTD",ltd:"$199 LTD",limit:kM,audience:"Business and studios",note:"Commercial use and larger workstation walls."}},zw={"mode1-jpeg":5,"mode2-lzo":8,"mode3-h264-hw":20,"mode4-h264-atlas":20};function gs(n,a){return`${n}:${a}`}const da={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-hardware",fps:zw["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},fa={frameMode:"mode3-h264-hw",h264DecodeAcceleration:"prefer-software",fps:30,maxWidth:1920,maxHeight:1080,quality:75,showScreenStatus:!1};function yd(n,a){if(n.length===0)return 0;const l=[...n].sort((c,u)=>c-u),r=Math.max(0,Math.min(l.length-1,Math.ceil(l.length*a)-1));return l[r]}function Kh(n,a){n.push(a),n.length>ey&&n.splice(0,n.length-ey)}function ny(n,a){n.sampleFrames=0,n.sampleStartedAt=a,n.intervalCount=0,n.intervalSumMs=0,n.minIntervalMs=Number.POSITIVE_INFINITY,n.maxIntervalMs=0,n.intervalSamplesMs.length=0,n.seqGapCount=0,n.maxSeqGap=0}function ay(n,a,l){if(n.lastAt!==void 0){const r=Math.max(0,a-n.lastAt);n.intervalCount+=1,n.intervalSumMs+=r,n.minIntervalMs=Math.min(n.minIntervalMs,r),n.maxIntervalMs=Math.max(n.maxIntervalMs,r),Kh(n.intervalSamplesMs,r)}if(n.lastFrameSeq!==void 0){const r=l-n.lastFrameSeq;r!==1&&(n.seqGapCount+=1,n.maxSeqGap=Math.max(n.maxSeqGap,Math.abs(r)))}n.lastAt=a,n.lastFrameSeq=l}function sy(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 IM(){const[n,a]=f.useState({framesPerSecond:0,averageIntervalMs:0,p95IntervalMs:0,maxIntervalMs:0,longTaskCount:0,longTaskMs:0});return f.useEffect(()=>{let l=0,r=performance.now(),c=0,u=0,m=[],p=0,v=0,g=null;const w=b=>{document.visibilityState==="visible"?(c+=1,u>0&&Kh(m,Math.max(0,b-u)),u=b):u=0,l=window.requestAnimationFrame(w)};try{g=new PerformanceObserver(b=>{for(const j of b.getEntries())p+=1,v+=j.duration}),g.observe({entryTypes:["longtask"]})}catch{g=null}l=window.requestAnimationFrame(w);const y=window.setInterval(()=>{const b=performance.now(),j=Math.max(1,b-r),C=m.reduce((A,T)=>A+T,0);a({framesPerSecond:c*1e3/j,averageIntervalMs:m.length>0?C/m.length:0,p95IntervalMs:yd(m,.95),maxIntervalMs:m.length>0?Math.max(...m):0,longTaskCount:p,longTaskMs:v}),r=b,c=0,m=[],p=0,v=0},1e3);return()=>{window.cancelAnimationFrame(l),window.clearInterval(y),g?.disconnect()}},[]),n}function iy(n){return!n||n.seqGapCount<=0?"none":`${n.seqGapCount} gaps / max ${n.maxSeqGap}`}function OM(n){return Number.isFinite(n)?String(n):"30+"}const wd=[{id:"mode4-h264-atlas",label:"Mode 4",detail:"Hub H.264 Atlas"},{id:"mode3-h264-hw",label:"Mode 3",detail:"H.264 hardware"}],jh=[{id:"prefer-software",label:"Software low latency"},{id:"prefer-hardware",label:"Hardware decode"},{id:"no-preference",label:"Browser auto"}],BM=[{id:"mode3-h264-hw",label:"Mode 3 - H.264 hardware"}],bd=[{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}],Xm=bd.filter(n=>n.width>=1280),Zm=[{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}],Qh=[1,2,5,8,12,20,30],FM=[20,30,60],ly=[45,60,75,90],ry={large:{maxWidth:1280,maxHeight:720},medium:{maxWidth:960,maxHeight:540},small:{maxWidth:640,maxHeight:360}},Vn={preserveConfiguredFpsDeviceCount:12,visibleRootMargin:"520px 0px 760px 0px",fallbackVisibleCounts:{large:12,medium:18,small:32},maxWallFramesPerSecond:96,maxWallBytesPerSecond:80*1024*1024,maxFrameGapMs:280,lowLoadFrameRatio:.58,lowLoadByteRatio:.52,downshiftCooldownMs:1800,recoveryCooldownMs:14e3,minFps:5},oy=2200,HM=8e3,PM=3500,$M=7e3,UM=2,qM=2600,GM=4200,VM=750,YM=2,cy=4200;function uy(n,a){return Math.min(3e4,n*2**Math.min(3,Math.max(0,a)))}function Tc(n,a){const l=n.capabilities?.[a];return typeof l=="boolean"?l:/^(1|true|yes|on)$/i.test(String(l||"").trim())}function rr(n){return n.deviceName||n.hostname||n.deviceId}function WM(){return"npx -y --prefer-online livedesk@latest client"}function KM(){return"npx -y --prefer-online livedesk@latest"}function QM(){try{return localStorage.getItem(Nw)||""}catch{return""}}function XM(){try{return localStorage.getItem(wh)==="1"}catch{return!1}}function to(n){try{n?localStorage.setItem(wh,"1"):localStorage.removeItem(wh)}catch{}}function Xa(n,a,l,r){const c=Number(n);return Number.isFinite(c)?Math.max(a,Math.min(l,Math.round(c))):r}function Ch(n){const a=String(n||"").trim();return a==="mode2-lz4"||a==="lz4"?"mode2-lzo":wd.some(l=>l.id===a)?a:da.frameMode}function Dd(n){const a=String(n||"").trim();return jh.some(l=>l.id===a)?a:da.h264DecodeAcceleration}function kh(n){return n==="mode3-h264-hw"?n:fa.frameMode}function Iw(n){return zw[n]||12}function Ow(n){return n==="mode3-h264-hw"||n==="mode4-h264-atlas"?20:30}function Ah(n,a){return Xa(n,1,Ow(a),Iw(a))}function dr(n){return n&&typeof n=="object"&&!Array.isArray(n)?n:{}}function Gn(n){const a=dr(n.status),l=dr(a.screens),r=dr(n.capabilities),c=[a.monitorCount,a.screenCount,l.count,r.monitorCount,r.screenCount];for(const u of c){const m=Number(u);if(Number.isFinite(m)&&m>0)return Math.max(1,Math.min(64,Math.floor(m)))}return 1}function jl(n){const a=Number(n);return Number.isFinite(a)&&a>0?Math.floor(a):0}function ZM(n){const a=dr(n.status),r=[dr(a.screens).displays,a.displays,a.monitors];for(const c of r)if(!(!Array.isArray(c)||c.length===0))return c.map(u=>dr(u));return[]}function Bw(n,a){const l=ZM(n),r=l.find(v=>Number(v.index)===a)||l[a]||l[0]||{},c=jl(r.width),u=jl(r.height),m=[r.name,r.displayName,r.deviceName,r.id].find(v=>typeof v=="string"&&v.trim()),p=typeof m=="string"?m.trim():`Display ${a+1}`;return{index:a,name:p,width:c,height:u,primary:r.primary===!0||r.isPrimary===!0}}function JM(n){const a=Gn(n);return Array.from({length:a},(l,r)=>Bw(n,r))}function eN(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 Fw(n,a){const l=Bw(n,a);if(l.width>0&&l.height>0)return{width:l.width,height:l.height};const r=dr(n.status),c=jl(r.screenWidth||r.width),u=jl(r.screenHeight||r.height);return c>0&&u>0?{width:c,height:u}:null}function Hw(n){if(!n)return null;const a=jl(n.sourceWidth)||jl(n.width),l=jl(n.sourceHeight)||jl(n.height);return a>0&&l>0?{width:a,height:l}:null}function tN(n,a,l){const u=((typeof a?.monitorIndex=="number"?Jn(a.monitorIndex,Math.max(1,a.monitorCount||1)):l)===l?Hw(a):null)||Fw(n,l);return u?Math.max(.25,Math.min(4,u.width/u.height)):16/9}const fd=16/9;function Jn(n,a){const l=Math.max(1,Math.min(64,Math.floor(Number(a)||1))),r=Math.floor(Number(n));return Number.isFinite(r)?Math.max(0,Math.min(l-1,r)):0}function nN(){try{const n=localStorage.getItem(Dw);if(!n)return{};const a=JSON.parse(n),l=a&&typeof a=="object"&&!Array.isArray(a)?a.selections:void 0;if(Number(a?.version)!==Lw||!l||typeof l!="object"||Array.isArray(l))return{};const r={};for(const[c,u]of Object.entries(l)){const m=c.trim(),p=Math.floor(Number(u));!m||!Number.isFinite(p)||(r[m]=Math.max(0,Math.min(63,p)))}return r}catch{return{}}}function aN(n){try{localStorage.setItem(Dw,JSON.stringify({version:Lw,selections:n}))}catch{}}function sN(){try{const n=JSON.parse(localStorage.getItem(Tw)||"{}");if(![Ew,14,13,12,11].includes(Number(n.version)))return da;const a=Ch(n.frameMode),l=Xa(n.maxWidth,320,3840,da.maxWidth),r=Xa(n.maxHeight,180,2160,da.maxHeight);return{frameMode:a,h264DecodeAcceleration:Dd(n.h264DecodeAcceleration),fps:Ah(n.fps,a),maxWidth:l,maxHeight:r,atlasTileWidth:Number(n.atlasTileWidth)>=480?480:320,atlasTileHeight:Number(n.atlasTileHeight)>=270?270:180,atlasTileSizeMode:n.atlasTileSizeMode==="fixed"?"fixed":"auto",quality:Xa(n.quality,20,95,da.quality),autoStartLive:typeof n.autoStartLive=="boolean"?n.autoStartLive:da.autoStartLive,showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:da.showScreenStatus,visibleOnlyLive:typeof n.visibleOnlyLive=="boolean"?n.visibleOnlyLive:da.visibleOnlyLive,adaptiveLoadShedding:typeof n.adaptiveLoadShedding=="boolean"?n.adaptiveLoadShedding:da.adaptiveLoadShedding,adaptiveSizeByWall:typeof n.adaptiveSizeByWall=="boolean"?n.adaptiveSizeByWall:da.adaptiveSizeByWall}}catch{return da}}function iN(n){try{localStorage.setItem(Tw,JSON.stringify({...n,version:Ew}))}catch{}}function lN(){try{const n=JSON.parse(localStorage.getItem(Rw)||"{}"),a=Number(n.version);if(![bh,5,4,3,2,1].includes(a))return fa;const l=Xa(n.fps,20,60,fa.fps),r=a<bh;return{frameMode:r?fa.frameMode:kh(n.frameMode),h264DecodeAcceleration:r?fa.h264DecodeAcceleration:Dd(n.h264DecodeAcceleration),fps:r?fa.fps:l,maxWidth:Xa(n.maxWidth,1280,3840,fa.maxWidth),maxHeight:Xa(n.maxHeight,720,2160,fa.maxHeight),quality:Xa(n.quality,20,95,fa.quality),showScreenStatus:typeof n.showScreenStatus=="boolean"?n.showScreenStatus:fa.showScreenStatus}}catch{return fa}}function rN(n){try{localStorage.setItem(Rw,JSON.stringify({...n,version:bh}))}catch{}}function Jm(n,a){return n.length!==a.length?!1:n.every((l,r)=>l===a[r])}function eh(n){return[...new Set(n.filter(Boolean))].sort()}function oN(n){return Vn.fallbackVisibleCounts[n]||Vn.fallbackVisibleCounts.large}function cN(n,a,l){if(n.frameMode==="mode2-lzo")return{maxWidth:320,maxHeight:180};if(n.frameMode==="mode4-h264-atlas")return n.atlasTileSizeMode==="auto"?a==="large"?{maxWidth:480,maxHeight:270}:{maxWidth:320,maxHeight:180}:{maxWidth:n.atlasTileWidth,maxHeight:n.atlasTileHeight};if(!n.adaptiveSizeByWall)return{maxWidth:n.maxWidth,maxHeight:n.maxHeight};const r=ry[a]||ry.large;return{maxWidth:Math.min(n.maxWidth,r.maxWidth),maxHeight:Math.min(n.maxHeight,r.maxHeight)}}function uN(n,a=Vn.minFps){const l=[...Qh].sort((c,u)=>c-u),r=Math.max(a,Math.floor(n/2));return[...l].reverse().find(c=>c<n&&c>=a)||r}function dN(n,a){return[...Qh].sort((r,c)=>r-c).find(r=>r>n&&r<=a)||a}function yc(n){if(!Number.isFinite(n)||n<=0)return"0 B";const a=["B","KB","MB","GB","TB"];let l=n,r=0;for(;l>=1024&&r<a.length-1;)l/=1024,r+=1;const c=r===0||l>=100?0:1;return`${l.toFixed(c)} ${a[r]}`}function dy(n){if(!Number.isFinite(n)||!n||n<=0)return"0GB";const a=1024**4,l=1024**3;return n>=a?`${Math.max(1,Math.round(n/a))}TB`:`${Math.max(1,Math.round(n/l))}GB`}function th(n,a){if(!Number.isFinite(n)||!n||n<=0)return"not reported";const l=Math.max(0,n-Math.max(0,Number(a||0)));return`${dy(l)} / ${dy(n)}`}function fN(n){const a=new Uint8Array(n),l=32768;let r="";for(let c=0;c<a.length;c+=l){const u=a.subarray(c,c+l);r+=String.fromCharCode(...u)}return btoa(r)}function fy(n){return Array.from(n).filter(a=>a.size>=0).map(a=>{const l=a.webkitRelativePath||a.name;return{file:a,relativePath:l,fingerprint:`${a.size}:${a.lastModified}`}})}function mN(n){return n===1?"middle":n===2?"right":"left"}function my(n,...a){for(const l of a){const r=n?.[l];if(typeof r=="string"&&r.trim())return r.trim()}return""}function hy(n){const a=Number(n);return Number.isInteger(a)&&a>=1&&a<=CM?a:0}const hN={cpu:"CPU",memory:"MEM",disk:"Disk",gpu:"GPU",vram:"VRAM",npu:"NPU",temp:"Temp",network:"Net"};function pN(n,a,l){if(n==="online")return"Online";if(n==="busy")return"Busy";if(n==="stale")return"Stale";if(n==="offline")return"Offline";if(l==="failed")return"Task failed";const r=n==="critical"?"critical":"warn",c=a.find(m=>m.state===r)||a.find(m=>m.state==="critical"||m.state==="warn");if(!c)return n==="critical"?"Issue":"Check";const u=hN[c.id]||c.label;return c.value&&c.value!=="-"?`${u} ${c.value}`:u}function Pd(n,a){const l=a.split(".");let r=n;for(const c of l){if(r==null)return;if(Array.isArray(r)){const u=Number(c);r=Number.isInteger(u)?r[u]:void 0;continue}if(typeof r=="object"){r=r[c];continue}return}return r}function Ot(n,...a){for(const l of a){const r=Pd(n,l),c=Number(r);if(Number.isFinite(c))return c}}function ma(n,...a){for(const l of a){const r=Pd(n,l);if(typeof r=="string"&&r.trim())return r.trim();if(typeof r=="number"&&Number.isFinite(r))return String(r)}return""}function gN(n,...a){for(const l of a){const r=Pd(n,l);if(typeof r=="boolean")return r;if(/^(1|true|yes|on|online|running|ready)$/i.test(String(r||"").trim()))return!0;if(/^(0|false|no|off|offline|stopped|missing)$/i.test(String(r||"").trim()))return!1}}function ki(n){const a=Number(n);if(Number.isFinite(a))return Math.max(0,Math.min(1,a>1?a/100:a))}function nh(n,a){if(!(typeof n!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(a)||n<=0))return ki((n-Math.max(0,a))/n)}function no(n){return n===void 0?"-":`${Math.round(n*100)}%`}function ah(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 ar(n,a=.92,l=.78){return n===void 0?"unknown":n>=a?"critical":n>=l?"warn":"good"}function Pw(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 md(n,a,l){const r=Pd(n,`tools.${a}`),c=ma(n,`tools.${a}.status`,`tooling.${a}.status`,`${a}.status`).toLowerCase(),u=gN(n,`tools.${a}.running`,`tooling.${a}.running`,`${a}.running`),m=ma(n,`tools.${a}.version`,`tooling.${a}.version`,`${a}.version`),p=ma(n,`tools.${a}.port`,`tooling.${a}.port`,`${a}.port`);let v="unknown";return c==="busy"?v="busy":["online","running","ready","active"].includes(c)||u===!0?v="online":(["offline","stopped","missing","not-found"].includes(c)||u===!1||r===!1)&&(v="offline"),{id:a,label:l,status:v,detail:v==="offline"?"offline":m||(p?`:${p}`:v==="unknown"?"not reported":v)}}function $w(n){const a=n.status||{},l=Ot(a,"cpu.cores","cpuCores","processorCount"),r=Ot(a,"loadavg.0","cpu.load1"),c=ki(Ot(a,"cpu.usedRatio","cpu.usageRatio","cpu.ratio","cpu.usedPct","cpu.usagePct","cpu.percent")??(l&&r!==void 0?r/Math.max(1,l):void 0)),u=Ot(a,"memory.totalBytes","totalMem"),m=Ot(a,"memory.freeBytes","freeMem"),p=ki(Ot(a,"memory.usedRatio","memory.usedPct","usedMemRatio"))??nh(u,m),v=Ot(a,"disk.totalBytes","rootDisk.totalBytes","storage.totalBytes"),g=Ot(a,"disk.freeBytes","rootDisk.freeBytes","storage.freeBytes"),w=ki(Ot(a,"disk.usedRatio","disk.usedPct","rootDisk.usedRatio","storage.usedRatio"))??nh(v,g),y=Ot(a,"thermal.cpuC","temperatureC","cpu.temperatureC","gpu.temperatureC"),b=ki(Ot(a,"gpu.usedRatio","gpu.usageRatio","gpu.usedPct","gpu.usagePct","gpu.percent","accelerators.gpu.usageRatio")),j=ma(a,"gpu.name","gpu.model","accelerators.gpu.name"),C=Ot(a,"gpu.memory.totalBytes","gpu.totalMemoryBytes","gpu.vramTotalBytes"),A=Ot(a,"gpu.memory.freeBytes","gpu.freeMemoryBytes","gpu.vramFreeBytes"),T=ki(Ot(a,"gpu.memory.usedRatio","gpu.vramUsedRatio"))??nh(C,A),k=Ot(a,"gpu.temperatureC","thermal.gpuC"),E=ki(Ot(a,"npu.usedRatio","npu.usageRatio","npu.usedPct","npu.usagePct","npu.percent","accelerators.npu.usageRatio")),R=ma(a,"npu.name","npu.model","accelerators.npu.name"),U=Ot(a,"npu.tops","npu.topsInt8","accelerators.npu.tops"),F=Ot(a,"network.rxMbps","network.receiveMbps","network.downMbps"),V=Ot(a,"network.txMbps","network.transmitMbps","network.upMbps"),_=Ot(a,"network.latencyMs","network.rttMs"),I=ki(Ot(a,"network.usedRatio","network.usageRatio","network.saturationRatio")),me=ma(a,"network.link","network.interface","network.name"),Y=y===void 0?void 0:ki((y-35)/60),ue=ma(a,"workload.role","role","lane")||(Tc(n,"aiAssist")?"Agent worker":Tc(n,"taskDispatch")?"Task worker":"Local machine"),K=ma(n.latestTask,"status")||ma(a,"workload.status")||"idle",ie=ma(n.latestTask,"title","instructionPreview")||ma(a,"workload.title"),ee=ma(n.latestTask,"resultSummary","error","instructionPreview")||ma(a,"workload.summary"),W=[md(a,"ollama","Ollama"),md(a,"lmStudio","LM Studio"),md(a,"comfyui","ComfyUI"),md(a,"stableDiffusion","Stable Diffusion")],z=W.some(L=>L.status!=="unknown"),Q=Date.parse(n.lastSeenAt||n.connectedAt||""),X=Number.isFinite(Q)?Date.now()-Q:0;let P="online";n.connected?X>5*6e4?P="stale":(y??0)>=86||(k??0)>=88||(c??0)>=.94||(b??0)>=.96||(T??0)>=.96||(E??0)>=.96||(p??0)>=.94||(w??0)>=.94||(_??0)>=200||K==="failed"?P="critical":(y??0)>=78||(k??0)>=80||(c??0)>=.82||(b??0)>=.86||(T??0)>=.88||(E??0)>=.86||(p??0)>=.82||(w??0)>=.86||(_??0)>=80?P="warn":(["queued","running","targeted"].includes(K)||W.some(L=>L.status==="busy"))&&(P="busy"):P="offline";const le=W.filter(L=>L.status==="online"||L.status==="busy").length,we=[{id:"cpu",label:"CPU",value:no(c),detail:l?`${l} cores`:r!==void 0?`load ${r.toFixed(1)}`:"not reported",ratio:c,state:ar(c,.92,.78)},{id:"memory",label:"RAM",value:no(p),detail:th(u,m),ratio:p,state:ar(p,.92,.78)},{id:"disk",label:"DISK",value:no(w),detail:th(v,g),ratio:w,state:ar(w,.92,.82)},{id:"gpu",label:"GPU",value:no(b),detail:j||(C&&A!==void 0?`${yc(A)} VRAM free`:k!==void 0?`${Math.round(k)}C`:"not reported"),ratio:b,state:k!==void 0&&k>=88?"critical":k!==void 0&&k>=80?"warn":ar(b,.96,.86)},{id:"vram",label:"VRAM",value:no(T),detail:th(C,A),ratio:T,state:ar(T,.96,.88)},{id:"npu",label:"NPU",value:E!==void 0?no(E):U!==void 0?`${Math.round(U)} TOPS`:"-",detail:R||(U!==void 0?"neural engine":"not reported"),ratio:E,state:ar(E,.96,.86)},{id:"temp",label:"TEMP",value:y===void 0?"-":`${Math.round(y)}C`,detail:le>0?`${le} local tools`:`uptime ${Pw(Ot(a,"uptimeSec"))}`,ratio:Y,state:y===void 0?"unknown":y>=86?"critical":y>=78?"warn":"good"},{id:"network",label:"NET",value:ah(F)||(_!==void 0?`${Math.round(_)}ms`:me||"-"),detail:ah(V)?`${ah(V)} up`:me||"not reported",ratio:I,state:_!==void 0&&_>=200?"critical":_!==void 0&&_>=80?"warn":ar(I,.9,.75)}];return{state:P,label:pN(P,we,K),role:ue,taskLabel:ie||(K==="idle"?"idle":K),taskStatus:K,taskSummary:ee,tools:z?W:W.map(L=>({...L,detail:"not reported"})),metrics:we}}function vN({size:n=22}){return i.jsxs("svg",{width:n,height:n,viewBox:"0 0 28 28",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[i.jsx("rect",{x:"2.5",y:"4",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.42"}),i.jsx("path",{d:"M7 16v1.5h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.42"}),i.jsx("rect",{x:"10.5",y:"2.5",width:"14",height:"9",rx:"1.5",stroke:"currentColor",strokeWidth:"1.7",opacity:"0.62"}),i.jsx("path",{d:"M15 14.5V16h5",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",opacity:"0.62"}),i.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"}),i.jsx("path",{d:"M12 21v1.5H9.5M16 21v1.5h2.5M9.5 22.5h9",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round"})]})}const xN=[{id:"small",label:"Small"},{id:"medium",label:"Medium"},{id:"large",label:"Large"}],yN=[{id:"wall",label:"Wall",icon:Ec,accent:"blue"},{id:"control",label:"Control",icon:pd,accent:"red"},{id:"share-files",label:"Share Files",icon:hd,accent:"green"},{id:"agents",label:"Agents",icon:pc,accent:"violet"},{id:"sync-server",label:"Sync Server",icon:wc,accent:"blue"}],wN=[{id:"doc",label:"Doc",icon:lh,accent:"amber"},{id:"support",label:"Support",icon:hc,accent:"violet"},{id:"pricing",label:"Pricing",icon:gc,accent:"green"}];function bN(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 Bt(n){return bN(n).replace(/\bRemoteHub\b/g,"Hub client endpoint").replace(/\bManagers\b/g,"Hubs").replace(/\bManager\b/g,"Hub").replace(/\bmanager\b/g,"Hub").replace(/\bMANAGER\b/g,"HUB").replace(/매니저/g,"Hub")}function sr(n){return n.map(a=>Bt(a))}function Un(n){return{languageName:n.languageName,languageLabel:n.languageLabel,eyebrow:n.eyebrow,title:Bt(n.title),intro:Bt(n.intro),sections:[{title:Bt(n.managerTitle),body:Bt(n.managerBody),points:sr(n.managerPoints)},{title:Bt(n.clientTitle),body:Bt(n.clientBody),points:sr(n.clientPoints)},{title:Bt(n.syncTitle),body:Bt(n.syncBody),points:sr(n.syncPoints)},...n.agentTitle&&n.agentBody&&n.agentPoints?[{title:Bt(n.agentTitle),body:Bt(n.agentBody),points:sr(n.agentPoints)}]:[],{title:Bt(n.platformTitle),body:Bt(n.platformBody),points:sr(n.platformPoints)}],sync:{title:Bt(n.syncTitle),body:Bt(n.syncBody),points:sr(n.syncPoints)},firewall:{title:Bt(n.firewallTitle),body:Bt(n.firewallBody),points:sr(n.firewallPoints)},commands:{title:Bt(n.commandsTitle),body:Bt(n.commandsBody),manager:Bt(n.managerCommandLabel),primary:Bt(n.clientCommandLabel),slot:Bt(n.slotCommandLabel),manual:Bt(n.manualCommandLabel)}}}const lo={ko:Un({languageName:"한국어",languageLabel:"문서 언어",eyebrow:"LiveDesk Manual",title:"한 줄로 여는 로컬 Screen Wall",intro:"LiveDesk는 매니저 PC 한 대에서 여러 작업 PC, AI 박스, 맥미니, 개발 장비를 한 화면에 모니터링하고 필요한 제어를 실행하는 npm-first 원격 작업 데크입니다.",managerTitle:"1. 매니저 실행",managerBody:"화면을 모아 볼 컴퓨터에서 LiveDesk 매니저를 실행합니다. 매니저는 UI와 로컬 서버를 같이 열고 브라우저를 http://127.0.0.1:5179 로 띄웁니다.",managerPoints:["명령은 npx -y livedesk 입니다.","매니저는 Screen Wall/API 포트 5179와 클라이언트 접속 포트 5197을 사용합니다.","기존 LiveDesk 포트가 남아 있으면 기본적으로 정리하고 새로 시작합니다. 필요하면 --no-clean 을 붙입니다."],clientTitle:"2. 워크스테이션 연결",clientBody:"모니터링할 PC에서는 Google 로그인 또는 Hub 화면의 6자리 PIN으로 연결합니다. Hub가 켜져 있지 않아도 클라이언트는 종료하지 않고 5초마다 계속 찾습니다.",clientPoints:["빈 자리에 자동 배치하려면 npx -y livedesk client 를 실행합니다.","자리 번호를 고정하려면 npx -y livedesk client 3 처럼 번호를 붙입니다.","브라우저 연결 페이지에서 Google 버튼 또는 6자리 PIN 입력 중 하나를 선택합니다."],syncTitle:"3. Sync Server와 자동 발견",syncBody:"Sync Server는 이 매니저를 현재 계정의 활성 Screen Wall로 Supabase에 등록합니다. 클라이언트는 같은 Google 계정으로 로그인한 뒤 그 기록을 읽고 접속 후보들을 순서대로 시도합니다.",syncPoints:["등록 정보에는 host instance, LAN/private 주소, public 후보 주소, pair token, 짧은 lease가 포함됩니다.","같은 LAN 후보를 먼저 쓰고, 필요하면 외부 주소 후보를 시도합니다.","매니저 위치, VPN, 방화벽, 공유기 설정이 바뀌었거나 개발 중 활성 매니저를 바꿀 때 Sync Server를 누릅니다.","이제 livedesk.pages.dev의 Chrome Local Network Access 허용은 기본 실행 경로가 아닙니다. npm 매니저 앱이 실제 서버입니다."],agentTitle:"4. Agent로 여러 장비 작업하기",agentBody:"Agents 화면은 Hub에서 실행되는 Codex 기반 Agent가 연결된 장비를 확인하고, 선택한 권한 범위 안에서 작업을 실행하는 공간입니다. 클라이언트 PC에 Codex 앱이나 Codex SDK를 설치할 필요는 없습니다.",agentPoints:["Suggested tasks에는 현재 72개의 읽기·운영 작업 템플릿이 있으며, 검색과 권한·플랫폼·capability 조건으로 실행 가능 항목을 안내합니다.","Ask, Safe Auto, Full Access, Custom 권한 모드를 선택할 수 있습니다. 위험한 변경 작업은 승인 카드와 장비 capability 검사를 거칩니다.","All connected 또는 Selected로 대상 장비를 제한하고, 결과는 장비별 상태 칩과 실제 RAM·디스크·GPU·프로세스 요약으로 확인합니다.","Agent 실행은 Hub의 격리된 runtime과 LiveDesk MCP 도구를 통해서만 장비에 전달되며, 모든 작업은 timeout·취소·tool limit·감사 로그 경계를 가집니다."],platformTitle:"5. 현재 플랫폼과 스트림 상태",platformBody:"Windows의 Wall, Control, 파일 전송, 원격 오디오와 RemoteFast 경로를 현재 기준으로 확인했습니다. macOS와 Linux는 같은 npm 명령 경로를 유지하면서 권한과 캡처 백엔드를 확장하고 있습니다.",platformPoints:["Wall은 Mode 3 H.264와 Mode 4 H.264 Atlas를 사용합니다. Mode 2/5 호환 경로는 오류 복구 시 자동으로만 사용됩니다.","원격 오디오는 선택한 장비가 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:Un({languageName:"English",languageLabel:"Document language",eyebrow:"LiveDesk Manual",title:"Open a local Screen Wall with one command",intro:"LiveDesk is an npm-first remote work deck for monitoring many workstations, AI boxes, Mac minis, and dev machines from one manager PC.",managerTitle:"1. Run the manager",managerBody:"Run LiveDesk on the computer that will watch the screens. The manager starts the UI and local server together, then opens http://127.0.0.1:5179.",managerPoints:["The command is npx -y livedesk.","The manager uses port 5179 for the Screen Wall/API and port 5197 for client connections.","If an old LiveDesk process still owns those ports, startup cleans it by default. Add --no-clean when you want to keep it."],clientTitle:"2. Connect a workstation",clientBody:"On each monitored computer, connect with Google sign-in or the 6-digit PIN shown on the Hub screen. If no manager is online yet, the client keeps running and retries every 5 seconds.",clientPoints:["Run npx -y livedesk client for first available placement.","Run npx -y livedesk client 3 to pin the machine to slot 3.","The browser connection page lets you choose Google or a 6-digit PIN."],syncTitle:"3. Sync Server and discovery",syncBody:"Sync Server publishes this manager as the active Screen Wall for the signed-in account. Clients read that Supabase record after Google sign-in and try the endpoint candidates in order.",syncPoints:["The record includes host instance, LAN/private addresses, public endpoint candidates, pair token, and a short lease.","LAN candidates are preferred first, then public candidates if needed.","Press Sync Server after manager moves, VPN/firewall/router changes, or when this development machine should take over as active manager.","Chrome Local Network Access on livedesk.pages.dev is no longer the default runtime path. The npm manager app is the real server."],agentTitle:"4. Run multi-workstation tasks with Agent",agentBody:"The Agents page runs a Codex-based Agent in the Hub to inspect connected workstations and perform actions within the selected permission scope. Client PCs do not need the Codex app or Codex SDK installed.",agentPoints:["Suggested tasks currently contains 72 read-only and operational templates with search plus permission, platform, and capability availability checks.","Choose Ask, Safe Auto, Full Access, or Custom. Risky changes go through approval cards and explicit client capability checks.","Limit targets with All connected or Selected. Results use compact per-device status chips and show real RAM, disk, GPU, and process summaries.","Runs stay inside the Hub-isolated runtime and LiveDesk MCP tools, with timeout, cancellation, tool-call limits, and audit-log boundaries."],platformTitle:"5. Current platform and stream state",platformBody:"Windows Wall, Control, file transfer, remote audio, and the RemoteFast path are verified against the current implementation. macOS and Linux keep the same npm command path while capture and permission backends expand.",platformPoints:["Wall uses Mode 3 H.264 and Mode 4 H.264 Atlas. Mode 2/5 compatibility paths are used automatically only for recovery.","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:Un({languageName:"日本語",languageLabel:"ドキュメント言語",eyebrow:"LiveDesk Manual",title:"1行でローカル Screen Wall を開く",intro:"LiveDesk は、複数の作業 PC、AI マシン、Mac mini、開発機を1台の manager PC から監視する npm-first のリモート作業デッキです。",managerTitle:"1. manager を実行",managerBody:"画面を集めて見るコンピューターで LiveDesk manager を実行します。UI とローカルサーバーが同時に起動し、http://127.0.0.1:5179 が開きます。",managerPoints:["コマンドは npx -y livedesk です。","Screen Wall/API は 5179、client 接続は 5197 を使います。","古い LiveDesk プロセスがポートを使っている場合は、基本的に自動で整理して起動します。"],clientTitle:"2. workstation を接続",clientBody:"監視される PC で同じ Google アカウントにログインします。manager がまだ無くても client は終了せず、5秒ごとに再試行します。",clientPoints:["空きスロットに入れるには npx -y livedesk client を実行します。","スロットを固定するには npx -y livedesk client 3 のように番号を付けます。","大量の PC でも再ログインなしで待ち続けます。"],syncTitle:"3. Sync Server と自動検出",syncBody:"Sync Server はこの manager を現在の Google アカウントの active Screen Wall として Supabase に登録します。",syncPoints:["host instance、LAN/private アドレス、public 候補、pair token、短い lease を登録します。","client は LAN 候補を優先し、必要なら public 候補も試します。","VPN、firewall、router、manager の場所が変わったら Sync Server を押します。","livedesk.pages.dev の Chrome Local Network Access は標準実行経路ではありません。npm manager アプリが実際のサーバーです。"],platformTitle:"4. 現在のプラットフォーム状態",platformBody:"Windows は live screen transfer まで確認済みです。macOS と Linux も同じ npm コマンド経路を目標に対応を広げています。",platformPoints:["Windows: 動作確認済み。","macOS: 画面取得と制御には Screen Recording/Accessibility 権限が必要です。","Linux: linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend を追加済み。audio は未対応です。"],firewallTitle:"Firewall と外部拠点",firewallBody:"同じ LAN なら通常 router forwarding は不要です。外部拠点では client が manager の接続ポートへ到達できる必要があります。",firewallPoints:["client 接続ポートは TCP 5197 です。","client 側は通常 outbound だけで足ります。","外部 network では manager PC の firewall で TCP 5197 inbound を許可し、router から manager PC へ forward します。","5179 は manager UI 用なので、外部ブラウザで Wall を開く必要がある時だけ公開を検討します。","公開 internet より VPN、Tailscale、ZeroTier、IP allowlist を優先してください。"],commandsTitle:"現在のコマンド",commandsBody:"Web サイトから installer を探すより、OS をまたいで terminal 1行で動かす方向です。",managerCommandLabel:"manager 起動",clientCommandLabel:"workstation 接続",slotCommandLabel:"slot 3 に固定",manualCommandLabel:"高度な手動接続"}),"zh-CN":Un({languageName:"简体中文",languageLabel:"文档语言",eyebrow:"LiveDesk Manual",title:"用一条命令打开本地 Screen Wall",intro:"LiveDesk 是 npm-first 的远程工作台,用一台 manager PC 监控多台工作站、AI 主机、Mac mini 和开发机器。",managerTitle:"1. 运行 manager",managerBody:"在负责查看屏幕的电脑上运行 LiveDesk manager。它会同时启动 UI 和本地服务器,并打开 http://127.0.0.1:5179。",managerPoints:["命令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 连接使用 5197。","如果旧的 LiveDesk 进程占用端口,默认会清理后重新启动。"],clientTitle:"2. 连接 workstation",clientBody:"在被监控的电脑上使用同一个 Google 账号登录。即使 manager 还没在线,client 也会继续运行并每 5 秒重试。",clientPoints:["自动放入空位: npx -y livedesk client。","固定到 3 号位置: npx -y livedesk client 3。","大量电脑也可以持续等待,不需要反复登录。"],syncTitle:"3. Sync Server 和自动发现",syncBody:"Sync Server 会把当前 manager 作为该账号的 active Screen Wall 写入 Supabase。client 登录后读取记录并依次尝试连接候选地址。",syncPoints:["记录包括 host instance、LAN/private 地址、public 候选、pair token 和短 lease。","优先尝试同一 LAN 地址,需要时再尝试外部地址。","manager 位置、VPN、防火墙或路由变化后请点击 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是默认运行方式。npm manager app 才是真正服务器。"],platformTitle:"4. 当前平台状态",platformBody:"Windows 已确认可传输实时画面。macOS 和 Linux 正按同一 npm 命令路径扩展支持。",platformPoints:["Windows: 已确认可用。","macOS: 画面捕获和控制需要 Screen Recording/Accessibility 权限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot 捕获、xdotool 输入后端。音频尚未启用。"],firewallTitle:"防火墙和外部地点",firewallBody:"同一 LAN 通常不需要路由端口转发。不同地点连接时,client 必须能访问 manager 的 client 连接端口。",firewallPoints:["client 连接端口是 TCP 5197。","client 机器通常只需要出站访问。","跨网络时,在 manager 防火墙放行 TCP 5197 入站,并在路由器转发到 manager PC。","5179 是 manager UI 端口,仅在需要远程浏览器直接打开 Wall 时考虑暴露。","优先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"当前命令",commandsBody:"产品方向是跨操作系统使用一条终端命令,而不是先找网站、下载、安装。",managerCommandLabel:"启动 manager",clientCommandLabel:"连接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"高级手动连接"}),"zh-TW":Un({languageName:"繁體中文",languageLabel:"文件語言",eyebrow:"LiveDesk Manual",title:"用一行指令開啟本機 Screen Wall",intro:"LiveDesk 是 npm-first 的遠端工作台,用一台 manager PC 監看多台工作站、AI 主機、Mac mini 與開發機。",managerTitle:"1. 執行 manager",managerBody:"在負責看畫面的電腦上執行 LiveDesk manager。它會同時啟動 UI 與本機伺服器,並開啟 http://127.0.0.1:5179。",managerPoints:["指令是 npx -y livedesk。","Screen Wall/API 使用 5179,client 連線使用 5197。","若舊的 LiveDesk 程序占用連接埠,預設會清理後重新啟動。"],clientTitle:"2. 連接 workstation",clientBody:"在被監看的電腦上使用同一個 Google 帳號登入。即使 manager 尚未上線,client 也會持續執行並每 5 秒重試。",clientPoints:["自動放入空位: npx -y livedesk client。","固定到 3 號位置: npx -y livedesk client 3。","大量電腦也能持續等待,不需要反覆登入。"],syncTitle:"3. Sync Server 與自動探索",syncBody:"Sync Server 會把目前 manager 登錄為此帳號的 active Screen Wall。client 登入後讀取 Supabase 記錄並依序嘗試連線候選地址。",syncPoints:["記錄包含 host instance、LAN/private 位址、public 候選、pair token 與短 lease。","優先嘗試 LAN 位址,需要時再嘗試外部位址。","manager 位置、VPN、防火牆或路由設定改變後請按 Sync Server。","livedesk.pages.dev 的 Chrome Local Network Access 不再是預設執行路徑。npm manager app 才是真正伺服器。"],platformTitle:"4. 目前平台狀態",platformBody:"Windows 已確認可傳輸即時畫面。macOS 與 Linux 也沿用相同 npm 指令路徑擴充支援。",platformPoints:["Windows: 已確認可用。","macOS: 畫面擷取與控制需要 Screen Recording/Accessibility 權限。","Linux: 已加入 linux-x64 runtime、grim/gnome-screenshot/import/scrot capture、xdotool input backend。音訊尚未啟用。"],firewallTitle:"防火牆與外部地點",firewallBody:"同一 LAN 通常不需要路由器轉發。不同地點連線時,client 必須能到達 manager 的 client 連線埠。",firewallPoints:["client 連線埠是 TCP 5197。","client 電腦通常只需要對外連線。","跨網路時,請在 manager 防火牆允許 TCP 5197 inbound,並從路由器轉發到 manager PC。","5179 是 manager UI 連接埠,只在需要遠端瀏覽器直接打開 Wall 時才考慮公開。","優先使用 VPN、Tailscale、ZeroTier 或固定 IP allowlist。"],commandsTitle:"目前指令",commandsBody:"產品方向是跨作業系統用一行 terminal 指令,而不是先找網站、下載、安裝。",managerCommandLabel:"啟動 manager",clientCommandLabel:"連接 workstation",slotCommandLabel:"固定到 slot 3",manualCommandLabel:"進階手動連線"}),es:Un({languageName:"Español",languageLabel:"Idioma del documento",eyebrow:"LiveDesk Manual",title:"Abre un Screen Wall local con un comando",intro:"LiveDesk es una consola npm-first para vigilar muchas estaciones, cajas de IA, Mac mini y equipos de desarrollo desde un PC manager.",managerTitle:"1. Ejecuta el manager",managerBody:"Ejecuta LiveDesk en el equipo que verá las pantallas. El manager inicia la UI y el servidor local juntos y abre http://127.0.0.1:5179.",managerPoints:["El comando es npx -y livedesk.","El manager usa 5179 para Screen Wall/API y 5197 para conexiones client.","Si un proceso antiguo ocupa los puertos, el arranque lo limpia por defecto."],clientTitle:"2. Conecta una workstation",clientBody:"En cada equipo monitoreado, inicia sesión con la misma cuenta Google. Si el manager aún no está activo, el client sigue intentando cada 5 segundos.",clientPoints:["Usa npx -y livedesk client para el primer slot libre.","Usa npx -y livedesk client 3 para fijar el equipo al slot 3.","Los clients siguen esperando para no repetir login en muchas máquinas."],syncTitle:"3. Sync Server y descubrimiento",syncBody:"Sync Server publica este manager como Screen Wall activo para la cuenta. Los clients leen el registro en Supabase y prueban los endpoints.",syncPoints:["Incluye host instance, direcciones LAN/private, candidatos public, pair token y lease corto.","Primero se prueban candidatos LAN, luego públicos si hace falta.","Pulsa Sync Server después de cambios de manager, VPN, firewall o router.","Chrome Local Network Access en livedesk.pages.dev ya no es el flujo principal. La app npm manager es el servidor real."],platformTitle:"4. Estado de plataformas",platformBody:"Windows ya fue verificado con transferencia de pantalla. macOS y Linux siguen el mismo camino npm.",platformPoints:["Windows: verificado.","macOS: captura y control requieren permisos Screen Recording/Accessibility.","Linux: agregado linux-x64 runtime, captura grim/gnome-screenshot/import/scrot y entrada xdotool. Audio aún desactivado."],firewallTitle:"Firewall y sedes remotas",firewallBody:"En la misma LAN normalmente no hace falta port forwarding. Para otra red, los clients deben llegar al puerto client del manager.",firewallPoints:["Puerto de conexión client: TCP 5197.","Los equipos client normalmente solo necesitan salida.","Para redes remotas, permite TCP 5197 inbound en el manager y reenvía TCP 5197 al PC manager.","El puerto 5179 es para la UI del manager; expónlo solo si un navegador remoto debe abrir el Wall.","Prefiere VPN, Tailscale, ZeroTier o allowlist de IP fijas."],commandsTitle:"Comandos actuales",commandsBody:"La dirección del producto es un comando de terminal común entre sistemas, no descargar e instalar desde una web.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fijar al slot 3",manualCommandLabel:"Conexión manual avanzada"}),fr:Un({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:Un({languageName:"Deutsch",languageLabel:"Dokumentsprache",eyebrow:"LiveDesk Manual",title:"Lokale Screen Wall mit einem Befehl öffnen",intro:"LiveDesk ist ein npm-first Arbeitsdeck, um viele Workstations, AI-Boxen, Mac minis und Dev-Rechner von einem Manager-PC zu überwachen.",managerTitle:"1. Manager starten",managerBody:"Starte LiveDesk auf dem Computer, der die Screens sieht. Der Manager startet UI und lokalen Server zusammen und öffnet http://127.0.0.1:5179.",managerPoints:["Der Befehl ist npx -y livedesk.","Der Manager nutzt 5179 für Screen Wall/API und 5197 für Client-Verbindungen.","Wenn alte LiveDesk-Prozesse Ports belegen, werden sie beim Start standardmäßig bereinigt."],clientTitle:"2. Workstation verbinden",clientBody:"Melde dich auf jedem überwachten Computer mit demselben Google-Konto an. Wenn kein Manager online ist, versucht der Client alle 5 Sekunden weiter.",clientPoints:["npx -y livedesk client nutzt den ersten freien Slot.","npx -y livedesk client 3 fixiert den Rechner auf Slot 3.","Clients warten weiter, damit große Setups kein wiederholtes Login brauchen."],syncTitle:"3. Sync Server und Discovery",syncBody:"Sync Server veröffentlicht diesen Manager als aktive Screen Wall des Kontos. Clients lesen den Supabase-Eintrag und testen Endpoints der Reihe nach.",syncPoints:["Enthält host instance, LAN/private Adressen, public Kandidaten, pair token und kurze lease.","LAN-Kandidaten werden zuerst versucht, danach public Kandidaten.","Nach Änderungen an Manager, VPN, Firewall oder Router Sync Server drücken.","Chrome Local Network Access auf livedesk.pages.dev ist nicht mehr der Standardpfad. Die npm Manager App ist der echte Server."],platformTitle:"4. Plattformstatus",platformBody:"Windows wurde mit Live-Screen-Transfer geprüft. macOS und Linux folgen demselben npm-Pfad.",platformPoints:["Windows: verifiziert.","macOS: Capture und Control brauchen Screen Recording/Accessibility Rechte.","Linux: linux-x64 Runtime, grim/gnome-screenshot/import/scrot Capture und xdotool Input Backend sind ergänzt. Audio ist deaktiviert."],firewallTitle:"Firewall und entfernte Standorte",firewallBody:"Im gleichen LAN ist Router-Forwarding meist unnötig. Aus anderen Netzwerken müssen Clients den Client-Port des Managers erreichen.",firewallPoints:["Client-Verbindungsport: TCP 5197.","Client-Rechner brauchen normalerweise nur ausgehenden Zugriff.","Für entfernte Netzwerke TCP 5197 inbound am Manager erlauben und vom Router zum Manager-PC forwarden.","Port 5179 ist für die Manager-UI; nur öffnen, wenn ein Remote-Browser die Wall direkt öffnen muss.","VPN, Tailscale, ZeroTier oder feste IP-Allowlists bevorzugen."],commandsTitle:"Aktuelle Befehle",commandsBody:"Die Produktlinie ist ein Terminalbefehl über Betriebssysteme hinweg, statt Website suchen, herunterladen und installieren.",managerCommandLabel:"Manager starten",clientCommandLabel:"Workstation verbinden",slotCommandLabel:"An Slot 3 fixieren",manualCommandLabel:"Erweiterte manuelle Verbindung"}),"pt-BR":Un({languageName:"Português",languageLabel:"Idioma do documento",eyebrow:"LiveDesk Manual",title:"Abra um Screen Wall local com um comando",intro:"LiveDesk é um deck npm-first para monitorar várias estações, caixas de IA, Mac minis e máquinas dev a partir de um PC manager.",managerTitle:"1. Execute o manager",managerBody:"Rode LiveDesk no computador que verá as telas. O manager inicia a UI e o servidor local juntos e abre http://127.0.0.1:5179.",managerPoints:["O comando é npx -y livedesk.","O manager usa 5179 para Screen Wall/API e 5197 para conexões client.","Se um processo antigo ocupa as portas, a inicialização limpa por padrão."],clientTitle:"2. Conecte uma workstation",clientBody:"Em cada computador monitorado, entre com a mesma conta Google. Se o manager ainda não estiver online, o client tenta a cada 5 segundos.",clientPoints:["Use npx -y livedesk client para o primeiro slot livre.","Use npx -y livedesk client 3 para fixar no slot 3.","Clients continuam tentando para evitar login repetido em muitos PCs."],syncTitle:"3. Sync Server e descoberta",syncBody:"Sync Server publica este manager como Screen Wall ativo da conta. Clients leem o registro no Supabase e testam endpoints.",syncPoints:["Inclui host instance, endereços LAN/private, candidatos public, pair token e lease curto.","Candidatos LAN vêm primeiro; public depois se necessário.","Clique Sync Server após mudanças de manager, VPN, firewall ou roteador.","Chrome Local Network Access em livedesk.pages.dev não é mais o caminho padrão. O app npm manager é o servidor real."],platformTitle:"4. Estado das plataformas",platformBody:"Windows foi verificado com transferência de tela. macOS e Linux seguem o mesmo caminho npm.",platformPoints:["Windows: verificado.","macOS: captura e controle precisam de permissões Screen Recording/Accessibility.","Linux: runtime linux-x64, captura grim/gnome-screenshot/import/scrot e entrada xdotool adicionados. Áudio ainda desativado."],firewallTitle:"Firewall e locais remotos",firewallBody:"Na mesma LAN normalmente não é preciso port forwarding. Em outra rede, clients precisam alcançar a porta client do manager.",firewallPoints:["Porta client: TCP 5197.","Máquinas client normalmente só precisam de saída.","Para redes remotas, permita TCP 5197 inbound no manager e encaminhe TCP 5197 para o PC manager.","A porta 5179 é para a UI do manager; exponha apenas se um navegador remoto precisar abrir o Wall.","Prefira VPN, Tailscale, ZeroTier ou allowlist de IP fixo."],commandsTitle:"Comandos atuais",commandsBody:"A direção do produto é um comando de terminal comum entre sistemas, não baixar e instalar manualmente.",managerCommandLabel:"Iniciar manager",clientCommandLabel:"Conectar workstation",slotCommandLabel:"Fixar no slot 3",manualCommandLabel:"Conexão manual avançada"}),it:Un({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:Un({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:Un({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:Un({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:Un({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:Un({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:Un({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ı"})},SN=Object.entries(lo).map(([n,a])=>({id:n,label:a.languageName}));function jN(){if(typeof navigator>"u")return"en";const n=navigator.languages?.length?navigator.languages:[navigator.language];for(const a of n){const l=a.toLowerCase();if(lo[a])return a;if(l.startsWith("zh-tw")||l.startsWith("zh-hk"))return"zh-TW";if(l.startsWith("pt"))return"pt-BR";const r=l.split("-")[0];if(lo[r])return r}return"en"}function py({index:n}){const a=n+1;return i.jsx("article",{className:"device-tile placeholder-tile","aria-label":`Empty slot ${a}`,children:i.jsxs("div",{className:"tile-screen","aria-hidden":"true",children:[i.jsx("span",{className:"slot-grid","aria-hidden":"true"}),i.jsxs("span",{className:"empty-screen",children:[i.jsx(Jt,{size:24}),i.jsxs("strong",{children:["Slot ",String(a).padStart(3,"0")]})]})]})})}function sh({device:n,frame:a,selected:l,controlEnabled:r,showStatus:c,monitorIndex:u,monitorCount:m,onSelect:p,onFocusDevice:v,onOpenControl:g,onCycleMonitor:w,onCanvasReady:y,sendInput:b,updateIndicator:j,presentationReady:C,showPresentationSpinner:A=!1}){const T=f.useRef(null),k=f.useRef(null),E=f.useRef(0),R=f.useRef(null),U=$w(n),F=["cpu","gpu","memory","vram"].map(L=>U.metrics.find($=>$.id===L)).filter(L=>!!L),V=Jn(u,m),_=m>1,I=C??!!a,me=A&&n.connected&&!I,Y=tN(n,a,V),ue=Y>=fd?100:Y/fd*100,K=Y>=fd?fd/Y*100:100,ie={"--screen-aspect":Y.toFixed(5),"--screen-content-width":`${Math.max(1,Math.min(100,ue)).toFixed(3)}%`,"--screen-content-height":`${Math.max(1,Math.min(100,K)).toFixed(3)}%`},ee=f.useCallback(L=>{T.current=L,y(n.deviceId,L)},[n.deviceId,y]),W=L=>{const $=L.currentTarget.getBoundingClientRect();return{normalizedX:Math.max(0,Math.min(1,(L.clientX-$.left)/Math.max(1,$.width))),normalizedY:Math.max(0,Math.min(1,(L.clientY-$.top)/Math.max(1,$.height)))}},z=L=>({shiftKey:L.shiftKey,ctrlKey:L.ctrlKey,altKey:L.altKey,metaKey:L.metaKey}),Q=f.useCallback(()=>{R.current!==null&&(window.cancelAnimationFrame(R.current),R.current=null)},[]),X=f.useCallback(()=>{const L=k.current;if(!L)return;k.current=null;const $=Number(L.input.normalizedX),xe=Number(L.input.normalizedY);if(!Number.isFinite($)||!Number.isFinite(xe))return;b(n.deviceId,{...L.input,normalizedX:$,normalizedY:xe})&&(E.current=performance.now())},[n.deviceId,b]),P=f.useCallback(()=>{R.current===null&&(R.current=window.requestAnimationFrame(()=>{R.current=null,X()}))},[X]);f.useEffect(()=>()=>{Q(),k.current=null},[Q]);const le=(L,$)=>{if(!r)return;const xe={type:$,monitorIndex:V,...W(L),button:mN(L.button),...z(L)};if($==="pointermove"){const Se=performance.now();k.current={input:xe},Se-E.current>=AM&&(Q(),X()),P();return}k.current&&(Q(),X()),b(n.deviceId,xe)},we=f.useCallback(L=>{const $=document.activeElement;$ instanceof HTMLElement&&L.contains($)&&$.classList.contains("monitor-cycle-button")&&$.blur()},[]);return i.jsx("article",{className:`device-tile ${l?"selected":""} ${n.connected?"online":"offline"}`,"data-live-device-id":n.deviceId,style:ie,children:i.jsxs("div",{className:`tile-screen ${I?"has-frame":"is-empty"}`,role:"button",tabIndex:r?-1:0,"aria-pressed":l,onClick:L=>{L.target instanceof Element&&L.target.closest(".monitor-cycle")||r||p()},onKeyDown:L=>{L.target instanceof Element&&L.target.closest(".monitor-cycle")||r||(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),p())},onDoubleClick:L=>{L.target instanceof Element&&L.target.closest(".monitor-cycle")||(L.preventDefault(),g())},onPointerLeave:L=>we(L.currentTarget),children:[i.jsx("span",{className:`screen-content ${I?"has-frame":"is-empty"}`,children:i.jsx("canvas",{ref:ee,className:`remote-canvas ${I?"has-frame":"is-empty"}`,tabIndex:r?0:-1,onPointerDown:L=>{r&&(L.preventDefault(),L.stopPropagation(),v(),L.currentTarget.focus(),L.currentTarget.setPointerCapture(L.pointerId),le(L,"pointerdown"))},onPointerMove:L=>{r&&L.preventDefault(),le(L,"pointermove")},onPointerUp:L=>{r&&(L.preventDefault(),L.stopPropagation(),le(L,"pointerup"),L.currentTarget.hasPointerCapture(L.pointerId)&&L.currentTarget.releasePointerCapture(L.pointerId))},onPointerCancel:L=>{L.currentTarget.hasPointerCapture(L.pointerId)&&L.currentTarget.releasePointerCapture(L.pointerId)},onWheel:L=>{r&&(L.preventDefault(),b(n.deviceId,{type:"wheel",monitorIndex:V,...W(L),deltaX:L.deltaX,deltaY:L.deltaY,...z(L)}))},onKeyDown:L=>{r&&(L.preventDefault(),L.stopPropagation(),b(n.deviceId,{type:"keydown",monitorIndex:V,key:L.key,code:L.code,keyCode:L.keyCode||L.which||0,location:L.location,text:L.key.length===1?L.key:"",repeat:L.repeat,...z(L)}))},onKeyUp:L=>{r&&(L.preventDefault(),L.stopPropagation(),b(n.deviceId,{type:"keyup",monitorIndex:V,key:L.key,code:L.code,keyCode:L.keyCode||L.which||0,location:L.location,text:L.key.length===1?L.key:"",repeat:!1,...z(L)}))},onContextMenu:L=>r&&L.preventDefault()})}),!I&&i.jsx("span",{className:"empty-screen",children:i.jsx(Jt,{size:26})}),me&&i.jsxs("span",{className:"wall-presentation-loading",role:"status","aria-live":"polite",children:[i.jsx("span",{className:"wall-presentation-spinner","aria-hidden":"true"}),i.jsx("strong",{children:"Preparing video"})]}),j&&i.jsxs("span",{className:`wall-update-status ${j==="updated"?"updated":""}`,role:"status","aria-live":"polite",children:[j==="updating"?i.jsx("span",{className:"wall-update-spinner","aria-hidden":"true"}):i.jsx(On,{size:20,"aria-hidden":"true"}),i.jsx("strong",{children:j==="updating"?"Updating...":"Updated"})]}),c&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:`tile-health-pill state-${U.state}`,children:U.label}),i.jsx("span",{className:"tile-metrics","aria-label":`${rr(n)} status`,children:F.map(L=>i.jsxs("span",{className:`tile-metric state-${L.state}`,children:[i.jsx("b",{children:L.label}),i.jsx("em",{children:L.value}),L.ratio!==void 0&&i.jsx("i",{style:{width:`${Math.round(L.ratio*100)}%`}})]},L.id))})]}),_&&i.jsxs("span",{className:"monitor-cycle","aria-label":`${rr(n)} display ${V+1} of ${m}`,onPointerDown:L=>L.stopPropagation(),onClick:L=>L.stopPropagation(),onDoubleClick:L=>L.stopPropagation(),children:[i.jsx("button",{className:"monitor-cycle-button previous",onClick:L=>{L.preventDefault(),L.stopPropagation(),w(-1),L.currentTarget.blur()},title:"Previous display",type:"button",children:i.jsx(jy,{size:18})}),i.jsxs("span",{className:"monitor-cycle-count",children:["Screen ",V+1,"/",m]}),i.jsx("button",{className:"monitor-cycle-button next",onClick:L=>{L.preventDefault(),L.stopPropagation(),w(1),L.currentTarget.blur()},title:"Next display",type:"button",children:i.jsx(Rh,{size:18})})]}),l&&i.jsx("span",{className:"device-selection-check","aria-hidden":"true",children:i.jsx(oo,{size:23,strokeWidth:3.5})})]})})}function CN({visible:n}){return f.useEffect(()=>{if(!n||!Wm)return;if(!document.getElementById(Xx)){const l=document.createElement("script");l.id=Xx,l.async=!0,l.crossOrigin="anonymous",l.src=`https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=${encodeURIComponent(Sh)}`,document.head.appendChild(l)}const a=window.setTimeout(()=>{try{window.adsbygoogle=window.adsbygoogle||[],window.adsbygoogle.push({})}catch{}},120);return()=>window.clearTimeout(a)},[n]),n?i.jsxs("aside",{className:`free-ad-banner ${Wm?"adsense-ready":"house-ad"}`,"aria-label":"Advertisement",children:[i.jsx("span",{className:"ad-label",children:"Advertisement"}),Wm?i.jsx("ins",{className:"adsbygoogle livedesk-ad-unit",style:{display:"block"},"data-ad-client":Sh,"data-ad-slot":_w,"data-ad-format":"auto","data-full-width-responsive":"true"}):i.jsxs("div",{className:"house-ad-copy",children:[i.jsx("strong",{children:"Sponsored placement"}),i.jsx("span",{children:"Local AI gear, mini PCs, GPUs, NAS, and developer tools."})]})]}):null}function kN(){const n=IM(),{session:a,loading:l}=F0(),{target:r,error:c,refresh:u}=P0(a),m=f.useMemo(()=>{if(!r?.active)return null;const x=r.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY;return Number.isFinite(x)&&x<=Date.now()?null:r},[r]),p=f.useMemo(()=>Yv(m),[m]),v=f.useMemo(()=>p.length>0?[...new Set([...p,bn])]:[bn],[p]),[g,w]=f.useState(XM),y=f.useMemo(()=>v.some(x=>!!Ac(x)),[v]),b=!y||g,{status:j,devices:C,error:A,refresh:T,hubBaseUrl:k}=H0(v,b),{entitlement:E,licensed:R,loading:U,error:F,refresh:V}=$0(a),[_,I]=f.useState([]),[me,Y]=f.useState(""),[ue,K]=f.useState(""),[ie,ee]=f.useState(""),[W,z]=f.useState(""),[Q,X]=f.useState(""),[P,le]=f.useState("idle"),[we,L]=f.useState(!1),[$,xe]=f.useState(""),Se=f.useRef("");Se.current=W;const[fe,Te]=f.useState(!1),[Ie,oe]=f.useState(!1),Ye=f.useRef(""),De=f.useRef(new Map),We=f.useRef(0),[D,ne]=f.useState(""),[je,te]=f.useState(""),[ce,Me]=f.useState(null),Ce=f.useRef(null),it=f.useRef(0),he=f.useCallback(x=>{const M=String(x||"").trim();if(te(M),Ce.current!==null&&(window.clearTimeout(Ce.current),Ce.current=null),!M){Me(null);return}const O=++it.current;Me({id:O,message:M});const q=window.setTimeout(()=>{Me(B=>B?.id===O?null:B),Ce.current===q&&(Ce.current=null)},5e3);Ce.current=q},[]);f.useEffect(()=>()=>{Ce.current!==null&&window.clearTimeout(Ce.current)},[]);const[Fe,Le]=f.useState(()=>typeof window<"u"&&window.location.pathname.startsWith("/support")?"support":"wall");f.useEffect(()=>{const x=()=>{Le(window.location.pathname.startsWith("/support")?"support":M=>M==="support"?"wall":M)};return window.addEventListener("popstate",x),()=>window.removeEventListener("popstate",x)},[]);const[Ge,ea]=f.useState("large"),[gn,kn]=f.useState(jN),[Yn,Ml]=f.useState(!1),[Da,Bn]=f.useState(!1),[mr,ys]=f.useState(!1),[mt,An]=f.useState(QM),[Ne,Nl]=f.useState(sN),[Je,hr]=f.useState(lN),[kt,La]=f.useState(nN),[Gt,Wn]=f.useState(null),[ga,_a]=f.useState([]),[Vt,qs]=f.useState(Ne.fps),[ws,bs]=f.useState(""),[pr,gr]=f.useState(0),[za,Ss]=f.useState(()=>new Set),Mn=f.useRef(new Map),ta=f.useRef(new Map),tn=f.useRef(new Map),Gs=f.useRef(new Map),Nn=f.useRef(new Set),J=f.useRef(new Map),ke=f.useRef(0),_e=f.useRef(""),Ke=f.useRef(""),xt=f.useRef(null),gt=f.useRef(new Map),$e=f.useRef(null),dt=f.useRef(0),nn=f.useRef(new Map),[Ft,Tn]=f.useState({}),At=f.useRef(new Map),[Ht,Dt]=f.useState({}),[js,vn]=f.useState(!1),Yt=f.useRef(null),bt=f.useRef(null),Ia=f.useRef(0),Ja=f.useRef(""),es=f.useRef(new Map),Tl=f.useRef(new Map),Vs=f.useRef(performance.now()),Cs=f.useRef(new Map),Fn=f.useRef(new Map),un=f.useRef(new Map),vr=f.useRef(new Map),El=f.useRef(0),Ni=f.useRef(0),Rl=f.useRef(0),Ys=f.useRef(0),fo=f.useRef(0),Kn=f.useRef(new Map),Oa=f.useRef(new Map),[ks,Ba]=f.useState(null),[Ti,xr]=f.useState(!1),[$d,Ei]=f.useState([]),[Ri,Oc]=f.useState("all"),[Ws,Dl]=f.useState([]),[Xh,Zh]=f.useState(!1),[mo,ts]=f.useState(!0),yr=f.useRef(null),wr=f.useRef(null),Di=f.useRef(null),Li=f.useRef(null),Bc=f.useRef(!1),Ll=f.useRef(!1),ho=f.useRef(0),ns=f.useRef(0),xn=f.useRef(0),_i=Fe==="settings",zi=Fe==="pricing",as=Fe==="doc",br=Fe==="support",As=Fe==="share-files",po=Fe==="agents",_l=!_i&&!zi&&!as&&!br&&!As&&!po,Ve=Fe==="control",at=Ne.frameMode==="mode4-h264-atlas",Et=Q||Je.frameMode,ss=Et!=="mode3-h264-hw"?Math.min(30,Je.fps):Je.fps,va=Et!=="mode3-h264-hw"?{maxWidth:Math.min(1920,Je.maxWidth),maxHeight:Math.min(1080,Je.maxHeight)}:{maxWidth:Je.maxWidth,maxHeight:Je.maxHeight};f.useEffect(()=>{if(j?.started){if(!a?.access_token){Be("/api/remote/license",{method:"DELETE"},k).catch(()=>{});return}Be("/api/remote/license/sync",{method:"POST",headers:{Authorization:`Bearer ${a.access_token}`}},k).catch(x=>{console.warn("[LiveDesk] Hub license sync failed",x)})}},[E?.updated_at,k,a?.access_token,j?.started]),f.useEffect(()=>{!a?.access_token||!j?.started||j.runtimeRole!=="hub"||!j.deviceId||(async()=>{try{const{data:x,error:M}=await zt.rpc("register_livedesk_device",{p_device_id:j.deviceId,p_device_name:j.deviceName||j.deviceId,p_role:"hub",p_assigned_hub_id:null,p_platform:navigator.platform||navigator.userAgent,p_os_version:navigator.userAgent,p_app_version:j.managerVersion||j.managerPackage||""}),O=Array.isArray(x)?x[0]:x;(M||O?.ok===!1)&&console.warn("[LiveDesk] Hub device role registration failed",M||O?.reason||"unknown-error")}catch(x){console.warn("[LiveDesk] Hub device role registration failed",x)}})()},[a?.access_token,j?.deviceId,j?.deviceName,j?.managerPackage,j?.managerVersion,j?.runtimeRole,j?.started]);const Qe=f.useMemo(()=>C.filter(x=>x.connected),[C]),Fc=Ri==="all"?Qe.length:Ws.filter(x=>Qe.some(M=>M.deviceId===x)).length,go=f.useMemo(()=>Qe.reduce((x,M)=>Math.max(x,hy(M.slotNumber)),0),[Qe]),Ii=Math.max(jM,Qe.length,go),is=f.useMemo(()=>{const x=Array(Ii).fill(null),M=[];for(const O of Qe){const q=hy(O.slotNumber);q>0&&q<=Ii&&!x[q-1]?x[q-1]=O:M.push(O)}for(const O of M){const q=x.findIndex(B=>!B);q<0?x.push(O):x[q]=O}return x},[Qe]),Oi=f.useMemo(()=>Qe.map(x=>x.deviceId),[Qe]),Ks=f.useMemo(()=>new Set(_),[_]),xa=f.useMemo(()=>Qe.filter(x=>Ks.has(x.deviceId)),[Qe,Ks]),Bi=f.useMemo(()=>C.find(x=>x.deviceId===me)||xa[0]||null,[C,me,xa]),En=f.useMemo(()=>C.find(x=>x.deviceId===ue)||null,[ue,C]),Fi=En?Jn(kt[En.deviceId],Gn(En)):0,Ee=Ve?En:Bi,Hc=f.useMemo(()=>new Set(Ws),[Ws]),Ud=f.useMemo(()=>Ri==="all"?Qe.map(x=>x.deviceId):Qe.filter(x=>Hc.has(x.deviceId)).map(x=>x.deviceId),[Qe,Hc,Ri]),Fa=f.useMemo(()=>Ee?$w(Ee):null,[Ee]),qd=Ee?Tc(Ee,"control"):!1,Pc=Ee?.platform==="macos"&&Ee.capabilities?.controlPermission===!1,zl=Ee?Tc(Ee,"audio")||Tc(Ee,"remoteAudio"):!1,Rt=R?E?.plan==="pro"?"pro":"ltd":"free",$c=nr[Rt],Sr=$c.limit,ls=f.useMemo(()=>{if(!Number.isFinite(Sr))return new Set(Qe.map(M=>M.deviceId));const x=Ee?[Ee,...Qe.filter(M=>M.deviceId!==Ee.deviceId)]:Qe;return new Set(x.slice(0,Sr).map(M=>M.deviceId))},[Sr,Qe,Ee]),Gd=!Ee||ls.has(Ee.deviceId),Vd=Rt==="free",Wt=Gd,Qs=Rt==="ltd"?`Plus includes up to ${xc} workstations. Upgrade to Pro for commercial use and larger walls.`:`Free includes up to ${vc} workstations. Upgrade to Plus for ${xc} devices and no ads.`,Yd=Rt==="free",Uc=Wt&&!!Ee,rs=Wt&&!!Ee&&qd,qc=Wt&&!!Ee&&zl,jr=f.useMemo(()=>is.filter(x=>!!x?.connected).slice(0,oN(Ge)).map(x=>x.deviceId),[is,Ge]),Xs=f.useMemo(()=>at?Oi:Ne.visibleOnlyLive?ga.length>0?ga:jr:Oi,[jr,at,ga,Ne.visibleOnlyLive,Oi]),Ha=f.useMemo(()=>eh(Xs.filter(x=>ls.has(x))),[ls,Xs]),dn=f.useMemo(()=>Ha.filter(x=>x!==ws),[Ha,ws]);f.useEffect(()=>{const x=new Set(Ha);Ss(M=>{let O=!1;const q=new Set;for(const B of M)x.has(B)?q.add(B):O=!0;return O?q:M})},[Ha]);const Wd=f.useMemo(()=>{const x=B=>Qe.find(ve=>ve.deviceId===B)||null,M=B=>Jn(kt[B],x(B)?Gn(x(B)):0),O=(B,ve=M(B))=>B===ie&&(P==="connecting"||P==="active"||P==="warm")?tn.current.get(B)||ta.current.get(B)||null:at?gt.current.get(B)||Mn.current.get(B)||null:Mn.current.get(B)||null,q=(B,ve=M(B))=>{const ge=x(B);return`${ge?rr(ge):B} · Monitor ${ve+1}`};return{resolveCurrentTarget(){if(Ve&&En){const Pe=Fi;return{type:"control",deviceIds:[En.deviceId],monitorIndex:Pe,label:`${rr(En)} · Monitor ${Pe+1}`,sourceCanvas:O(En.deviceId,Pe),signature:`control:${En.deviceId}:${Pe}:${Je.frameMode}`}}const B=xa.map(Pe=>Pe.deviceId).filter(Pe=>dn.includes(Pe)),ve=Bi&&dn.includes(Bi.deviceId)?Bi.deviceId:"",ge=B.length>0?B:ve?[ve]:dn,Re=B.length===0&&!ve;if(ge.length===0)return null;if(ge.length===1){const Pe=ge[0],Xe=M(Pe);return{type:Re?"wall":B.length>1?"selection":"device",deviceIds:ge,monitorIndex:Xe,label:Re?"Wall":q(Pe,Xe),sourceCanvas:Re?null:O(Pe,Xe),signature:`${Re?"wall":"device"}:${Pe}:${Xe}:${at?"atlas":"direct"}`}}return{type:B.length>1?"selection":"wall",deviceIds:ge,label:B.length>1?`${ge.length} selected workstations`:"Wall",sourceCanvas:null,signature:`${B.length>1?"selection":"wall"}:${ge.join(",")}:${Ge}`}},getDeviceCanvas:O,composeWall(B,ve={}){return dM(B.map(ge=>{const Re=M(ge);return{deviceId:ge,label:q(ge,Re),canvas:O(ge,Re)}}),ve)}}},[Qe,En,ie,P,Je.frameMode,Mn,at,kt,Fi,xa,Ve,dn,Bi,Ge]),Cr=SM({hubUrl:k,sourceRegistry:Wd,onToast:he}),Pa=f.useMemo(()=>Wt&&ie&&ls.has(ie)&&(P==="connecting"||P==="active"||P==="warm")?[ie]:[],[ie,P,Wt,ls]),Kd=f.useMemo(()=>eh([...Ha,...Pa]),[Pa,Ha]),Pt=f.useMemo(()=>cN(Ne,Ge),[Ne,Ge]),Ms=f.useCallback((x,M)=>{if(x.width<=0||x.height<=0)return!1;(M.width!==x.width||M.height!==x.height)&&(M.width=x.width,M.height=x.height);const O=M.getContext("2d",{alpha:!1});return O?(O.imageSmoothingEnabled=!0,O.imageSmoothingQuality="high",O.drawImage(x,0,0,x.width,x.height,0,0,M.width,M.height),!0):!1},[]),Il=f.useCallback(x=>{x&&Ss(M=>{if(M.has(x))return M;const O=new Set(M);return O.add(x),O})},[]),Ol=f.useCallback(x=>{x&&Ss(M=>{if(!M.has(x))return M;const O=new Set(M);return O.delete(x),O})},[]),$a=f.useCallback((x,M=!1)=>{if(!Nn.current.has(x))return!1;const O=performance.now(),q=J.current.get(x)||0;if(!M&&O-q<150)return!1;const B=tn.current.get(x)||ta.current.get(x),ve=at?gt.current.get(x):Mn.current.get(x);return!B||!ve||!Ms(B,ve)?!1:(J.current.set(x,O),Il(x),!0)},[Il,at,Ms]);f.useEffect(()=>{_e.current=ws},[ws]);const Hi=f.useCallback((x,M)=>{const O=Mn.current.get(x);if(O&&O!==M&&uc(O),M){Mn.current.set(x,M),$a(x,!0);return}Mn.current.delete(x),Ol(x)},[Ol,$a]),Qd=f.useCallback((x,M)=>{const O=ta.current.get(x);if(O&&O!==M&&uc(O),M){ta.current.set(x,M);const q=tn.current.get(x);q&&Ms(q,M);return}ta.current.delete(x)},[Ms]),kr=f.useCallback((x,M,O)=>{const q=performance.now(),B=gs(x,O.deviceId);let ve=O;if(x==="control"&&O.visualChanged){const Re=W0(O.deviceId),Pe=Kn.current.get(O.deviceId)||0,Xe=Re?q-Re.sentAt:Number.POSITIVE_INFINITY;Re&&Re.inputSeq>Pe&&Xe<=Zx&&(ve={...O,inputFeedbackSeq:Re.inputSeq,inputFeedbackMs:Math.max(0,Xe),inputFeedbackAt:q},Kn.current.set(O.deviceId,Re.inputSeq))}Tl.current.set(B,q);const ge=nn.current.get(B)||{totalFrames:0,totalChangedFrames:0,sampleFrames:0,sampleChangedFrames:0,sampleStartedAt:q,intervalCount:0,intervalSumMs:0,minIntervalMs:Number.POSITIVE_INFINITY,maxIntervalMs:0,intervalSamplesMs:[],seqGapCount:0,maxSeqGap:0,sampleDecoderInputBase:0,sampleDecoderOutputBase:0};x==="control"&&ve.inputFeedbackMs===void 0&&ge.lastInfo?.inputFeedbackMs!==void 0&&ge.lastInfo.inputFeedbackAt!==void 0&&q-ge.lastInfo.inputFeedbackAt<=Zx&&(ve={...ve,inputFeedbackSeq:ge.lastInfo.inputFeedbackSeq,inputFeedbackMs:ge.lastInfo.inputFeedbackMs,inputFeedbackAt:ge.lastInfo.inputFeedbackAt}),ge.totalFrames+=1,ge.sampleFrames+=1,ay(ge,q,ve.frameSeq),ve.visualChanged&&(ge.totalChangedFrames+=1,ge.sampleChangedFrames+=1),ge.lastInfo=ve,nn.current.set(B,ge)},[]),Ar=f.useCallback((x,M)=>{kr("wall",x,M),x.kind==="live"&&Il(x.deviceId);const O=we&&ie===x.deviceId;_e.current!==x.deviceId&&!O&&(Nn.current.delete(x.deviceId),J.current.delete(x.deviceId))},[ie,we,Il,kr]),vo=f.useCallback((x,M)=>{kr("control",x,M),xe(ve=>ve&&"");const O=tn.current.get(x.deviceId),q=ta.current.get(x.deviceId);O&&O.width>0&&O.height>0&&(q&&Ms(O,q),Gs.current.set(x.deviceId,{...x,payload:new ArrayBuffer(0),byteLength:0}),Nn.current.add(x.deviceId),x.deviceId===ie&&(L(!0),le(ve=>ve==="connecting"?"active":ve)),$a(x.deviceId));const B=Yt.current;!B||!zM(B,x)||vn(!0)},[ie,Ms,$a,kr]);f.useEffect(()=>{const x=window.setInterval(()=>{const M=performance.now(),O={};for(const[q,B]of nn.current.entries()){const ve=Math.max(1,M-B.sampleStartedAt);O[q]={totalFrames:B.totalFrames,totalChangedFrames:B.totalChangedFrames,framesPerSecond:B.sampleFrames*1e3/ve,changedFramesPerSecond:B.sampleChangedFrames*1e3/ve,averageIntervalMs:B.intervalCount>0?B.intervalSumMs/B.intervalCount:0,minIntervalMs:Number.isFinite(B.minIntervalMs)?B.minIntervalMs:0,maxIntervalMs:B.maxIntervalMs,p95IntervalMs:yd(B.intervalSamplesMs,.95),intervalCount:B.intervalCount,seqGapCount:B.seqGapCount,maxSeqGap:B.maxSeqGap,decoderInputFps:Math.max(0,(Number(B.lastInfo?.decoderInputCount||0)-B.sampleDecoderInputBase)*1e3/ve),decoderOutputFps:Math.max(0,(Number(B.lastInfo?.decoderOutputCount||0)-B.sampleDecoderOutputBase)*1e3/ve),sampleMs:ve,lastInfo:B.lastInfo},B.sampleDecoderInputBase=Number(B.lastInfo?.decoderInputCount||0),B.sampleDecoderOutputBase=Number(B.lastInfo?.decoderOutputCount||0),B.sampleChangedFrames=0,ny(B,M)}Tn(O)},1e3);return()=>window.clearInterval(x)},[]);const Zs=f.useCallback((x,M)=>{const O=performance.now(),q=gs(x,M.deviceId);es.current.set(q,O),Oa.current.delete(q),x==="control"&&Fn.current.delete(q);const B=At.current.get(q)||{totalFrames:0,sampleFrames:0,sampleStartedAt:O,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(B.totalFrames+=1,B.sampleFrames+=1,B.sampleBytes+=Math.max(0,Number(M.byteLength||0)),String(M.frameMode||M.mode||M.codec||M.mimeType||"").toLowerCase().includes("h264")){B.sampleH264Frames+=1,Number(M.byteLength||0)<=DM&&(B.sampleTinyFrames+=1);const Pe=String(M.contentHash||"");Pe&&B.lastContentHash===Pe&&(B.sampleRepeatedFrames+=1),B.lastContentHash=Pe}const Re=Number(M.agentSendGapMs||0);Re>0&&Re<1e3&&Kh(B.sourceSendIntervalsMs,Re),B.lastFrame=M,ay(B,O,M.frameSeq),At.current.set(q,B)},[]);f.useEffect(()=>{const x=window.setInterval(()=>{const M=performance.now(),O={};for(const[q,B]of At.current.entries()){const ve=Math.max(1,M-B.sampleStartedAt);O[q]={totalFrames:B.totalFrames,framesPerSecond:B.sampleFrames*1e3/ve,averageIntervalMs:B.intervalCount>0?B.intervalSumMs/B.intervalCount:0,minIntervalMs:Number.isFinite(B.minIntervalMs)?B.minIntervalMs:0,maxIntervalMs:B.maxIntervalMs,p95IntervalMs:yd(B.intervalSamplesMs,.95),intervalCount:B.intervalCount,seqGapCount:B.seqGapCount,maxSeqGap:B.maxSeqGap,averageFrameBytes:B.sampleFrames>0?B.sampleBytes/B.sampleFrames:0,tinyFrameRatio:B.sampleH264Frames>0?B.sampleTinyFrames/B.sampleH264Frames:0,repeatedFrameRatio:B.sampleH264Frames>0?B.sampleRepeatedFrames/B.sampleH264Frames:0,sourceSendAverageMs:B.sourceSendIntervalsMs.length>0?B.sourceSendIntervalsMs.reduce((ge,Re)=>ge+Re,0)/B.sourceSendIntervalsMs.length:0,sourceSendP95Ms:yd(B.sourceSendIntervalsMs,.95),sourceSendSampleCount:B.sourceSendIntervalsMs.length,sampleMs:ve,lastFrame:B.lastFrame},B.sampleBytes=0,B.sampleH264Frames=0,B.sampleTinyFrames=0,B.sampleRepeatedFrames=0,B.sourceSendIntervalsMs.length=0,ny(B,M)}Dt(O)},1e3);return()=>window.clearInterval(x)},[]);const Pi=f.useCallback(x=>{Zs("wall",x);const M=Mn.current.get(x.deviceId);M&&Lm(M,x,()=>Mn.current.get(x.deviceId)!==M,Ar,Ne.h264DecodeAcceleration).catch(()=>{})},[Ar,Zs,Ne.h264DecodeAcceleration]),$i=f.useCallback(x=>{Zs("control",x);let M=tn.current.get(x.deviceId);M||(M=document.createElement("canvas"),M.setAttribute("aria-hidden","true"),tn.current.set(x.deviceId,M));const O=M,q=Se.current;Lm(O,x,()=>tn.current.get(x.deviceId)!==O,vo,Je.h264DecodeAcceleration,"interactive").catch(B=>{Se.current!==q||tn.current.get(x.deviceId)!==O||ie!==x.deviceId||xe(B instanceof Error?B.message:String(B||"Control H.264 decode failed"))})},[ie,Je.h264DecodeAcceleration,vo,Zs]),Xd=f.useCallback(x=>{const M=xt.current;M&&M!==x&&uc(M),xt.current=x,El.current=0,Ni.current=0,Rl.current=0,Ys.current=0,fo.current=0,dt.current=0},[]),os=f.useCallback(()=>{const x=xt.current,M=$e.current;if(!(!x||!M||x.width<=0||x.height<=0||dt.current!==M.layoutVersion))for(const O of M.tiles){const q=gt.current.get(O.deviceId);if(!q||O.width<=0||O.height<=0)continue;const B=Math.max(1,Math.round(O.width)),ve=Math.max(1,Math.round(O.height)),ge=LM,Re=_M;(q.width!==ge||q.height!==Re)&&(q.width=ge,q.height=Re);const Pe=q.getContext("2d",{alpha:!1});if(Pe){Pe.imageSmoothingEnabled=!0,Pe.imageSmoothingQuality="high";try{Pe.drawImage(x,Math.round(O.x),Math.round(O.y),B,ve,0,0,ge,Re)}catch{}}}},[]),Gc=f.useCallback((x,M)=>{if(M){gt.current.set(x,M),window.requestAnimationFrame(os),window.requestAnimationFrame(()=>$a(x,!0));return}gt.current.delete(x),Ol(x)},[Ol,os,$a]),xo=f.useCallback((x,M)=>{Rl.current=performance.now(),dt.current=Number(x.layoutVersion||0),os();const O=$e.current?.tiles||[],q=O.length>0?Math.round(x.byteLength/O.length):x.byteLength;for(const B of O){const ve={...x,deviceId:B.deviceId,width:B.width,height:B.height,sourceWidth:B.width,sourceHeight:B.height,byteLength:q};Ar(ve,{...M,deviceId:B.deviceId,width:B.width,height:B.height,byteLength:q}),_e.current===B.deviceId&&$a(B.deviceId,!0)}},[Ar,os,$a]),yo=f.useCallback(x=>{const M=performance.now();El.current<=0&&(El.current=M),Ni.current=M;const O=xt.current;if(!O)return;const q=$e.current?.tiles||[],B=q.length>0?Math.round(x.byteLength/q.length):x.byteLength;for(const ve of q)Zs("wall",{...x,deviceId:ve.deviceId,width:ve.width,height:ve.height,sourceWidth:ve.width,sourceHeight:ve.height,byteLength:B});Lm(O,x,()=>xt.current!==O,xo).catch(()=>{})},[xo,Zs]),wo=f.useMemo(()=>({fps:Vt,maxWidth:Pt.maxWidth,maxHeight:Pt.maxHeight,quality:Ne.quality,mode:Ne.frameMode,frameMode:Ne.frameMode,streamPurpose:"wall",monitorSelections:kt,onFrame:Pi}),[Vt,Pi,Pt,kt,Ne]),Vc=f.useMemo(()=>({fps:ss,maxWidth:va.maxWidth,maxHeight:va.maxHeight,quality:Je.quality,mode:Et,frameMode:Et,streamPurpose:"control",forceRestart:W!=="",forceRestartToken:W,restartReason:W?"control-session-start":"",monitorSelections:kt,onFrame:$i}),[W,Je.quality,$i,ss,Et,va.maxHeight,va.maxWidth,kt]),{frames:bo,state:Ui,error:Yc,stats:Ns,restartLive:Mr}=sx(at?[]:dn,!at&&Ne.autoStartLive&&dn.length>0,k,wo),{frame:qi,layout:Js,state:Rn,stats:Bl,refreshInputs:So}=K0(Xs,at&&Ne.autoStartLive&&Xs.length>0,k,{fps:20,width:1920,height:1080,tileWidth:Pt.maxWidth,tileHeight:Pt.maxHeight,captureDeviceIds:dn,monitorSelections:kt,onFrame:yo});f.useEffect(()=>{$e.current=Js,Js&&window.requestAnimationFrame(os)},[Js,os]),f.useEffect(()=>{if(!at||Rn!=="open"){El.current=0,Ni.current=0,Rl.current=0;return}const x=window.setInterval(()=>{const M=xt.current,O=performance.now();if(!M||document.visibilityState!=="visible"||O-Vs.current<Km)return;const q=Ni.current,B=El.current;if(q<=0||B<=0||O-q>500)return;const ve=Rl.current||B,ge=O-ve;if(ge>=NM&&O-fo.current>=EM){Rm(M)&&(fo.current=O,Ys.current=O);return}ge>=MM&&O-Ys.current>=TM&&D0(M)&&(Ys.current=O)},250);return()=>window.clearInterval(x)},[Rn,at]);const{frames:Nr,state:Tr,error:Gi,stats:jo,restartLive:Er,reconnectLive:ei}=sx(Pa,Pa.length>0,k,Vc),Vi=f.useMemo(()=>{const x=new Map(bo);if(at&&qi){const M=new Map((Js?.tiles||[]).map(q=>[q.deviceId,q])),O=Math.max(1,M.size);for(const q of Xs){const B=M.get(q);x.set(q,{...qi,deviceId:q,width:B?.width||Pt.maxWidth,height:B?.height||Pt.maxHeight,sourceWidth:B?.width||Pt.maxWidth,sourceHeight:B?.height||Pt.maxHeight,byteLength:Math.round(qi.byteLength/O)})}}for(const[M,O]of Nr.entries())x.set(M,O);for(const M of Xs){if(!Nn.current.has(M)||x.has(M))continue;const O=Gs.current.get(M);O&&x.set(M,O)}return x},[qi,Js,Nr,Pt,at,bo,Xs,pr]),ti=Ve&&Pa.length>0?Tr:at?Rn:Ui,Fl=Ve&&Pa.length>0?jo:at?Bl:Ns;f.useCallback((x,M="browser-stale")=>{const O=Mr(x,M),q=Er(x,M);return O||q},[Er,Mr]),f.useEffect(()=>{at&&!Ve&&So()},[at,So,Ve]);const Hl=f.useCallback((x,M,O)=>{const q=M==="control"?tn.current.get(x)||null:Mn.current.get(x)||null;if(!q||!Rm(q))return!1;const B=performance.now();return vr.current.set(gs(M,x),B),!0},[]),Ua=f.useCallback(x=>{if(Et!=="mode3-h264-hw"||!ie||Q)return!1;const M=Qe.find(Pe=>Pe.deviceId===ie)||En,O=String(M?.platform||"").toLowerCase(),q=["win32","windows","win32nt"].includes(O)?"mode5-lzo-delta":"mode2-lzo",B=gs("control",ie),ve=performance.now();un.current.set(B,ve),es.current.delete(B),Tl.current.delete(B),Cs.current.delete(B),Fn.current.delete(B),Oa.current.delete(B),Rm(tn.current.get(ie)||null),ei([ie],"control-decode-fallback"),X(q),z(`control-${q}-fallback-${ie}-${Date.now()}`),L(!1),vn(!1);const ge=x==="no first frame"||x==="control-first-frame-timeout",Re=q==="mode5-lzo-delta"?"Mode 5":"Mode 2";return xe(Pe=>Pe||(ge?`Control frame transport timeout; retrying Control with ${Re} (${x})`:`H.264 decode failed; retrying Control with ${Re} (${x})`)),le("connecting"),!0},[Qe,En,ie,Q,Et,ei]);f.useEffect(()=>{const x=Ve?En:null;if(x){Yt.current={deviceId:x.deviceId,monitorIndex:Fi,frameMode:Et,startedAtEpochMs:Date.now()},vn(ie===x.deviceId&&we);return}Yt.current=null,vn(!1)},[En?.sessionId,ue,ie,we,Et,Fi,Ve]);const Ts=f.useCallback(async x=>{const M=at,O=C.find(ge=>ge.deviceId===x),q=Jn(kt[x],O?Gn(O):1),B=M?{fps:8,maxWidth:Pt.maxWidth,maxHeight:Pt.maxHeight,quality:60,mode:"mode2-lzo",frameMode:"mode2-lzo",streamPurpose:"atlas",monitorIndex:q}:{fps:Vt,maxWidth:Pt.maxWidth,maxHeight:Pt.maxHeight,quality:Ne.quality,mode:Ne.frameMode,frameMode:Ne.frameMode,streamPurpose:"wall",monitorIndex:q},ve=await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/start`,{method:"POST",body:JSON.stringify(B)},k);if(ve?.ok===!1)throw new Error(ve.error||"wall-stream-start-failed");return ve},[Vt,C,Pt.maxHeight,Pt.maxWidth,k,at,kt,Ne.frameMode,Ne.quality]),Rr=f.useCallback(async x=>{const M=await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:at?"atlas":"wall",reason:"control-active"})},k);if(M?.ok===!1)throw new Error(M.error||"wall-stream-stop-failed");return M},[k,at]),ni=f.useCallback(async(x,M="control-session-stop")=>{const O=await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/stop`,{method:"POST",body:JSON.stringify({streamPurpose:"control",reason:M})},k);if(O?.ok===!1)throw new Error(O.error||"control-stream-stop-failed");return O},[k]),na=f.useCallback(x=>{const M=tn.current.get(x);M&&(uc(M),tn.current.delete(x));const O=ta.current.get(x);O&&uc(O),Gs.current.delete(x),Nn.current.delete(x),J.current.delete(x)},[]);f.useEffect(()=>{if(!Ve)return;const x=ue&&Qe.find(B=>B.deviceId===ue)||null;if(!Wt||!x)return;if(ie===x.deviceId&&(P==="active"||P==="warm"||P==="connecting")){le(B=>B==="warm"?"active":B);return}if(Ja.current===x.deviceId)return;const M=++Ia.current,O=ie;Ja.current=x.deviceId,(async()=>{if(O){if(le("stopping"),await ni(O,"control-session-switch").catch(()=>{}),M!==Ia.current)return;na(O)}if(M!==Ia.current)return;const B=gs("control",x.deviceId),ve=`control-session-${M}-${x.deviceId}`;un.current.set(B,performance.now()),es.current.delete(B),Tl.current.delete(B),Oa.current.delete(B),Fn.current.delete(B),X(""),xe(""),z(ve),ee(x.deviceId),L(!1),le("connecting"),Ia.current===M&&Ja.current===x.deviceId&&(Ja.current="")})()},[Qe,ue,ie,P,Wt,na,Ve,ni]),f.useEffect(()=>{if(!ie||Qe.some(O=>O.deviceId===ie))return;const x=ie,M=++Ia.current;le("stopping"),ni(x,"control-device-disconnected").catch(()=>{}).finally(()=>{M===Ia.current&&(na(x),L(!1),z(""),X(""),xe(""),ee(O=>O===x?"":O),le("idle"))})},[Qe,ie,na,ni]),f.useEffect(()=>{if(bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null),!ie||P==="idle"||P==="stopping"||P==="error"||Ve||Fe==="wall"){ie&&!Ve&&Fe==="wall"&&le(O=>O==="warm"||O==="active"?"active":O);return}le(O=>O==="idle"||O==="stopping"?O:"warm");const x=ie,M=++Ia.current;return bt.current=window.setTimeout(()=>{bt.current=null,le("stopping"),ni(x,"control-session-warm-timeout").catch(()=>{}).finally(()=>{M===Ia.current&&(na(x),L(!1),z(""),X(""),xe(""),ee(O=>O===x?"":O),le("idle"))})},RM),()=>{bt.current!==null&&(window.clearTimeout(bt.current),bt.current=null)}},[Fe,ie,P,na,Ve,ni]),f.useEffect(()=>()=>{bt.current!==null&&window.clearTimeout(bt.current)},[]),f.useEffect(()=>{const x=++ke.current,M=we&&(P==="active"||P==="warm")&&ie?ie:"",O=_e.current;if(Ke.current||!M&&!O||M&&M===O)return;(async()=>{Ke.current=M||O;try{if(O&&O!==M){if(await Ts(O),x!==ke.current)return;_e.current="",bs("")}if(!M||x!==ke.current)return;if(await Rr(M),x!==ke.current){await Ts(M).catch(()=>{});return}_e.current=M,bs(M),Nn.current.add(M),he(O&&O!==M?`Wall paused for Control: ${M}`:"")}catch(B){x===ke.current&&he(B instanceof Error?B.message:String(B))}finally{Ke.current===(M||O)&&(Ke.current="")}})()},[ie,we,P,at,Ts,Rr]);const{state:Pl,sendInput:Yi,stats:ya,error:Wc}=Q0(rs&&fe,k),{state:Co,lastFrame:Kc,stats:yn,error:ko}=i1(Ee?.deviceId||"",qc&&Ie,k),$l=f.useRef(new Map);f.useEffect(()=>{const x=[["hub",A],["registry",c],["license",F],["wall-stream",Yc],["control-stream",Gi],["control-decode",$],["remote-input",Wc],["remote-audio",ko]];for(const[M,O]of x){const q=String(O||"").trim();if(!q){$l.current.delete(M);continue}$l.current.get(M)!==q&&($l.current.set(M,q),he(q))}},[ko,$,Gi,A,Wc,F,c,he,Yc]),f.useEffect(()=>{if(!Ve||!fe||!rs||!Ee)return;const x=(q,B)=>{const ve=q.target,ge=ve?.tagName?.toLowerCase();ve?.isContentEditable||ge==="input"||ge==="textarea"||ge==="select"||(q.preventDefault(),q.stopPropagation(),Yi(Ee.deviceId,{type:B,monitorIndex:Jn(kt[Ee.deviceId],Gn(Ee)),key:q.key,code:q.code,keyCode:q.keyCode||q.which||0,location:q.location,text:q.key.length===1?q.key:"",repeat:B==="keydown"?q.repeat:!1,shiftKey:q.shiftKey,ctrlKey:q.ctrlKey,altKey:q.altKey,metaKey:q.metaKey}))},M=q=>x(q,"keydown"),O=q=>x(q,"keyup");return window.addEventListener("keydown",M),window.addEventListener("keyup",O),()=>{window.removeEventListener("keydown",M),window.removeEventListener("keyup",O)}},[rs,fe,kt,Ee,Yi,Ve]),f.useEffect(()=>{const x=()=>{document.visibilityState==="visible"&&(Vs.current=performance.now())};return document.addEventListener("visibilitychange",x),window.addEventListener("pageshow",x),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("pageshow",x)}},[]),f.useEffect(()=>{if(!ie||P!=="connecting"&&P!=="active"&&P!=="warm"||Tr!=="open")return;const x=ie,M=gs("control",x),O=window.setInterval(()=>{const q=performance.now();if(document.visibilityState!=="visible"||q-Vs.current<Km)return;const B=es.current.get(M)||0,ve=Tl.current.get(M)||0,ge=Cs.current.get(M)||0,Re=un.current.get(M)||q;un.current.has(M)||un.current.set(M,Re);const Pe=B<=0,Xe=Pe?q-Re>HM:q-B>oy,Lt=B>0&&(ve<=0||q-ve>oy);if(!Xe&&Lt){const Bs=vr.current.get(M)||0;q-Bs>=cy&&Hl(x,"control","decoder-paint-stale");return}if(!Xe)return;const sn=Fn.current.get(M)||0;if(sn>0){if(q-sn<$M)return;Fn.current.delete(M)}const Ln=Oa.current.get(M)||0;if(Ln>=UM){if(Ua(Pe?"no first frame":"stale stream"))return;L(!1),vn(!1),le("error");return}if(q-ge<uy(PM,Ln))return;Er([x],Pe?"control-first-frame-timeout":"control-receive-stale")&&(Cs.current.set(M,q),Fn.current.set(M,q),un.current.set(M,q),Oa.current.set(M,Ln+1))},650);return()=>window.clearInterval(O)},[Tr,ie,P,Ua,Hl,Er]),f.useEffect(()=>{!$||Et!=="mode3-h264-hw"||Ua($)},[$,Et,Ua]),f.useEffect(()=>{!Ve||!ie||!Gi||le(x=>x==="error"?x:"error")},[Gi,ie,Ve]),f.useEffect(()=>{if(at||Ui!=="open"||!Ne.autoStartLive||dn.length===0)return;const x=window.setInterval(()=>{const M=performance.now();if(document.visibilityState!=="visible"||M-Vs.current<Km)return;const O=1e3/Math.max(1,Vt||Ne.fps||1),q=Math.max(qM,Math.ceil(O*4)),B=[];for(const ve of dn){if(B.length>=YM)break;const ge=gs("wall",ve),Re=es.current.get(ge)||0;if(Re<=0)continue;const Pe=Cs.current.get(ge)||0,Xe=Tl.current.get(ge)||0,Lt=M-Re>q,sn=Xe<=0||M-Xe>q;if(!Lt&&sn){const ms=vr.current.get(ge)||0;M-ms>=cy&&Hl(ve,"wall","decoder-paint-stale");continue}if(!Lt)continue;const Ln=Oa.current.get(ge)||0;M-Pe>=uy(GM,Ln)&&B.push(ve)}if(B.length>0&&Mr(B,"wall-frame-stale"))for(const ve of B){const ge=gs("wall",ve);Cs.current.set(ge,M),Oa.current.set(ge,(Oa.current.get(ge)||0)+1)}},VM);return()=>window.clearInterval(x)},[Vt,at,Hl,Mr,Ne.autoStartLive,Ne.fps,dn,Ui]),f.useEffect(()=>{qs(Ne.fps),ns.current=Date.now(),xn.current=0},[Ne.fps,Ne.frameMode,Ne.adaptiveLoadShedding]),f.useEffect(()=>{j0({h264DecodeAcceleration:Ne.h264DecodeAcceleration})},[Ne.h264DecodeAcceleration]),f.useEffect(()=>{if(!Wt||Ve||!Ne.visibleOnlyLive){_a([]);return}const x=yr.current;if(!x||typeof IntersectionObserver>"u"){_a(jr);return}const M=Array.from(x.querySelectorAll("[data-live-device-id]"));if(M.length===0){_a([]);return}const O=new Map,q=()=>{const ve=eh(M.map(ge=>String(ge.dataset.liveDeviceId||"")).filter(ge=>(O.get(ge)||0)>0));_a(ge=>Jm(ge,ve)?ge:ve)},B=new IntersectionObserver(ve=>{for(const ge of ve){const Re=String(ge.target.dataset.liveDeviceId||"");Re&&O.set(Re,ge.isIntersecting?ge.intersectionRatio||.01:0)}q()},{root:null,rootMargin:Vn.visibleRootMargin,threshold:[0,.01,.2,.6,1]});return M.forEach(ve=>B.observe(ve)),q(),()=>B.disconnect()},[jr,Wt,Ve,is,Ne.visibleOnlyLive,Ge]),f.useEffect(()=>{if(at||!Ne.adaptiveLoadShedding||!Ne.autoStartLive||dn.length===0)return;const x=Ne.fps;if(dn.length<=Vn.preserveConfiguredFpsDeviceCount){Vt!==x&&(qs(x),ns.current=Date.now(),xn.current=0);return}if(Ui!=="open"||Ns.sampleMs<500)return;const M=Date.now(),O=dn.length*Vt,q=Ns.framesPerSecond,B=Ns.bytesPerSecond,ve=Math.max(0,...dn.map(Lt=>Ht[gs("wall",Lt)]?.maxIntervalMs||0)),ge=Math.max(0,...dn.map(Lt=>Ft[gs("wall",Lt)]?.maxIntervalMs||0)),Re=O>8&&q>0&&q<O*.72;if(q>Vn.maxWallFramesPerSecond||B>Vn.maxWallBytesPerSecond||ve>Vn.maxFrameGapMs||ge>Vn.maxFrameGapMs||Re){xn.current=0;const Lt=Vn.minFps;if(M-ns.current>=Vn.downshiftCooldownMs&&Vt>Lt){const sn=Math.max(Lt,uN(Vt,Lt));sn<Vt&&(qs(sn),ns.current=M)}return}const Xe=q<Vn.maxWallFramesPerSecond*Vn.lowLoadFrameRatio&&B<Vn.maxWallBytesPerSecond*Vn.lowLoadByteRatio;if(!Xe||Vt>=x){Xe||(xn.current=0);return}if(!xn.current){xn.current=M;return}if(M-xn.current>=Vn.recoveryCooldownMs){const Lt=Math.min(x,dN(Vt,x));Lt>Vt&&(qs(Lt),ns.current=M,xn.current=0)}},[Vt,at,Ft,Ht,dn.length,dn,Ui,Ns.bytesPerSecond,Ns.framesPerSecond,Ns.lastUpdatedAt,Ns.sampleMs,Ne.adaptiveLoadShedding,Ne.autoStartLive,Ne.frameMode,Ne.fps]),f.useEffect(()=>{const x=new URLSearchParams(window.location.search).get("checkout");if(x==="success"){he("Checkout returned. Waiting for Dodo confirmation."),V();const M=window.setInterval(()=>{V()},4e3),O=window.setTimeout(()=>{window.clearInterval(M)},45e3);return()=>{window.clearInterval(M),window.clearTimeout(O)}}x==="cancelled"&&he("Checkout cancelled.")},[V]),f.useEffect(()=>{!Wt&&fe&&Te(!1),!Wt&&Ie&&oe(!1)},[Ie,fe,Wt]),f.useEffect(()=>{const x=Ee?.deviceId||"",M=Ye.current;if(Ye.current=x,!M||M===x)return;const O=++We.current,q=x?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:"";x&&Ie&&De.current.set(x,q);let B=!0;return(async()=>{try{const ge=De.current.get(M);if(De.current.delete(M),await Be(`/api/remote/devices/${encodeURIComponent(M)}/audio/stop`,{method:"POST",body:JSON.stringify(ge?{streamId:ge}:{})},k),!B||O!==We.current||!Ie||!x||!Wt||!zl)return;const Re=await Be(`/api/remote/devices/${encodeURIComponent(x)}/audio/start`,{method:"POST",body:JSON.stringify({streamId:q,mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},k);if(Re.ok===!1)throw new Error(Re.error||"Remote audio start failed.")}catch(ge){B&&(De.current.delete(x),oe(!1),he(ge instanceof Error?ge.message:String(ge)))}})(),()=>{B=!1}},[Ie,Wt,k,zl,Ee?.deviceId]),f.useEffect(()=>{const x=Qe.map(q=>q.deviceId),M=new Set(x),O=new Map(Qe.map(q=>[q.deviceId,q]));I(q=>{const B=q.filter(ve=>M.has(ve));return Jm(q,B)?q:B}),Y(q=>q&&M.has(q)?q:""),K(q=>q&&M.has(q)?q:""),La(q=>{let B=!1;const ve={};for(const[ge,Re]of Object.entries(q)){const Pe=O.get(ge);if(!Pe){ve[ge]=Re;continue}const Xe=Jn(Re,Pe?Gn(Pe):1);ve[ge]=Xe,Xe!==Re&&(B=!0)}return B?ve:q}),Dl(q=>{const B=q.filter(ve=>M.has(ve));return Jm(q,B)?q:B})},[Qe,Ii]),f.useEffect(()=>{Ei([]),ts(!1)},[$a]),f.useEffect(()=>{!As||Ri!=="selected"||Ws.length>0||xa.length===0||Dl(xa.map(x=>x.deviceId))},[xa,Ws.length,Ri,As]),f.useEffect(()=>{try{localStorage.setItem(Nw,mt)}catch{}},[mt]),f.useEffect(()=>{iN(Ne)},[Ne]),f.useEffect(()=>{rN(Je)},[Je]),f.useEffect(()=>{aN(kt)},[kt]);const Qn=f.useCallback(async()=>{const x=new Set(v);x.add(bn);try{const ve=await Be("/api/remote/status",void 0,bn);Yv({endpoint:ve.agentEndpoint,endpoint_candidates:[...ve.agentEndpointCandidates||[],...ve.hostTargetEndpointCandidates||[]]}).forEach(ge=>x.add(ge))}catch{}const M=[...x].sort((ve,ge)=>{const Re=Pe=>{const Xe=Ac(Pe);return Xe==="local"?0:Xe==="loopback"?1:2};return Re(ve)-Re(ge)||ve.localeCompare(ge)});let O=!1,q="",B=!1;try{for(const ve of M){const ge=Ac(ve);try{if(await Be("/api/health",void 0,ve),ge==="local")return w(!0),to(!0),ve;ge==="loopback"&&(O=!0,q=ve)}catch{ge==="local"&&(B=!0)}}return O?(B&&he("LiveDesk Hub is reachable on this PC, but not through the LAN address yet. Restart LiveDesk Hub to bind 5179 on the network."),w(!0),to(!0),q||bn):(w(!1),to(!1),"")}catch{return w(!1),to(!1),""}},[v]),Es=async()=>{ne("auth"),Bn(!1),await Qn();const{error:x}=await zt.auth.signInWithOAuth({provider:"google",options:{redirectTo:window.location.origin}});x&&(he(x.message),ne(""))},aa=async()=>{ne("auth"),Bn(!1),await zt.auth.signOut(),ne("")};f.useEffect(()=>{if(!Da)return;const x=O=>{O.target instanceof Element&&(O.target.closest(".account-popover, .rail-account")||Bn(!1))},M=O=>{O.key==="Escape"&&Bn(!1)};return window.addEventListener("pointerdown",x),window.addEventListener("keydown",M),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",M)}},[Da]);const wa=f.useCallback(async(x={})=>{const M=x.silent===!0,O=x.takeover===!0,q=x.requestLocalAccess===!0,B=q?await Qn():"";if(!a?.user){M||he("Sign in before publishing this host.");return}if(!Ll.current){Ll.current=!0,M||ne("host");try{const ve=B||k||bn,ge=j||await Be("/api/remote/status",void 0,ve);if(!ge.started)throw new Error("Start LiveDesk on this computer before syncing the server.");const Re=ge.deviceId||`livedesk-${a.user.id}`,Pe=await Be("/api/remote/host-target",{method:"POST",body:JSON.stringify({nodeId:Re,leaseMs:6e4,takeover:O})},ve);if(!Pe.ok)throw new Error(Pe.error||"host-target-failed");const Xe=await Be("/api/remote/status",void 0,ve),Lt=await Be("/api/remote/registry-credentials",void 0,ve),sn=Pe.hostTarget||{},Ln=Xe.hostTargetEndpointCandidates||Xe.agentEndpointCandidates||ge.agentEndpointCandidates||[Xe.agentEndpoint||ge.agentEndpoint].filter(Boolean),{data:ms,error:Bs}=await zt.rpc("set_livedesk_remote_host_target",{p_node_id:Re,p_lease_id:String(sn.leaseId||Xe.hostTargetLeaseId||crypto.randomUUID()),p_host_instance_id:Xe.hostInstanceId||Re,p_endpoint:Xe.hostTargetEndpoint||Xe.agentEndpoint||ge.agentEndpoint,p_pair_token:Lt.pairToken||"",p_manager_package:"@livedesk/hub",p_manager_version:Xe.managerVersion||"0.1.0",p_agent_package:"@livedesk/client",p_activated_at:new Date().toISOString(),p_expires_at:new Date(Date.now()+6e4).toISOString(),p_takeover:O,p_endpoint_candidates:Ln,p_pairing_pin:Lt.pairingPin||Xe.pairingPin||""});if(Bs)throw Bs;const Ya=Array.isArray(ms)?ms[0]:ms;if(Ya&&Ya.ok===!1)throw new Error(Ya.reason||"registry-rejected");M||(he("Host published."),(q||y)&&(w(!0),to(!0)),T()),u()}catch(ve){if(!M){const ge=ve instanceof Error?ve.message:String(ve);ge.includes("local network access")&&(w(!1),to(!1)),he(ge)}}finally{Ll.current=!1,M||ne("")}}},[k,y,T,u,Qn,a,j]),Ao=f.useCallback(async()=>{if(!(!j?.update?.canApply||D==="update")){ne("update");try{const x=await Be("/api/update/apply",{method:"POST",body:JSON.stringify({})},k||bn);if(!x.ok)throw new Error(x.error||"LiveDesk update could not be started.");const M=[...new Set((x.targets||[]).map(O=>String(O.deviceId||"").trim()).filter(Boolean))];M.length>0&&Wn({operationId:String(x.operationId||`wall-update-${Date.now()}`),targetIds:M,stage:x.state==="clients-updated"?"updated":"updating",requiresHubRestart:!!(x.managerUpdateAvailable||x.clientPackageUpdateAvailable),initialHostInstanceId:String(j.hostInstanceId||"")}),he(x.state==="hub-restart-requested"?Qm:ty),T()}catch(x){he(x instanceof Error?x.message:String(x))}finally{ne("")}}},[D,k,T,j]);f.useEffect(()=>{const x=Gt,M=j?.update;if(!x||x.stage==="updated"||!M)return;if(M.state==="failed"){Wn(B=>B?.operationId===x.operationId?null:B);return}if(M.operationId===x.operationId){!x.requiresHubRestart&&M.state==="clients-updated"&&Wn(B=>B?.operationId===x.operationId?{...B,stage:"updated"}:B);return}if(!x.requiresHubRestart)return;const O=j.started===!0&&(!x.initialHostInstanceId||j.hostInstanceId&&j.hostInstanceId!==x.initialHostInstanceId),q=M.state==="idle"&&M.updateAvailable===!1;O&&q&&Wn(B=>B?.operationId===x.operationId?{...B,stage:"updated"}:B)},[j,Gt]),f.useEffect(()=>{if(!Gt||Gt.stage!=="updated")return;const x=Gt.operationId,M=window.setTimeout(()=>{Wn(O=>O?.operationId===x?null:O)},8e3);return()=>window.clearTimeout(M)},[Gt]),f.useEffect(()=>{if(je!==ty&&je!==Qm)return;const x=j?.update,M=String(x?.state||"");if(M==="failed"){he(x?.error||"LiveDesk update failed.");return}(M==="clients-updated"||M==="idle"&&x?.updateAvailable===!1||!j&&A&&je===Qm)&&he("")},[A,je,j,j?.update?.error,j?.update?.state,j?.update?.updateAvailable]);const Dr=f.useCallback(async()=>{if(!D){ne("pin");try{const M=await Be("/api/remote/pairing-pin",{method:"POST"},k||bn);if(!M.ok)throw new Error(M.error||"pin-rotation-failed");await T(),a?.user&&await wa({silent:!0,takeover:!0}),he("New PIN published.")}catch(x){he(x instanceof Error?x.message:String(x))}finally{ne("")}}},[D,k,wa,T,a]);f.useEffect(()=>{if(!a?.user||!j?.started||A)return;const x=r?.expires_at?Date.parse(r.expires_at):Number.POSITIVE_INFINITY,M=r?.active===!0&&(!r.expires_at||!Number.isFinite(x)||x>Date.now()),O=!!r?.host_instance_id&&!!j.hostInstanceId&&r.host_instance_id===j.hostInstanceId;if(M&&!O)return;let q=!1;const B=()=>{if(q)return;const ge=Date.now();ge-ho.current<25e3||(ho.current=ge,wa({silent:!0}))};B();const ve=window.setInterval(B,3e4);return()=>{q=!0,window.clearInterval(ve)}},[A,wa,a?.user?.id,j?.agentEndpoint,j?.hostInstanceId,j?.started,r?.active,r?.expires_at,r?.host_instance_id]);const ai=f.useCallback(x=>{x&&(Y(x),I(M=>M.includes(x)?M:[...M,x]))},[]),Lr=f.useCallback(x=>{if(!x)return;const M=Ks.has(x);Y(O=>M&&O===x?"":x),I(O=>M?O.filter(q=>q!==x):O.includes(x)?O:[...O,x])},[Ks]),ba=f.useCallback(()=>{I([]),Y("")},[Ms]),Mo=f.useCallback(()=>{I(Qe.map(x=>x.deviceId)),Y("")},[Qe]),Wi=f.useCallback((x,M)=>{const O=Qe.find(B=>B.deviceId===x);if(!O)return;const q=Gn(O);q<=1||(La(B=>{const ge=(Jn(B[x],q)+M+q)%q;return{...B,[x]:ge}}),Ve&&(vn(!1),K(x)))},[Qe,Ve]);f.useEffect(()=>{const x=M=>{if(Ve&&fe&&rs)return;const O=M.target,q=O?.tagName?.toLowerCase();O?.isContentEditable||q==="input"||q==="textarea"||q==="select"||((M.ctrlKey||M.metaKey)&&M.key.toLowerCase()==="a"&&(M.preventDefault(),Mo()),M.key==="Escape"&&ba())};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[rs,ba,fe,Mo,Ve]);const si=async(x,M={})=>{if(!ls.has(x)){he(Qs);return}const O=M.focused||Ve;O?(vn(!1),K(x)):ai(x);try{const q=Qe.find(ge=>ge.deviceId===x),B=O?{maxWidth:Je.maxWidth,maxHeight:Je.maxHeight}:Pt,ve=Jn(M.monitorIndex??kt[x],q?Gn(q):1);await Be(`/api/remote/devices/${encodeURIComponent(x)}/live/start`,{method:"POST",body:JSON.stringify({fps:O?Je.fps:Vt,maxWidth:B.maxWidth,maxHeight:B.maxHeight,quality:O?Je.quality:Ne.quality,mode:O?Je.frameMode:Ne.frameMode,frameMode:O?Je.frameMode:Ne.frameMode,streamPurpose:O?"control":"wall",monitorIndex:ve})},k),T()}catch(q){he(q instanceof Error?q.message:String(q))}},Zd=(x,M)=>{const O=Qe.find(B=>B.deviceId===x),q=Jn(M,O?Gn(O):1);La(B=>({...B,[x]:q})),Ve?(vn(!1),K(x)):ai(x)},Dn=async x=>{if(vn(!1),K(x),Le("control"),!ls.has(x)){Te(!1),he(Qs);return}Te(!0)},No=async()=>{if(!Ee){he("Select a workstation before playing audio.");return}if(!Wt){he(Qs);return}if(!zl){he("Selected workstation does not report remote audio support yet.");return}const x=!Ie,M=x?`audio-${Date.now()}-${Math.random().toString(36).slice(2,8)}`:De.current.get(Ee.deviceId);x&&M?De.current.set(Ee.deviceId,M):x||De.current.delete(Ee.deviceId),oe(x);try{await Be(`/api/remote/devices/${encodeURIComponent(Ee.deviceId)}/audio/${x?"start":"stop"}`,{method:"POST",body:JSON.stringify({...M?{streamId:M}:{},mimeType:"audio/pcm;format=f32le",sampleRate:48e3,channels:2})},k)}catch(O){x&&De.current.delete(Ee.deviceId),oe(!1),he(O instanceof Error?O.message:String(O))}},qa=async(x,M,O="files")=>{const q=x.filter(Re=>Re.file.size>=0);if(q.length===0)return{files:0,bytes:0};if(!Wt)throw new Error(Qs);if(M.length===0)throw new Error("Select at least one connected workstation.");const B=crypto.randomUUID(),ve=q.reduce((Re,Pe)=>Re+Pe.file.size,0);let ge=0;Ba({id:B,status:"reading",progress:1,message:`Preparing ${q.length} ${O}`});try{for(let Re=0;Re<q.length;Re+=1){const Pe=q[Re],Xe=Pe.file,Lt=Math.max(1,Math.ceil(Xe.size/Ym));for(let sn=0;sn<Lt;sn+=1){const Ln=sn*Ym,ms=Math.min(Xe.size,Ln+Ym),Bs=Xe.size===0?new ArrayBuffer(0):await Xe.slice(Ln,ms).arrayBuffer(),Ya=sn===Lt-1;Ba({id:B,status:"sending",progress:Math.max(2,Math.min(98,Math.round(ge/Math.max(1,ve)*96))),message:`${Re+1}/${q.length} ${Pe.relativePath}`});const fi=await Be("/api/remote/files/chunk",{method:"POST",body:JSON.stringify({transferId:B,deviceIds:M,remoteDirectory:mt.trim(),name:Xe.name,relativePath:Pe.relativePath,size:Xe.size,type:Xe.type,lastModified:Xe.lastModified,offset:Ln,totalBytes:Xe.size,final:Ya,dataBase64:fN(Bs)})},k);if(!fi.ok||fi.queued!==M.length)throw new Error(fi.error||`file-chunk-not-queued-${fi.queued}/${M.length}`);ge+=Bs.byteLength,await new Promise(lu=>window.setTimeout(lu,0))}}return Ba({id:B,status:"queued",progress:100,message:`Sent ${q.length} file${q.length===1?"":"s"} to ${M.length} workstation${M.length===1?"":"s"}`}),window.setTimeout(()=>{Ba(Re=>Re?.id===B&&Re.status==="queued"?null:Re)},4500),{files:q.length,bytes:ve}}catch(Re){throw Ba({id:B,status:"failed",progress:100,message:Re instanceof Error?Re.message:String(Re)}),Re}},To=async x=>{const M=xa.length>0?xa.map(O=>O.deviceId):Ee?[Ee.deviceId]:[];try{await qa(fy(x),M)}catch(O){he(O instanceof Error?O.message:String(O))}},Ul=async x=>{try{await qa(fy(x),Ud)}catch(M){he(M instanceof Error?M.message:String(M))}};f.useEffect(()=>{Bc.current=!1},[]);const ii=x=>{x.preventDefault(),x.stopPropagation(),xr(!1),To(x.dataTransfer.files)},Ki=async(x="ltd")=>{if(!a){he("Sign in with Google before checkout.");return}if(R&&x===Rt){he("LiveDesk license is already active.");return}if(R&&Rt==="pro"){he("LiveDesk Pro is already active.");return}ne("checkout");try{const{data:M,error:O}=await zt.functions.invoke("dodo-checkout",{body:{plan:x}});if(O)throw O;if(!M?.checkout_url)throw new Error("Checkout function did not return a checkout URL.");window.location.assign(M.checkout_url)}catch(M){he(M instanceof Error?M.message:String(M)),ne("")}},cs=WM(),Qi=KM(),Qc=Qe.length,Hn=Kd.filter(x=>Vi.has(x)).length,Rs=ti==="open"&&Fl.sampleMs>0?`${Fl.framesPerSecond.toFixed(1)} fps`:ti,Ae=Ee?Ve?Nr.get(Ee.deviceId):Vi.get(Ee.deviceId):void 0,li=Ee?Jn(kt[Ee.deviceId],Gn(Ee)):0,Xi=Ee?JM(Ee):[],sa=typeof Ae?.monitorIndex=="number"?Jn(Ae.monitorIndex,Math.max(1,Ae.monitorCount||1)):li,Ga=(Ae&&sa===li?Hw(Ae):null)||(Ee?Fw(Ee,li):null),Va=Ga?`${Ga.width}x${Ga.height}`:"-",Xn=Ee?gs(Ve?"control":"wall",Ee.deviceId):"",Mt=Xn?Ht[Xn]:void 0,Pn=Xn?Ft[Xn]:void 0,st=Pn?.lastInfo,Eo=Mt&&Mt.sampleMs>0?`${Mt.framesPerSecond.toFixed(1)} fps`:"waiting",Xc=Mt?`#${Mt.totalFrames} / ${Eo}`:"waiting",fn=Pn&&Pn.sampleMs>0?`${Pn.framesPerSecond.toFixed(1)} fps`:"waiting",Nt=Pn&&Pn.sampleMs>0?`${Pn.changedFramesPerSecond.toFixed(1)} fps`:"waiting",lt=st?`#${st.frameSeq} ${st.decoderLabel} q${st.queueSize} r${st.renderQueueSize} d${st.droppedForLatency} f${st.decoderFlushCount} t${st.decoderTimestampFallbacks} io${st.decoderInputCount}/${st.decoderOutputCount} ${st.visualChanged?"changed":"same"}`:"waiting",Ds=st?`${Math.round(st.queuedForMs)}ms total / ${Math.round(st.decodedForMs)}ms decode / ${Math.round(st.scheduledForMs)}ms pace / ${st.drawMs.toFixed(1)}ms draw`:"-",ia=st?.targetPaintIntervalMs?`${st.targetPaintIntervalMs.toFixed(1)}ms / ${(1e3/st.targetPaintIntervalMs).toFixed(1)} fps`:"-",Ro=Pn?`${Pn.decoderInputFps.toFixed(1)} in / ${Pn.decoderOutputFps.toFixed(1)} out fps`:"waiting",Ls=st?.canvasPresentation||"-",Zc=st?`${st.interactiveBufferWaitCount} waits / ${Math.round(st.interactiveBufferWaitMs)}ms / ${st.interactiveQueueDrainCount} drains`:"waiting",Jc=n.framesPerSecond>0?`${n.framesPerSecond.toFixed(1)} fps / p95 ${n.p95IntervalMs.toFixed(1)}ms / max ${n.maxIntervalMs.toFixed(1)}ms / long ${n.longTaskCount} (${Math.round(n.longTaskMs)}ms)`:"waiting",Zi=Mt?Ae?.frameMode==="mode5-lzo-delta"?`${yc(Mt.averageFrameBytes)} avg / visual ${Ae.deltaVisualTileCount||0} + refresh ${Ae.deltaRefreshTileCount||0} / ${Ae.deltaTotalTiles||0}`:`${yc(Mt.averageFrameBytes)} avg / tiny ${Math.round(Mt.tinyFrameRatio*100)}% / repeat ${Math.round(Mt.repeatedFrameRatio*100)}%`:"waiting",ri=Mt&&Mt.sourceSendSampleCount>0?`${Mt.sourceSendAverageMs.toFixed(1)}ms avg / p95 ${Mt.sourceSendP95Ms.toFixed(1)}ms`:"waiting",Do=sy(Mt),ql=sy(Pn),Lo=Mt&&Pn?`rx ${iy(Mt)} / paint ${iy(Pn)}`:"waiting",us=Ae?Ae.frameMode||Ae.mode||Ae.codec||Ae.mimeType:Ve?Je.frameMode:Ne.frameMode,ja=Ve?Je.frameMode:Ne.frameMode,_s=us!==ja?`${ja} -> ${us}`:ja,ds=Ae?`${Ae.width}x${Ae.height} ${yc(Ae.byteLength)}`:Ve?`${va.maxWidth}x${va.maxHeight}`:`${Ne.maxWidth}x${Ne.maxHeight}`,_o=Ae?Ae.frameMode==="mode2-lzo"?"independent":`${Ae.isKeyFrame?"key":String(Ae.chunkType||"delta")}`:"-",zo=Ae&&Ae.monitorCount?`${(Ae.monitorIndex??0)+1}/${Ae.monitorCount}`:"-",Ji=Ae?[`src ${Math.round(Ae.sourceGapMs||0)}ms`,`gap ${Math.round(Ae.agentSendGapMs||0)}ms`,`tx ${Math.round(Ae.agentSendDurationMs||0)}ms`,`pace ${Math.round(Ae.agentPaceMs||0)}ms`,`queue ${Math.round(Ae.agentQueueBeforePaceMs||0)}ms`,`age ${Math.round(Ae.agentFrameAgeMs||0)}ms`,Ae.browserReceivedEpochMs&&Ae.receivedAt?`hub ${Math.max(0,Math.round(Ae.browserReceivedEpochMs-Date.parse(Ae.receivedAt)))}ms`:"",Ae.browserReceivedEpochMs&&Ae.hubPacketEpochMs?`sock ${Math.max(0,Math.round(Ae.browserReceivedEpochMs-Ae.hubPacketEpochMs))}ms`:"",Ae.droppedByAgent?`drop ${Ae.droppedByAgent}`:"",Ae.hubIngressDropped?`ingress-drop ${Ae.hubIngressDropped}`:"",Ae.hubClientDropped?`ws-drop ${Ae.hubClientDropped}`:"",Ae.captureStageMs?`capture ${Math.round(Ae.captureStageMs)}ms`:"",Ae.requestedFps?`req ${Math.round(Ae.requestedFps)}fps`:"",Ae.effectiveFps?`eff ${Math.round(Ae.effectiveFps)}fps`:"",Ae.captureAverageMs?`avg ${Math.round(Ae.captureAverageMs)}ms`:"",Ae.captureP95Ms?`p95 ${Math.round(Ae.captureP95Ms)}ms`:"",Ae.slowFrameCount?`slow ${Math.round(Ae.slowFrameCount)}`:"",Ae.captureHelperRestarts?`helper ${Math.round(Ae.captureHelperRestarts)}`:"",Ae.convertMs?`rgb565 ${Math.round(Ae.convertMs)}ms`:"",Ae.compressMs?`lzo ${Math.round(Ae.compressMs)}ms`:"",Ae.captureSourceSerial?`cap #${Ae.captureSourceSerial}`:"",Ae.captureSourceSkipped?`cap skip ${Ae.captureSourceSkipped}`:"",Ae.frameMode==="mode5-lzo-delta"?`tiles ${Ae.deltaVisualTileCount||0}+${Ae.deltaRefreshTileCount||0}/${Ae.deltaTotalTiles||0}@${Ae.deltaTileSize||0}`:"",Ae.platformProfile||Ae.hardwareEncoder||"-",Ae.atlasComposeMs?`atlas ${Ae.atlasComposeMs.toFixed(1)}ms`:"",Ae.atlasPoolStarved?`pool ${Ae.atlasPoolStarved}`:"",Ae.atlasTileCount?`tiles ${Ae.atlasReadyTiles||0}/${Ae.atlasTileCount}`:"",st?.inputFeedbackMs!==void 0&&st.inputFeedbackAt!==void 0&&performance.now()-st.inputFeedbackAt<=Jx?`feedback ${Math.round(st.inputFeedbackMs)}ms`:"",Ae.contentHash?`enc ${Ae.contentHash.slice(0,6)}`:"",st?.visualHash?`pix ${st.visualHash.slice(0,6)}`:""].filter(Boolean).join(" / "):"-",_r=Pl==="open"?[`${ya.sentPerSecond.toFixed(1)} hz`,ya.lastInputSeq>0?`rtt ${Math.round(ya.lastRoundTripMs)}ms`:"",ya.lastInputSeq>0?`apply ${ya.lastAgentApplyMs.toFixed(1)}ms`:"",ya.droppedPerSecond>0?`drop ${ya.droppedPerSecond.toFixed(1)}/s`:"",ya.bufferedAmount>0?`buf ${yc(ya.bufferedAmount)}`:"",ya.lastInputType||"ready"].filter(Boolean).join(" / "):Pl,oi=st?.inputFeedbackMs!==void 0&&st.inputFeedbackAt!==void 0&&performance.now()-st.inputFeedbackAt<=Jx?`${Math.round(st.inputFeedbackMs)}ms / input #${st.inputFeedbackSeq||0}`:"waiting for changed frame",mn=Ie?[Co,`context ${yn.audioContextState}`,`queue ${Math.round(yn.queuedMs)}ms`,`last ${Math.round(yn.lastPacketAgeMs)}ms`,`accepted ${Math.round(yn.lastAcceptedAgeMs)}ms`,`process ${Math.round(yn.localProcessingAgeMs)}ms`,`remote ${Math.round(yn.browserAgeMs)}/${Math.round(yn.captureAgeMs)}ms`,`heartbeat ${Math.round(yn.captureStatusAgeMs)}ms`,`capture ${yn.captureAlive&&yn.helperAlive?"alive":"down"}`,`drop ${yn.drops}`,`resync ${yn.resyncs}`,`restart ${yn.automaticRestarts}`,yn.pendingDecodes>0?`decode ${yn.pendingDecodes}`:"",Kc?`#${Kc.frameSeq}`:"waiting"].filter(Boolean).join(" / "):"off",zr=Ae?`#${Ae.frameSeq} ${rh(Ae.receivedAt||Ae.capturedAt)}`:"waiting",ci=Math.max(0,Fl.bytesPerSecond*8/1e6),eu=qi?.atlasReadyTiles??Hn,Io=qi?.atlasTileCount??Hn,Jd=eu===Io?`${Io} tiles`:`${eu}/${Io} tiles`,$t=Ve?`1 stream / ${Rs} / ${ci.toFixed(ci>=10?0:1)}Mbps`:at?`1 stream / ${Jd} / ${Rs} / ${ci.toFixed(ci>=10?0:1)}Mbps`:`${Hn} screens / ${Rs} / ${ci.toFixed(ci>=10?0:1)}Mbps`,Ir=A?"offline":j?.started?"online":"starting",zs=xa.length,Gl=Ve?Ee?rr(Ee):"No workstation":zs===0?"No workstation":zs>1?`${zs} selected`:Ee?rr(Ee):"No workstation",hn=lo[gn]||lo.en,fs=hn.sync||lo.en.sync,ui=l||U?"checking":R?Rt==="pro"?"Pro LTD active":`Plus LTD ${Qe.length}/${xc}`:Vd?`Free ${Qe.length}/${vc}`:`Upgrade ${Qe.length}/${vc}`,ef=Rt==="pro"?"Pro active":D==="checkout"?"Opening":Rt==="ltd"?"Pro $199":"Plus $79",nf=R?Rt==="pro"?"Pro active":"Upgrade to Pro LTD":a?D==="checkout"?"Opening checkout":Rt==="ltd"?"Buy Pro LTD":"Buy Plus LTD":D==="auth"?"Opening Google":"Sign in to buy",tu=Rt==="pro"||D==="checkout"||D==="auth"||l||U,Is=a?.user.user_metadata,el=my(Is,"avatar_url","picture"),Os=my(Is,"full_name","name")||a?.user.email||"Google",Oo=Os.slice(0,1).toUpperCase(),tl=j?.started?"Local app ready":"Start LiveDesk",Bo=r?.active?"Published":a?"Not published":"Sign in required",Or=/^\d{6}$/.test(j?.pairingPin||"")?j?.pairingPin:"------",Br=bd.find(x=>x.width===Ne.maxWidth&&x.height===Ne.maxHeight)?.id||`${Ne.maxWidth}x${Ne.maxHeight}`,nu=Ne.atlasTileSizeMode==="auto"?"auto":Zm.find(x=>x.width===Ne.atlasTileWidth&&x.height===Ne.atlasTileHeight)?.id||"320x180",au=Xm.find(x=>x.width===Je.maxWidth&&x.height===Je.maxHeight)?.id||`${Je.maxWidth}x${Je.maxHeight}`,di=wd.find(x=>x.id===Ne.frameMode)||wd[0],an=x=>{Nl(M=>{const O=x.frameMode?Ch(x.frameMode):M.frameMode,q=x.frameMode!==void 0&&O!==M.frameMode;return{...M,...x,frameMode:O,fps:Ah(x.fps??(q?Iw(O):M.fps),O)}})},su=x=>{const M=bd.find(O=>O.id===x);M&&an({maxWidth:M.width,maxHeight:M.height})},iu=x=>{if(x==="auto"){an({atlasTileSizeMode:"auto"});return}const M=Zm.find(O=>O.id===x);!M?.width||!M?.height||an({atlasTileSizeMode:"fixed",atlasTileWidth:M.width,atlasTileHeight:M.height})},Ca=x=>{x.frameMode!==void 0&&(X(""),xe("")),hr(M=>{const O=x.frameMode?kh(x.frameMode):M.frameMode,q=x.frameMode!==void 0&&O!==M.frameMode,B=x.fps??(q?30:M.fps),ve=x.maxWidth??M.maxWidth,ge=x.maxHeight??M.maxHeight;return{...M,...x,frameMode:O,fps:Xa(B,20,O==="mode3-h264-hw"?60:30,O==="mode3-h264-hw"?60:30),maxWidth:O==="mode3-h264-hw"?ve:Math.min(1920,ve),maxHeight:O==="mode3-h264-hw"?ge:Math.min(1080,ge)}})},Vl=x=>{const M=Xm.find(O=>O.id===x);M&&Ca({maxWidth:M.width,maxHeight:M.height})},nl=x=>{if(typeof window<"u"&&(x==="support"?window.history.pushState({},"","/support"):Fe==="support"&&window.history.pushState({},"","/")),x==="control"){const M=En||Bi;if(M&&(vn(!1),K(M.deviceId)),Le(x),!Wt){Te(!1),he(Qs);return}Te(!0);return}x==="wall"&&gr(M=>M+1),Le(x),Te(!1)},Yl=D==="update"||["dispatching","waiting-for-clients","hub-restart-requested"].includes(j?.update?.state||""),Wl=f.useCallback(x=>{if(Gt?.targetIds.includes(x))return Gt.stage},[Gt]);return i.jsxs("main",{className:"app-shell",children:[i.jsxs("aside",{className:"tool-rail","aria-label":"LiveDesk tools",children:[i.jsx("div",{className:"rail-brand",title:"LiveDesk",children:i.jsx(vN,{size:25})}),i.jsx("nav",{className:"rail-tools",children:yN.map(x=>{const M=x.icon;return i.jsxs(f.Fragment,{children:[i.jsxs("button",{className:`rail-tool ${x.id==="sync-server"?"sync-server":""} ${Fe===x.id?"active":""} accent-${x.accent}`,onClick:()=>x.id==="sync-server"?void wa({takeover:!0,requestLocalAccess:!0}):nl(x.id),title:x.label,type:"button",children:[i.jsx(M,{size:19}),i.jsx("span",{children:x.label})]}),x.id==="sync-server"&&j?.update?.updateAvailable&&j.update.canApply&&!Yl?i.jsxs("button",{className:"rail-update-button",onClick:()=>{Ao()},title:`Update LiveDesk to ${j.update.latestVersion||"latest"}`,type:"button",children:[i.jsx(Sy,{size:16}),i.jsx("span",{children:"Update"})]}):null]},x.id)})}),i.jsxs("div",{className:"rail-footer",children:[wN.map(x=>{const M=x.icon;return i.jsxs("button",{className:`rail-tool compact ${Fe===x.id?"active":""} accent-${x.accent}`,onClick:()=>nl(x.id),title:x.label,type:"button",children:[i.jsx(M,{size:18}),i.jsx("span",{children:x.label})]},x.id)}),i.jsxs("button",{className:`rail-tool compact local-settings ${_i?"active":""}`,onClick:()=>{Le("settings"),typeof window<"u"&&window.history.pushState({},"","/"),Bn(!1),Te(!1),Ml(!1)},title:"Settings",type:"button",children:[i.jsx(TS,{size:18}),i.jsx("span",{children:"Settings"})]}),i.jsxs("button",{className:`rail-account ${a?"signed-in":""}`,onClick:()=>{Bn(x=>!x)},disabled:l||D==="auth","aria-expanded":Da,title:a?`Account: ${a.user.email||Os}`:"Sign in with Google",type:"button",children:[a?el?i.jsx("img",{src:el,alt:Os,referrerPolicy:"no-referrer"}):i.jsx("span",{className:"avatar-fallback",children:Oo}):i.jsx(Cm,{size:18}),i.jsx("span",{children:a?"Account":"Google"})]}),Da&&i.jsxs("section",{className:"account-popover",role:"dialog","aria-label":"LiveDesk account",children:[i.jsxs("div",{className:"account-popover-head",children:[i.jsx("div",{className:"account-popover-avatar",children:a&&el?i.jsx("img",{src:el,alt:Os,referrerPolicy:"no-referrer"}):a?i.jsx("span",{children:Oo}):i.jsx(Cm,{size:18})}),i.jsxs("div",{children:[i.jsx("strong",{children:a?Os:"Account"}),i.jsx("p",{children:a?.user.email||"Not signed in"})]})]}),i.jsxs("dl",{className:"account-popover-facts",children:[i.jsx("dt",{children:"User"}),i.jsx("dd",{children:a?.user.email||"Not signed in"}),i.jsx("dt",{children:"Network"}),i.jsx("dd",{children:tl}),i.jsx("dt",{children:"Access"}),i.jsx("dd",{children:Bo}),i.jsx("dt",{children:"Plan"}),i.jsx("dd",{children:ui}),i.jsx("dt",{children:"Ads"}),i.jsx("dd",{children:Rt==="free"?"Standard banner":"Removed"})]}),a?i.jsxs("button",{className:"account-popover-action",onClick:aa,disabled:D==="auth",type:"button",children:[i.jsx(ES,{size:16}),"Logout"]}):i.jsxs("button",{className:"account-popover-action primary",onClick:Es,disabled:D==="auth",type:"button",children:[i.jsx(Cm,{size:16}),"Sign in with Google"]})]})]})]}),i.jsxs("section",{className:`desk-stage ${_l&&!Yn?"dock-open":""} ${Ve?"control-stage":""}`,children:[i.jsxs("header",{className:"topbar",children:[i.jsxs("div",{className:"brand",children:[i.jsx("span",{className:"brand-mark",children:i.jsx(Zt,{size:18})}),i.jsxs("div",{children:[i.jsx("h1",{children:"LiveDesk"}),i.jsx("p",{children:"Control wall for local machines"})]})]}),As&&!Ve&&i.jsxs("div",{className:"file-share-top-route","aria-label":"File distribution route",children:[i.jsxs("div",{children:[i.jsx(mc,{size:17}),i.jsxs("span",{children:[i.jsx("small",{children:"Source"}),i.jsx("strong",{children:"LiveDesk Hub"})]})]}),i.jsx(Eh,{size:15}),i.jsx(RS,{size:16}),i.jsxs("div",{children:[i.jsx("span",{className:"file-share-top-route-laptops",children:"▣ ▣ ▣"}),i.jsxs("span",{children:[i.jsx("small",{children:"Destination"}),i.jsxs("strong",{children:[Fc," workstation",Fc===1?"":"s"]}),i.jsx("em",{children:mt.trim()||"Desktop/LiveDeskFiles"})]})]})]}),_l&&!Ve&&i.jsxs("div",{className:"top-actions",children:[i.jsx(Kx,{controller:Cr,onError:he}),i.jsx("span",{className:"top-actions-divider","aria-hidden":"true"}),i.jsx("div",{className:"segmented-control","aria-label":"Screen size",children:xN.map(x=>i.jsx("button",{className:Ge===x.id?"active":"",onClick:()=>ea(x.id),type:"button",children:x.label},x.id))})]}),Ve&&i.jsx("div",{className:"top-actions",children:i.jsx(Kx,{controller:Cr,onError:he})})]}),as?i.jsxs("section",{className:"doc-page",lang:gn,dir:gn==="ar"?"rtl":"ltr",children:[i.jsxs("section",{className:"doc-hero",children:[i.jsxs("div",{className:"doc-hero-copy",children:[i.jsxs("span",{className:"pricing-eyebrow",children:[i.jsx(lh,{size:16}),hn.eyebrow]}),i.jsx("h2",{children:hn.title}),i.jsx("p",{children:hn.intro})]}),i.jsxs("label",{className:"doc-language-picker",children:[i.jsxs("span",{children:[i.jsx(DS,{size:17}),hn.languageLabel]}),i.jsx("select",{value:gn,onChange:x=>kn(x.target.value),children:SN.map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),i.jsx("section",{className:"doc-grid",children:hn.sections.map((x,M)=>{const q=[Bv,pc,wc,en,bc][M]||lh;return i.jsxs("article",{className:"doc-card",children:[i.jsx("div",{className:"doc-card-icon",children:i.jsx(q,{size:19})}),i.jsxs("div",{children:[i.jsx("h3",{children:x.title}),i.jsx("p",{children:x.body}),i.jsx("ul",{children:x.points.map(B=>i.jsx("li",{children:B},B))})]})]},x.title)})}),fs&&i.jsxs("section",{className:"doc-sync",children:[i.jsxs("div",{className:"doc-sync-head",children:[i.jsx(wc,{size:20}),i.jsxs("div",{children:[i.jsx("h3",{children:fs.title}),i.jsx("p",{children:fs.body})]})]}),i.jsx("ul",{children:fs.points.map(x=>i.jsx("li",{children:x},x))})]}),i.jsxs("section",{className:"doc-firewall",children:[i.jsxs("div",{className:"doc-firewall-head",children:[i.jsx(en,{size:20}),i.jsxs("div",{children:[i.jsx("h3",{children:hn.firewall.title}),i.jsx("p",{children:hn.firewall.body})]})]}),i.jsx("ul",{children:hn.firewall.points.map(x=>i.jsx("li",{children:x},x))})]}),i.jsxs("section",{className:"doc-command-panel",children:[i.jsxs("div",{className:"doc-command-head",children:[i.jsx(pc,{size:20}),i.jsxs("div",{children:[i.jsx("h3",{children:hn.commands.title}),i.jsx("p",{children:hn.commands.body})]})]}),i.jsxs("div",{className:"doc-command-list",children:[hn.commands.manager&&i.jsxs("div",{className:"doc-command-row",children:[i.jsx("span",{children:hn.commands.manager}),i.jsx("code",{children:Qi}),i.jsx("button",{className:"icon-button",onClick:()=>ir(Qi),title:"Copy command",type:"button",children:i.jsx(Jl,{size:16})})]}),i.jsxs("div",{className:"doc-command-row",children:[i.jsx("span",{children:hn.commands.primary}),i.jsx("code",{children:cs}),i.jsx("button",{className:"icon-button",onClick:()=>ir(cs),title:"Copy command",type:"button",children:i.jsx(Jl,{size:16})})]}),i.jsxs("div",{className:"doc-command-row",children:[i.jsx("span",{children:hn.commands.slot}),i.jsx("code",{children:`${cs} 3`}),i.jsx("button",{className:"icon-button",onClick:()=>ir(`${cs} 3`),title:"Copy command",type:"button",children:i.jsx(Jl,{size:16})})]})]})]})]}):po?i.jsx(PA,{hubUrl:k,devices:C}):As?i.jsx(qk,{hubUrl:k,devices:Qe,localFeatureAccess:Wt,upgradeNotice:Qs,remoteDirectory:mt,onRemoteDirectoryChange:An,targetMode:Ri,selectedTargetIds:Ws,onTargetModeChange:Oc,onTargetToggle:x=>Dl(M=>M.includes(x)?M.filter(O=>O!==x):[...M,x]),filePickerRef:Di,folderPickerRef:Li,onBrowserFileImport:x=>{Ul(x)},onBrowserFolderImport:x=>{Ul(x)},onNotice:he,onTransferChange:x=>{if(!x){Ba(null);return}const M=x.state==="failed"||x.state==="partially-failed"||x.state==="cancelled"?"failed":x.state==="completed"?"queued":x.state==="sending"?"sending":"reading";Ba({id:x.id,status:M,progress:x.progress,message:x.message}),["completed","partially-failed","failed","cancelled"].includes(x.state)&&window.setTimeout(()=>Ba(O=>O?.id===x.id?null:O),4500)}}):br?i.jsx(sM,{session:a,currentProductKey:"livedesk",appVersion:"",onSignIn:Es}):_i?i.jsx(r1,{hubUrl:k,runtimeRole:j?.runtimeRole||"hub",runtimeDeviceId:j?.deviceId||"",sessionAccessToken:a?.access_token||"",pin:i.jsxs(o1,{children:[i.jsxs("div",{className:"settings-section-grid",children:[i.jsxs("section",{className:"settings-section-card settings-pairing-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Pair a workstation"}),i.jsx("h3",{children:"Connect another local PC"})]}),i.jsx(Jt,{size:20})]}),i.jsxs("div",{className:"settings-pin-display",children:[i.jsx("span",{children:"Hub PIN"}),i.jsx("strong",{children:Or}),i.jsxs("button",{className:"text-button ghost compact",onClick:Dr,disabled:!j?.started||D==="pin",type:"button",children:[i.jsx(Ai,{size:15}),D==="pin"?"Creating":"New PIN"]})]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Hub status"}),i.jsx("h3",{children:Ir})]}),i.jsx("span",{className:`settings-status-dot state-${Ir}`})]}),i.jsxs("dl",{className:"settings-facts",children:[i.jsx("dt",{children:"Address"}),i.jsx("dd",{children:k||"-"}),i.jsx("dt",{children:"Connected workstations"}),i.jsxs("dd",{children:[Qc,"/",Ii]}),i.jsx("dt",{children:"Sync access"}),i.jsx("dd",{children:j?.started?"Local app ready":"Start Hub first"}),i.jsx("dt",{children:"Plan"}),i.jsx("dd",{children:ui})]}),i.jsxs("div",{className:"settings-action-row",children:[i.jsxs("button",{className:"text-button primary",onClick:()=>wa({takeover:!0,requestLocalAccess:!0}),disabled:!a||D==="host",type:"button",children:[i.jsx(wc,{size:16}),"Sync access"]}),i.jsxs("button",{className:"text-button buy",onClick:()=>Ki(Rt==="ltd"?"pro":"ltd"),disabled:D==="checkout"||Rt==="pro",type:"button",children:[i.jsx(gc,{size:16}),ef]})]})]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"File transfer"}),i.jsx("h3",{children:"Client destination folder"})]}),i.jsx(Cc,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Remote folder"}),i.jsx("input",{value:mt,onChange:x=>An(x.target.value),placeholder:"Desktop/LiveDeskFiles"})]}),i.jsx("p",{className:"settings-help",children:"Blank uses Desktop/LiveDeskFiles on each workstation."})]})]}),wall:i.jsx(c1,{children:i.jsxs("div",{className:"settings-section-grid",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Wall stream"}),i.jsx("h3",{children:"Frame delivery"})]}),i.jsx(Ec,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Frame mode"}),i.jsx("select",{value:Ne.frameMode,onChange:x=>an({frameMode:Ch(x.target.value)}),children:wd.map(x=>i.jsxs("option",{value:x.id,children:[x.label," - ",x.detail]},x.id))})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"H.264 decode"}),i.jsx("select",{value:Ne.h264DecodeAcceleration,onChange:x=>an({h264DecodeAcceleration:Dd(x.target.value)}),children:jh.map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]}),i.jsxs("div",{className:"settings-field-grid",children:[i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"FPS"}),i.jsx("select",{value:Ne.fps,onChange:x=>an({fps:Ah(x.target.value,Ne.frameMode)}),children:Qh.filter(x=>x<=Ow(Ne.frameMode)).map(x=>i.jsx("option",{value:x,children:x},x))})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:at?"Atlas tile":"Resolution"}),i.jsx("select",{value:at?nu:Br,onChange:x=>at?iu(x.target.value):su(x.target.value),children:(at?Zm:bd).map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Quality"}),i.jsx("select",{value:Ne.quality,onChange:x=>an({quality:Xa(x.target.value,20,95,da.quality)}),children:ly.map(x=>i.jsx("option",{value:x,children:x},x))})]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Wall behavior"}),i.jsx("h3",{children:"Visibility and load"})]}),i.jsx(Zt,{size:20})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:Ne.autoStartLive,onChange:x=>an({autoStartLive:x.target.checked})}),i.jsx("span",{children:"Auto live on connected screens"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:Ne.visibleOnlyLive,onChange:x=>an({visibleOnlyLive:x.target.checked})}),i.jsx("span",{children:"Stream visible tiles first"})]}),!at&&i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:Ne.adaptiveSizeByWall,onChange:x=>an({adaptiveSizeByWall:x.target.checked})}),i.jsx("span",{children:"Fit stream size to Wall"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:Ne.adaptiveLoadShedding,onChange:x=>an({adaptiveLoadShedding:x.target.checked})}),i.jsx("span",{children:"Reduce FPS under load"})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:Ne.showScreenStatus,onChange:x=>an({showScreenStatus:x.target.checked})}),i.jsx("span",{children:"Screen status overlay"})]}),i.jsxs("div",{className:"settings-summary",children:[i.jsx("span",{children:di.label}),i.jsxs("strong",{children:[Pt.maxWidth,"x",Pt.maxHeight," / ",Vt,"fps"]})]}),i.jsxs("button",{className:"settings-reset",onClick:()=>Nl(da),type:"button",children:[i.jsx(jc,{size:15})," Reset Wall settings"]})]})]})}),control:i.jsx(u1,{children:i.jsxs("div",{className:"settings-section-grid",children:[i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Control stream"}),i.jsx("h3",{children:"Low-latency delivery"})]}),i.jsx(pd,{size:20})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Frame mode"}),i.jsx("select",{value:Je.frameMode,onChange:x=>Ca({frameMode:kh(x.target.value)}),children:BM.map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]}),Je.frameMode==="mode3-h264-hw"&&i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"H.264 decode"}),i.jsx("select",{value:Je.h264DecodeAcceleration,onChange:x=>Ca({h264DecodeAcceleration:Dd(x.target.value)}),children:jh.map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]}),i.jsxs("div",{className:"settings-field-grid",children:[i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"FPS"}),i.jsx("select",{value:Je.fps,onChange:x=>Ca({fps:Xa(x.target.value,20,60,fa.fps)}),children:FM.filter(x=>Je.frameMode==="mode3-h264-hw"||x<=30).map(x=>i.jsx("option",{value:x,children:x},x))})]}),i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Resolution"}),i.jsx("select",{value:au,onChange:x=>Vl(x.target.value),children:Xm.filter(x=>Je.frameMode==="mode3-h264-hw"||x.width<=1920).map(x=>i.jsx("option",{value:x.id,children:x.label},x.id))})]})]}),Je.frameMode==="mode3-h264-hw"&&i.jsxs("label",{className:"settings-field",children:[i.jsx("span",{children:"Quality"}),i.jsx("select",{value:Je.quality,onChange:x=>Ca({quality:Xa(x.target.value,20,95,fa.quality)}),children:ly.map(x=>i.jsx("option",{value:x,children:x},x))})]})]}),i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Control behavior"}),i.jsx("h3",{children:"Session display"})]}),i.jsx(Jt,{size:20})]}),i.jsxs("label",{className:"settings-toggle",children:[i.jsx("input",{type:"checkbox",checked:Je.showScreenStatus,onChange:x=>Ca({showScreenStatus:x.target.checked})}),i.jsx("span",{children:"Screen status overlay"})]}),i.jsxs("div",{className:"settings-summary control",children:[i.jsx("span",{children:Je.frameMode==="mode5-lzo-delta"?"Mode 5 tile delta":Je.frameMode==="mode2-lzo"?"Mode 2 RGB565":"Mode 3 H.264"}),i.jsxs("strong",{children:[va.maxWidth,"x",va.maxHeight," / ",ss,"fps"]})]}),i.jsxs("button",{className:"settings-reset",onClick:()=>hr(fa),type:"button",children:[i.jsx(jc,{size:15})," Reset Control settings"]})]})]})}),agent:i.jsx(d1,{hubUrl:k}),captureGallery:i.jsx(uM,{hubUrl:k,onToast:he}),advancedExtras:i.jsxs("section",{className:"settings-section-card",children:[i.jsxs("div",{className:"settings-section-heading",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Connection commands"}),i.jsx("h3",{children:"Developer setup"})]}),i.jsx(Jl,{size:20})]}),i.jsxs("div",{className:"settings-command-list",children:[i.jsxs("div",{className:"settings-command-row",children:[i.jsx("span",{children:"Client"}),i.jsx("code",{children:cs}),i.jsx("button",{className:"icon-button",onClick:()=>ir(cs),title:"Copy client command",type:"button",children:i.jsx(Jl,{size:16})})]}),i.jsxs("div",{className:"settings-command-row",children:[i.jsx("span",{children:"Slot example"}),i.jsx("code",{children:`${cs} 3`}),i.jsx("button",{className:"icon-button",onClick:()=>ir(`${cs} 3`),title:"Copy slot command",type:"button",children:i.jsx(Jl,{size:16})})]}),i.jsxs("div",{className:"settings-command-row",children:[i.jsx("span",{children:"Hub"}),i.jsx("code",{children:Qi}),i.jsx("button",{className:"icon-button",onClick:()=>ir(Qi),title:"Copy Hub command",type:"button",children:i.jsx(Jl,{size:16})})]})]})]})}):zi?i.jsxs("section",{className:"pricing-page",children:[i.jsxs("header",{className:"pricing-header",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"pricing-eyebrow",children:[i.jsx(ih,{size:15})," LiveDesk plans"]}),i.jsx("h2",{children:"Choose the plan that fits your wall"}),i.jsx("p",{children:"Start free with a local screen wall. Upgrade when you need ad-free monitoring, more workstations, or commercial controls."})]}),i.jsx("button",{className:"pricing-close",onClick:()=>nl("wall"),title:"Close pricing",type:"button",children:i.jsx(Ps,{size:18})})]}),i.jsxs("div",{className:"pricing-status","aria-live":"polite",children:[i.jsx("span",{children:"Current plan"}),i.jsx("strong",{children:$c.name}),i.jsxs("small",{children:[Qe.length,"/",OM(Sr)," connected devices"]})]}),i.jsxs("div",{className:"pricing-cards","aria-label":"LiveDesk plans",children:[i.jsxs("article",{className:`pricing-plan-card ${Rt==="free"?"current":""}`,children:[i.jsxs("div",{className:"pricing-plan-topline",children:[i.jsx("span",{className:"pricing-plan-badge free",children:"Free"}),i.jsx("strong",{children:"$0"})]}),i.jsx("p",{className:"pricing-plan-audience",children:nr.free.audience}),i.jsx("h3",{children:"Monitor your local wall"}),i.jsx("p",{children:nr.free.note}),i.jsxs("ul",{children:[i.jsxs("li",{children:[i.jsx(On,{size:16})," Up to ",vc," devices"]}),i.jsxs("li",{children:[i.jsx(On,{size:16})," Live view and local control"]}),i.jsxs("li",{children:[i.jsx(On,{size:16})," Standard ad-supported banner"]})]}),i.jsx("span",{className:"pricing-current-label",children:Rt==="free"?"Current plan":"Included for everyone"})]}),i.jsxs("article",{className:`pricing-plan-card featured ${Rt==="ltd"?"current":""}`,children:[i.jsxs("div",{className:"pricing-plan-topline",children:[i.jsxs("span",{className:"pricing-plan-badge plus",children:[i.jsx(LS,{size:14})," Plus"]}),i.jsx("strong",{children:"$5"})]}),i.jsx("p",{className:"pricing-plan-audience",children:nr.ltd.audience}),i.jsx("h3",{children:"Ad-free monitoring"}),i.jsx("p",{children:"More room for personal AI workstations without the standard banner."}),i.jsxs("ul",{children:[i.jsxs("li",{children:[i.jsx(On,{size:16})," Up to ",xc," devices"]}),i.jsxs("li",{children:[i.jsx(On,{size:16})," No standard ad banner"]}),i.jsxs("li",{children:[i.jsx(On,{size:16})," ",nr.ltd.ltd]})]}),i.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>Ki("ltd"):Es,disabled:Rt!=="free"||D==="checkout"||D==="auth"||l||U,type:"button",children:[i.jsx(gc,{size:16}),Rt==="free"?a?"Choose Plus":"Sign in for Plus":"Plus active"]})]}),i.jsxs("article",{className:`pricing-plan-card pro ${Rt==="pro"?"current":""}`,children:[i.jsxs("div",{className:"pricing-plan-topline",children:[i.jsxs("span",{className:"pricing-plan-badge pro",children:[i.jsx(en,{size:14})," Pro"]}),i.jsx("strong",{children:"$15"})]}),i.jsx("p",{className:"pricing-plan-audience",children:nr.pro.audience}),i.jsx("h3",{children:"For serious operations"}),i.jsx("p",{children:"Commercial-ready monitoring for larger AI labs, studios, and teams."}),i.jsxs("ul",{children:[i.jsxs("li",{children:[i.jsx(On,{size:16})," 30+ workstation walls"]}),i.jsxs("li",{children:[i.jsx(On,{size:16})," Commercial use included"]}),i.jsxs("li",{children:[i.jsx(On,{size:16})," ",nr.pro.ltd]})]}),i.jsxs("button",{className:"pricing-plan-button",onClick:a?()=>Ki("pro"):Es,disabled:Rt==="pro"||D==="checkout"||D==="auth"||l||U,type:"button",children:[i.jsx(gc,{size:16}),Rt==="pro"?"Pro active":a?"Choose Pro":"Sign in for Pro"]})]})]}),i.jsxs("section",{className:"pricing-includes",children:[i.jsxs("div",{children:[i.jsx(Jt,{size:17}),i.jsx("span",{children:"Screen wall"}),i.jsx("strong",{children:"120+ slots"})]}),i.jsxs("div",{children:[i.jsx(pd,{size:17}),i.jsx("span",{children:"Focused control"}),i.jsx("strong",{children:"Local-first"})]}),i.jsxs("div",{children:[i.jsx(Fv,{size:17}),i.jsx("span",{children:"Remote audio"}),i.jsx("strong",{children:"Available"})]}),i.jsxs("div",{children:[i.jsx(Cc,{size:17}),i.jsx("span",{children:"File transfer"}),i.jsx("strong",{children:"Included"})]})]}),i.jsxs("p",{className:"pricing-note",children:[i.jsx(On,{size:15})," Commercial use requires Pro. Plus LTD is for personal, creator, and homelab use."]}),i.jsxs("button",{className:"pricing-primary-cta",onClick:a?()=>Ki(Rt==="ltd"?"pro":"ltd"):Es,disabled:tu,type:"button",children:[i.jsx(gc,{size:18}),nf]})]}):i.jsx(i.Fragment,{children:i.jsxs("section",{className:`monitor-layout ${Yn?"dock-collapsed":""}`,children:[i.jsxs("section",{ref:yr,className:`screen-wall-panel ${Ti?"drop-active":""}`,onClick:x=>{x.currentTarget===x.target&&ba()},onDragEnter:x=>{x.preventDefault(),xr(!0)},onDragOver:x=>{x.preventDefault(),x.dataTransfer.dropEffect="copy"},onDragLeave:x=>{x.currentTarget===x.target&&xr(!1)},onDrop:ii,children:[at&&i.jsx("canvas",{ref:Xd,className:"atlas-source-canvas",width:Js?.width||1920,height:Js?.height||1080,"aria-hidden":"true"}),Ve?i.jsx("section",{className:"control-focus",children:i.jsxs("div",{className:"control-wall",children:[Ee&&Xi.length>1&&i.jsx("div",{className:"control-monitor-tabs","aria-label":"Select monitor",children:Xi.map(x=>i.jsxs("button",{className:x.index===li?"active":"",onClick:()=>Zd(Ee.deviceId,x.index),title:eN(x),type:"button",children:[i.jsx("span",{children:x.name||`Display ${x.index+1}`}),x.width>0&&x.height>0&&i.jsxs("small",{children:[x.width,"x",x.height]})]},x.index))}),Ee?i.jsx(sh,{device:Ee,frame:Ae,selected:!1,controlEnabled:rs&&fe,showStatus:Je.showScreenStatus,monitorIndex:Jn(kt[Ee.deviceId],Gn(Ee)),monitorCount:Gn(Ee),onSelect:()=>{},onFocusDevice:()=>K(Ee.deviceId),onOpenControl:()=>Dn(Ee.deviceId),onCycleMonitor:x=>Wi(Ee.deviceId,x),onCanvasReady:Qd,sendInput:Yi,presentationReady:js},Ee.deviceId):i.jsxs("div",{className:"control-empty",children:[i.jsx(Jt,{size:30}),i.jsx("strong",{children:"No workstation"}),i.jsx("span",{children:"Open a workstation from the Wall."})]}),Ee&&!js&&i.jsxs("div",{className:"control-connection-overlay",role:"status","aria-live":"polite",children:[P!=="error"&&i.jsx("span",{className:"control-connection-spinner","aria-hidden":"true"}),i.jsx("strong",{children:P==="error"?"Connection failed":"Connecting"}),i.jsx("small",{children:P==="error"?"See the notification for details. Reopen Control to retry.":Gi||$?"Control stream is recovering. See the notification for details.":ti==="open"?"Preparing the first control frame":"Opening the Control stream"})]})]})}):at?i.jsx("div",{className:`screen-wall atlas-slot-wall size-${Ge}`,onClick:x=>{x.currentTarget===x.target&&ba()},children:is.map((x,M)=>x?i.jsx(sh,{device:x,frame:Vi.get(x.deviceId),selected:Ks.has(x.deviceId),controlEnabled:!1,showStatus:Ne.showScreenStatus,monitorIndex:Jn(kt[x.deviceId],Gn(x)),monitorCount:Gn(x),onSelect:()=>Lr(x.deviceId),onFocusDevice:()=>ai(x.deviceId),onOpenControl:()=>Dn(x.deviceId),onCycleMonitor:O=>Wi(x.deviceId,O),onCanvasReady:Gc,sendInput:Yi,updateIndicator:Wl(x.deviceId),presentationReady:Ne.autoStartLive&&Ha.includes(x.deviceId)?za.has(x.deviceId):void 0,showPresentationSpinner:Ne.autoStartLive&&Ha.includes(x.deviceId)},x.deviceId):i.jsx(py,{index:M},`slot-${M}`))}):i.jsx("div",{className:`screen-wall size-${Ge}`,onClick:x=>{x.currentTarget===x.target&&ba()},children:is.map((x,M)=>x?i.jsx(sh,{device:x,frame:Vi.get(x.deviceId),selected:Ks.has(x.deviceId),controlEnabled:rs&&fe&&Ee?.deviceId===x.deviceId,showStatus:Ne.showScreenStatus,monitorIndex:Jn(kt[x.deviceId],Gn(x)),monitorCount:Gn(x),onSelect:()=>Lr(x.deviceId),onFocusDevice:()=>ai(x.deviceId),onOpenControl:()=>Dn(x.deviceId),onCycleMonitor:O=>Wi(x.deviceId,O),onCanvasReady:Hi,sendInput:Yi,updateIndicator:Wl(x.deviceId),presentationReady:Ne.autoStartLive&&Ha.includes(x.deviceId)?za.has(x.deviceId):void 0,showPresentationSpinner:Ne.autoStartLive&&Ha.includes(x.deviceId)},x.deviceId):i.jsx(py,{index:M},`slot-${M}`))}),i.jsx(CN,{visible:Yd&&!Ve})]}),!_i&&i.jsxs("aside",{className:`right-dock actions-mode ${Yn?"collapsed":""}`,"aria-label":"LiveDesk tools",children:[i.jsx("button",{className:"dock-toggle",onClick:()=>Ml(x=>!x),"aria-label":Yn?"Show control panel":"Hide control panel",title:Yn?"Show control panel":"Hide control panel",type:"button",children:Yn?i.jsx(jy,{size:18}):i.jsx(Rh,{size:18})}),!Yn&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"action-dock",children:[i.jsxs("div",{className:"action-context",children:[i.jsx("span",{children:Ve?"Control target":zs>0?"Selection":"No selection"}),i.jsx("strong",{children:Gl})]}),i.jsx("input",{ref:wr,className:"hidden-file-input",type:"file",multiple:!0,onChange:x=>{x.currentTarget.files&&To(x.currentTarget.files),x.currentTarget.value=""}}),i.jsxs("div",{className:"action-grid",children:[i.jsxs("button",{className:"action-tile primary",onClick:()=>Ee&&si(Ee.deviceId),disabled:!Uc,type:"button",children:[i.jsx(Hv,{size:21}),i.jsx("span",{children:"Live"})]}),i.jsxs("button",{className:`action-tile ${fe?"active":""}`,onClick:()=>Te(x=>!x),disabled:!rs,title:Pc?"Allow Accessibility for the terminal app that starts LiveDesk, then restart the Mac client.":rs?"Remote keyboard and mouse control":"Remote control is not available on this workstation",type:"button",children:[i.jsx(pd,{size:21}),i.jsx("span",{children:Pl!=="idle"?Pl:"Control"})]}),i.jsxs("button",{className:`action-tile ${Ie?"active":""}`,onClick:No,disabled:!qc,type:"button",title:zl?"Remote PC audio":"Remote audio is not supported by this workstation yet",children:[i.jsx(Fv,{size:21}),i.jsx("span",{children:Ie&&Co!=="idle"?Co:"Audio"})]}),i.jsxs("button",{className:"action-tile",onClick:()=>wr.current?.click(),disabled:!Wt||(Ve?!Ee:xa.length===0),type:"button",title:"File transfer",children:[i.jsx(Cc,{size:21}),i.jsx("span",{children:"Files"})]}),i.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Reboot",children:[i.jsx(jc,{size:21}),i.jsx("span",{children:"Reboot"})]}),i.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Power",children:[i.jsx(_S,{size:21}),i.jsx("span",{children:"Power"})]}),i.jsxs("button",{className:"action-tile",disabled:!0,type:"button",title:"Terminal",children:[i.jsx(pc,{size:21}),i.jsx("span",{children:"Shell"})]})]})]}),Ee&&Fa&&i.jsxs("section",{className:"side-panel selected-panel",children:[i.jsxs("div",{className:"machine-detail-head",children:[i.jsxs("div",{className:"panel-title",children:[i.jsx(Jt,{size:17}),i.jsx("h2",{children:"Machine detail"})]}),i.jsx("span",{className:`machine-health state-${Fa.state}`,children:Fa.label})]}),i.jsxs("div",{className:"machine-title",children:[i.jsx("strong",{children:rr(Ee)}),i.jsx("span",{children:Fa.role})]}),i.jsx("div",{className:"machine-metric-grid",children:Fa.metrics.map(x=>i.jsxs("article",{className:`machine-metric state-${x.state}`,children:[i.jsx("span",{children:x.label}),i.jsx("strong",{children:x.value}),i.jsx("small",{children:x.detail}),x.ratio!==void 0&&i.jsx("i",{children:i.jsx("b",{style:{width:`${Math.round(x.ratio*100)}%`}})})]},x.id))}),i.jsxs("section",{className:"machine-section",children:[i.jsxs("div",{className:"machine-section-title",children:[i.jsx(Zt,{size:15}),i.jsx("span",{children:"Stream"})]}),i.jsxs("dl",{className:"facts compact",children:[i.jsx("dt",{children:"Frames"}),i.jsx("dd",{children:Xc}),i.jsx("dt",{children:Ve?"Control RX":at?"Atlas RX":"Wall RX"}),i.jsx("dd",{children:$t}),i.jsx("dt",{children:"Painted"}),i.jsx("dd",{children:fn}),i.jsx("dt",{children:Ve?"Encoded changes":"Visual samples"}),i.jsx("dd",{children:Nt}),i.jsx("dt",{children:"Decoder"}),i.jsx("dd",{children:lt}),i.jsx("dt",{children:"Decoder IO"}),i.jsx("dd",{children:Ro}),i.jsx("dt",{children:"Canvas"}),i.jsx("dd",{children:Ls}),i.jsx("dt",{children:"Control buffer"}),i.jsx("dd",{children:Zc}),i.jsx("dt",{children:"Browser RAF"}),i.jsx("dd",{children:Jc}),i.jsx("dt",{children:"Latency"}),i.jsx("dd",{children:Ds}),i.jsx("dt",{children:"Cadence"}),i.jsx("dd",{children:ia}),i.jsx("dt",{children:"Source send"}),i.jsx("dd",{children:ri}),i.jsx("dt",{children:"Packet mix"}),i.jsx("dd",{children:Zi}),i.jsx("dt",{children:"Receive gap"}),i.jsx("dd",{children:Do}),i.jsx("dt",{children:"Paint gap"}),i.jsx("dd",{children:ql}),i.jsx("dt",{children:"Seq gap"}),i.jsx("dd",{children:Lo}),i.jsx("dt",{children:"Selected"}),i.jsx("dd",{children:zr}),i.jsx("dt",{children:"Requested"}),i.jsx("dd",{children:_s}),i.jsx("dt",{children:"Mode"}),i.jsx("dd",{children:us}),i.jsx("dt",{children:"Chunk"}),i.jsx("dd",{children:_o}),i.jsx("dt",{children:"Size"}),i.jsx("dd",{children:ds}),i.jsx("dt",{children:"Native"}),i.jsx("dd",{children:Va}),i.jsx("dt",{children:"Monitor"}),i.jsx("dd",{children:zo}),i.jsx("dt",{children:"Source"}),i.jsx("dd",{children:Ji}),i.jsx("dt",{children:"Input"}),i.jsx("dd",{children:_r}),i.jsx("dt",{children:"Audio"}),i.jsx("dd",{children:mn}),Ve&&i.jsxs(i.Fragment,{children:[i.jsx("dt",{children:"Visual feedback"}),i.jsx("dd",{children:oi})]})]})]}),i.jsxs("section",{className:"machine-section",children:[i.jsxs("div",{className:"machine-section-title",children:[i.jsx(pc,{size:15}),i.jsx("span",{children:"Local services"})]}),i.jsx("div",{className:"tool-probe-list",children:Fa.tools.map(x=>i.jsxs("span",{className:`tool-probe state-${x.status}`,children:[i.jsx("b",{children:x.label}),i.jsx("em",{children:x.detail})]},x.id))})]}),i.jsxs("section",{className:"machine-section",children:[i.jsxs("div",{className:"machine-section-title",children:[i.jsx(ro,{size:15}),i.jsx("span",{children:"Workload"})]}),i.jsxs("div",{className:"workload-card",children:[i.jsx("strong",{children:Fa.taskLabel}),i.jsx("span",{children:Fa.taskStatus}),Fa.taskSummary&&i.jsx("p",{children:Fa.taskSummary})]})]}),i.jsxs("div",{className:"machine-section",children:[i.jsxs("div",{className:"machine-section-title",children:[i.jsx(Bv,{size:15}),i.jsx("span",{children:"System"})]}),i.jsxs("dl",{className:"facts compact",children:[i.jsx("dt",{children:"Platform"}),i.jsxs("dd",{children:[Ee.platform||"-"," ",Ee.arch||""]}),i.jsx("dt",{children:"Release"}),i.jsx("dd",{children:ma(Ee.status,"release")||"-"}),i.jsx("dt",{children:"Uptime"}),i.jsx("dd",{children:Pw(Ot(Ee.status,"uptimeSec"))}),i.jsx("dt",{children:"Last seen"}),i.jsx("dd",{children:rh(Ee.lastSeenAt||Ee.connectedAt)}),i.jsx("dt",{children:"Agent"}),i.jsx("dd",{children:Ee.agentVersion||"-"}),i.jsx("dt",{children:"Address"}),i.jsx("dd",{children:Ee.remoteAddress||"-"})]})]}),i.jsxs("button",{className:"text-button full",onClick:()=>Ee&&si(Ee.deviceId),disabled:!Uc,type:"button",children:[i.jsx(Hv,{size:16}),"Start live"]})]})]})]})]})})]}),ks&&i.jsxs("aside",{className:`transfer-bar state-${ks.status}`,"aria-live":"polite",children:[i.jsx("span",{className:"transfer-bar-icon","aria-hidden":"true",children:ks.status==="queued"?i.jsx(On,{size:18}):ks.status==="failed"?i.jsx(Ps,{size:18}):i.jsx(vy,{size:18})}),i.jsxs("div",{className:"transfer-bar-copy",children:[i.jsx("p",{children:ks.message}),i.jsx("div",{className:"transfer-bar-track",children:i.jsx("span",{style:{width:`${Math.max(0,Math.min(100,ks.progress))}%`}})})]}),i.jsxs("strong",{children:[Math.max(0,Math.min(100,ks.progress)),"%"]})]}),ce&&i.jsxs("aside",{className:"livedesk-toast",role:"alert","aria-live":"assertive",children:[i.jsx("span",{children:ce.message}),i.jsx("button",{className:"livedesk-toast-close",onClick:()=>he(""),type:"button","aria-label":"Dismiss notification",title:"Dismiss notification",children:i.jsx(Ps,{size:15})})]})]})}function AN(){if(typeof window>"u")return[];const n=window.location.origin;return window.location.port==="5198"||window.location.port==="5179"?[n]:["http://127.0.0.1:5198","http://127.0.0.1:5179"]}function MN(){const n="".trim().toLowerCase(),a=n==="hub"?"hub":"client",[l,r]=f.useState(a);return f.useEffect(()=>{if(n==="client"||n==="hub")return;let c=!1;return(async()=>{for(const m of AN())try{const p=await fetch(`${m}/api/runtime`,{cache:"no-store"});if(!p.ok)continue;const g=(await p.json()).role==="client"?"client":"hub";c||r(g);return}catch{}})(),()=>{c=!0}},[n]),l==="client"?i.jsx(JS,{}):i.jsx(kN,{})}$S.createRoot(document.getElementById("root")).render(i.jsx(f.StrictMode,{children:i.jsx(MN,{})}));