From 84c990e5122af8a671cd508a2a197cbbb8663df0 Mon Sep 17 00:00:00 2001 From: BOB450 Date: Fri, 14 Aug 2026 23:39:30 -0600 Subject: [PATCH] Update admin_ecma.cpp Chart duplicates now truncate titles safely to the 80-character limit(To fix issue when copying a plot) Invalid chart layouts cannot overwrite valid persisted layouts. --- console/embedded/admin_ecma.cpp | 114 ++++++++++++++++---------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/console/embedded/admin_ecma.cpp b/console/embedded/admin_ecma.cpp index 75f7d90a..470fddf6 100644 --- a/console/embedded/admin_ecma.cpp +++ b/console/embedded/admin_ecma.cpp @@ -23,9 +23,9 @@ namespace server { // Simple test ecma script for embedded page. DEFINE_EMBEDDED_PAGE(admin_pages, char, ecma, -R"DELIM((function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))s(c);new MutationObserver(c=>{for(const d of c)if(d.type==="childList")for(const f of d.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&s(f)}).observe(document,{childList:!0,subtree:!0});function u(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function s(c){if(c.ep)return;c.ep=!0;const d=u(c);fetch(c.href,d)}})();function Xv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Zd={exports:{}},_r={};var s0;function eS(){if(s0)return _r;s0=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function u(s,c,d){var f=null;if(d!==void 0&&(f=""+d),c.key!==void 0&&(f=""+c.key),"key"in c){d={};for(var p in c)p!=="key"&&(d[p]=c[p])}else d=c;return c=d.ref,{$$typeof:n,type:s,key:f,ref:c!==void 0?c:null,props:d}}return _r.Fragment=a,_r.jsx=u,_r.jsxs=u,_r}var r0;function tS(){return r0||(r0=1,Zd.exports=eS()),Zd.exports}var z=tS(),Ld={exports:{}},Re={};var c0;function nS(){if(c0)return Re;c0=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),T=Symbol.iterator;function w(A){return A===null||typeof A!="object"?null:(A=T&&A[T]||A["@@iterator"],typeof A=="function"?A:null)}var O={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Y=Object.assign,W={};function F(A,L,G){this.props=A,this.context=L,this.refs=W,this.updater=G||O}F.prototype.isReactComponent={},F.prototype.setState=function(A,L){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,L,"setState")},F.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function B(){}B.prototype=F.prototype;function I(A,L,G){this.props=A,this.context=L,this.refs=W,this.updater=G||O}var q=I.prototype=new B;q.constructor=I,Y(q,F.prototype),q.isPureReactComponent=!0;var ae=Array.isArray;function ne(){}var le={H:null,A:null,T:null,S:null},se=Object.prototype.hasOwnProperty;function Ae(A,L,G){var ie=G.ref;return{$$typeof:n,type:A,key:L,ref:ie!==void 0?ie:null,props:G}}function ze(A,L){return Ae(A.type,L,A.props)}function ee(A){return typeof A=="object"&&A!==null&&A.$$typeof===n}function ye(A){var L={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(G){return L[G]})}var ce=/\/+/g;function Ee(A,L){return typeof A=="object"&&A!==null&&A.key!=null?ye(""+A.key):L.toString(36)}function de(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(ne,ne):(A.status="pending",A.then(function(L){A.status==="pending"&&(A.status="fulfilled",A.value=L)},function(L){A.status==="pending"&&(A.status="rejected",A.reason=L)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function U(A,L,G,ie,xe){var pe=typeof A;(pe==="undefined"||pe==="boolean")&&(A=null);var ge=!1;if(A===null)ge=!0;else switch(pe){case"bigint":case"string":case"number":ge=!0;break;case"object":switch(A.$$typeof){case n:case a:ge=!0;break;case x:return ge=A._init,U(ge(A._payload),L,G,ie,xe)}}if(ge)return xe=xe(A),ge=ie===""?"."+Ee(A,0):ie,ae(xe)?(G="",ge!=null&&(G=ge.replace(ce,"$&/")+"/"),U(xe,L,G,"",function(nt){return nt})):xe!=null&&(ee(xe)&&(xe=ze(xe,G+(xe.key==null||A&&A.key===xe.key?"":(""+xe.key).replace(ce,"$&/")+"/")+ge)),L.push(xe)),1;ge=0;var mt=ie===""?".":ie+":";if(ae(A))for(var Qe=0;Qe>>1,be=U[Oe];if(0>>1;Oec(G,me))iec(xe,G)?(U[Oe]=xe,U[ie]=me,Oe=ie):(U[Oe]=G,U[L]=me,Oe=L);else if(iec(xe,me))U[Oe]=xe,U[ie]=me,Oe=ie;else break e}}return Q}function c(U,Q){var me=U.sortIndex-Q.sortIndex;return me!==0?me:U.id-Q.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var g=[],v=[],x=1,S=null,T=3,w=!1,O=!1,Y=!1,W=!1,F=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function q(U){for(var Q=u(v);Q!==null;){if(Q.callback===null)s(v);else if(Q.startTime<=U)s(v),Q.sortIndex=Q.expirationTime,a(g,Q);else break;Q=u(v)}}function ae(U){if(Y=!1,q(U),!O)if(u(g)!==null)O=!0,ne||(ne=!0,ye());else{var Q=u(v);Q!==null&&de(ae,Q.startTime-U)}}var ne=!1,le=-1,se=5,Ae=-1;function ze(){return W?!0:!(n.unstable_now()-AeU&&ze());){var Oe=S.callback;if(typeof Oe=="function"){S.callback=null,T=S.priorityLevel;var be=Oe(S.expirationTime<=U);if(U=n.unstable_now(),typeof be=="function"){S.callback=be,q(U),Q=!0;break t}S===u(g)&&s(g),q(U)}else s(g);S=u(g)}if(S!==null)Q=!0;else{var A=u(v);A!==null&&de(ae,A.startTime-U),Q=!1}}break e}finally{S=null,T=me,w=!1}Q=void 0}}finally{Q?ye():ne=!1}}}var ye;if(typeof I=="function")ye=function(){I(ee)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,Ee=ce.port2;ce.port1.onmessage=ee,ye=function(){Ee.postMessage(null)}}else ye=function(){F(ee,0)};function de(U,Q){le=F(function(){U(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(U){U.callback=null},n.unstable_forceFrameRate=function(U){0>U||125Oe?(U.sortIndex=me,a(v,U),u(g)===null&&U===u(v)&&(Y?(B(le),le=-1):Y=!0,de(ae,me-Oe))):(U.sortIndex=be,a(g,U),O||w||(O=!0,ne||(ne=!0,ye()))),U},n.unstable_shouldYield=ze,n.unstable_wrapCallback=function(U){var Q=T;return function(){var me=T;T=Q;try{return U.apply(this,arguments)}finally{T=me}}}})(qd)),qd}var d0;function iS(){return d0||(d0=1,Bd.exports=aS()),Bd.exports}var Gd={exports:{}},On={};var h0;function uS(){if(h0)return On;h0=1;var n=xh();function a(g){var v="https://react.dev/errors/"+g;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Gd.exports=uS(),Gd.exports}var p0;function rS(){if(p0)return xr;p0=1;var n=iS(),a=xh(),u=sS();function s(e){var t="https://react.dev/errors/"+e;if(1be||(e.current=Oe[be],Oe[be]=null,be--)}function G(e,t){be++,Oe[be]=e.current,e.current=t}var ie=A(null),xe=A(null),pe=A(null),ge=A(null);function mt(e,t){switch(G(pe,t),G(xe,e),G(ie,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Ng(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Ng(t),e=jg(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}L(ie),G(ie,e)}function Qe(){L(ie),L(xe),L(pe)}function nt(e){e.memoizedState!==null&&G(ge,e);var t=ie.current,l=jg(t,e.type);t!==l&&(G(xe,e),G(ie,l))}function Nn(e){xe.current===e&&(L(ie),L(xe)),ge.current===e&&(L(ge),vr._currentValue=me)}var Pn,jn;function xn(e){if(Pn===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Pn=t&&t[1]||"",jn=-1{for(const d of c)if(d.type==="childList")for(const f of d.addedNodes)f.tagName==="LINK"&&f.rel==="modulepreload"&&s(f)}).observe(document,{childList:!0,subtree:!0});function u(c){const d={};return c.integrity&&(d.integrity=c.integrity),c.referrerPolicy&&(d.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?d.credentials="include":c.crossOrigin==="anonymous"?d.credentials="omit":d.credentials="same-origin",d}function s(c){if(c.ep)return;c.ep=!0;const d=u(c);fetch(c.href,d)}})();function Fv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Zd={exports:{}},_r={};var c0;function lS(){if(c0)return _r;c0=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function u(s,c,d){var f=null;if(d!==void 0&&(f=""+d),c.key!==void 0&&(f=""+c.key),"key"in c){d={};for(var p in c)p!=="key"&&(d[p]=c[p])}else d=c;return c=d.ref,{$$typeof:n,type:s,key:f,ref:c!==void 0?c:null,props:d}}return _r.Fragment=a,_r.jsx=u,_r.jsxs=u,_r}var o0;function aS(){return o0||(o0=1,Zd.exports=lS()),Zd.exports}var z=aS(),Ld={exports:{}},Re={};var f0;function iS(){if(f0)return Re;f0=1;var n=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),d=Symbol.for("react.consumer"),f=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),S=Symbol.for("react.activity"),T=Symbol.iterator;function w(A){return A===null||typeof A!="object"?null:(A=T&&A[T]||A["@@iterator"],typeof A=="function"?A:null)}var O={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Y=Object.assign,W={};function F(A,L,G){this.props=A,this.context=L,this.refs=W,this.updater=G||O}F.prototype.isReactComponent={},F.prototype.setState=function(A,L){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,L,"setState")},F.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function B(){}B.prototype=F.prototype;function I(A,L,G){this.props=A,this.context=L,this.refs=W,this.updater=G||O}var q=I.prototype=new B;q.constructor=I,Y(q,F.prototype),q.isPureReactComponent=!0;var ae=Array.isArray;function ne(){}var le={H:null,A:null,T:null,S:null},se=Object.prototype.hasOwnProperty;function Ae(A,L,G){var ie=G.ref;return{$$typeof:n,type:A,key:L,ref:ie!==void 0?ie:null,props:G}}function ze(A,L){return Ae(A.type,L,A.props)}function ee(A){return typeof A=="object"&&A!==null&&A.$$typeof===n}function ye(A){var L={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(G){return L[G]})}var ce=/\/+/g;function Ee(A,L){return typeof A=="object"&&A!==null&&A.key!=null?ye(""+A.key):L.toString(36)}function de(A){switch(A.status){case"fulfilled":return A.value;case"rejected":throw A.reason;default:switch(typeof A.status=="string"?A.then(ne,ne):(A.status="pending",A.then(function(L){A.status==="pending"&&(A.status="fulfilled",A.value=L)},function(L){A.status==="pending"&&(A.status="rejected",A.reason=L)})),A.status){case"fulfilled":return A.value;case"rejected":throw A.reason}}throw A}function U(A,L,G,ie,xe){var pe=typeof A;(pe==="undefined"||pe==="boolean")&&(A=null);var ge=!1;if(A===null)ge=!0;else switch(pe){case"bigint":case"string":case"number":ge=!0;break;case"object":switch(A.$$typeof){case n:case a:ge=!0;break;case x:return ge=A._init,U(ge(A._payload),L,G,ie,xe)}}if(ge)return xe=xe(A),ge=ie===""?"."+Ee(A,0):ie,ae(xe)?(G="",ge!=null&&(G=ge.replace(ce,"$&/")+"/"),U(xe,L,G,"",function(nt){return nt})):xe!=null&&(ee(xe)&&(xe=ze(xe,G+(xe.key==null||A&&A.key===xe.key?"":(""+xe.key).replace(ce,"$&/")+"/")+ge)),L.push(xe)),1;ge=0;var mt=ie===""?".":ie+":";if(ae(A))for(var Qe=0;Qe>>1,be=U[Oe];if(0>>1;Oec(G,me))iec(xe,G)?(U[Oe]=xe,U[ie]=me,Oe=ie):(U[Oe]=G,U[L]=me,Oe=L);else if(iec(xe,me))U[Oe]=xe,U[ie]=me,Oe=ie;else break e}}return Q}function c(U,Q){var me=U.sortIndex-Q.sortIndex;return me!==0?me:U.id-Q.id}if(n.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var d=performance;n.unstable_now=function(){return d.now()}}else{var f=Date,p=f.now();n.unstable_now=function(){return f.now()-p}}var g=[],v=[],x=1,S=null,T=3,w=!1,O=!1,Y=!1,W=!1,F=typeof setTimeout=="function"?setTimeout:null,B=typeof clearTimeout=="function"?clearTimeout:null,I=typeof setImmediate<"u"?setImmediate:null;function q(U){for(var Q=u(v);Q!==null;){if(Q.callback===null)s(v);else if(Q.startTime<=U)s(v),Q.sortIndex=Q.expirationTime,a(g,Q);else break;Q=u(v)}}function ae(U){if(Y=!1,q(U),!O)if(u(g)!==null)O=!0,ne||(ne=!0,ye());else{var Q=u(v);Q!==null&&de(ae,Q.startTime-U)}}var ne=!1,le=-1,se=5,Ae=-1;function ze(){return W?!0:!(n.unstable_now()-AeU&&ze());){var Oe=S.callback;if(typeof Oe=="function"){S.callback=null,T=S.priorityLevel;var be=Oe(S.expirationTime<=U);if(U=n.unstable_now(),typeof be=="function"){S.callback=be,q(U),Q=!0;break t}S===u(g)&&s(g),q(U)}else s(g);S=u(g)}if(S!==null)Q=!0;else{var A=u(v);A!==null&&de(ae,A.startTime-U),Q=!1}}break e}finally{S=null,T=me,w=!1}Q=void 0}}finally{Q?ye():ne=!1}}}var ye;if(typeof I=="function")ye=function(){I(ee)};else if(typeof MessageChannel<"u"){var ce=new MessageChannel,Ee=ce.port2;ce.port1.onmessage=ee,ye=function(){Ee.postMessage(null)}}else ye=function(){F(ee,0)};function de(U,Q){le=F(function(){U(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(U){U.callback=null},n.unstable_forceFrameRate=function(U){0>U||125Oe?(U.sortIndex=me,a(v,U),u(g)===null&&U===u(v)&&(Y?(B(le),le=-1):Y=!0,de(ae,me-Oe))):(U.sortIndex=be,a(g,U),O||w||(O=!0,ne||(ne=!0,ye()))),U},n.unstable_shouldYield=ze,n.unstable_wrapCallback=function(U){var Q=T;return function(){var me=T;T=Q;try{return U.apply(this,arguments)}finally{T=me}}}})(qd)),qd}var m0;function rS(){return m0||(m0=1,Bd.exports=sS()),Bd.exports}var Gd={exports:{}},On={};var p0;function cS(){if(p0)return On;p0=1;var n=xh();function a(g){var v="https://react.dev/errors/"+g;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Gd.exports=cS(),Gd.exports}var v0;function fS(){if(v0)return xr;v0=1;var n=rS(),a=xh(),u=oS();function s(e){var t="https://react.dev/errors/"+e;if(1be||(e.current=Oe[be],Oe[be]=null,be--)}function G(e,t){be++,Oe[be]=e.current,e.current=t}var ie=A(null),xe=A(null),pe=A(null),ge=A(null);function mt(e,t){switch(G(pe,t),G(xe,e),G(ie,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Dg(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Dg(t),e=Cg(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}L(ie),G(ie,e)}function Qe(){L(ie),L(xe),L(pe)}function nt(e){e.memoizedState!==null&&G(ge,e);var t=ie.current,l=Cg(t,e.type);t!==l&&(G(xe,e),G(ie,l))}function Nn(e){xe.current===e&&(L(ie),L(xe)),ge.current===e&&(L(ge),vr._currentValue=me)}var Pn,jn;function xn(e){if(Pn===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);Pn=t&&t[1]||"",jn=-1)":-1")&&($=$.replace("",e.displayName)),$}while(1<=i&&0<=r);break}}}finally{Yl=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?xn(l):""}function Ni(e,t){switch(e.tag){case 26:case 27:case 5:return xn(e.type);case 16:return xn("Lazy");case 13:return e.child!==t&&t!==null?xn("Suspense Fallback"):xn("Suspense");case 19:return xn("SuspenseList");case 0:case 15:return $l(e.type,!1);case 11:return $l(e.type.render,!1);case 1:return $l(e.type,!0);case 31:return xn("Activity");default:return""}}function ji(e){try{var t="",l=null;do t+=Ni(e,l),l=e,e=e.return;while(e);return t}catch(i){return` Error generating stack: `+i.message+` `+i.stack}}var Nl=Object.prototype.hasOwnProperty,Ft=n.unstable_scheduleCallback,Vl=n.unstable_cancelCallback,jl=n.unstable_shouldYield,sa=n.unstable_requestPaint,Te=n.unstable_now,oe=n.unstable_getCurrentPriorityLevel,lt=n.unstable_ImmediatePriority,Nt=n.unstable_UserBlockingPriority,Dl=n.unstable_NormalPriority,ra=n.unstable_LowPriority,el=n.unstable_IdlePriority,ca=n.log,Dn=n.unstable_setDisableYieldValue,nn=null,rt=null;function Qt(e){if(typeof ca=="function"&&Dn(e),rt&&typeof rt.setStrictMode=="function")try{rt.setStrictMode(nn,e)}catch{}}var on=Math.clz32?Math.clz32:oa,vu=Math.log,Ba=Math.LN2;function oa(e){return e>>>=0,e===0?32:31-(vu(e)/Ba|0)|0}var fa=256,fn=262144,qa=4194304;function Kl(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 8)DELIM" -R"DELIM(192: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 yu(e,t,l){var i=e.pendingLanes;if(i===0)return 0;var r=0,o=e.suspendedLanes,h=e.pingedLanes;e=e.warmLanes;var b=i&134217727;return b!==0?(i=b&~o,i!==0?r=Kl(i):(h&=b,h!==0?r=Kl(h):l||(l=b&~e,l!==0&&(r=Kl(l))))):(b=i&~o,b!==0?r=Kl(b):h!==0?r=Kl(h):l||(l=i&~e,l!==0&&(r=Kl(l)))),r===0?0:t!==0&&t!==r&&(t&o)===0&&(o=r&-r,l=t&-t,o>=l||o===32&&(l&4194048)!==0)?t:r}function Di(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function qo(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 Br(){var e=qa;return qa<<=1,(qa&62914560)===0&&(qa=4194304),e}function zs(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function tl(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ln(e,t,l,i,r,o){var h=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var b=e.entanglements,M=e.expirationTimes,k=e.hiddenUpdates;for(l=h&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Go=/[\n"\\]/g;function Rn(e){return e.replace(Go,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Eu(e,t,l,i,r,o,h,b){e.name="",h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?e.type=h:e.removeAttribute("type"),t!=null?h==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Cn(t)):e.value!==""+Cn(t)&&(e.value=""+Cn(t)):h!=="submit"&&h!=="reset"||e.removeAttribute("value"),t!=null?Tu(e,h,Cn(t)):l!=null?Tu(e,h,Cn(l)):i!=null&&e.removeAttribute("value"),r==null&&o!=null&&(e.defaultChecked=!!o),r!=null&&(e.checked=r&&typeof r!="function"&&typeof r!="symbol"),b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.name=""+Cn(b):e.removeAttribute("name")}function Qr(e,t,l,i,r,o,h,b){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||l!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){xu(e);return}l=l!=null?""+Cn(l):"",t=t!=null?""+Cn(t):l,b||t===e.value||(e.value=t),e.defaultValue=t}i=i??r,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=b?e.checked:!!i,e.defaultChecked=!!i,h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.name=h),xu(e)}function Tu(e,t,l){t==="number"&&zu(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Fl(e,t,l,i){if(e=e.options,t){t={};for(var r=0;r=l||o===32&&(l&4194048)!==0)?t:r}function Di(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function qo(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 Br(){var e=qa;return qa<<=1,(qa&62914560)===0&&(qa=4194304),e}function zs(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function tl(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ln(e,t,l,i,r,o){var h=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var b=e.entanglements,M=e.expirationTimes,k=e.hiddenUpdates;for(l=h&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Go=/[\n"\\]/g;function Rn(e){return e.replace(Go,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Eu(e,t,l,i,r,o,h,b){e.name="",h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?e.type=h:e.removeAttribute("type"),t!=null?h==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Cn(t)):e.value!==""+Cn(t)&&(e.value=""+Cn(t)):h!=="submit"&&h!=="reset"||e.removeAttribute("value"),t!=null?Tu(e,h,Cn(t)):l!=null?Tu(e,h,Cn(l)):i!=null&&e.removeAttribute("value"),r==null&&o!=null&&(e.defaultChecked=!!o),r!=null&&(e.checked=r&&typeof r!="function"&&typeof r!="symbol"),b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"?e.name=""+Cn(b):e.removeAttribute("name")}function Qr(e,t,l,i,r,o,h,b){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||l!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){xu(e);return}l=l!=null?""+Cn(l):"",t=t!=null?""+Cn(t):l,b||t===e.value||(e.value=t),e.defaultValue=t}i=i??r,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=b?e.checked:!!i,e.defaultChecked=!!i,h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"&&(e.name=h),xu(e)}function Tu(e,t,l){t==="number"&&zu(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Fl(e,t,l,i){if(e=e.options,t){t={};for(var r=0;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ou=!1;if(Tn)try{var Xa={};Object.defineProperty(Xa,"passive",{get:function(){Ou=!0}}),window.addEventListener("test",Xa,Xa),window.removeEventListener("test",Xa,Xa)}catch{Ou=!1}var kn=null,Il=null,Li=null;function Cs(){if(Li)return Li;var e,t=Il,l=t.length,i,r="value"in kn?kn.value:kn.textContent,o=r.length;for(e=0;e=Ia),qs=" ",ya=!1;function Gi(e,t){switch(e){case"keyup":return ec.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ht(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ba=!1;function Dt(e,t){switch(e){case"compositionend":return Ht(t);case"keypress":return t.which!==32?null:(ya=!0,qs);case"textInput":return e=t.data,e===qs&&ya?null:e;default:return null}}function tc(e,t){if(ba)return e==="compositionend"||!Nu&&Gi(e,t)?(e=Cs(),Li=Il=kn=null,ba=!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)return{node:l,offset:t-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Ne(l)}}function ct(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ct(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function St(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zu(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=zu(e.document)}return t}function Ct(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 et=Tn&&"documentMode"in document&&11>=document.documentMode,it=null,hn=null,Bt=null,wn=!1;function Yn(e,t,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;wn||it==null||it!==zu(i)||(i=it,"selectionStart"in i&&Ct(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Bt&&Ue(Bt,i)||(Bt=i,i=$c(hn,"onSelect"),0>=h,r-=h,ta=1<<32-on(t)+r|l<Ze?(qe=ve,ve=null):qe=ve.sibling;var Xe=Z(D,ve,R[Ze],K);if(Xe===null){ve===null&&(ve=qe);break}e&&ve&&Xe.alternate===null&&t(D,ve),j=o(Xe,j,Ze),Ke===null?we=Xe:Ke.sibling=Xe,Ke=Xe,ve=qe}if(Ze===R.leng)DELIM" -R"DELIM(th)return l(D,ve),Ye&&xa(D,Ze),we;if(ve===null){for(;ZeZe?(qe=ve,ve=null):qe=ve.sibling;var _i=Z(D,ve,Xe.value,K);if(_i===null){ve===null&&(ve=qe);break}e&&ve&&_i.alternate===null&&t(D,ve),j=o(_i,j,Ze),Ke===null?we=_i:Ke.sibling=_i,Ke=_i,ve=qe}if(Xe.done)return l(D,ve),Ye&&xa(D,Ze),we;if(ve===null){for(;!Xe.done;Ze++,Xe=R.next())Xe=J(D,Xe.value,K),Xe!==null&&(j=o(Xe,j,Ze),Ke===null?we=Xe:Ke.sibling=Xe,Ke=Xe);return Ye&&xa(D,Ze),we}for(ve=i(ve);!Xe.done;Ze++,Xe=R.next())Xe=H(ve,D,Ze,Xe.value,K),Xe!==null&&(e&&Xe.alternate!==null&&ve.delete(Xe.key===null?Ze:Xe.key),j=o(Xe,j,Ze),Ke===null?we=Xe:Ke.sibling=Xe,Ke=Xe);return e&&ve.forEach(function(P1){return t(D,P1)}),Ye&&xa(D,Ze),we}function dt(D,j,R,K){if(typeof R=="object"&&R!==null&&R.type===Y&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case w:e:{for(var we=R.key;j!==null;){if(j.key===we){if(we=R.type,we===Y){if(j.tag===7){l(D,j.sibling),K=r(j,R.props.children),K.return=D,D=K;break e}}else if(j.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===se&&Fi(we)===j.type){l(D,j.sibling),K=r(j,R.props),Xs(K,R),K.return=D,D=K;break e}l(D,j);break}else t(D,j);j=j.sibling}R.type===Y?(K=$i(R.props.children,D.mode,K,R.key),K.return=D,D=K):(K=rc(R.type,R.key,R.props,null,D.mode,K),Xs(K,R),K.return=D,D=K)}return h(D);case O:e:{for(we=R.key;j!==null;){if(j.key===we)if(j.tag===4&&j.stateNode.containerInfo===R.containerInfo&&j.stateNode.implementation===R.implementation){l(D,j.sibling),K=r(j,R.children||[]),K.return=D,D=K;break e}else{l(D,j);break}else t(D,j);j=j.sibling}K=ef(R,D.mode,K),K.return=D,D=K}return h(D);case se:return R=Fi(R),dt(D,j,R,K)}if(de(R))return he(D,j,R,K);if(ye(R)){if(we=ye(R),typeof we!="function")throw Error(s(150));return R=we.call(R),je(D,j,R,K)}if(typeof R.then=="function")return dt(D,j,pc(R),K);if(R.$$typeof===I)return dt(D,j,fc(D,R),K);gc(D,R)}return typeof R=="string"&&R!==""||typeof R=="number"||typeof R=="bigint"?(R=""+R,j!==null&&j.tag===6?(l(D,j.sibling),K=r(j,R),K.return=D,D=K):(l(D,j),K=Po(R,D.mode,K),K.return=D,D=K),h(D)):l(D,j)}return function(D,j,R,K){try{Ks=0;var we=dt(D,j,R,K);return Bu=null,we}catch(ve){if(ve===Hu||ve===hc)throw ve;var Ke=al(29,ve,null,D.mode);return Ke.lanes=K,Ke.return=D,Ke}}}var Ii=_m(!0),xm=_m(!1),ai=!1;function hf(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mf(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 ii(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ui(e,t,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(We&2)!==0){var r=i.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=sc(e),im(e,null,l),t}return uc(e,i,t,l),sc(e)}function Js(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,l|=i,t.lanes=l,da(e,l)}}function pf(e,t){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var r=null,o=null;if(l=l.firstBaseUpdate,l!==null){do{var h={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};o===null?r=o=h:o=o.next=h,l=l.next}while(l!==null);o===null?r=o=t:o=o.next=t}else r=o=t;l={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var gf=!1;function Fs(){if(gf){var e=Lu;if(e!==null)throw e}}function Ws(e,t,l,i){gf=!1;var r=e.updateQueue;ai=!1;var o=r.firstBaseUpdate,h=r.lastBaseUpdate,b=r.shared.pending;if(b!==null){r.shared.pending=null;var M=b,k=M.next;M.next=null,h===null?o=k:h.next=k,h=M;var $=e.alternate;$!==null&&($=$.updateQueue,b=$.lastBaseUpdate,b!==h&&(b===null?$.firstBaseUpdate=k:b.next=k,$.lastBaseUpdate=M))}if(o!==null){var J=r.baseState;h=0,$=k=M=null,b=o;do{var Z=b.lane&-536870913,H=Z!==b.lane;if(H?(Be&Z)===Z:(i&Z)===Z){Z!==0&&Z===Zu&&(gf=!0),$!==null&&($=$.next={lane:0,tag:b.tag,payload:b.payload,callback:null,next:null});e:{var he=e,je=b;Z=t;var dt=l;switch(je.tag){case 1:if(he=je.payload,typeof he=="function"){J=he.call(dt,J,Z);break e}J=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=je.payload,Z=typeof he=="function"?he.call(dt,J,Z):he,Z==null)break e;J=S({},J,Z);break e;case 2:ai=!0}}Z=b.callback,Z!==null&&(e.flags|=64,H&&(e.flags|=8192),H=r.callbacks,H===null?r.callbacks=[Z]:H.push(Z))}else H={lane:Z,tag:b.tag,payload:b.payload,callback:b.callback,next:null},$===null?(k=$=H,M=J):$=$.next=H,h|=Z;if(b=b.next,b===null){if(b=r.shared.pending,b===null)break;H=b,b=H.next,H.next=null,r.lastBaseUpdate=H,r.shared.pending=null}}while(!0);$===null&&(M=J),r.baseState=M,r.firstBaseUpdate=k,r.lastBaseUpdate=$,o===null&&(r.shared.lanes=0),fi|=h,e.lanes=h,e.memoizedState=J}}function zm(e,t){if(typeof e!="function")throw Error(s(191,e));e.call(t)}function Em(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;eo?o:8;var h=U.T,b={};U.T=b,Uf(e,!1,t,l);try{var M=r(),k=U.S;if(k!==null&&k(b,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var $=Gb(M,i);er(e,t,$,cl(e))}else er(e,t,i,cl(e))}catch(J){er(e,t,{then:function(){},status:"rejected",reason:J},cl())}finally{Q.p=o,h!==null&&b.types!==null&&(h.types=b.types),U.T=h}}function Xb(){}function Cf(e,t,l,i){if(e.tag!==5)throw Error(s(476));var r=np(e).queue;tp(e,r,t,me,l===null?Xb:function(){return lp(e),l(i)})}function np(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:me,baseState:me,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:me},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function lp(e){var t=np(e);t.next===null&&(t=e.alternate.memoizedState),er(e,t.next.queue,{},cl())}function Rf(){return gn(vr)}function ap(){return Gt().memoizedState}function ip(){return Gt().memoizedState}function Jb(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=cl();e=ii(l);var i=ui(t,e,l);i!==null&&(Fn(i,t,l),Js(i,t,l)),t={cache:cf()},e.payload=t;return}t=t.return}}function Fb(e,t,l){var i=cl();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wc(e)?sp(t,l):(l=Wo(e,t,l,i),l!==null&&(Fn(l,e,i),rp(l,t,i)))}function up(e,t,l){var i=cl();er(e,t,l,i)}function er(e,t,l,i){var r={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(wc(e))sp(t,r);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var h=t.lastRenderedState,b=o(h,l);if(r.hasEagerState=!0,r.eagerState=b,Ce(b,h))return uc(e,t,r,0),pt===null&&ic(),!1}catch{}if(l=Wo(e,t,r,i),l!==null)return Fn(l,e,i),rp(l,t,i),!0}return!1}function Uf(e,t,l,i){if(i={lane:2,revertLane:hd(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},wc(e)){if(t)throw Error(s(479))}else t=Wo(e,l,i,2),t!==null&&Fn(t,e,2)}function wc(e){var t=e.alternate;return e===ke||t!==null&&t===ke}function sp(e,t){Gu=bc=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function rp(e,t,l){if((l&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,l|=i,t.lanes=l,da(e,l)}}var tr={readContext:gn,use:xc,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useLayoutEffect:Rt,useInsertionEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useSyncExternalStore:Rt,useId:Rt,useHostTransitionStatus:Rt,useFormState:Rt,useActionState:Rt,useOptimistic:Rt,useMemoCache:Rt,useCacheRefresh:Rt};tr.useEffectEvent=Rt;var cp={readContext:gn,use:xc,useCallback:function(e,t){return Ln().memoizedState=[e,t===void 0?null:t],e},useContext:gn,useEffect:Vm,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Ec(4194308,4,Fm.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Ec(4194308,4,e,t)},useInsertionEffect:function(e,t){Ec(4,2,e,t)},useMemo:function(e,t){var l=Ln();t=t===void 0?null:t;var i=e();if(Pi){Qt(!0);try{e()}finally{Qt(!1)}}return l.memoizedState=[i,t],i},useReducer:function(e,t,l){var i=Ln();if(l!==void 0){var r=l(t);if(Pi){Qt(!0);try{l(t)}finally{Qt(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=Fb.bind(null,ke,e),[i.memoizedState,e]},useRef:function(e){var t=Ln();return e={current:e},t.memoizedState=e},useState:function(e){e=Af(e);var t=e.queue,l=up.bind(null,ke,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:jf,useDeferredValue:function(e,t){var l=Ln();return Df(l,e,t)},useTransition:function(){var e=Af(!1);return e=tp.bind(null,ke,e.queue,!0,!1),Ln().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var i=ke,r=Ln();if(Ye){if(l===void 0)throw Error(s(407));l=l()}else{if(l=t(),pt===null)throw Error(s(349));(Be&127)!==0||Nm(i,t,l)}r.memoizedState=l;var o={value:l,getSnapshot:t};return r.queue=o,Vm(Dm.bind(null,i,o,e),[e]),i.flags|=2048,Yu(9,{destroy:void 0},jm.bind(null,i,o,l,t),null),l},useId:function(){var e=Ln(),t=pt.identifierPrefix;if(Ye){var l=na,i=ta;l=(i&~(1<<32-on(i)-1)).toString(32)+l,t="_"+t+"R_"+l,l=Sc++,0<\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof i.is=="string"?h.createElement("select",{is:i.is}):h.createElement("select"),i.multiple?o.multiple=!0:i.size&&(o.size=i.size);break;default:o=typeof i.is=="string"?h.createElement(r,{is:i.is}):h.createElement(r)}}o[Wt]=t,o[En]=i;e:for(h=t.child;h!==null;){if(h.tag===5||h.tag===6)o.appendChild(h.stateNode);else if(h.tag!==4&&h.tag!==27&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}t.stateNode=o;e:switch(yn(o,r,i),r){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Aa(t)}}return xt(t),Jf(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Aa(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(s(166));if(e=pe.current,Uu(t)){if(e=t.stateNode,l=t.memoizedProps,i=null,r=pn,r!==null)switch(r.tag){case 27:case 5:i=r.memoizedProps}e[Wt]=t,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Ag(e.nodeValue,l)),e||ni(t,!0)}else e=Vc(e).createTextNode(i),e[Wt]=t,t.stateNode=e}return xt(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(i=Uu(t),l!==null){if(e===null){if(!i)throw Error(s(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(s(557));e[Wt]=t}else Vi(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;xt(t),e=!1}else l=af(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(ul(t),t):(ul(t),null);if((t.flags&128)!==0)throw Error(s(558))}return xt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(r=Uu(t),i!==null&&i.dehydrated!==null){if(e===null){if(!r)throw Err)DELIM" -R"DELIM(or(s(318));if(r=t.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));r[Wt]=t}else Vi(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;xt(t),r=!1}else r=af(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return t.flags&256?(ul(t),t):(ul(t),null)}return ul(t),(t.flags&128)!==0?(t.lanes=l,t):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=t.child,r=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(r=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==r&&(i.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),jc(t,t.updateQueue),xt(t),null);case 4:return Qe(),e===null&&vd(t.stateNode.containerInfo),xt(t),null;case 10:return Ea(t.type),xt(t),null;case 19:if(L(qt),i=t.memoizedState,i===null)return xt(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)lr(i,!1);else{if(Ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(o=yc(e),o!==null){for(t.flags|=128,lr(i,!1),e=o.updateQueue,t.updateQueue=e,jc(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)um(l,e),l=l.sibling;return G(qt,qt.current&1|2),Ye&&xa(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Te()>kc&&(t.flags|=128,r=!0,lr(i,!1),t.lanes=4194304)}else{if(!r)if(e=yc(o),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,jc(t,e),lr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ye)return xt(t),null}else 2*Te()-i.renderingStartTime>kc&&l!==536870912&&(t.flags|=128,r=!0,lr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e!==null?e.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Te(),e.sibling=null,l=qt.current,G(qt,r?l&1|2:l&1),Ye&&xa(t,i.treeForkCount),e):(xt(t),null);case 22:case 23:return ul(t),yf(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(l&536870912)!==0&&(t.flags&128)===0&&(xt(t),t.subtreeFlags&6&&(t.flags|=8192)):xt(t),l=t.updateQueue,l!==null&&jc(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==l&&(t.flags|=2048),e!==null&&L(Ji),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Ea($t),xt(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function t1(e,t){switch(nf(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ea($t),Qe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Nn(t),null;case 31:if(t.memoizedState!==null){if(ul(t),t.alternate===null)throw Error(s(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ul(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L(qt),null;case 4:return Qe(),null;case 10:return Ea(t.type),null;case 22:case 23:return ul(t),yf(),e!==null&&L(Ji),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ea($t),null;case 25:return null;default:return null}}function Cp(e,t){switch(nf(t),t.tag){case 3:Ea($t),Qe();break;case 26:case 27:case 5:Nn(t);break;case 4:Qe();break;case 31:t.memoizedState!==null&&ul(t);break;case 13:ul(t);break;case 19:L(qt);break;case 10:Ea(t.type);break;case 22:case 23:ul(t),yf(),e!==null&&L(Ji);break;case 24:Ea($t)}}function ar(e,t){try{var l=t.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var r=i.next;l=r;do{if((l.tag&e)===e){i=void 0;var o=l.create,h=l.inst;i=o(),h.destroy=i}l=l.next}while(l!==r)}}catch(b){st(t,t.return,b)}}function ci(e,t,l){try{var i=t.updateQueue,r=i!==null?i.lastEffect:null;if(r!==null){var o=r.next;i=o;do{if((i.tag&e)===e){var h=i.inst,b=h.destroy;if(b!==void 0){h.destroy=void 0,r=t;var M=l,k=b;try{k()}catch($){st(r,M,$)}}}i=i.next}while(i!==o)}}catch($){st(t,t.return,$)}}function Rp(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{Em(t,l)}catch(i){st(e,e.return,i)}}}function Up(e,t,l){l.props=eu(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){st(e,t,i)}}function ir(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(r){st(e,t,r)}}function la(e,t){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(r){st(e,t,r)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(r){st(e,t,r)}else l.current=null}function kp(e){var t=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(r){st(e,e.return,r)}}function Ff(e,t,l){try{var i=e.stateNode;z1(i,e.type,l,t),i[En]=t}catch(r){st(e,e.return,r)}}function Zp(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&gi(e.type)||e.tag===4}function Wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Zp(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&&gi(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 If(e,t,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=Un));else if(i!==4&&(i===27&&gi(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(If(e,t,l),e=e.sibling;e!==null;)If(e,t,l),e=e.sibling}function Dc(e,t,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(i!==4&&(i===27&&gi(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Dc(e,t,l),e=e.sibling;e!==null;)Dc(e,t,l),e=e.sibling}function Lp(e){var t=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);yn(t,i,l),t[Wt]=e,t[En]=l}catch(o){st(e,e.return,o)}}var Oa=!1,Xt=!1,Pf=!1,Hp=typeof WeakSet=="function"?WeakSet:Set,rn=null;function n1(e,t){if(e=e.containerInfo,Sd=Pc,e=St(e),Ct(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var r=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{l.nodeType,o.nodeType}catch{l=null;break e}var h=0,b=-1,M=-1,k=0,$=0,J=e,Z=null;t:for(;;){for(var H;J!==l||r!==0&&J.nodeType!==3||(b=h+r),J!==o||i!==0&&J.nodeType!==3||(M=h+i),J.nodeType===3&&(h+=J.nodeValue.length),(H=J.firstChild)!==null;)Z=J,J=H;for(;;){if(J===e)break t;if(Z===l&&++k===r&&(b=h),Z===o&&++$===i&&(M=h),(H=J.nextSibling)!==null)break;J=Z,Z=J.parentNode}J=H}l=b===-1||M===-1?null:{start:b,end:M}}else l=null}l=l||{start:0,end:0}}else l=null;for(_d={focusedElem:e,selectionRange:l},Pc=!1,rn=t;rn!==null;)if(t=rn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,rn=e;else for(;rn!==null;){switch(t=rn,o=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(l=0;l title"))),yn(o,i,l),o[Wt]=e,Lt(o),i=o;break e;case"link":var h=$g("link","href",r).get(i+(l.href||""));if(h){for(var b=0;bdt&&(h=dt,dt=je,je=h);var D=Se(b,je),j=Se(b,dt);if(D&&j&&(H.rangeCount!==1||H.anchorNode!==D.node||H.anchorOffset!==D.offset||H.focusNode!==j.node||H.focusOffset!==j.offset)){var R=J.createRange();R.setStart(D.node,D.offset),H.removeAllRanges(),je>dt?(H.addRange(R),H.extend(j.node,j.offset)):(R.setEnd(j.node,j.offset),H.addRange(R))}}}}for(J=[],H=b;H=H.parentNode;)H.nodeType===1&&J.push({element:H,left:H.scrollLeft,top:H.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;bl?32:l,U.T=null,l=ud,ud=null;var o=hi,h=Ra;if(It=0,Ju=hi=null,Ra=0,(We&6)!==0)throw Error(s(331));var b=We;if(We|=4,Fp(o.current),Kp(o,o.current,h,l),We=b,fr(0,!1),rt&&typeof rt.onPostCommitFiberRoot=="function")try{rt.onPostCommitFiberRoot(nn,o)}catch{}return!0}finally{Q.p=r,U.T=i,mg(e,t)}}function gg(e,t,l){t=bl(l,t),t=Hf(e.stateNode,t,2),e=ui(e,t,2),e!==null&&(tl(e,2),aa(e))}function st(e,t,l){if(e.tag===3)gg(e,e,l);else for(;t!==null;){if(t.tag===3){gg(t,e,l);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(di===null||!di.has(i))){e=bl(l,e),l=vp(2),i=ui(t,l,2),i!==null&&(yp(l,i,t,e),tl(i,2),aa(i));break}}t=t.return}}function od(e,t,l){var i=e.pingCache;if(i===null){i=e.pingCache=new i1;var r=new Set;i.set(t,r)}else r=i.get(t),r===void 0&&(r=new Set,i.set(t,r));r.has(l)||(nd=!0,r.add(l),e=o1.bind(null,e,t,l),t.then(e,e))}function o1(e,t,l){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,pt===e&&(Be&l)===l&&(Ut===4||Ut===3&&(Be&62914560)===Be&&300>Te()-Uc?(We&2)===0&&Fu(e,0):ld|=l,Xu===Be&&(Xu=0)),aa(e)}function vg(e,t){t===0&&(t=Br()),e=Yi(e,t),e!==null&&(tl(e,t),aa(e))}function f1(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),vg(e,l)}function d1(e,t){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,r=e.memoizedState;r!==null&&(l=r.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(s(314))}i!==null&&i.delete(t),vg(e,l)}function h1(e,t){return Ft(e,t)}var Gc=null,Iu=null,fd=!1,Qc=!1,dd=!1,pi=0;function aa(e){e!==Iu&&e.next===null&&(Iu===null?Gc=Iu=e:Iu=Iu.next=e),Qc=!0,fd||(fd=!0,p1())}function fr(e,t){if(!dd&&Qc){dd=!0;do for(var l=!1,i=Gc;i!==null;){if(e!==0){var r=i.pendingLanes;if(r===0)var o=0;else{var h=i.suspendedLanes,b=i.pingedLanes;o=(1<<31-on(42|e)+1)-1,o&=r&~(h&~b),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(l=!0,_g(i,o))}else o=Be,o=yu(i,i===pt?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(o&3)===0||Di(i,o)||(l=!0,_g(i,o));i=i.next}while(l);dd=!1}}function m1(){yg()}function yg(){Qc=fd=!1;var e=0;pi!==0&&T1()&&(e=pi);for(var t=Te(),l=null,i=Gc;i!==null;){var r=i.next,o=bg(i,t);o===0?(i.next=null,l===null?Gc=r:l.next=r,r===null&&(Iu=l)):(l=i,(e!==0||(o&3)!==0)&&(Qc=!0)),i=r}It!==0&&It!==5||fr(e),pi!==0&&(pi=0)}function bg(e,t){for(var l=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,o=e.pendingLanes&-62914561;0b)break;var $=M.transferSize,J=M.initiatorType;$&&Og(J)&&(M=M.responseEnd,h+=$*(M"u"?null:document;function qg(e,t,l){var i=Pu;if(i&&typeof t=="string"&&t){var r=Rn(t);r='link[rel="'+e+'"][href="'+r+'"]',typeof l=="string"&&(r+='[crossorigin="'+l+'"]'),Bg.has(r)||(Bg.add(r),e={rel:e,crossOrigin:l,href:t},i.querySelector(r)===null&&(t=i.createElement("link"),yn(t,"link",e),Lt(t),i.head.appendChild(t)))}}function R1(e){Ua.D(e),qg("dns-prefetch",e,null)}function U1(e,t){Ua.C(e,t),qg("preconnect",e,t)}function k1(e,t,l){Ua.L(e,t,l);var i=Pu;if(i&&e&&t){var r='link[rel="preload"][as="'+Rn(t)+'"]';t==="image"&&l&&l.imageSrcSet?(r+='[imagesrcset="'+Rn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(r+='[imagesizes="'+Rn(l.imageSizes)+'"]')):r+='[href="'+Rn(e)+'"]';var o=r;switch(t){case"style":o=es(e);break;case"script":o=ts(e)}Tl.has(o)||(e=S({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Tl.set(o,e),i.querySelector(r)!==null||t==="style"&&i.querySelector(pr(o))||t==="script"&&i.querySelector(gr(o))||(t=i.createElement("link"),yn(t,"link",e),Lt(t),i.head.appendChild(t)))}}function Z1(e,t){Ua.m(e,t);var l=Pu;if(l&&e){var i=t&&typeof t.as=="string"?t.as:"script",r='link[rel="modulepreload"][as="'+Rn(i)+'"][href="'+Rn(e)+'"]',o=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=ts(e)}if(!Tl.has(o)&&(e=S({rel:"modulepreload",href:e},t),Tl.set(o,e),l.querySelector(r)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(gr(o)))return}i=l.createElement("link"),yn(i,"link",e),Lt(i),l.head.appendChild(i)}}}function L1(e,t,l){Ua.S(e,t,l);var i=Pu;if(i&&e){var r=pl(i).hoistableStyles,o=es(e);t=t||"default";var h=r.get(o);if(!h){var b={loading:0,preload:null};if(h=i.querySelector(pr(o)))b.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Tl.get(o))&&Ad(e,l);var M=h=i.createElement("link");Lt(M),yn(M,"link",e),M._p=new Promise(function(k,$){M.onload=k,M.onerror=$}),M.addEventListener("load",function(){b.loading|=1}),M.addEventListener("error",function(){b.loading|=2}),b.loading|=4,Xc(h,t,i)}h={type:"stylesheet",instance:h,count:1,state:b},r.set(o,h)}}}function H1(e,t){Ua.X(e,t);var l=Pu;if(l&&e){var i=pl(l).hoistableScripts,r=ts(e),o=i.get(r);o||(o=l.querySelector(gr(r)),o||(e=S({src:e,async:!0},t),(t=Tl.get(r))&&Od(e,t),o=l.createElement("script"),Lt(o),yn(o,"link",e),l.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},i.set(r,o))}}function B1(e,t){Ua.M(e,t);var l=Pu;if(l&&e){var i=pl(l).hoistableScripts,r=ts(e),o=i.get(r);o||(o=)DELIM" -R"DELIM(l.querySelector(gr(r)),o||(e=S({src:e,async:!0,type:"module"},t),(t=Tl.get(r))&&Od(e,t),o=l.createElement("script"),Lt(o),yn(o,"link",e),l.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},i.set(r,o))}}function Gg(e,t,l,i){var r=(r=pe.current)?Kc(r):null;if(!r)throw Error(s(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=es(l.href),l=pl(r).hoistableStyles,i=l.get(t),i||(i={type:"style",instance:null,count:0,state:null},l.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=es(l.href);var o=pl(r).hoistableStyles,h=o.get(e);if(h||(r=r.ownerDocument||r,h={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,h),(o=r.querySelector(pr(e)))&&!o._p&&(h.instance=o,h.state.loading=5),Tl.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Tl.set(e,l),o||q1(r,e,l,h.state))),t&&i===null)throw Error(s(528,""));return h}if(t&&i!==null)throw Error(s(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=ts(l),l=pl(r).hoistableScripts,i=l.get(t),i||(i={type:"script",instance:null,count:0,state:null},l.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,e))}}function es(e){return'href="'+Rn(e)+'"'}function pr(e){return'link[rel="stylesheet"]['+e+"]"}function Qg(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function q1(e,t,l,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),yn(t,"link",l),Lt(t),e.head.appendChild(t))}function ts(e){return'[src="'+Rn(e)+'"]'}function gr(e){return"script[async]"+e}function Yg(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+Rn(l.href)+'"]');if(i)return t.instance=i,Lt(i),i;var r=S({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Lt(i),yn(i,"style",r),Xc(i,l.precedence,e),t.instance=i;case"stylesheet":r=es(l.href);var o=e.querySelector(pr(r));if(o)return t.state.loading|=4,t.instance=o,Lt(o),o;i=Qg(l),(r=Tl.get(r))&&Ad(i,r),o=(e.ownerDocument||e).createElement("link"),Lt(o);var h=o;return h._p=new Promise(function(b,M){h.onload=b,h.onerror=M}),yn(o,"link",i),t.state.loading|=4,Xc(o,l.precedence,e),t.instance=o;case"script":return o=ts(l.src),(r=e.querySelector(gr(o)))?(t.instance=r,Lt(r),r):(i=l,(r=Tl.get(o))&&(i=S({},l),Od(i,r)),e=e.ownerDocument||e,r=e.createElement("script"),Lt(r),yn(r,"link",i),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(s(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,Xc(i,l.precedence,e));return t.instance}function Xc(e,t,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,o=r,h=0;h title"):null)}function G1(e,t,l){if(l===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 Kg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Q1(e,t,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var r=es(i.href),o=t.querySelector(pr(r));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Fc.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=o,Lt(o);return}o=t.ownerDocument||t,i=Qg(i),(r=Tl.get(r))&&Ad(i,r),o=o.createElement("link"),Lt(o);var h=o;h._p=new Promise(function(b,M){h.onload=b,h.onerror=M}),yn(o,"link",i),l.instance=o}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Fc.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Nd=0;function Y1(e,t){return e.stylesheets&&e.count===0&&Ic(e,e.stylesheets),0Nd?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}function Fc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ic(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Wc=null;function Ic(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Wc=new Map,t.forEach($1,e),Wc=null,Fc.call(e))}function $1(e,t){if(!(t.state.loading&4)){var l=Wc.get(e);if(l)var i=l.get(null);else{l=new Map,Wc.set(e,l);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Hd.exports=rS(),Hd.exports}var oS=cS();const fS=Xv(oS),zh="libbitcoinAdminDashboardEndpoints";function dS(){return globalThis.window?.location.origin??"http://localhost"}function ua(n){const a=n.trim();if(!a)throw new Error("Endpoint URL is required");const u=/^[a-z][a-z\d+\-.]*:\/\//iu.test(a)?a:`http://${a}`,s=new URL(u);if(s.protocol!=="http:"&&s.protocol!=="https:")throw new Error("Endpoint must use HTTP or HTTPS");return s.pathname=s.pathname.replace(/\/+$/u,"")||"/",s.search="",s.hash="",s.toString().replace(/\/$/u,"")}function Jv(n){const a=new URL(ua(n));return a.protocol=a.protocol==="https:"?"wss:":"ws:",a.pathname="/",a.search="",a.hash="",a.toString()}function hS(n,a=dS()){return new URL(ua(n)).origin===new URL(a).origin}function Fv(){return{adminUrl:ua("http://172.20.208.1:8080"),nativeUrl:ua("http://172.20.208.1:80")}}function mS(){const n=Fv(),u=globalThis.window?.localStorage.getItem(zh);if(!u)return n;try{const s=JSON.parse(u);if(!s||typeof s!="object"||Array.isArray(s))return n;const c=s;return{adminUrl:typeof c.adminUrl=="string"?ua(c.adminUrl):n.adminUrl,nativeUrl:typeof c.nativeUrl=="string"?ua(c.nativeUrl):n.nativeUrl}}catch{return n}}function pS(n){const a={adminUrl:ua(n.adminUrl),nativeUrl:ua(n.nativeUrl)};globalThis.window?.localStorage.setItem(zh,JSON.stringify(a))}function gS(){globalThis.window?.localStorage.removeItem(zh)}function vS({configuration:n,onClose:a,onReset:u,onSave:s}){const[c,d]=_e.useState(n.adminUrl),[f,p]=_e.useState(n.nativeUrl),[g,v]=_e.useState(null);function x(S){S.preventDefault();try{s({adminUrl:ua(c),nativeUrl:ua(f)})}catch(T){v(T instanceof Error?T.message:"Invalid endpoint configuration")}}return z.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",role:"presentation",onMouseDown:S=>{S.target===S.currentTarget&&a()},children:z.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"endpoint-settings-title",className:"border-accent/30 bg-surface w-full max-w-xl rounded-2xl border shadow-2xl shadow-black/50",children:[z.jsxs("header",{className:"border-accent/20 flex items-start justify-between border-b p-5",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Runtime configuration"}),z.jsx("h2",{id:"endpoint-settings-title",className:"mt-1 text-xl font-semibold",children:"Node endpoints"})]}),z.jsx("button",{type:"button",onClick:a,className:"text-textMuted hover:text-accent rounded p-1 text-xl","aria-label":"Close endpoint settings",children:"×"})]}),z.jsxs("form",{onSubmit:x,className:"space-y-5 p-5",children:[z.jsxs("label",{className:"block space-y-2",children:[z.jsx("span",{className:"text-textPrimary text-sm font-medium",children:"Admin endpoint"}),z.jsx("input",{value:c,onChange:S=>{d(S.target.value)},className:"border-accent/30 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 font-mono text-sm focus:ring-0",placeholder:"http://node-host:admin-port",autoComplete:"url"})]}),z.jsxs("label",{className:"block space-y-2",children:[z.jsx("span",{className:"text-textPrimary text-sm font-medium",children:"Native endpoint"}),z.jsx("input",{value:f,onChange:S=>{p(S.target.value)},className:"border-accent/30 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 font-mono text-sm focus:ring-0",placeholder:"http://node-host:native-port",autoComplete:"url"})]}),g&&z.jsx("p",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-300",children:g}),z.jsxs("div",{className:"flex flex-wrap justify-between gap-3 pt-2",children:[z.jsx("button",{type:"button",onClick:u,className:"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary rounded-lg border px-4 py-2 text-sm",children:"Reset defaults"}),z.jsxs("div",{className:"flex gap-2",children:[z.jsx("button",{type:"button",onClick:a,className:"text-textMuted hover:text-textPrimary rounded-lg px-4 py-2 text-sm",children:"Cancel"}),z.jsx("button",{type:"submit",className:"bg-accent text-background hover:bg-accent/90 rounded-lg px-4 py-2 text-sm font-semibold",children:"Save and reconnect"})]})]})]})]})})}var v0;function X(n,a,u){function s(p,g){if(p._zod||Object.defineProperty(p,"_zod",{value:{def:g,constr:f,traits:new Set},enumerable:!1}),p._zod.traits.has(n))return;p._zod.traits.add(n),a(p,g);const v=f.prototype,x=Object.keys(v);for(let S=0;Su?.Parent&&p instanceof u.Parent?!0:p?._zod?.traits?.has(n)}),Object.defineProperty(f,"name",{value:n}),f}class cs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Wv extends Error{constructor(a){super(`Encountered unidirectional transform during encode: ${a}`),this.name="ZodEncodeError"}}(v0=globalThis).__zod_globalConfig??(v0.__zod_globalConfig={});const Eh=globalThis.__zod_globalConfig;function fu(n){return Eh}function Iv(n){const a=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,c])=>a.indexOf(+s)===-1).map(([s,c])=>c)}function Pd(n,a){return typeof a=="bigint"?a.toString():a}function Th(n){return{get value(){{const a=n();return Object.defineProperty(this,"value",{value:a}),a}}}}function wh(n){return n==null}function Mh(n){const a=n.startsWith("^")?1:0,u=n.endsWith("$")?n.length-1:n.length;return n.slice(a,u)}function yS(n,a){const u=n/a,s=Math.round(u),c=Number.EPSILON*Math.max(Math.abs(u),1);return Math.abs(u-s){};function bo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const SS=Th(()=>{if(Eh.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const n=Function;return new n(""),!0}catch{return!1}});function Dr(n){if(bo(n)===!1)return!1;const a=n.constructor;if(a===void 0||typeof a!="function")return!0;const u=a.prototype;return!(bo(u)===!1||Object.prototype.hasOwnProperty.call(u,"isPrototypeOf")===!1)}function ey(n){return Dr(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}const _S=new Set(["string","number","symbol"]);function ds(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oi(n,a,u){const s=new n._zod.constr(a??n._zod.def);return(!a||u?.parent)&&(s._zod.parent=n),s}function Me(n){const a=n;if(!a)return{};if(typeof a=="string")return{error:()=>a};if(a?.message!==void 0){if(a?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");a.error=a.message}return delete a.message,typeof a.error=="string"?{...a,error:()=>a.error}:a}function xS(n){return Object.keys(n).filter(a=>n[a]._zod.optin==="optional"&&n[a]._zod.optout==="optional")}const zS={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ES(n,a){const u=n._zod.def,s=u.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const d=Ai(n._zod.def,{get shape(){const f={};for(const p in a){if(!(p in u.shape))throw new Error(`Unrecognized key: "${p}"`);a[p]&&(f[p]=u.shape[p])}return mu(this,"shape",f),f},checks:[]});return Oi(n,d)}function TS(n,a){const u=n._zod.def,s=u.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const d=Ai(n._zod.def,{get shape(){const f={...n._zod.def.shape};for(const p in a){if(!(p in u.shape))throw new Error(`Unrecognized key: "${p}"`);a[p]&&delete f[p]}return mu(this,"shape",f),f},checks:[]});return Oi(n,d)}function wS(n,a){if(!Dr(a))throw new Error("Invalid input to extend: expected a plain object");const u=n._zod.def.checks;if(u&&u.length>0){const d=n._zod.def.shape;for(const f in a)if(Object.getOwnPropertyDescriptor(d,f)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const c=Ai(n._zod.def,{get shape(){const d={...n._zod.def.shape,...a};return mu(this,"shape",d),d}});return Oi(n,c)}function MS(n,a){if(!Dr(a))throw new Error("Invalid input to safeExtend: expected a plain object");const u=Ai(n._zod.def,{get shape(){const s={...n._zod.def.shape,...a};return mu(this,"shape",s),s}});return Oi(n,u)}function AS(n,a){if(n._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const u=Ai(n._zod.def,{get shape(){const s={...n._zod.def.shape,...a._zod.def.shape};return mu(this,"shape",s),s},get catchall(){return a._zod.def.catchall},checks:a._zod.def.checks??[]});return Oi(n,u)}function OS(n,a,u){const c=a._zod.def.checks;if(c&&c.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const f=Ai(a._zod.def,{get shape(){const p=a._zod.def.shape,g={...p};if(u)for(const v in u){if(!(v in p))throw new Error(`Unrecognized key: "${v}"`);u[v]&&(g[v]=n?new n({type:"optional",innerType:p[v]}):p[v])}else for(const v in p)g[v]=n?new n({type:"optional",innerType:p[v]}):p[v];return mu(this,"shape",g),g},checks:[]});return Oi(a,f)}function NS(n,a,u){const s=Ai(a._zod.def,{get shape(){const c=a._zod.def.shape,d={...c};if(u)for(const f in u){if(!(f in d))throw new Error(`Unrecognized key: "${f}"`);u[f]&&(d[f]=new n({type:"nonoptional",innerType:c[f]}))}else for(const f in c)d[f]=new n({type:"nonoptional",innerType:c[f]});return mu(this,"shape",d),d}});return Oi(a,s)}function rs(n,a=0){if(n.aborted===!0)return!0;for(let u=a;u{var s;return(s=u).path??(s.path=[]),u.path.unshift(n),u})}function uo(n){return typeof n=="string"?n:n?.message}function du(n,a,u){const s=n.message?n.message:uo(n.inst?._zod.def?.error?.(n))??uo(a?.error?.(n))??uo(u.customError?.(n))??uo(u.localeError?.(n))??"Invalid input",{inst:c,continue:d,input:f,...p}=n;return p.path??(p.path=[]),p.message=s,a?.reportInput&&(p.input=f),p}function Ah(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Cr(...n){const[a,u,s]=n;return typeof a=="string"?{message:a,code:"custom",input:u,inst:s}:{...a}}const ny=(n,a)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:a,enumerable:!1}),n.message=JSON.stringify(a,Pd,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},ly=X("$ZodError",ny),ay=X("$ZodError",ny,{Parent:Error});function DS(n,a=u=>u.message){const u={},s=[];for(const c of n.issues)c.path.length>0?(u[c.path[0]]=u[c.path[0]]||[],u[c.path[0]].push(a(c))):s.push(a(c));return{formErrors:s,fieldErrors:u}}function CS(n,a=u=>u.message){const u={_errors:[]},s=(c,d=[])=>{for(const f of c.issues)if(f.code==="invalid_union"&&f.errors.length)f.errors.map(p=>s({issues:p},[...d,...f.path]));else if(f.code==="invalid_key")s({issues:f.issues},[...d,...f.path]);else if(f.code==="invalid_element")s({issues:f.issues},[...d,...f.path]);else{const p=[...d,...f.path];if(p.length===0)u._errors.push(a(f));else{let g=u,v=0;for(;v(a,u,s,c)=>{const d=s?{...s,async:!1}:{async:!1},f=a._zod.run({value:u,issues:[]},d);if(f instanceof Promise)throw new cs;if(f.issues.length){const p=new(c?.Err??n)(f.issues.map(g=>du(g,d,fu())));throw Pv(p,c?.callee),p}return f.value},Nh=n=>async(a,u,s,c)=>{const d=s?{...s,async:!0}:{async:!0};let f=a._zod.run({value:u,issues:[]},d);if(f instanceof Promise&&(f=await f),f.issues.length){const p=new(c?.Err??n)(f.issues.map(g=>du(g,d,fu())));throw Pv(p,c?.callee),p}return f.value},Oo=n=>(a,u,s)=>{const c=s?{...s,async:!1}:{async:!1},d=a._zod.run({value:u,issues:[]},c);if(d instanceof Promise)throw new cs;return d.issues.length?{success:!1,error:new(n??ly)(d.issues.map(f=>du(f,c,fu())))}:{success:!0,data:d.value}},RS=Oo(ay),No=n=>async(a,u,s)=>{const c=s?{...s,async:!0}:{async:!0};let d=a._zod.run({value:u,issues:[]},c);return d instanceof Promise&&(d=await d),d.issues.length?{success:!1,error:new n(d.issues.map(f=>du(f,c,fu())))}:{success:!0,data:d.value}},US=No(ay),kS=n=>(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return Oh(n)(a,u,c)},ZS=n=>(a,u,s)=>Oh(n)(a,u,s),LS=n=>async(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return Nh(n)(a,u,c)},HS=n=>async(a,u,s)=>Nh(n)(a,u,s),BS=n=>(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return Oo(n)(a,u,c)},qS=n=>(a,u,s)=>Oo(n)(a,u,s),GS=n=>async(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return No(n)(a,u,c)},QS=n=>async(a,u,s)=>No(n)(a,u,s),YS=/^[cC][0-9a-z]{6,}$/,$S=/^[0-9a-z]+$/,VS=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,KS=/^[0-9a-vA-V]{20}$/,XS=/^[A-Za-z0-9]{27}$/,JS=/^)DELIM" -R"DELIM([a-zA-Z0-9_-]{21}$/,FS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,WS=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,S0=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,IS=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,PS="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function e_(){return new RegExp(PS,"u")}const t_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,n_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,l_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,a_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,i_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,iy=/^[A-Za-z0-9_-]*$/,u_=/^https?$/,s_=/^\+[1-9]\d{6,14}$/,uy="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",r_=new RegExp(`^${uy}$`);function sy(n){const a="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${a}`:n.precision===0?`${a}:[0-5]\\d`:`${a}:[0-5]\\d\\.\\d{${n.precision}}`:`${a}(?::[0-5]\\d(?:\\.\\d+)?)?`}function c_(n){return new RegExp(`^${sy(n)}$`)}function o_(n){const a=sy({precision:n.precision}),u=["Z"];n.local&&u.push(""),n.offset&&u.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${a}(?:${u.join("|")})`;return new RegExp(`^${uy}T(?:${s})$`)}const f_=n=>{const a=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${a}$`)},d_=/^-?\d+$/,h_=/^-?\d+(?:\.\d+)?$/,m_=/^(?:true|false)$/i,p_=/^[^A-Z]*$/,g_=/^[^a-z]*$/,In=X("$ZodCheck",(n,a)=>{var u;n._zod??(n._zod={}),n._zod.def=a,(u=n._zod).onattach??(u.onattach=[])}),ry={number:"number",bigint:"bigint",object:"date"},cy=X("$ZodCheckLessThan",(n,a)=>{In.init(n,a);const u=ry[typeof a.value];n._zod.onattach.push(s=>{const c=s._zod.bag,d=(a.inclusive?c.maximum:c.exclusiveMaximum)??Number.POSITIVE_INFINITY;a.value{(a.inclusive?s.value<=a.value:s.value{In.init(n,a);const u=ry[typeof a.value];n._zod.onattach.push(s=>{const c=s._zod.bag,d=(a.inclusive?c.minimum:c.exclusiveMinimum)??Number.NEGATIVE_INFINITY;a.value>d&&(a.inclusive?c.minimum=a.value:c.exclusiveMinimum=a.value)}),n._zod.check=s=>{(a.inclusive?s.value>=a.value:s.value>a.value)||s.issues.push({origin:u,code:"too_small",minimum:typeof a.value=="object"?a.value.getTime():a.value,input:s.value,inclusive:a.inclusive,inst:n,continue:!a.abort})}}),v_=X("$ZodCheckMultipleOf",(n,a)=>{In.init(n,a),n._zod.onattach.push(u=>{var s;(s=u._zod.bag).multipleOf??(s.multipleOf=a.value)}),n._zod.check=u=>{if(typeof u.value!=typeof a.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof u.value=="bigint"?u.value%a.value===BigInt(0):yS(u.value,a.value)===0)||u.issues.push({origin:typeof u.value,code:"not_multiple_of",divisor:a.value,input:u.value,inst:n,continue:!a.abort})}}),y_=X("$ZodCheckNumberFormat",(n,a)=>{In.init(n,a),a.format=a.format||"float64";const u=a.format?.includes("int"),s=u?"int":"number",[c,d]=zS[a.format];n._zod.onattach.push(f=>{const p=f._zod.bag;p.format=a.format,p.minimum=c,p.maximum=d,u&&(p.pattern=d_)}),n._zod.check=f=>{const p=f.value;if(u){if(!Number.isInteger(p)){f.issues.push({expected:s,format:a.format,code:"invalid_type",continue:!1,input:p,inst:n});return}if(!Number.isSafeInteger(p)){p>0?f.issues.push({input:p,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!a.abort}):f.issues.push({input:p,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!a.abort});return}}pd&&f.issues.push({origin:"number",input:p,code:"too_big",maximum:d,inclusive:!0,inst:n,continue:!a.abort})}}),b_=X("$ZodCheckMaxLength",(n,a)=>{var u;In.init(n,a),(u=n._zod.def).when??(u.when=s=>{const c=s.value;return!wh(c)&&c.length!==void 0}),n._zod.onattach.push(s=>{const c=s._zod.bag.maximum??Number.POSITIVE_INFINITY;a.maximum{const c=s.value;if(c.length<=a.maximum)return;const f=Ah(c);s.issues.push({origin:f,code:"too_big",maximum:a.maximum,inclusive:!0,input:c,inst:n,continue:!a.abort})}}),S_=X("$ZodCheckMinLength",(n,a)=>{var u;In.init(n,a),(u=n._zod.def).when??(u.when=s=>{const c=s.value;return!wh(c)&&c.length!==void 0}),n._zod.onattach.push(s=>{const c=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;a.minimum>c&&(s._zod.bag.minimum=a.minimum)}),n._zod.check=s=>{const c=s.value;if(c.length>=a.minimum)return;const f=Ah(c);s.issues.push({origin:f,code:"too_small",minimum:a.minimum,inclusive:!0,input:c,inst:n,continue:!a.abort})}}),__=X("$ZodCheckLengthEquals",(n,a)=>{var u;In.init(n,a),(u=n._zod.def).when??(u.when=s=>{const c=s.value;return!wh(c)&&c.length!==void 0}),n._zod.onattach.push(s=>{const c=s._zod.bag;c.minimum=a.length,c.maximum=a.length,c.length=a.length}),n._zod.check=s=>{const c=s.value,d=c.length;if(d===a.length)return;const f=Ah(c),p=d>a.length;s.issues.push({origin:f,...p?{code:"too_big",maximum:a.length}:{code:"too_small",minimum:a.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!a.abort})}}),jo=X("$ZodCheckStringFormat",(n,a)=>{var u,s;In.init(n,a),n._zod.onattach.push(c=>{const d=c._zod.bag;d.format=a.format,a.pattern&&(d.patterns??(d.patterns=new Set),d.patterns.add(a.pattern))}),a.pattern?(u=n._zod).check??(u.check=c=>{a.pattern.lastIndex=0,!a.pattern.test(c.value)&&c.issues.push({origin:"string",code:"invalid_format",format:a.format,input:c.value,...a.pattern?{pattern:a.pattern.toString()}:{},inst:n,continue:!a.abort})}):(s=n._zod).check??(s.check=()=>{})}),x_=X("$ZodCheckRegex",(n,a)=>{jo.init(n,a),n._zod.check=u=>{a.pattern.lastIndex=0,!a.pattern.test(u.value)&&u.issues.push({origin:"string",code:"invalid_format",format:"regex",input:u.value,pattern:a.pattern.toString(),inst:n,continue:!a.abort})}}),z_=X("$ZodCheckLowerCase",(n,a)=>{a.pattern??(a.pattern=p_),jo.init(n,a)}),E_=X("$ZodCheckUpperCase",(n,a)=>{a.pattern??(a.pattern=g_),jo.init(n,a)}),T_=X("$ZodCheckIncludes",(n,a)=>{In.init(n,a);const u=ds(a.includes),s=new RegExp(typeof a.position=="number"?`^.{${a.position}}${u}`:u);a.pattern=s,n._zod.onattach.push(c=>{const d=c._zod.bag;d.patterns??(d.patterns=new Set),d.patterns.add(s)}),n._zod.check=c=>{c.value.includes(a.includes,a.position)||c.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:a.includes,input:c.value,inst:n,continue:!a.abort})}}),w_=X("$ZodCheckStartsWith",(n,a)=>{In.init(n,a);const u=new RegExp(`^${ds(a.prefix)}.*`);a.pattern??(a.pattern=u),n._zod.onattach.push(s=>{const c)DELIM" -R"DELIM(=s._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(u)}),n._zod.check=s=>{s.value.startsWith(a.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:a.prefix,input:s.value,inst:n,continue:!a.abort})}}),M_=X("$ZodCheckEndsWith",(n,a)=>{In.init(n,a);const u=new RegExp(`.*${ds(a.suffix)}$`);a.pattern??(a.pattern=u),n._zod.onattach.push(s=>{const c=s._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(u)}),n._zod.check=s=>{s.value.endsWith(a.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:a.suffix,input:s.value,inst:n,continue:!a.abort})}}),A_=X("$ZodCheckOverwrite",(n,a)=>{In.init(n,a),n._zod.check=u=>{u.value=a.tx(u.value)}});class O_{constructor(a=[]){this.content=[],this.indent=0,this&&(this.args=a)}indented(a){this.indent+=1,a(this),this.indent-=1}write(a){if(typeof a=="function"){a(this,{execution:"sync"}),a(this,{execution:"async"});return}const s=a.split(` +R"DELIM(lt?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=at)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=at)},persist:function(){},isPersistent:at}),t}var yt={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},At=Ve(yt),Fe=S({},yt,{view:0,detail:0}),Ja=Ve(Fe),Fa,Rs,Qn,Zn=S({},Fe,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Us,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!==Qn&&(Qn&&e.type==="mousemove"?(Fa=e.screenX-Qn.screenX,Rs=e.screenY-Qn.screenY):Rs=Fa=0,Qn=e),Fa)},movementY:function(e){return"movementY"in e?e.movementY:Rs}}),Vr=Ve(Zn),Qo=S({},Zn,{dataTransfer:0}),Yo=Ve(Qo),$o=S({},Fe,{relatedTarget:0}),ll=Ve($o),Pl=S({},yt,{animationName:0,elapsedTime:0,pseudoElement:0}),ga=Ve(Pl),Wa=S({},yt,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Vo=Ve(Wa),vl=S({},yt,{data:0}),Kr=Ve(vl),Xr={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Jr={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"},Hi={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Bi(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Hi[e])?!!t[e]:!1}function Us(){return Bi}var ks=S({},Fe,{key:function(e){if(e.key){var t=Xr[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Pe(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Jr[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Us,charCode:function(e){return e.type==="keypress"?Pe(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Pe(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Ko=Ve(ks),va=S({},Zn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Zl=Ve(va),qi=S({},Fe,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Us}),Fr=Ve(qi),Zs=S({},yt,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ls=Ve(Zs),Hs=S({},Zn,{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}),Wr=Ve(Hs),Ir=S({},yt,{newState:0,oldState:0}),Pr=Ve(Ir),ec=[9,13,27,32],Nu=Tn&&"CompositionEvent"in window,Ia=null;Tn&&"documentMode"in document&&(Ia=document.documentMode);var Xo=Tn&&"TextEvent"in window&&!Ia,Bs=Tn&&(!Nu||Ia&&8=Ia),qs=" ",ya=!1;function Gi(e,t){switch(e){case"keyup":return ec.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ht(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ba=!1;function Dt(e,t){switch(e){case"compositionend":return Ht(t);case"keypress":return t.which!==32?null:(ya=!0,qs);case"textInput":return e=t.data,e===qs&&ya?null:e;default:return null}}function tc(e,t){if(ba)return e==="compositionend"||!Nu&&Gi(e,t)?(e=Cs(),Li=Il=kn=null,ba=!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)return{node:l,offset:t-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Ne(l)}}function ct(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?ct(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function St(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zu(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=zu(e.document)}return t}function Ct(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 et=Tn&&"documentMode"in document&&11>=document.documentMode,it=null,hn=null,Bt=null,wn=!1;function Yn(e,t,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;wn||it==null||it!==zu(i)||(i=it,"selectionStart"in i&&Ct(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Bt&&Ue(Bt,i)||(Bt=i,i=$c(hn,"onSelect"),0>=h,r-=h,ta=1<<32-on(t)+r|l<Ze?(qe=ve,ve=null):qe=ve.sibling;var Xe=Z(D,ve,R[Ze],K);if(Xe===null){ve===null&&(ve=qe);break}e&&ve&&Xe.alternate===null&&t(D,ve),j=o(Xe,j,Ze),Ke===null?we=Xe:Ke.sibling=Xe,Ke=Xe,ve=qe}if(Ze===R.leng)DELIM" +R"DELIM(th)return l(D,ve),Ye&&xa(D,Ze),we;if(ve===null){for(;ZeZe?(qe=ve,ve=null):qe=ve.sibling;var _i=Z(D,ve,Xe.value,K);if(_i===null){ve===null&&(ve=qe);break}e&&ve&&_i.alternate===null&&t(D,ve),j=o(_i,j,Ze),Ke===null?we=_i:Ke.sibling=_i,Ke=_i,ve=qe}if(Xe.done)return l(D,ve),Ye&&xa(D,Ze),we;if(ve===null){for(;!Xe.done;Ze++,Xe=R.next())Xe=J(D,Xe.value,K),Xe!==null&&(j=o(Xe,j,Ze),Ke===null?we=Xe:Ke.sibling=Xe,Ke=Xe);return Ye&&xa(D,Ze),we}for(ve=i(ve);!Xe.done;Ze++,Xe=R.next())Xe=H(ve,D,Ze,Xe.value,K),Xe!==null&&(e&&Xe.alternate!==null&&ve.delete(Xe.key===null?Ze:Xe.key),j=o(Xe,j,Ze),Ke===null?we=Xe:Ke.sibling=Xe,Ke=Xe);return e&&ve.forEach(function(nS){return t(D,nS)}),Ye&&xa(D,Ze),we}function dt(D,j,R,K){if(typeof R=="object"&&R!==null&&R.type===Y&&R.key===null&&(R=R.props.children),typeof R=="object"&&R!==null){switch(R.$$typeof){case w:e:{for(var we=R.key;j!==null;){if(j.key===we){if(we=R.type,we===Y){if(j.tag===7){l(D,j.sibling),K=r(j,R.props.children),K.return=D,D=K;break e}}else if(j.elementType===we||typeof we=="object"&&we!==null&&we.$$typeof===se&&Fi(we)===j.type){l(D,j.sibling),K=r(j,R.props),Xs(K,R),K.return=D,D=K;break e}l(D,j);break}else t(D,j);j=j.sibling}R.type===Y?(K=$i(R.props.children,D.mode,K,R.key),K.return=D,D=K):(K=rc(R.type,R.key,R.props,null,D.mode,K),Xs(K,R),K.return=D,D=K)}return h(D);case O:e:{for(we=R.key;j!==null;){if(j.key===we)if(j.tag===4&&j.stateNode.containerInfo===R.containerInfo&&j.stateNode.implementation===R.implementation){l(D,j.sibling),K=r(j,R.children||[]),K.return=D,D=K;break e}else{l(D,j);break}else t(D,j);j=j.sibling}K=ef(R,D.mode,K),K.return=D,D=K}return h(D);case se:return R=Fi(R),dt(D,j,R,K)}if(de(R))return he(D,j,R,K);if(ye(R)){if(we=ye(R),typeof we!="function")throw Error(s(150));return R=we.call(R),je(D,j,R,K)}if(typeof R.then=="function")return dt(D,j,pc(R),K);if(R.$$typeof===I)return dt(D,j,fc(D,R),K);gc(D,R)}return typeof R=="string"&&R!==""||typeof R=="number"||typeof R=="bigint"?(R=""+R,j!==null&&j.tag===6?(l(D,j.sibling),K=r(j,R),K.return=D,D=K):(l(D,j),K=Po(R,D.mode,K),K.return=D,D=K),h(D)):l(D,j)}return function(D,j,R,K){try{Ks=0;var we=dt(D,j,R,K);return Bu=null,we}catch(ve){if(ve===Hu||ve===hc)throw ve;var Ke=al(29,ve,null,D.mode);return Ke.lanes=K,Ke.return=D,Ke}}}var Ii=zm(!0),Em=zm(!1),ai=!1;function hf(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mf(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 ii(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ui(e,t,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(We&2)!==0){var r=i.pending;return r===null?t.next=t:(t.next=r.next,r.next=t),i.pending=t,t=sc(e),sm(e,null,l),t}return uc(e,i,t,l),sc(e)}function Js(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var i=t.lanes;i&=e.pendingLanes,l|=i,t.lanes=l,da(e,l)}}function pf(e,t){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var r=null,o=null;if(l=l.firstBaseUpdate,l!==null){do{var h={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};o===null?r=o=h:o=o.next=h,l=l.next}while(l!==null);o===null?r=o=t:o=o.next=t}else r=o=t;l={baseState:i.baseState,firstBaseUpdate:r,lastBaseUpdate:o,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var gf=!1;function Fs(){if(gf){var e=Lu;if(e!==null)throw e}}function Ws(e,t,l,i){gf=!1;var r=e.updateQueue;ai=!1;var o=r.firstBaseUpdate,h=r.lastBaseUpdate,b=r.shared.pending;if(b!==null){r.shared.pending=null;var M=b,k=M.next;M.next=null,h===null?o=k:h.next=k,h=M;var $=e.alternate;$!==null&&($=$.updateQueue,b=$.lastBaseUpdate,b!==h&&(b===null?$.firstBaseUpdate=k:b.next=k,$.lastBaseUpdate=M))}if(o!==null){var J=r.baseState;h=0,$=k=M=null,b=o;do{var Z=b.lane&-536870913,H=Z!==b.lane;if(H?(Be&Z)===Z:(i&Z)===Z){Z!==0&&Z===Zu&&(gf=!0),$!==null&&($=$.next={lane:0,tag:b.tag,payload:b.payload,callback:null,next:null});e:{var he=e,je=b;Z=t;var dt=l;switch(je.tag){case 1:if(he=je.payload,typeof he=="function"){J=he.call(dt,J,Z);break e}J=he;break e;case 3:he.flags=he.flags&-65537|128;case 0:if(he=je.payload,Z=typeof he=="function"?he.call(dt,J,Z):he,Z==null)break e;J=S({},J,Z);break e;case 2:ai=!0}}Z=b.callback,Z!==null&&(e.flags|=64,H&&(e.flags|=8192),H=r.callbacks,H===null?r.callbacks=[Z]:H.push(Z))}else H={lane:Z,tag:b.tag,payload:b.payload,callback:b.callback,next:null},$===null?(k=$=H,M=J):$=$.next=H,h|=Z;if(b=b.next,b===null){if(b=r.shared.pending,b===null)break;H=b,b=H.next,H.next=null,r.lastBaseUpdate=H,r.shared.pending=null}}while(!0);$===null&&(M=J),r.baseState=M,r.firstBaseUpdate=k,r.lastBaseUpdate=$,o===null&&(r.shared.lanes=0),fi|=h,e.lanes=h,e.memoizedState=J}}function Tm(e,t){if(typeof e!="function")throw Error(s(191,e));e.call(t)}function wm(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;eo?o:8;var h=U.T,b={};U.T=b,Uf(e,!1,t,l);try{var M=r(),k=U.S;if(k!==null&&k(b,M),M!==null&&typeof M=="object"&&typeof M.then=="function"){var $=$b(M,i);er(e,t,$,cl(e))}else er(e,t,i,cl(e))}catch(J){er(e,t,{then:function(){},status:"rejected",reason:J},cl())}finally{Q.p=o,h!==null&&b.types!==null&&(h.types=b.types),U.T=h}}function Wb(){}function Cf(e,t,l,i){if(e.tag!==5)throw Error(s(476));var r=ap(e).queue;lp(e,r,t,me,l===null?Wb:function(){return ip(e),l(i)})}function ap(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:me,baseState:me,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:me},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wa,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ip(e){var t=ap(e);t.next===null&&(t=e.alternate.memoizedState),er(e,t.next.queue,{},cl())}function Rf(){return gn(vr)}function up(){return Gt().memoizedState}function sp(){return Gt().memoizedState}function Ib(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=cl();e=ii(l);var i=ui(t,e,l);i!==null&&(Fn(i,t,l),Js(i,t,l)),t={cache:cf()},e.payload=t;return}t=t.return}}function Pb(e,t,l){var i=cl();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},wc(e)?cp(t,l):(l=Wo(e,t,l,i),l!==null&&(Fn(l,e,i),op(l,t,i)))}function rp(e,t,l){var i=cl();er(e,t,l,i)}function er(e,t,l,i){var r={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(wc(e))cp(t,r);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var h=t.lastRenderedState,b=o(h,l);if(r.hasEagerState=!0,r.eagerState=b,Ce(b,h))return uc(e,t,r,0),pt===null&&ic(),!1}catch{}if(l=Wo(e,t,r,i),l!==null)return Fn(l,e,i),op(l,t,i),!0}return!1}function Uf(e,t,l,i){if(i={lane:2,revertLane:hd(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},wc(e)){if(t)throw Error(s(479))}else t=Wo(e,l,i,2),t!==null&&Fn(t,e,2)}function wc(e){var t=e.alternate;return e===ke||t!==null&&t===ke}function cp(e,t){Gu=bc=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function op(e,t,l){if((l&4194048)!==0){var i=t.lanes;i&=e.pendingLanes,l|=i,t.lanes=l,da(e,l)}}var tr={readContext:gn,use:xc,useCallback:Rt,useContext:Rt,useEffect:Rt,useImperativeHandle:Rt,useLayoutEffect:Rt,useInsertionEffect:Rt,useMemo:Rt,useReducer:Rt,useRef:Rt,useState:Rt,useDebugValue:Rt,useDeferredValue:Rt,useTransition:Rt,useSyncExternalStore:Rt,useId:Rt,useHostTransitionStatus:Rt,useFormState:Rt,useActionState:Rt,useOptimistic:Rt,useMemoCache:Rt,useCacheRefresh:Rt};tr.useEffectEvent=Rt;var fp={readContext:gn,use:xc,useCallback:function(e,t){return Ln().memoizedState=[e,t===void 0?null:t],e},useContext:gn,useEffect:Xm,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Ec(4194308,4,Im.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Ec(4194308,4,e,t)},useInsertionEffect:function(e,t){Ec(4,2,e,t)},useMemo:function(e,t){var l=Ln();t=t===void 0?null:t;var i=e();if(Pi){Qt(!0);try{e()}finally{Qt(!1)}}return l.memoizedState=[i,t],i},useReducer:function(e,t,l){var i=Ln();if(l!==void 0){var r=l(t);if(Pi){Qt(!0);try{l(t)}finally{Qt(!1)}}}else r=t;return i.memoizedState=i.baseState=r,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:r},i.queue=e,e=e.dispatch=Pb.bind(null,ke,e),[i.memoizedState,e]},useRef:function(e){var t=Ln();return e={current:e},t.memoizedState=e},useState:function(e){e=Af(e);var t=e.queue,l=rp.bind(null,ke,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:jf,useDeferredValue:function(e,t){var l=Ln();return Df(l,e,t)},useTransition:function(){var e=Af(!1);return e=lp.bind(null,ke,e.queue,!0,!1),Ln().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var i=ke,r=Ln();if(Ye){if(l===void 0)throw Error(s(407));l=l()}else{if(l=t(),pt===null)throw Error(s(349));(Be&127)!==0||Dm(i,t,l)}r.memoizedState=l;var o={value:l,getSnapshot:t};return r.queue=o,Xm(Rm.bind(null,i,o,e),[e]),i.flags|=2048,Yu(9,{destroy:void 0},Cm.bind(null,i,o,l,t),null),l},useId:function(){var e=Ln(),t=pt.identifierPrefix;if(Ye){var l=na,i=ta;l=(i&~(1<<32-on(i)-1)).toString(32)+l,t="_"+t+"R_"+l,l=Sc++,0<\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof i.is=="string"?h.createElement("select",{is:i.is}):h.createElement("select"),i.multiple?o.multiple=!0:i.size&&(o.size=i.size);break;default:o=typeof i.is=="string"?h.createElement(r,{is:i.is}):h.createElement(r)}}o[Wt]=t,o[En]=i;e:for(h=t.child;h!==null;){if(h.tag===5||h.tag===6)o.appendChild(h.stateNode);else if(h.tag!==4&&h.tag!==27&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===t)break e;for(;h.sibling===null;){if(h.return===null||h.return===t)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}t.stateNode=o;e:switch(yn(o,r,i),r){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Aa(t)}}return xt(t),Jf(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==i&&Aa(t);else{if(typeof i!="string"&&t.stateNode===null)throw Error(s(166));if(e=pe.current,Uu(t)){if(e=t.stateNode,l=t.memoizedProps,i=null,r=pn,r!==null)switch(r.tag){case 27:case 5:i=r.memoizedProps}e[Wt]=t,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Ng(e.nodeValue,l)),e||ni(t,!0)}else e=Vc(e).createTextNode(i),e[Wt]=t,t.stateNode=e}return xt(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(i=Uu(t),l!==null){if(e===null){if(!i)throw Error(s(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(s(557));e[Wt]=t}else Vi(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;xt(t),e=!1}else l=af(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(ul(t),t):(ul(t),null);if((t.flags&128)!==0)throw Error(s(558))}return xt(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(r=Uu(t),i!==null&&i.dehydrated!==null){if(e===null){if(!r)throw Err)DELIM" +R"DELIM(or(s(318));if(r=t.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));r[Wt]=t}else Vi(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;xt(t),r=!1}else r=af(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),r=!0;if(!r)return t.flags&256?(ul(t),t):(ul(t),null)}return ul(t),(t.flags&128)!==0?(t.lanes=l,t):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=t.child,r=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(r=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==r&&(i.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),jc(t,t.updateQueue),xt(t),null);case 4:return Qe(),e===null&&vd(t.stateNode.containerInfo),xt(t),null;case 10:return Ea(t.type),xt(t),null;case 19:if(L(qt),i=t.memoizedState,i===null)return xt(t),null;if(r=(t.flags&128)!==0,o=i.rendering,o===null)if(r)lr(i,!1);else{if(Ut!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(o=yc(e),o!==null){for(t.flags|=128,lr(i,!1),e=o.updateQueue,t.updateQueue=e,jc(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)rm(l,e),l=l.sibling;return G(qt,qt.current&1|2),Ye&&xa(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Te()>kc&&(t.flags|=128,r=!0,lr(i,!1),t.lanes=4194304)}else{if(!r)if(e=yc(o),e!==null){if(t.flags|=128,r=!0,e=e.updateQueue,t.updateQueue=e,jc(t,e),lr(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Ye)return xt(t),null}else 2*Te()-i.renderingStartTime>kc&&l!==536870912&&(t.flags|=128,r=!0,lr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e!==null?e.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Te(),e.sibling=null,l=qt.current,G(qt,r?l&1|2:l&1),Ye&&xa(t,i.treeForkCount),e):(xt(t),null);case 22:case 23:return ul(t),yf(),i=t.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(t.flags|=8192):i&&(t.flags|=8192),i?(l&536870912)!==0&&(t.flags&128)===0&&(xt(t),t.subtreeFlags&6&&(t.flags|=8192)):xt(t),l=t.updateQueue,l!==null&&jc(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==l&&(t.flags|=2048),e!==null&&L(Ji),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),Ea($t),xt(t),null;case 25:return null;case 30:return null}throw Error(s(156,t.tag))}function a1(e,t){switch(nf(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ea($t),Qe(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Nn(t),null;case 31:if(t.memoizedState!==null){if(ul(t),t.alternate===null)throw Error(s(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(ul(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(s(340));Vi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return L(qt),null;case 4:return Qe(),null;case 10:return Ea(t.type),null;case 22:case 23:return ul(t),yf(),e!==null&&L(Ji),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ea($t),null;case 25:return null;default:return null}}function Up(e,t){switch(nf(t),t.tag){case 3:Ea($t),Qe();break;case 26:case 27:case 5:Nn(t);break;case 4:Qe();break;case 31:t.memoizedState!==null&&ul(t);break;case 13:ul(t);break;case 19:L(qt);break;case 10:Ea(t.type);break;case 22:case 23:ul(t),yf(),e!==null&&L(Ji);break;case 24:Ea($t)}}function ar(e,t){try{var l=t.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var r=i.next;l=r;do{if((l.tag&e)===e){i=void 0;var o=l.create,h=l.inst;i=o(),h.destroy=i}l=l.next}while(l!==r)}}catch(b){st(t,t.return,b)}}function ci(e,t,l){try{var i=t.updateQueue,r=i!==null?i.lastEffect:null;if(r!==null){var o=r.next;i=o;do{if((i.tag&e)===e){var h=i.inst,b=h.destroy;if(b!==void 0){h.destroy=void 0,r=t;var M=l,k=b;try{k()}catch($){st(r,M,$)}}}i=i.next}while(i!==o)}}catch($){st(t,t.return,$)}}function kp(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{wm(t,l)}catch(i){st(e,e.return,i)}}}function Zp(e,t,l){l.props=eu(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){st(e,t,i)}}function ir(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(r){st(e,t,r)}}function la(e,t){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(r){st(e,t,r)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(r){st(e,t,r)}else l.current=null}function Lp(e){var t=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(r){st(e,e.return,r)}}function Ff(e,t,l){try{var i=e.stateNode;w1(i,e.type,l,t),i[En]=t}catch(r){st(e,e.return,r)}}function Hp(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&gi(e.type)||e.tag===4}function Wf(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Hp(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&&gi(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 If(e,t,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=Un));else if(i!==4&&(i===27&&gi(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(If(e,t,l),e=e.sibling;e!==null;)If(e,t,l),e=e.sibling}function Dc(e,t,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(i!==4&&(i===27&&gi(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Dc(e,t,l),e=e.sibling;e!==null;)Dc(e,t,l),e=e.sibling}function Bp(e){var t=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,r=t.attributes;r.length;)t.removeAttributeNode(r[0]);yn(t,i,l),t[Wt]=e,t[En]=l}catch(o){st(e,e.return,o)}}var Oa=!1,Xt=!1,Pf=!1,qp=typeof WeakSet=="function"?WeakSet:Set,rn=null;function i1(e,t){if(e=e.containerInfo,Sd=Pc,e=St(e),Ct(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var r=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{l.nodeType,o.nodeType}catch{l=null;break e}var h=0,b=-1,M=-1,k=0,$=0,J=e,Z=null;t:for(;;){for(var H;J!==l||r!==0&&J.nodeType!==3||(b=h+r),J!==o||i!==0&&J.nodeType!==3||(M=h+i),J.nodeType===3&&(h+=J.nodeValue.length),(H=J.firstChild)!==null;)Z=J,J=H;for(;;){if(J===e)break t;if(Z===l&&++k===r&&(b=h),Z===o&&++$===i&&(M=h),(H=J.nextSibling)!==null)break;J=Z,Z=J.parentNode}J=H}l=b===-1||M===-1?null:{start:b,end:M}}else l=null}l=l||{start:0,end:0}}else l=null;for(_d={focusedElem:e,selectionRange:l},Pc=!1,rn=t;rn!==null;)if(t=rn,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,rn=e;else for(;rn!==null;){switch(t=rn,o=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(l=0;l title"))),yn(o,i,l),o[Wt]=e,Lt(o),i=o;break e;case"link":var h=Kg("link","href",r).get(i+(l.href||""));if(h){for(var b=0;bdt&&(h=dt,dt=je,je=h);var D=Se(b,je),j=Se(b,dt);if(D&&j&&(H.rangeCount!==1||H.anchorNode!==D.node||H.anchorOffset!==D.offset||H.focusNode!==j.node||H.focusOffset!==j.offset)){var R=J.createRange();R.setStart(D.node,D.offset),H.removeAllRanges(),je>dt?(H.addRange(R),H.extend(j.node,j.offset)):(R.setEnd(j.node,j.offset),H.addRange(R))}}}}for(J=[],H=b;H=H.parentNode;)H.nodeType===1&&J.push({element:H,left:H.scrollLeft,top:H.scrollTop});for(typeof b.focus=="function"&&b.focus(),b=0;bl?32:l,U.T=null,l=ud,ud=null;var o=hi,h=Ra;if(It=0,Ju=hi=null,Ra=0,(We&6)!==0)throw Error(s(331));var b=We;if(We|=4,Ip(o.current),Jp(o,o.current,h,l),We=b,fr(0,!1),rt&&typeof rt.onPostCommitFiberRoot=="function")try{rt.onPostCommitFiberRoot(nn,o)}catch{}return!0}finally{Q.p=r,U.T=i,gg(e,t)}}function yg(e,t,l){t=bl(l,t),t=Hf(e.stateNode,t,2),e=ui(e,t,2),e!==null&&(tl(e,2),aa(e))}function st(e,t,l){if(e.tag===3)yg(e,e,l);else for(;t!==null;){if(t.tag===3){yg(t,e,l);break}else if(t.tag===1){var i=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(di===null||!di.has(i))){e=bl(l,e),l=bp(2),i=ui(t,l,2),i!==null&&(Sp(l,i,t,e),tl(i,2),aa(i));break}}t=t.return}}function od(e,t,l){var i=e.pingCache;if(i===null){i=e.pingCache=new r1;var r=new Set;i.set(t,r)}else r=i.get(t),r===void 0&&(r=new Set,i.set(t,r));r.has(l)||(nd=!0,r.add(l),e=h1.bind(null,e,t,l),t.then(e,e))}function h1(e,t,l){var i=e.pingCache;i!==null&&i.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,pt===e&&(Be&l)===l&&(Ut===4||Ut===3&&(Be&62914560)===Be&&300>Te()-Uc?(We&2)===0&&Fu(e,0):ld|=l,Xu===Be&&(Xu=0)),aa(e)}function bg(e,t){t===0&&(t=Br()),e=Yi(e,t),e!==null&&(tl(e,t),aa(e))}function m1(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),bg(e,l)}function p1(e,t){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,r=e.memoizedState;r!==null&&(l=r.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(s(314))}i!==null&&i.delete(t),bg(e,l)}function g1(e,t){return Ft(e,t)}var Gc=null,Iu=null,fd=!1,Qc=!1,dd=!1,pi=0;function aa(e){e!==Iu&&e.next===null&&(Iu===null?Gc=Iu=e:Iu=Iu.next=e),Qc=!0,fd||(fd=!0,y1())}function fr(e,t){if(!dd&&Qc){dd=!0;do for(var l=!1,i=Gc;i!==null;){if(e!==0){var r=i.pendingLanes;if(r===0)var o=0;else{var h=i.suspendedLanes,b=i.pingedLanes;o=(1<<31-on(42|e)+1)-1,o&=r&~(h&~b),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(l=!0,zg(i,o))}else o=Be,o=yu(i,i===pt?o:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(o&3)===0||Di(i,o)||(l=!0,zg(i,o));i=i.next}while(l);dd=!1}}function v1(){Sg()}function Sg(){Qc=fd=!1;var e=0;pi!==0&&A1()&&(e=pi);for(var t=Te(),l=null,i=Gc;i!==null;){var r=i.next,o=_g(i,t);o===0?(i.next=null,l===null?Gc=r:l.next=r,r===null&&(Iu=l)):(l=i,(e!==0||(o&3)!==0)&&(Qc=!0)),i=r}It!==0&&It!==5||fr(e),pi!==0&&(pi=0)}function _g(e,t){for(var l=e.suspendedLanes,i=e.pingedLanes,r=e.expirationTimes,o=e.pendingLanes&-62914561;0b)break;var $=M.transferSize,J=M.initiatorType;$&&jg(J)&&(M=M.responseEnd,h+=$*(M"u"?null:document;function Qg(e,t,l){var i=Pu;if(i&&typeof t=="string"&&t){var r=Rn(t);r='link[rel="'+e+'"][href="'+r+'"]',typeof l=="string"&&(r+='[crossorigin="'+l+'"]'),Gg.has(r)||(Gg.add(r),e={rel:e,crossOrigin:l,href:t},i.querySelector(r)===null&&(t=i.createElement("link"),yn(t,"link",e),Lt(t),i.head.appendChild(t)))}}function Z1(e){Ua.D(e),Qg("dns-prefetch",e,null)}function L1(e,t){Ua.C(e,t),Qg("preconnect",e,t)}function H1(e,t,l){Ua.L(e,t,l);var i=Pu;if(i&&e&&t){var r='link[rel="preload"][as="'+Rn(t)+'"]';t==="image"&&l&&l.imageSrcSet?(r+='[imagesrcset="'+Rn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(r+='[imagesizes="'+Rn(l.imageSizes)+'"]')):r+='[href="'+Rn(e)+'"]';var o=r;switch(t){case"style":o=es(e);break;case"script":o=ts(e)}Tl.has(o)||(e=S({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Tl.set(o,e),i.querySelector(r)!==null||t==="style"&&i.querySelector(pr(o))||t==="script"&&i.querySelector(gr(o))||(t=i.createElement("link"),yn(t,"link",e),Lt(t),i.head.appendChild(t)))}}function B1(e,t){Ua.m(e,t);var l=Pu;if(l&&e){var i=t&&typeof t.as=="string"?t.as:"script",r='link[rel="modulepreload"][as="'+Rn(i)+'"][href="'+Rn(e)+'"]',o=r;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=ts(e)}if(!Tl.has(o)&&(e=S({rel:"modulepreload",href:e},t),Tl.set(o,e),l.querySelector(r)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(gr(o)))return}i=l.createElement("link"),yn(i,"link",e),Lt(i),l.head.appendChild(i)}}}function q1(e,t,l){Ua.S(e,t,l);var i=Pu;if(i&&e){var r=pl(i).hoistableStyles,o=es(e);t=t||"default";var h=r.get(o);if(!h){var b={loading:0,preload:null};if(h=i.querySelector(pr(o)))b.loading=5;else{e=S({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Tl.get(o))&&Ad(e,l);var M=h=i.createElement("link");Lt(M),yn(M,"link",e),M._p=new Promise(function(k,$){M.onload=k,M.onerror=$}),M.addEventListener("load",function(){b.loading|=1}),M.addEventListener("error",function(){b.loading|=2}),b.loading|=4,Xc(h,t,i)}h={type:"stylesheet",instance:h,count:1,state:b},r.set(o,h)}}}function G1(e,t){Ua.X(e,t);var l=Pu;if(l&&e){var i=pl(l).hoistableScripts,r=ts(e),o=i.get(r);o||(o=l.querySelector(gr(r)),o||(e=S({src:e,async:!0},t),(t=Tl.get(r))&&Od(e,t),o=l.createElement("script"),Lt(o),yn(o,"link",e),l.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},i.set(r,o))}}function Q1(e,t){Ua.M(e,t);var l=Pu;if(l&&e){var i=pl(l).hoistableScripts,r=ts(e),o=i.get(r);o||(o=)DELIM" +R"DELIM(l.querySelector(gr(r)),o||(e=S({src:e,async:!0,type:"module"},t),(t=Tl.get(r))&&Od(e,t),o=l.createElement("script"),Lt(o),yn(o,"link",e),l.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},i.set(r,o))}}function Yg(e,t,l,i){var r=(r=pe.current)?Kc(r):null;if(!r)throw Error(s(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=es(l.href),l=pl(r).hoistableStyles,i=l.get(t),i||(i={type:"style",instance:null,count:0,state:null},l.set(t,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=es(l.href);var o=pl(r).hoistableStyles,h=o.get(e);if(h||(r=r.ownerDocument||r,h={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,h),(o=r.querySelector(pr(e)))&&!o._p&&(h.instance=o,h.state.loading=5),Tl.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Tl.set(e,l),o||Y1(r,e,l,h.state))),t&&i===null)throw Error(s(528,""));return h}if(t&&i!==null)throw Error(s(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=ts(l),l=pl(r).hoistableScripts,i=l.get(t),i||(i={type:"script",instance:null,count:0,state:null},l.set(t,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,e))}}function es(e){return'href="'+Rn(e)+'"'}function pr(e){return'link[rel="stylesheet"]['+e+"]"}function $g(e){return S({},e,{"data-precedence":e.precedence,precedence:null})}function Y1(e,t,l,i){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?i.loading=1:(t=e.createElement("link"),i.preload=t,t.addEventListener("load",function(){return i.loading|=1}),t.addEventListener("error",function(){return i.loading|=2}),yn(t,"link",l),Lt(t),e.head.appendChild(t))}function ts(e){return'[src="'+Rn(e)+'"]'}function gr(e){return"script[async]"+e}function Vg(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var i=e.querySelector('style[data-href~="'+Rn(l.href)+'"]');if(i)return t.instance=i,Lt(i),i;var r=S({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Lt(i),yn(i,"style",r),Xc(i,l.precedence,e),t.instance=i;case"stylesheet":r=es(l.href);var o=e.querySelector(pr(r));if(o)return t.state.loading|=4,t.instance=o,Lt(o),o;i=$g(l),(r=Tl.get(r))&&Ad(i,r),o=(e.ownerDocument||e).createElement("link"),Lt(o);var h=o;return h._p=new Promise(function(b,M){h.onload=b,h.onerror=M}),yn(o,"link",i),t.state.loading|=4,Xc(o,l.precedence,e),t.instance=o;case"script":return o=ts(l.src),(r=e.querySelector(gr(o)))?(t.instance=r,Lt(r),r):(i=l,(r=Tl.get(o))&&(i=S({},l),Od(i,r)),e=e.ownerDocument||e,r=e.createElement("script"),Lt(r),yn(r,"link",i),e.head.appendChild(r),t.instance=r);case"void":return null;default:throw Error(s(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(i=t.instance,t.state.loading|=4,Xc(i,l.precedence,e));return t.instance}function Xc(e,t,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),r=i.length?i[i.length-1]:null,o=r,h=0;h title"):null)}function $1(e,t,l){if(l===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 Jg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function V1(e,t,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var r=es(i.href),o=t.querySelector(pr(r));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Fc.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=o,Lt(o);return}o=t.ownerDocument||t,i=$g(i),(r=Tl.get(r))&&Ad(i,r),o=o.createElement("link"),Lt(o);var h=o;h._p=new Promise(function(b,M){h.onload=b,h.onerror=M}),yn(o,"link",i),l.instance=o}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=Fc.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Nd=0;function K1(e,t){return e.stylesheets&&e.count===0&&Ic(e,e.stylesheets),0Nd?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(r)}}:null}function Fc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ic(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Wc=null;function Ic(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Wc=new Map,t.forEach(X1,e),Wc=null,Fc.call(e))}function X1(e,t){if(!(t.state.loading&4)){var l=Wc.get(e);if(l)var i=l.get(null);else{l=new Map,Wc.set(e,l);for(var r=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(a){console.error(a)}}return n(),Hd.exports=fS(),Hd.exports}var hS=dS();const mS=Fv(hS),zh="libbitcoinAdminDashboardEndpoints";function Eh(){try{return globalThis.window?.localStorage??null}catch{return null}}function pS(){return globalThis.window?.location.origin??"http://localhost"}function ua(n){const a=n.trim();if(!a)throw new Error("Endpoint URL is required");const u=/^[a-z][a-z\d+\-.]*:\/\//iu.test(a)?a:`http://${a}`,s=new URL(u);if(s.protocol!=="http:"&&s.protocol!=="https:")throw new Error("Endpoint must use HTTP or HTTPS");return s.pathname=s.pathname.replace(/\/+$/u,"")||"/",s.search="",s.hash="",s.toString().replace(/\/$/u,"")}function Wv(n){const a=new URL(ua(n));return a.protocol=a.protocol==="https:"?"wss:":"ws:",a.pathname="/",a.search="",a.hash="",a.toString()}function gS(n,a=pS()){return new URL(ua(n)).origin===new URL(a).origin}function Iv(){return{adminUrl:ua("http://172.20.208.1:8080"),nativeUrl:ua("http://172.20.208.1:80")}}function vS(n=Eh()){const a=Iv();try{const u=n?.getItem(zh);if(!u)return a;const s=JSON.parse(u);if(!s||typeof s!="object"||Array.isArray(s))return a;const c=s;return{adminUrl:typeof c.adminUrl=="string"?ua(c.adminUrl):a.adminUrl,nativeUrl:typeof c.nativeUrl=="string"?ua(c.nativeUrl):a.nativeUrl}}catch{return a}}function yS(n,a=Eh()){const u={adminUrl:ua(n.adminUrl),nativeUrl:ua(n.nativeUrl)};try{a?.setItem(zh,JSON.stringify(u))}catch{}}function bS(n=Eh()){try{n?.removeItem(zh)}catch{}}function SS({configuration:n,onClose:a,onReset:u,onSave:s}){const[c,d]=_e.useState(n.adminUrl),[f,p]=_e.useState(n.nativeUrl),[g,v]=_e.useState(null);function x(S){S.preventDefault();try{s({adminUrl:ua(c),nativeUrl:ua(f)})}catch(T){v(T instanceof Error?T.message:"Invalid endpoint configuration")}}return z.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",role:"presentation",onMouseDown:S=>{S.target===S.currentTarget&&a()},children:z.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"endpoint-settings-title",className:"border-accent/30 bg-surface w-full max-w-xl rounded-2xl border shadow-2xl shadow-black/50",children:[z.jsxs("header",{className:"border-accent/20 flex items-start justify-between border-b p-5",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Runtime configuration"}),z.jsx("h2",{id:"endpoint-settings-title",className:"mt-1 text-xl font-semibold",children:"Node endpoints"})]}),z.jsx("button",{type:"button",onClick:a,className:"text-textMuted hover:text-accent rounded p-1 text-xl","aria-label":"Close endpoint settings",children:"×"})]}),z.jsxs("form",{onSubmit:x,className:"space-y-5 p-5",children:[z.jsxs("label",{className:"block space-y-2",children:[z.jsx("span",{className:"text-textPrimary text-sm font-medium",children:"Admin endpoint"}),z.jsx("input",{value:c,onChange:S=>{d(S.target.value)},className:"border-accent/30 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 font-mono text-sm focus:ring-0",placeholder:"http://node-host:admin-port",autoComplete:"url"})]}),z.jsxs("label",{className:"block space-y-2",children:[z.jsx("span",{className:"text-textPrimary text-sm font-medium",children:"Native endpoint"}),z.jsx("input",{value:f,onChange:S=>{p(S.target.value)},className:"border-accent/30 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 font-mono text-sm focus:ring-0",placeholder:"http://node-host:native-port",autoComplete:"url"})]}),g&&z.jsx("p",{className:"rounded-lg border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-300",children:g}),z.jsxs("div",{className:"flex flex-wrap justify-between gap-3 pt-2",children:[z.jsx("button",{type:"button",onClick:u,className:"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary rounded-lg border px-4 py-2 text-sm",children:"Reset defaults"}),z.jsxs("div",{className:"flex gap-2",children:[z.jsx("button",{type:"button",onClick:a,className:"text-textMuted hover:text-textPrimary rounded-lg px-4 py-2 text-sm",children:"Cancel"}),z.jsx("button",{type:"submit",className:"bg-accent text-background hover:bg-accent/90 rounded-lg px-4 py-2 text-sm font-semibold",children:"Save and reconnect"})]})]})]})]})})}var b0;function X(n,a,u){function s(p,g){if(p._zod||Object.defineProperty(p,"_zod",{value:{def:g,constr:f,traits:new Set},enumerable:!1}),p._zod.traits.has(n))return;p._zod.traits.add(n),a(p,g);const v=f.prototype,x=Object.keys(v);for(let S=0;Su?.Parent&&p instanceof u.Parent?!0:p?._zod?.traits?.has(n)}),Object.defineProperty(f,"name",{value:n}),f}class cs extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Pv extends Error{constructor(a){super(`Encountered unidirectional transform during encode: ${a}`),this.name="ZodEncodeError"}}(b0=globalThis).__zod_globalConfig??(b0.__zod_globalConfig={});const Th=globalThis.__zod_globalConfig;function fu(n){return Th}function ey(n){const a=Object.values(n).filter(s=>typeof s=="number");return Object.entries(n).filter(([s,c])=>a.indexOf(+s)===-1).map(([s,c])=>c)}function Pd(n,a){return typeof a=="bigint"?a.toString():a}function wh(n){return{get value(){{const a=n();return Object.defineProperty(this,"value",{value:a}),a}}}}function Mh(n){return n==null}function Ah(n){const a=n.startsWith("^")?1:0,u=n.endsWith("$")?n.length-1:n.length;return n.slice(a,u)}function _S(n,a){const u=n/a,s=Math.round(u),c=Number.EPSILON*Math.max(Math.abs(u),1);return Math.abs(u-s){};function bo(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}const zS=wh(()=>{if(Th.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const n=Function;return new n(""),!0}catch{return!1}});function Dr(n){if(bo(n)===!1)return!1;const a=n.constructor;if(a===void 0||typeof a!="function")return!0;const u=a.prototype;return!(bo(u)===!1||Object.prototype.hasOwnProperty.call(u,"isPrototypeOf")===!1)}function ny(n){return Dr(n)?{...n}:Array.isArray(n)?[...n]:n instanceof Map?new Map(n):n instanceof Set?new Set(n):n}const ES=new Set(["string","number","symbol"]);function ds(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oi(n,a,u){const s=new n._zod.constr(a??n._zod.def);return(!a||u?.parent)&&(s._zod.parent=n),s}function Me(n){const a=n;if(!a)return{};if(typeof a=="string")return{error:()=>a};if(a?.message!==void 0){if(a?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");a.error=a.message}return delete a.message,typeof a.error=="string"?{...a,error:()=>a.error}:a}function TS(n){return Object.keys(n).filter(a=>n[a]._zod.optin==="optional"&&n[a]._zod.optout==="optional")}const wS={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function MS(n,a){const u=n._zod.def,s=u.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const d=Ai(n._zod.def,{get shape(){const f={};for(const p in a){if(!(p in u.shape))throw new Error(`Unrecognized key: "${p}"`);a[p]&&(f[p]=u.shape[p])}return mu(this,"shape",f),f},checks:[]});return Oi(n,d)}function AS(n,a){const u=n._zod.def,s=u.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const d=Ai(n._zod.def,{get shape(){const f={...n._zod.def.shape};for(const p in a){if(!(p in u.shape))throw new Error(`Unrecognized key: "${p}"`);a[p]&&delete f[p]}return mu(this,"shape",f),f},checks:[]});return Oi(n,d)}function OS(n,a){if(!Dr(a))throw new Error("Invalid input to extend: expected a plain object");const u=n._zod.def.checks;if(u&&u.length>0){const d=n._zod.def.shape;for(const f in a)if(Object.getOwnPropertyDescriptor(d,f)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const c=Ai(n._zod.def,{get shape(){const d={...n._zod.def.shape,...a};return mu(this,"shape",d),d}});return Oi(n,c)}function NS(n,a){if(!Dr(a))throw new Error("Invalid input to safeExtend: expected a plain object");const u=Ai(n._zod.def,{get shape(){const s={...n._zod.def.shape,...a};return mu(this,"shape",s),s}});return Oi(n,u)}function jS(n,a){if(n._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const u=Ai(n._zod.def,{get shape(){const s={...n._zod.def.shape,...a._zod.def.shape};return mu(this,"shape",s),s},get catchall(){return a._zod.def.catchall},checks:a._zod.def.checks??[]});return Oi(n,u)}function DS(n,a,u){const c=a._zod.def.checks;if(c&&c.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const f=Ai(a._zod.def,{get shape(){const p=a._zod.def.shape,g={...p};if(u)for(const v in u){if(!(v in p))throw new Error(`Unrecognized key: "${v}"`);u[v]&&(g[v]=n?new n({type:"optional",innerType:p[v]}):p[v])}else for(const v in p)g[v]=n?new n({type:"optional",innerType:p[v]}):p[v];return mu(this,"shape",g),g},checks:[]});return Oi(a,f)}function CS(n,a,u){const s=Ai(a._zod.def,{get shape(){const c=a._zod.def.shape,d={...c};if(u)for(const f in u){if(!(f in d))throw new Error(`Unrecognized key: "${f}"`);u[f]&&(d[f]=new n({type:"nonoptional",innerType:c[f]}))}else for(const f in c)d[f]=new n({type:"nonoptional",innerType:c[f]});return mu(this,"shape",d),d}});return Oi(a,s)}function rs(n,a=0){if(n.aborted===!0)return!0;for(let u=a;u{var s;return(s=u).path??(s.path=[]),u.path.unshift(n),u})}function uo(n){return typeof n=="string"?n:n?.message}function du(n,a,u){const s=n.message?n.message:uo(n.inst?._zod.def?.error?.(n))??uo(a?.error?.(n))??uo(u.customError?.(n))??uo(u.localeError?.(n))??"Invalid input",{inst:c,continue:d,input:f,...p}=n;return p.path??(p.path=[]),p.message=s,a?.reportInput&&(p.input=f),p}function Oh(n){return Array.isArray(n)?"array":typeof n=="string"?"string":"unknown"}function Cr(...n){const[a,u,s]=n;return typeof a=="string"?{message:a,code:"custom",input:u,inst:s}:{...a}}const ay=(n,a)=>{n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:a,enumerable:!1}),n.message=JSON.stringify(a,Pd,2),Object.defineProperty(n,"toString",{value:()=>n.message,enumerable:!1})},iy=X("$ZodError",ay),uy=X("$ZodError",ay,{Parent:Error});function US(n,a=u=>u.message){const u={},s=[];for(const c of n.issues)c.path.length>0?(u[c.path[0]]=u[c.path[0]]||[],u[c.path[0]].push(a(c))):s.push(a(c));return{formErrors:s,fieldErrors:u}}function kS(n,a=u=>u.message){const u={_errors:[]},s=(c,d=[])=>{for(const f of c.issues)if(f.code==="invalid_union"&&f.errors.length)f.errors.map(p=>s({issues:p},[...d,...f.path]));else if(f.code==="invalid_key")s({issues:f.issues},[...d,...f.path]);else if(f.code==="invalid_element")s({issues:f.issues},[...d,...f.path]);else{const p=[...d,...f.path];if(p.length===0)u._errors.push(a(f));else{let g=u,v=0;for(;v(a,u,s,c)=>{const d=s?{...s,async:!1}:{async:!1},f=a._zod.run({value:u,issues:[]},d);if(f instanceof Promise)throw new cs;if(f.issues.length){const p=new(c?.Err??n)(f.issues.map(g=>du(g,d,fu())));throw ty(p,c?.callee),p}return f.value},jh=n=>async(a,u,s,c)=>{const d=s?{...s,async:!0}:{async:!0};let f=a._zod.run({value:u,issues:[]},d);if(f instanceof Promise&&(f=await f),f.issues.length){const p=new(c?.Err??n)(f.issues.map(g=>du(g,d,fu())));throw ty(p,c?.callee),p}return f.value},Oo=n=>(a,u,s)=>{const c=s?{...s,async:!1}:{async:!1},d=a._zod.run({value:u,issues:[]},c);if(d instanceof Promise)throw new cs;return d.issues.length?{success:!1,error:new(n??iy)(d.issues.map(f=>du(f,c,fu())))}:{success:!0,data:d.value}},ZS=Oo(uy),No=n=>async(a,u,s)=>{const c=s?{...s,async:!0}:{async:!0};let d=a._zod.run({value:u,issues:[]},c);return d instanceof Promise&&(d=await d),d.issues.length?{success:!1,error:new n(d.issues.map(f=>du(f,c,fu())))}:{success:!0,data:d.value}},LS=No(uy),HS=n=>(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return Nh(n)(a,u,c)},BS=n=>(a,u,s)=>Nh(n)(a,u,s),qS=n=>async(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return jh(n)(a,u,c)},GS=n=>async(a,u,s)=>jh(n)(a,u,s),QS=n=>(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return Oo(n)(a,u,c)},YS=n=>(a,u,s)=>Oo(n)(a,u,s),$S=n=>async(a,u,s)=>{const c=s?{...s,direction:"backward"}:{direction:"backward"};return No(n)(a,u,c)},VS=n=>async(a,u,s)=>No(n)(a,u,s),KS=/^[cC][0-9a-z]{6,}$/,XS=/^[0-9a-z]+$/,JS=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,FS=/^[0)DELIM" +R"DELIM(-9a-vA-V]{20}$/,WS=/^[A-Za-z0-9]{27}$/,IS=/^[a-zA-Z0-9_-]{21}$/,PS=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,e_=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,x0=n=>n?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${n}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,t_=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,n_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function l_(){return new RegExp(n_,"u")}const a_=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,i_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,u_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,s_=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,r_=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,sy=/^[A-Za-z0-9_-]*$/,c_=/^https?$/,o_=/^\+[1-9]\d{6,14}$/,ry="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",f_=new RegExp(`^${ry}$`);function cy(n){const a="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof n.precision=="number"?n.precision===-1?`${a}`:n.precision===0?`${a}:[0-5]\\d`:`${a}:[0-5]\\d\\.\\d{${n.precision}}`:`${a}(?::[0-5]\\d(?:\\.\\d+)?)?`}function d_(n){return new RegExp(`^${cy(n)}$`)}function h_(n){const a=cy({precision:n.precision}),u=["Z"];n.local&&u.push(""),n.offset&&u.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${a}(?:${u.join("|")})`;return new RegExp(`^${ry}T(?:${s})$`)}const m_=n=>{const a=n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${a}$`)},p_=/^-?\d+$/,g_=/^-?\d+(?:\.\d+)?$/,v_=/^(?:true|false)$/i,y_=/^[^A-Z]*$/,b_=/^[^a-z]*$/,In=X("$ZodCheck",(n,a)=>{var u;n._zod??(n._zod={}),n._zod.def=a,(u=n._zod).onattach??(u.onattach=[])}),oy={number:"number",bigint:"bigint",object:"date"},fy=X("$ZodCheckLessThan",(n,a)=>{In.init(n,a);const u=oy[typeof a.value];n._zod.onattach.push(s=>{const c=s._zod.bag,d=(a.inclusive?c.maximum:c.exclusiveMaximum)??Number.POSITIVE_INFINITY;a.value{(a.inclusive?s.value<=a.value:s.value{In.init(n,a);const u=oy[typeof a.value];n._zod.onattach.push(s=>{const c=s._zod.bag,d=(a.inclusive?c.minimum:c.exclusiveMinimum)??Number.NEGATIVE_INFINITY;a.value>d&&(a.inclusive?c.minimum=a.value:c.exclusiveMinimum=a.value)}),n._zod.check=s=>{(a.inclusive?s.value>=a.value:s.value>a.value)||s.issues.push({origin:u,code:"too_small",minimum:typeof a.value=="object"?a.value.getTime():a.value,input:s.value,inclusive:a.inclusive,inst:n,continue:!a.abort})}}),S_=X("$ZodCheckMultipleOf",(n,a)=>{In.init(n,a),n._zod.onattach.push(u=>{var s;(s=u._zod.bag).multipleOf??(s.multipleOf=a.value)}),n._zod.check=u=>{if(typeof u.value!=typeof a.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof u.value=="bigint"?u.value%a.value===BigInt(0):_S(u.value,a.value)===0)||u.issues.push({origin:typeof u.value,code:"not_multiple_of",divisor:a.value,input:u.value,inst:n,continue:!a.abort})}}),__=X("$ZodCheckNumberFormat",(n,a)=>{In.init(n,a),a.format=a.format||"float64";const u=a.format?.includes("int"),s=u?"int":"number",[c,d]=wS[a.format];n._zod.onattach.push(f=>{const p=f._zod.bag;p.format=a.format,p.minimum=c,p.maximum=d,u&&(p.pattern=p_)}),n._zod.check=f=>{const p=f.value;if(u){if(!Number.isInteger(p)){f.issues.push({expected:s,format:a.format,code:"invalid_type",continue:!1,input:p,inst:n});return}if(!Number.isSafeInteger(p)){p>0?f.issues.push({input:p,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!a.abort}):f.issues.push({input:p,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:s,inclusive:!0,continue:!a.abort});return}}pd&&f.issues.push({origin:"number",input:p,code:"too_big",maximum:d,inclusive:!0,inst:n,continue:!a.abort})}}),x_=X("$ZodCheckMaxLength",(n,a)=>{var u;In.init(n,a),(u=n._zod.def).when??(u.when=s=>{const c=s.value;return!Mh(c)&&c.length!==void 0}),n._zod.onattach.push(s=>{const c=s._zod.bag.maximum??Number.POSITIVE_INFINITY;a.maximum{const c=s.value;if(c.length<=a.maximum)return;const f=Oh(c);s.issues.push({origin:f,code:"too_big",maximum:a.maximum,inclusive:!0,input:c,inst:n,continue:!a.abort})}}),z_=X("$ZodCheckMinLength",(n,a)=>{var u;In.init(n,a),(u=n._zod.def).when??(u.when=s=>{const c=s.value;return!Mh(c)&&c.length!==void 0}),n._zod.onattach.push(s=>{const c=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;a.minimum>c&&(s._zod.bag.minimum=a.minimum)}),n._zod.check=s=>{const c=s.value;if(c.length>=a.minimum)return;const f=Oh(c);s.issues.push({origin:f,code:"too_small",minimum:a.minimum,inclusive:!0,input:c,inst:n,continue:!a.abort})}}),E_=X("$ZodCheckLengthEquals",(n,a)=>{var u;In.init(n,a),(u=n._zod.def).when??(u.when=s=>{const c=s.value;return!Mh(c)&&c.length!==void 0}),n._zod.onattach.push(s=>{const c=s._zod.bag;c.minimum=a.length,c.maximum=a.length,c.length=a.length}),n._zod.check=s=>{const c=s.value,d=c.length;if(d===a.length)return;const f=Oh(c),p=d>a.length;s.issues.push({origin:f,...p?{code:"too_big",maximum:a.length}:{code:"too_small",minimum:a.length},inclusive:!0,exact:!0,input:s.value,inst:n,continue:!a.abort})}}),jo=X("$ZodCheckStringFormat",(n,a)=>{var u,s;In.init(n,a),n._zod.onattach.push(c=>{const d=c._zod.bag;d.format=a.format,a.pattern&&(d.patterns??(d.patterns=new Set),d.patterns.add(a.pattern))}),a.pattern?(u=n._zod).check??(u.check=c=>{a.pattern.lastIndex=0,!a.pattern.test(c.value)&&c.issues.push({origin:"string",code:"invalid_format",format:a.format,input:c.value,...a.pattern?{pattern:a.pattern.toString()}:{},inst:n,continue:!a.abort})}):(s=n._zod).check??(s.check=()=>{})}),T_=X("$ZodCheckRegex",(n,a)=>{jo.init(n,a),n._zod.check=u=>{a.pattern.lastIndex=0,!a.pattern.test(u.value)&&u.issues.push({origin:"string",code:"invalid_format",format:"regex",input:u.value,pattern:a.pattern.toString(),inst:n,continue:!a.abort})}}),w_=X("$ZodCheckLowerCase",(n,a)=>{a.pattern??(a.pattern=y_),jo.init(n,a)}),M_=X("$ZodCheckUpperCase",(n,a)=>{a.pattern??(a.pattern=b_),jo.init(n,a)}),A_=X("$ZodCheckIncludes",(n,a)=>{In.init(n,a);const u=ds(a.includes),s=new RegExp(typeof a.position=="number"?`^.{${a.position}}${u}`:u);a.pattern=s,n._zod.onattach.push(c=>{const d=c._zod.bag;d.patterns??(d.patterns=new Set),d.patterns.add(s)}),n._zod.check=c=>{c.value.includes(a.includes,a.position)||c.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:a.includes,input:c.value,inst:n,continue:!a.abort})}}),O_=X("$ZodCheckStartsWith",(n,a)=>{In.init(n,a);const u=new RegExp(`^${ds(a.prefix)}.*`);a.pattern??(a)DELIM" +R"DELIM(.pattern=u),n._zod.onattach.push(s=>{const c=s._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(u)}),n._zod.check=s=>{s.value.startsWith(a.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:a.prefix,input:s.value,inst:n,continue:!a.abort})}}),N_=X("$ZodCheckEndsWith",(n,a)=>{In.init(n,a);const u=new RegExp(`.*${ds(a.suffix)}$`);a.pattern??(a.pattern=u),n._zod.onattach.push(s=>{const c=s._zod.bag;c.patterns??(c.patterns=new Set),c.patterns.add(u)}),n._zod.check=s=>{s.value.endsWith(a.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:a.suffix,input:s.value,inst:n,continue:!a.abort})}}),j_=X("$ZodCheckOverwrite",(n,a)=>{In.init(n,a),n._zod.check=u=>{u.value=a.tx(u.value)}});class D_{constructor(a=[]){this.content=[],this.indent=0,this&&(this.args=a)}indented(a){this.indent+=1,a(this),this.indent-=1}write(a){if(typeof a=="function"){a(this,{execution:"sync"}),a(this,{execution:"async"});return}const s=a.split(` `).filter(f=>f),c=Math.min(...s.map(f=>f.length-f.trimStart().length)),d=s.map(f=>f.slice(c)).map(f=>" ".repeat(this.indent*2)+f);for(const f of d)this.content.push(f)}compile(){const a=Function,u=this?.args,c=[...(this?.content??[""]).map(d=>` ${d}`)];return new a(...u,c.join(` -`))}}const N_={major:4,minor:4,patch:3},kt=X("$ZodType",(n,a)=>{var u;n??(n={}),n._zod.def=a,n._zod.bag=n._zod.bag||{},n._zod.version=N_;const s=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&s.unshift(n);for(const c of s)for(const d of c._zod.onattach)d(n);if(s.length===0)(u=n._zod).deferred??(u.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{const c=(f,p,g)=>{let v=rs(f),x;for(const S of p){if(S._zod.def.when){if(jS(f)||!S._zod.def.when(f))continue}else if(v)continue;const T=f.issues.length,w=S._zod.check(f);if(w instanceof Promise&&g?.async===!1)throw new cs;if(x||w instanceof Promise)x=(x??Promise.resolve()).then(async()=>{await w,f.issues.length!==T&&(v||(v=rs(f,T)))});else{if(f.issues.length===T)continue;v||(v=rs(f,T))}}return x?x.then(()=>f):f},d=(f,p,g)=>{if(rs(f))return f.aborted=!0,f;const v=c(p,s,g);if(v instanceof Promise){if(g.async===!1)throw new cs;return v.then(x=>n._zod.parse(x,g))}return n._zod.parse(v,g)};n._zod.run=(f,p)=>{if(p.skipChecks)return n._zod.parse(f,p);if(p.direction==="backward"){const v=n._zod.parse({value:f.value,issues:[]},{...p,skipChecks:!0});return v instanceof Promise?v.then(x=>d(x,f,p)):d(v,f,p)}const g=n._zod.parse(f,p);if(g instanceof Promise){if(p.async===!1)throw new cs;return g.then(v=>c(v,s,p))}return c(g,s,p)}}ht(n,"~standard",()=>({validate:c=>{try{const d=RS(n,c);return d.success?{value:d.data}:{issues:d.error?.issues}}catch{return US(n,c).then(f=>f.success?{value:f.data}:{issues:f.error?.issues})}},vendor:"zod",version:1}))}),jh=X("$ZodString",(n,a)=>{kt.init(n,a),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??f_(n._zod.bag),n._zod.parse=(u,s)=>{if(a.coerce)try{u.value=String(u.value)}catch{}return typeof u.value=="string"||u.issues.push({expected:"string",code:"invalid_type",input:u.value,inst:n}),u}}),wt=X("$ZodStringFormat",(n,a)=>{jo.init(n,a),jh.init(n,a)}),j_=X("$ZodGUID",(n,a)=>{a.pattern??(a.pattern=WS),wt.init(n,a)}),D_=X("$ZodUUID",(n,a)=>{if(a.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[a.version];if(s===void 0)throw new Error(`Invalid UUID version: "${a.version}"`);a.pattern??(a.pattern=S0(s))}else a.pattern??(a.pattern=S0());wt.init(n,a)}),C_=X("$ZodEmail",(n,a)=>{a.pattern??(a.pattern=IS),wt.init(n,a)}),R_=X("$ZodURL",(n,a)=>{wt.init(n,a),n._zod.check=u=>{try{const s=u.value.trim();if(!a.normalize&&a.protocol?.source===u_.source&&!/^https?:\/\//i.test(s)){u.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:u.value,inst:n,continue:!a.abort});return}const c=new URL(s);a.hostname&&(a.hostname.lastIndex=0,a.hostname.test(c.hostname)||u.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:a.hostname.source,input:u.value,inst:n,continue:!a.abort})),a.protocol&&(a.protocol.lastIndex=0,a.protocol.test(c.protocol.endsWith(":")?c.protocol.slice(0,-1):c.protocol)||u.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:a.protocol.source,input:u.value,inst:n,continue:!a.abort})),a.normalize?u.value=c.href:u.value=s;return}catch{u.issues.push({code:"invalid_format",format:"url",input:u.value,inst:n,continue:!a.abort})}}}),U_=X("$ZodEmoji",(n,a)=>{a.pattern??(a.pattern=e_()),wt.init(n,a)}),k_=X("$ZodNanoID",(n,a)=>{a.pattern??(a.pattern=JS),wt.init(n,a)}),Z_=X("$ZodCUID",(n,a)=>{a.pattern??(a.pattern=YS),wt.init(n,a)}),L_=X("$ZodCUID2",(n,a)=>{a.pattern??(a.pattern=$S),wt.init(n,a)}),H_=X("$ZodULID",(n,a)=>{a.pattern??(a.pattern=VS),wt.init(n,a)}),B_=X("$ZodXID",(n,a)=>{a.pattern??(a.pattern=KS),wt.init(n,a)}),q_=X("$ZodKSUID",(n,a)=>{a.pattern??(a.pattern=XS),wt.init(n,a)}),G_=X("$ZodISODateTime",(n,a)=>{a.pattern??(a.pattern=o_(a)),wt.init(n,a)}),Q_=X("$ZodISODate",(n,a)=>{a.pattern??(a.pattern=r_),wt.init(n,a)}),Y_=X("$ZodISOTime",(n,a)=>{a.pattern??(a.pattern=c_(a)),wt.init(n,a)}),$_=X("$ZodISODuration",(n,a)=>{a.pattern??(a.pattern=FS),wt.init(n,a)}),V_=X("$ZodIPv4",(n,a)=>{a.pattern??(a.pattern=t_),wt.init(n,a),n._zod.bag.format="ipv4"}),K_=X("$ZodIPv6",(n,a)=>{a.pattern??(a.pattern=n_),wt.init(n,a),n._zod.bag.format="ipv6",n._zod.check=u=>{try{new URL(`http://[${u.value}]`)}catch{u.issues.push({code:"invalid_format",format:"ipv6",input:u.value,inst:n,continue:!a.abort})}}}),X_=X("$ZodCIDRv4",(n,a)=>{a.pattern??(a.pattern=l_),wt.init(n,a)}),J_=X("$ZodCIDRv6",(n,a)=>{a.pattern??(a.pattern=a_),wt.init(n,a),n._zod.check=u=>{const s=u.value.split("/");try{if(s.length!==2)throw new Error;const[c,d]=s;if(!d)throw new Error;const f=Number(d);if(`${f}`!==d)throw new Error;if(f<0||f>128)throw new Error;new URL(`http://[${c}]`)}catch{u.issues.push({code:"invalid_format",format:"cidrv6",input:u.value,inst:n,continue:!a.abort})}}});function fy(n){if(n==="")return!0;if(/\s/.test(n)||n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const F_=X("$ZodBase64",(n,a)=>{a.pattern??(a.pattern=i_),wt.init(n,a),n._zod.bag.contentEncoding="base64",n._zod.check=u=>{fy(u.value)||u.issues.push({code:"invalid_format",format:"base64",input:u.value,inst:n,continue:!a.abort})}});function W_(n){if(!iy.test(n))return!1;const a=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),u=a.padEnd(Math.ceil(a.length/4)*4,"=");return fy(u)}const I_=X("$ZodBase64URL",(n,a)=>{a.pattern??(a.pattern=iy),wt.init(n,a),n._zod.bag.contentEncoding="base64url",n._zod.check=u=>{W_(u.value)||u.issues.push({code:"invalid_format",format:"base64url",input:u.value,inst:n,continue:!a.abort})}}),P_=X("$ZodE164",(n,a)=>{a.pattern??(a.pattern=s_),wt.init(n,a)});function ex(n,a=null){try{const u=n.split(".");if(u.length!==3)return!1;const[s]=u;if(!s)return!1;const c=JSON.parse(atob(s));return!("typ"in c&&c?.typ!=="JWT"||!c.alg||a&&(!("alg"in c)||c.alg!==a))}catch{return!1}}const tx=X("$ZodJWT",(n,a)=>{wt.init(n,a),n._zod.check=u=>{ex(u.value,a.alg)||u.issues.push({code:"invalid_format",format:"jwt",input:u.value,inst:n,continue:!a.abort})}}),dy=X("$ZodNumber",(n,a)=>{kt.init(n,a),n._zod.pattern=n._zod.bag.pattern??h_,n._zod.parse=(u,s)=>{if(a.coerce)try{u.value=Number(u.value)}catch{}const c=u.value;if(typeof c=="number"&&!Number.isNaN(c)&&Number.isFinite(c))return u;const d=typeof c=="number"?Number.isNaN(c)?"NaN":Number.isFinite(c)?void 0:"Infinity":void 0;return u.issues.push({expected:"number",code:"invalid_type",input:c,inst:n,...d?{received:d}:{}}),u}}),nx=X("$ZodNumberFormat",(n,a)=>{y_.init(n,a),dy.init(n,a)}),lx=X("$ZodBoolean",(n,a)=>{kt.init(n,a),n._zod.pattern=m_,n._zod.parse=(u,s)=>{if(a.coerce)try{u.value=!!u.value}catch{}const c=u.value;return typeof c=="boolean"||u.issues.push({expected:"boolean",code:"invalid_type",input:c,inst:n}),u}}),ax=X("$ZodUnknown",(n,a)=>{kt.init(n,a),n._zod.parse=u=>u}),ix=X("$ZodNever",(n,a)=>{kt.init(n,a),n._zod.parse=(u,s)=>(u.issues.push({expected:"never",c)DELIM" -R"DELIM(ode:"invalid_type",input:u.value,inst:n}),u)});function _0(n,a,u){n.issues.length&&a.issues.push(...ty(u,n.issues)),a.value[u]=n.value}const ux=X("$ZodArray",(n,a)=>{kt.init(n,a),n._zod.parse=(u,s)=>{const c=u.value;if(!Array.isArray(c))return u.issues.push({expected:"array",code:"invalid_type",input:c,inst:n}),u;u.value=Array(c.length);const d=[];for(let f=0;f_0(v,u,f))):_0(g,u,f)}return d.length?Promise.all(d).then(()=>u):u}});function So(n,a,u,s,c,d){const f=u in s;if(n.issues.length){if(c&&d&&!f)return;a.issues.push(...ty(u,n.issues))}if(!f&&!c){n.issues.length||a.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[u]});return}n.value===void 0?f&&(a.value[u]=void 0):a.value[u]=n.value}function hy(n){const a=Object.keys(n.shape);for(const s of a)if(!n.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const u=xS(n.shape);return{...n,keys:a,keySet:new Set(a),numKeys:a.length,optionalKeys:new Set(u)}}function my(n,a,u,s,c,d){const f=[],p=c.keySet,g=c.catchall._zod,v=g.def.type,x=g.optin==="optional",S=g.optout==="optional";for(const T in a){if(T==="__proto__"||p.has(T))continue;if(v==="never"){f.push(T);continue}const w=g.run({value:a[T],issues:[]},s);w instanceof Promise?n.push(w.then(O=>So(O,u,T,a,x,S))):So(w,u,T,a,x,S)}return f.length&&u.issues.push({code:"unrecognized_keys",keys:f,input:a,inst:d}),n.length?Promise.all(n).then(()=>u):u}const sx=X("$ZodObject",(n,a)=>{if(kt.init(n,a),!Object.getOwnPropertyDescriptor(a,"shape")?.get){const p=a.shape;Object.defineProperty(a,"shape",{get:()=>{const g={...p};return Object.defineProperty(a,"shape",{value:g}),g}})}const s=Th(()=>hy(a));ht(n._zod,"propValues",()=>{const p=a.shape,g={};for(const v in p){const x=p[v]._zod;if(x.values){g[v]??(g[v]=new Set);for(const S of x.values)g[v].add(S)}}return g});const c=bo,d=a.catchall;let f;n._zod.parse=(p,g)=>{f??(f=s.value);const v=p.value;if(!c(v))return p.issues.push({expected:"object",code:"invalid_type",input:v,inst:n}),p;p.value={};const x=[],S=f.shape;for(const T of f.keys){const w=S[T],O=w._zod.optin==="optional",Y=w._zod.optout==="optional",W=w._zod.run({value:v[T],issues:[]},g);W instanceof Promise?x.push(W.then(F=>So(F,p,T,v,O,Y))):So(W,p,T,v,O,Y)}return d?my(x,v,p,g,s.value,n):x.length?Promise.all(x).then(()=>p):p}}),rx=X("$ZodObjectJIT",(n,a)=>{sx.init(n,a);const u=n._zod.parse,s=Th(()=>hy(a)),c=T=>{const w=new O_(["shape","payload","ctx"]),O=s.value,Y=I=>{const q=b0(I);return`shape[${q}]._zod.run({ value: input[${q}], issues: [] }, ctx)`};w.write("const input = payload.value;");const W=Object.create(null);let F=0;for(const I of O.keys)W[I]=`key_${F++}`;w.write("const newResult = {};");for(const I of O.keys){const q=W[I],ae=b0(I),ne=T[I],le=ne?._zod?.optin==="optional",se=ne?._zod?.optout==="optional";w.write(`const ${q} = ${Y(I)};`),le&&se?w.write(` +`))}}const C_={major:4,minor:4,patch:3},kt=X("$ZodType",(n,a)=>{var u;n??(n={}),n._zod.def=a,n._zod.bag=n._zod.bag||{},n._zod.version=C_;const s=[...n._zod.def.checks??[]];n._zod.traits.has("$ZodCheck")&&s.unshift(n);for(const c of s)for(const d of c._zod.onattach)d(n);if(s.length===0)(u=n._zod).deferred??(u.deferred=[]),n._zod.deferred?.push(()=>{n._zod.run=n._zod.parse});else{const c=(f,p,g)=>{let v=rs(f),x;for(const S of p){if(S._zod.def.when){if(RS(f)||!S._zod.def.when(f))continue}else if(v)continue;const T=f.issues.length,w=S._zod.check(f);if(w instanceof Promise&&g?.async===!1)throw new cs;if(x||w instanceof Promise)x=(x??Promise.resolve()).then(async()=>{await w,f.issues.length!==T&&(v||(v=rs(f,T)))});else{if(f.issues.length===T)continue;v||(v=rs(f,T))}}return x?x.then(()=>f):f},d=(f,p,g)=>{if(rs(f))return f.aborted=!0,f;const v=c(p,s,g);if(v instanceof Promise){if(g.async===!1)throw new cs;return v.then(x=>n._zod.parse(x,g))}return n._zod.parse(v,g)};n._zod.run=(f,p)=>{if(p.skipChecks)return n._zod.parse(f,p);if(p.direction==="backward"){const v=n._zod.parse({value:f.value,issues:[]},{...p,skipChecks:!0});return v instanceof Promise?v.then(x=>d(x,f,p)):d(v,f,p)}const g=n._zod.parse(f,p);if(g instanceof Promise){if(p.async===!1)throw new cs;return g.then(v=>c(v,s,p))}return c(g,s,p)}}ht(n,"~standard",()=>({validate:c=>{try{const d=ZS(n,c);return d.success?{value:d.data}:{issues:d.error?.issues}}catch{return LS(n,c).then(f=>f.success?{value:f.data}:{issues:f.error?.issues})}},vendor:"zod",version:1}))}),Dh=X("$ZodString",(n,a)=>{kt.init(n,a),n._zod.pattern=[...n?._zod.bag?.patterns??[]].pop()??m_(n._zod.bag),n._zod.parse=(u,s)=>{if(a.coerce)try{u.value=String(u.value)}catch{}return typeof u.value=="string"||u.issues.push({expected:"string",code:"invalid_type",input:u.value,inst:n}),u}}),wt=X("$ZodStringFormat",(n,a)=>{jo.init(n,a),Dh.init(n,a)}),R_=X("$ZodGUID",(n,a)=>{a.pattern??(a.pattern=e_),wt.init(n,a)}),U_=X("$ZodUUID",(n,a)=>{if(a.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[a.version];if(s===void 0)throw new Error(`Invalid UUID version: "${a.version}"`);a.pattern??(a.pattern=x0(s))}else a.pattern??(a.pattern=x0());wt.init(n,a)}),k_=X("$ZodEmail",(n,a)=>{a.pattern??(a.pattern=t_),wt.init(n,a)}),Z_=X("$ZodURL",(n,a)=>{wt.init(n,a),n._zod.check=u=>{try{const s=u.value.trim();if(!a.normalize&&a.protocol?.source===c_.source&&!/^https?:\/\//i.test(s)){u.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:u.value,inst:n,continue:!a.abort});return}const c=new URL(s);a.hostname&&(a.hostname.lastIndex=0,a.hostname.test(c.hostname)||u.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:a.hostname.source,input:u.value,inst:n,continue:!a.abort})),a.protocol&&(a.protocol.lastIndex=0,a.protocol.test(c.protocol.endsWith(":")?c.protocol.slice(0,-1):c.protocol)||u.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:a.protocol.source,input:u.value,inst:n,continue:!a.abort})),a.normalize?u.value=c.href:u.value=s;return}catch{u.issues.push({code:"invalid_format",format:"url",input:u.value,inst:n,continue:!a.abort})}}}),L_=X("$ZodEmoji",(n,a)=>{a.pattern??(a.pattern=l_()),wt.init(n,a)}),H_=X("$ZodNanoID",(n,a)=>{a.pattern??(a.pattern=IS),wt.init(n,a)}),B_=X("$ZodCUID",(n,a)=>{a.pattern??(a.pattern=KS),wt.init(n,a)}),q_=X("$ZodCUID2",(n,a)=>{a.pattern??(a.pattern=XS),wt.init(n,a)}),G_=X("$ZodULID",(n,a)=>{a.pattern??(a.pattern=JS),wt.init(n,a)}),Q_=X("$ZodXID",(n,a)=>{a.pattern??(a.pattern=FS),wt.init(n,a)}),Y_=X("$ZodKSUID",(n,a)=>{a.pattern??(a.pattern=WS),wt.init(n,a)}),$_=X("$ZodISODateTime",(n,a)=>{a.pattern??(a.pattern=h_(a)),wt.init(n,a)}),V_=X("$ZodISODate",(n,a)=>{a.pattern??(a.pattern=f_),wt.init(n,a)}),K_=X("$ZodISOTime",(n,a)=>{a.pattern??(a.pattern=d_(a)),wt.init(n,a)}),X_=X("$ZodISODuration",(n,a)=>{a.pattern??(a.pattern=PS),wt.init(n,a)}),J_=X("$ZodIPv4",(n,a)=>{a.pattern??(a.pattern=a_),wt.init(n,a),n._zod.bag.format="ipv4"}),F_=X("$ZodIPv6",(n,a)=>{a.pattern??(a.pattern=i_),wt.init(n,a),n._zod.bag.format="ipv6",n._zod.check=u=>{try{new URL(`http://[${u.value}]`)}catch{u.issues.push({code:"invalid_format",format:"ipv6",input:u.value,inst:n,continue:!a.abort})}}}),W_=X("$ZodCIDRv4",(n,a)=>{a.pattern??(a.pattern=u_),wt.init(n,a)}),I_=X("$ZodCIDRv6",(n,a)=>{a.pattern??(a.pattern=s_),wt.init(n,a),n._zod.check=u=>{const s=u.value.split("/");try{if(s.length!==2)throw new Error;const[c,d]=s;if(!d)throw new Error;const f=Number(d);if(`${f}`!==d)throw new Error;if(f<0||f>128)throw new Error;new URL(`http://[${c}]`)}catch{u.issues.push({code:"invalid_format",format:"cidrv6",input:u.value,inst:n,continue:!a.abort})}}});function hy(n){if(n==="")return!0;if(/\s/.test(n)||n.length%4!==0)return!1;try{return atob(n),!0}catch{return!1}}const P_=X("$ZodBase64",(n,a)=>{a.pattern??(a.pattern=r_),wt.init(n,a),n._zod.bag.contentEncoding="base64",n._zod.check=u=>{hy(u.value)||u.issues.push({code:"invalid_format",format:"base64",input:u.value,inst:n,continue:!a.abort})}});function ex(n){if(!sy.test(n))return!1;const a=n.replace(/[-_]/g,s=>s==="-"?"+":"/"),u=a.padEnd(Math.ceil(a.length/4)*4,"=");return hy(u)}const tx=X("$ZodBase64URL",(n,a)=>{a.pattern??(a.pattern=sy),wt.init(n,a),n._zod.bag.contentEncoding="base64url",n._zod.check=u=>{ex(u.value)||u.issues.push({code:"invalid_format",format:"base64url",input:u.value,inst:n,continue:!a.abort})}}),nx=X("$ZodE164",(n,a)=>{a.pattern??(a.pattern=o_),wt.init(n,a)});function lx(n,a=null){try{const u=n.split(".");if(u.length!==3)return!1;const[s]=u;if(!s)return!1;const c=JSON.parse(atob(s));return!("typ"in c&&c?.typ!=="JWT"||!c.alg||a&&(!("alg"in c)||c.alg!==a))}catch{return!1}}const ax=X("$ZodJWT",(n,a)=>{wt.init(n,a),n._zod.check=u=>{lx(u.value,a.alg)||u.issues.push({code:"invalid_format",format:"jwt",input:u.value,inst:n,continue:!a.abort})}}),my=X("$ZodNumber",(n,a)=>{kt.init(n,a),n._zod.pattern=n._zod.bag.pattern??g_,n._zod.parse=(u,s)=>{if(a.coerce)try{u.value=Number(u.value)}catch{}const c=u.value;if(typeof c=="number"&&!Number.isNaN(c)&&Number.isFinite(c))return u;const d=typeof c=="number"?Number.isNaN(c)?"NaN":Number.isFinite(c)?void 0:"Infinity":void 0;return u.issues.push({expected:"number",code:"invalid_type",input:c,inst:n,...d?{received:d}:{}}),u}}),ix=X("$ZodNumberFormat",(n,a)=>{__.init(n,a),my.init(n,a)}),ux=X("$ZodBoolean",(n,a)=>{kt.init(n,a),n._zod.pattern=v_,n._zod.parse=(u,s)=>{if(a.coerce)try{u.value=!!u.value}catch{}const c=u.value;return typeof c=="boolean"||u.issues.push({expected:"boolean",code:"invalid_type",input:c,inst:n}),u}}),sx=X("$ZodUnknown",(n,a)=>{kt.init(n,a),n._zod.parse=u=>u}),rx=X("$ZodNever",(n,a)=>{kt.init(n,a),n._zod.par)DELIM" +R"DELIM(se=(u,s)=>(u.issues.push({expected:"never",code:"invalid_type",input:u.value,inst:n}),u)});function z0(n,a,u){n.issues.length&&a.issues.push(...ly(u,n.issues)),a.value[u]=n.value}const cx=X("$ZodArray",(n,a)=>{kt.init(n,a),n._zod.parse=(u,s)=>{const c=u.value;if(!Array.isArray(c))return u.issues.push({expected:"array",code:"invalid_type",input:c,inst:n}),u;u.value=Array(c.length);const d=[];for(let f=0;fz0(v,u,f))):z0(g,u,f)}return d.length?Promise.all(d).then(()=>u):u}});function So(n,a,u,s,c,d){const f=u in s;if(n.issues.length){if(c&&d&&!f)return;a.issues.push(...ly(u,n.issues))}if(!f&&!c){n.issues.length||a.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[u]});return}n.value===void 0?f&&(a.value[u]=void 0):a.value[u]=n.value}function py(n){const a=Object.keys(n.shape);for(const s of a)if(!n.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${s}": expected a Zod schema`);const u=TS(n.shape);return{...n,keys:a,keySet:new Set(a),numKeys:a.length,optionalKeys:new Set(u)}}function gy(n,a,u,s,c,d){const f=[],p=c.keySet,g=c.catchall._zod,v=g.def.type,x=g.optin==="optional",S=g.optout==="optional";for(const T in a){if(T==="__proto__"||p.has(T))continue;if(v==="never"){f.push(T);continue}const w=g.run({value:a[T],issues:[]},s);w instanceof Promise?n.push(w.then(O=>So(O,u,T,a,x,S))):So(w,u,T,a,x,S)}return f.length&&u.issues.push({code:"unrecognized_keys",keys:f,input:a,inst:d}),n.length?Promise.all(n).then(()=>u):u}const ox=X("$ZodObject",(n,a)=>{if(kt.init(n,a),!Object.getOwnPropertyDescriptor(a,"shape")?.get){const p=a.shape;Object.defineProperty(a,"shape",{get:()=>{const g={...p};return Object.defineProperty(a,"shape",{value:g}),g}})}const s=wh(()=>py(a));ht(n._zod,"propValues",()=>{const p=a.shape,g={};for(const v in p){const x=p[v]._zod;if(x.values){g[v]??(g[v]=new Set);for(const S of x.values)g[v].add(S)}}return g});const c=bo,d=a.catchall;let f;n._zod.parse=(p,g)=>{f??(f=s.value);const v=p.value;if(!c(v))return p.issues.push({expected:"object",code:"invalid_type",input:v,inst:n}),p;p.value={};const x=[],S=f.shape;for(const T of f.keys){const w=S[T],O=w._zod.optin==="optional",Y=w._zod.optout==="optional",W=w._zod.run({value:v[T],issues:[]},g);W instanceof Promise?x.push(W.then(F=>So(F,p,T,v,O,Y))):So(W,p,T,v,O,Y)}return d?gy(x,v,p,g,s.value,n):x.length?Promise.all(x).then(()=>p):p}}),fx=X("$ZodObjectJIT",(n,a)=>{ox.init(n,a);const u=n._zod.parse,s=wh(()=>py(a)),c=T=>{const w=new D_(["shape","payload","ctx"]),O=s.value,Y=I=>{const q=_0(I);return`shape[${q}]._zod.run({ value: input[${q}], issues: [] }, ctx)`};w.write("const input = payload.value;");const W=Object.create(null);let F=0;for(const I of O.keys)W[I]=`key_${F++}`;w.write("const newResult = {};");for(const I of O.keys){const q=W[I],ae=_0(I),ne=T[I],le=ne?._zod?.optin==="optional",se=ne?._zod?.optout==="optional";w.write(`const ${q} = ${Y(I)};`),le&&se?w.write(` if (${q}.issues.length) { if (${ae} in input) { payload.issues = payload.issues.concat(${q}.issues.map(iss => ({ @@ -120,34 +120,34 @@ R"DELIM(ode:"invalid_type",input:u.value,inst:n}),u)});function _0(n,a,u){n.issu } } - `)}w.write("payload.value = newResult;"),w.write("return payload;");const B=w.compile();return(I,q)=>B(T,I,q)};let d;const f=bo,p=!Eh.jitless,v=p&&SS.value,x=a.catchall;let S;n._zod.parse=(T,w)=>{S??(S=s.value);const O=T.value;return f(O)?p&&v&&w?.async===!1&&w.jitless!==!0?(d||(d=c(a.shape)),T=d(T,w),x?my([],O,T,w,S,n):T):u(T,w):(T.issues.push({expected:"object",code:"invalid_type",input:O,inst:n}),T)}});function x0(n,a,u,s){for(const d of n)if(d.issues.length===0)return a.value=d.value,a;const c=n.filter(d=>!rs(d));return c.length===1?(a.value=c[0].value,c[0]):(a.issues.push({code:"invalid_union",input:a.value,inst:u,errors:n.map(d=>d.issues.map(f=>du(f,s,fu())))}),a)}const cx=X("$ZodUnion",(n,a)=>{kt.init(n,a),ht(n._zod,"optin",()=>a.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ht(n._zod,"optout",()=>a.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ht(n._zod,"values",()=>{if(a.options.every(s=>s._zod.values))return new Set(a.options.flatMap(s=>Array.from(s._zod.values)))}),ht(n._zod,"pattern",()=>{if(a.options.every(s=>s._zod.pattern)){const s=a.options.map(c=>c._zod.pattern);return new RegExp(`^(${s.map(c=>Mh(c.source)).join("|")})$`)}});const u=a.options.length===1?a.options[0]._zod.run:null;n._zod.parse=(s,c)=>{if(u)return u(s,c);let d=!1;const f=[];for(const p of a.options){const g=p._zod.run({value:s.value,issues:[]},c);if(g instanceof Promise)f.push(g),d=!0;else{if(g.issues.length===0)return g;f.push(g)}}return d?Promise.all(f).then(p=>x0(p,s,n,c)):x0(f,s,n,c)}}),ox=X("$ZodIntersection",(n,a)=>{kt.init(n,a),n._zod.parse=(u,s)=>{const c=u.value,d=a.left._zod.run({value:c,issues:[]},s),f=a.right._zod.run({value:c,issues:[]},s);return d instanceof Promise||f instanceof Promise?Promise.all([d,f]).then(([g,v])=>z0(u,g,v)):z0(u,d,f)}});function eh(n,a){if(n===a)return{valid:!0,data:n};if(n instanceof Date&&a instanceof Date&&+n==+a)return{valid:!0,data:n};if(Dr(n)&&Dr(a)){const u=Object.keys(a),s=Object.keys(n).filter(d=>u.indexOf(d)!==-1),c={...n,...a};for(const d of s){const f=eh(n[d],a[d]);if(!f.valid)return{valid:!1,mergeErrorPath:[d,...f.mergeErrorPath]};c[d]=f.data}return{valid:!0,data:c}}if(Array.isArray(n)&&Array.isArray(a)){if(n.length!==a.length)return{valid:!1,mergeErrorPath:[]};const u=[];for(let s=0;sp.l&&p.r).map(([p])=>p);if(d.length&&c&&n.issues.push({...c,keys:d}),rs(n))return n;const f=eh(a.value,u.value);if(!f.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(f.mergeErrorPath)}`);return n.value=f.data,n}const fx=X("$ZodEnum",(n,a)=>{kt.init(n,a);const u=Iv(a.entries),s=new Set(u);n._zod.values=s,n._zod.pattern=new RegExp(`^(${u.filter(c=>_S.has(typeof c)).map(c=>typeof c=="string"?ds(c):c.toString()).join("|")})$`),n._zod.parse=(c,d)=>{const f=c.value;return s.has(f)||c.issues.push({code)DELIM" -R"DELIM(:"invalid_value",values:u,input:f,inst:n}),c}}),dx=X("$ZodLiteral",(n,a)=>{if(kt.init(n,a),a.values.length===0)throw new Error("Cannot create literal schema with no valid values");const u=new Set(a.values);n._zod.values=u,n._zod.pattern=new RegExp(`^(${a.values.map(s=>typeof s=="string"?ds(s):s?ds(s.toString()):String(s)).join("|")})$`),n._zod.parse=(s,c)=>{const d=s.value;return u.has(d)||s.issues.push({code:"invalid_value",values:a.values,input:d,inst:n}),s}}),hx=X("$ZodTransform",(n,a)=>{kt.init(n,a),n._zod.optin="optional",n._zod.parse=(u,s)=>{if(s.direction==="backward")throw new Wv(n.constructor.name);const c=a.transform(u.value,u);if(s.async)return(c instanceof Promise?c:Promise.resolve(c)).then(f=>(u.value=f,u.fallback=!0,u));if(c instanceof Promise)throw new cs;return u.value=c,u.fallback=!0,u}});function E0(n,a){return a===void 0&&(n.issues.length||n.fallback)?{issues:[],value:void 0}:n}const py=X("$ZodOptional",(n,a)=>{kt.init(n,a),n._zod.optin="optional",n._zod.optout="optional",ht(n._zod,"values",()=>a.innerType._zod.values?new Set([...a.innerType._zod.values,void 0]):void 0),ht(n._zod,"pattern",()=>{const u=a.innerType._zod.pattern;return u?new RegExp(`^(${Mh(u.source)})?$`):void 0}),n._zod.parse=(u,s)=>{if(a.innerType._zod.optin==="optional"){const c=u.value,d=a.innerType._zod.run(u,s);return d instanceof Promise?d.then(f=>E0(f,c)):E0(d,c)}return u.value===void 0?u:a.innerType._zod.run(u,s)}}),mx=X("$ZodExactOptional",(n,a)=>{py.init(n,a),ht(n._zod,"values",()=>a.innerType._zod.values),ht(n._zod,"pattern",()=>a.innerType._zod.pattern),n._zod.parse=(u,s)=>a.innerType._zod.run(u,s)}),px=X("$ZodNullable",(n,a)=>{kt.init(n,a),ht(n._zod,"optin",()=>a.innerType._zod.optin),ht(n._zod,"optout",()=>a.innerType._zod.optout),ht(n._zod,"pattern",()=>{const u=a.innerType._zod.pattern;return u?new RegExp(`^(${Mh(u.source)}|null)$`):void 0}),ht(n._zod,"values",()=>a.innerType._zod.values?new Set([...a.innerType._zod.values,null]):void 0),n._zod.parse=(u,s)=>u.value===null?u:a.innerType._zod.run(u,s)}),gx=X("$ZodDefault",(n,a)=>{kt.init(n,a),n._zod.optin="optional",ht(n._zod,"values",()=>a.innerType._zod.values),n._zod.parse=(u,s)=>{if(s.direction==="backward")return a.innerType._zod.run(u,s);if(u.value===void 0)return u.value=a.defaultValue,u;const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(d=>T0(d,a)):T0(c,a)}});function T0(n,a){return n.value===void 0&&(n.value=a.defaultValue),n}const vx=X("$ZodPrefault",(n,a)=>{kt.init(n,a),n._zod.optin="optional",ht(n._zod,"values",()=>a.innerType._zod.values),n._zod.parse=(u,s)=>(s.direction==="backward"||u.value===void 0&&(u.value=a.defaultValue),a.innerType._zod.run(u,s))}),yx=X("$ZodNonOptional",(n,a)=>{kt.init(n,a),ht(n._zod,"values",()=>{const u=a.innerType._zod.values;return u?new Set([...u].filter(s=>s!==void 0)):void 0}),n._zod.parse=(u,s)=>{const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(d=>w0(d,n)):w0(c,n)}});function w0(n,a){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:a}),n}const bx=X("$ZodCatch",(n,a)=>{kt.init(n,a),n._zod.optin="optional",ht(n._zod,"optout",()=>a.innerType._zod.optout),ht(n._zod,"values",()=>a.innerType._zod.values),n._zod.parse=(u,s)=>{if(s.direction==="backward")return a.innerType._zod.run(u,s);const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(d=>(u.value=d.value,d.issues.length&&(u.value=a.catchValue({...u,error:{issues:d.issues.map(f=>du(f,s,fu()))},input:u.value}),u.issues=[],u.fallback=!0),u)):(u.value=c.value,c.issues.length&&(u.value=a.catchValue({...u,error:{issues:c.issues.map(d=>du(d,s,fu()))},input:u.value}),u.issues=[],u.fallback=!0),u)}}),Sx=X("$ZodPipe",(n,a)=>{kt.init(n,a),ht(n._zod,"values",()=>a.in._zod.values),ht(n._zod,"optin",()=>a.in._zod.optin),ht(n._zod,"optout",()=>a.out._zod.optout),ht(n._zod,"propValues",()=>a.in._zod.propValues),n._zod.parse=(u,s)=>{if(s.direction==="backward"){const d=a.out._zod.run(u,s);return d instanceof Promise?d.then(f=>so(f,a.in,s)):so(d,a.in,s)}const c=a.in._zod.run(u,s);return c instanceof Promise?c.then(d=>so(d,a.out,s)):so(c,a.out,s)}});function so(n,a,u){return n.issues.length?(n.aborted=!0,n):a._zod.run({value:n.value,issues:n.issues,fallback:n.fallback},u)}const _x=X("$ZodReadonly",(n,a)=>{kt.init(n,a),ht(n._zod,"propValues",()=>a.innerType._zod.propValues),ht(n._zod,"values",()=>a.innerType._zod.values),ht(n._zod,"optin",()=>a.innerType?._zod?.optin),ht(n._zod,"optout",()=>a.innerType?._zod?.optout),n._zod.parse=(u,s)=>{if(s.direction==="backward")return a.innerType._zod.run(u,s);const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(M0):M0(c)}});function M0(n){return n.value=Object.freeze(n.value),n}const xx=X("$ZodCustom",(n,a)=>{In.init(n,a),kt.init(n,a),n._zod.parse=(u,s)=>u,n._zod.check=u=>{const s=u.value,c=a.fn(s);if(c instanceof Promise)return c.then(d=>A0(d,u,s,n));A0(c,u,s,n)}});function A0(n,a,u,s){if(!n){const c={code:"custom",input:u,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(c.params=s._zod.def.params),a.issues.push(Cr(c))}}var O0;class zx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(a,...u){const s=u[0];return this._map.set(a,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,a),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(a){const u=this._map.get(a);return u&&typeof u=="object"&&"id"in u&&this._idmap.delete(u.id),this._map.delete(a),this}get(a){const u=a._zod.parent;if(u){const s={...this.get(u)??{}};delete s.id;const c={...s,...this._map.get(a)};return Object.keys(c).length?c:void 0}return this._map.get(a)}has(a){return this._map.has(a)}}function Ex(){return new zx}(O0=globalThis).__zod_globalRegistry??(O0.__zod_globalRegistry=Ex());const Tr=globalThis.__zod_globalRegistry;function Tx(n,a){return new n({type:"string",...Me(a)})}function wx(n,a){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Me(a)})}function N0(n,a){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Me(a)})}function Mx(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Me(a)})}function Ax(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Me(a)})}function Ox(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Me(a)})}function Nx(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Me(a)})}function jx(n,a){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Me(a)})}function Dx(n,a){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Me(a)})}function Cx(n,a){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Me(a)})}function Rx(n,a){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Me(a)})}function Ux(n,a){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Me(a)})}function kx(n,a){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Me(a)})}function Zx(n,a){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Me(a)})}function Lx(n,a){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Me(a)})}function Hx(n,a){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Me(a)})}function Bx(n,a){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Me(a)})}function qx(n,a){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Me(a)})}function Gx(n,a){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Me(a)})}function Qx(n,a){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Me(a)})}function Yx(n,a){return new n({type:"string",format:"base64url",check:"string_format",abort:!1,...Me(a)})}functio)DELIM" -R"DELIM(n $x(n,a){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Me(a)})}function Vx(n,a){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Me(a)})}function Kx(n,a){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Me(a)})}function Xx(n,a){return new n({type:"string",format:"date",check:"string_format",...Me(a)})}function Jx(n,a){return new n({type:"string",format:"time",check:"string_format",precision:null,...Me(a)})}function Fx(n,a){return new n({type:"string",format:"duration",check:"string_format",...Me(a)})}function Wx(n,a){return new n({type:"number",checks:[],...Me(a)})}function Ix(n,a){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Me(a)})}function Px(n,a){return new n({type:"boolean",...Me(a)})}function e2(n){return new n({type:"unknown"})}function t2(n,a){return new n({type:"never",...Me(a)})}function j0(n,a){return new cy({check:"less_than",...Me(a),value:n,inclusive:!1})}function Qd(n,a){return new cy({check:"less_than",...Me(a),value:n,inclusive:!0})}function D0(n,a){return new oy({check:"greater_than",...Me(a),value:n,inclusive:!1})}function Yd(n,a){return new oy({check:"greater_than",...Me(a),value:n,inclusive:!0})}function C0(n,a){return new v_({check:"multiple_of",...Me(a),value:n})}function gy(n,a){return new b_({check:"max_length",...Me(a),maximum:n})}function _o(n,a){return new S_({check:"min_length",...Me(a),minimum:n})}function vy(n,a){return new __({check:"length_equals",...Me(a),length:n})}function n2(n,a){return new x_({check:"string_format",format:"regex",...Me(a),pattern:n})}function l2(n){return new z_({check:"string_format",format:"lowercase",...Me(n)})}function a2(n){return new E_({check:"string_format",format:"uppercase",...Me(n)})}function i2(n,a){return new T_({check:"string_format",format:"includes",...Me(a),includes:n})}function u2(n,a){return new w_({check:"string_format",format:"starts_with",...Me(a),prefix:n})}function s2(n,a){return new M_({check:"string_format",format:"ends_with",...Me(a),suffix:n})}function ys(n){return new A_({check:"overwrite",tx:n})}function r2(n){return ys(a=>a.normalize(n))}function c2(){return ys(n=>n.trim())}function o2(){return ys(n=>n.toLowerCase())}function f2(){return ys(n=>n.toUpperCase())}function d2(){return ys(n=>bS(n))}function h2(n,a,u){return new n({type:"array",element:a,...Me(u)})}function m2(n,a,u){return new n({type:"custom",check:"custom",fn:a,...Me(u)})}function p2(n,a){const u=g2(s=>(s.addIssue=c=>{if(typeof c=="string")s.issues.push(Cr(c,s.value,u._zod.def));else{const d=c;d.fatal&&(d.continue=!1),d.code??(d.code="custom"),d.input??(d.input=s.value),d.inst??(d.inst=u),d.continue??(d.continue=!u._zod.def.abort),s.issues.push(Cr(d))}},n(s.value,s)),a);return u}function g2(n,a){const u=new In({check:"custom",...Me(a)});return u._zod.check=n,u}function yy(n){let a=n?.target??"draft-2020-12";return a==="draft-4"&&(a="draft-04"),a==="draft-7"&&(a="draft-07"),{processors:n.processors??{},metadataRegistry:n?.metadata??Tr,target:a,unrepresentable:n?.unrepresentable??"throw",override:n?.override??(()=>{}),io:n?.io??"output",counter:0,seen:new Map,cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0}}function _n(n,a,u={path:[],schemaPath:[]}){var s;const c=n._zod.def,d=a.seen.get(n);if(d)return d.count++,u.schemaPath.includes(n)&&(d.cycle=u.path),d.schema;const f={schema:{},count:1,cycle:void 0,path:u.path};a.seen.set(n,f);const p=n._zod.toJSONSchema?.();if(p)f.schema=p;else{const x={...u,schemaPath:[...u.schemaPath,n],path:u.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(a,f.schema,x);else{const T=f.schema,w=a.processors[c.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${c.type}`);w(n,a,T,x)}const S=n._zod.parent;S&&(f.ref||(f.ref=S),_n(S,a,x),a.seen.get(S).isParent=!0)}const g=a.metadataRegistry.get(n);return g&&Object.assign(f.schema,g),a.io==="input"&&Hn(n)&&(delete f.schema.examples,delete f.schema.default),a.io==="input"&&"_prefault"in f.schema&&((s=f.schema).default??(s.default=f.schema._prefault)),delete f.schema._prefault,a.seen.get(n).schema}function by(n,a){const u=n.seen.get(a);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const f of n.seen.entries()){const p=n.metadataRegistry.get(f[0])?.id;if(p){const g=s.get(p);if(g&&g!==f[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(p,f[0])}}const c=f=>{const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const S=n.external.registry.get(f[0])?.id,T=n.external.uri??(O=>O);if(S)return{ref:T(S)};const w=f[1].defId??f[1].schema.id??`schema${n.counter++}`;return f[1].defId=w,{defId:w,ref:`${T("__shared")}#/${p}/${w}`}}if(f[1]===u)return{ref:"#"};const v=`#/${p}/`,x=f[1].schema.id??`__schema${n.counter++}`;return{defId:x,ref:v+x}},d=f=>{if(f[1].schema.$ref)return;const p=f[1],{ref:g,defId:v}=c(f);p.def={...p.schema},v&&(p.defId=v);const x=p.schema;for(const S in x)delete x[S];x.$ref=g};if(n.cycles==="throw")for(const f of n.seen.entries()){const p=f[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/ + `)}w.write("payload.value = newResult;"),w.write("return payload;");const B=w.compile();return(I,q)=>B(T,I,q)};let d;const f=bo,p=!Th.jitless,v=p&&zS.value,x=a.catchall;let S;n._zod.parse=(T,w)=>{S??(S=s.value);const O=T.value;return f(O)?p&&v&&w?.async===!1&&w.jitless!==!0?(d||(d=c(a.shape)),T=d(T,w),x?gy([],O,T,w,S,n):T):u(T,w):(T.issues.push({expected:"object",code:"invalid_type",input:O,inst:n}),T)}});function E0(n,a,u,s){for(const d of n)if(d.issues.length===0)return a.value=d.value,a;const c=n.filter(d=>!rs(d));return c.length===1?(a.value=c[0].value,c[0]):(a.issues.push({code:"invalid_union",input:a.value,inst:u,errors:n.map(d=>d.issues.map(f=>du(f,s,fu())))}),a)}const dx=X("$ZodUnion",(n,a)=>{kt.init(n,a),ht(n._zod,"optin",()=>a.options.some(s=>s._zod.optin==="optional")?"optional":void 0),ht(n._zod,"optout",()=>a.options.some(s=>s._zod.optout==="optional")?"optional":void 0),ht(n._zod,"values",()=>{if(a.options.every(s=>s._zod.values))return new Set(a.options.flatMap(s=>Array.from(s._zod.values)))}),ht(n._zod,"pattern",()=>{if(a.options.every(s=>s._zod.pattern)){const s=a.options.map(c=>c._zod.pattern);return new RegExp(`^(${s.map(c=>Ah(c.source)).join("|")})$`)}});const u=a.options.length===1?a.options[0]._zod.run:null;n._zod.parse=(s,c)=>{if(u)return u(s,c);let d=!1;const f=[];for(const p of a.options){const g=p._zod.run({value:s.value,issues:[]},c);if(g instanceof Promise)f.push(g),d=!0;else{if(g.issues.length===0)return g;f.push(g)}}return d?Promise.all(f).then(p=>E0(p,s,n,c)):E0(f,s,n,c)}}),hx=X("$ZodIntersection",(n,a)=>{kt.init(n,a),n._zod.parse=(u,s)=>{const c=u.value,d=a.left._zod.run({value:c,issues:[]},s),f=a.right._zod.run({value:c,issues:[]},s);return d instanceof Promise||f instanceof Promise?Promise.all([d,f]).then(([g,v])=>T0(u,g,v)):T0(u,d,f)}});function eh(n,a){if(n===a)return{valid:!0,data:n};if(n instanceof Date&&a instanceof Date&&+n==+a)return{valid:!0,data:n};if(Dr(n)&&Dr(a)){const u=Object.keys(a),s=Object.keys(n).filter(d=>u.indexOf(d)!==-1),c={...n,...a};for(const d of s){const f=eh(n[d],a[d]);if(!f.valid)return{valid:!1,mergeErrorPath:[d,...f.mergeErrorPath]};c[d]=f.data}return{valid:!0,data:c}}if(Array.isArray(n)&&Array.isArray(a)){if(n.length!==a.length)return{valid:!1,mergeErrorPath:[]};const u=[];for(let s=0;sp.l&&p.r).map(([p])=>p);if(d.length&&c&&n.issues.push({...c,keys:d}),rs(n))return n;const f=eh(a.value,u.value);if(!f.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(f.mergeErrorPath)}`);return n.value=f.data,n}const mx=X("$ZodEnum",(n,a)=>{kt.init(n,a);const u=ey(a.entries),s=new Set(u);n._zod.values=s,n._zod.pattern=new RegExp(`^(${u.filter(c=>ES.has(typeof c)).map(c=>typeof c=="string"?ds(c):c.toString()).join("|")})$`),n._zod.parse=(c,d)=>{const f=)DELIM" +R"DELIM(c.value;return s.has(f)||c.issues.push({code:"invalid_value",values:u,input:f,inst:n}),c}}),px=X("$ZodLiteral",(n,a)=>{if(kt.init(n,a),a.values.length===0)throw new Error("Cannot create literal schema with no valid values");const u=new Set(a.values);n._zod.values=u,n._zod.pattern=new RegExp(`^(${a.values.map(s=>typeof s=="string"?ds(s):s?ds(s.toString()):String(s)).join("|")})$`),n._zod.parse=(s,c)=>{const d=s.value;return u.has(d)||s.issues.push({code:"invalid_value",values:a.values,input:d,inst:n}),s}}),gx=X("$ZodTransform",(n,a)=>{kt.init(n,a),n._zod.optin="optional",n._zod.parse=(u,s)=>{if(s.direction==="backward")throw new Pv(n.constructor.name);const c=a.transform(u.value,u);if(s.async)return(c instanceof Promise?c:Promise.resolve(c)).then(f=>(u.value=f,u.fallback=!0,u));if(c instanceof Promise)throw new cs;return u.value=c,u.fallback=!0,u}});function w0(n,a){return a===void 0&&(n.issues.length||n.fallback)?{issues:[],value:void 0}:n}const vy=X("$ZodOptional",(n,a)=>{kt.init(n,a),n._zod.optin="optional",n._zod.optout="optional",ht(n._zod,"values",()=>a.innerType._zod.values?new Set([...a.innerType._zod.values,void 0]):void 0),ht(n._zod,"pattern",()=>{const u=a.innerType._zod.pattern;return u?new RegExp(`^(${Ah(u.source)})?$`):void 0}),n._zod.parse=(u,s)=>{if(a.innerType._zod.optin==="optional"){const c=u.value,d=a.innerType._zod.run(u,s);return d instanceof Promise?d.then(f=>w0(f,c)):w0(d,c)}return u.value===void 0?u:a.innerType._zod.run(u,s)}}),vx=X("$ZodExactOptional",(n,a)=>{vy.init(n,a),ht(n._zod,"values",()=>a.innerType._zod.values),ht(n._zod,"pattern",()=>a.innerType._zod.pattern),n._zod.parse=(u,s)=>a.innerType._zod.run(u,s)}),yx=X("$ZodNullable",(n,a)=>{kt.init(n,a),ht(n._zod,"optin",()=>a.innerType._zod.optin),ht(n._zod,"optout",()=>a.innerType._zod.optout),ht(n._zod,"pattern",()=>{const u=a.innerType._zod.pattern;return u?new RegExp(`^(${Ah(u.source)}|null)$`):void 0}),ht(n._zod,"values",()=>a.innerType._zod.values?new Set([...a.innerType._zod.values,null]):void 0),n._zod.parse=(u,s)=>u.value===null?u:a.innerType._zod.run(u,s)}),bx=X("$ZodDefault",(n,a)=>{kt.init(n,a),n._zod.optin="optional",ht(n._zod,"values",()=>a.innerType._zod.values),n._zod.parse=(u,s)=>{if(s.direction==="backward")return a.innerType._zod.run(u,s);if(u.value===void 0)return u.value=a.defaultValue,u;const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(d=>M0(d,a)):M0(c,a)}});function M0(n,a){return n.value===void 0&&(n.value=a.defaultValue),n}const Sx=X("$ZodPrefault",(n,a)=>{kt.init(n,a),n._zod.optin="optional",ht(n._zod,"values",()=>a.innerType._zod.values),n._zod.parse=(u,s)=>(s.direction==="backward"||u.value===void 0&&(u.value=a.defaultValue),a.innerType._zod.run(u,s))}),_x=X("$ZodNonOptional",(n,a)=>{kt.init(n,a),ht(n._zod,"values",()=>{const u=a.innerType._zod.values;return u?new Set([...u].filter(s=>s!==void 0)):void 0}),n._zod.parse=(u,s)=>{const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(d=>A0(d,n)):A0(c,n)}});function A0(n,a){return!n.issues.length&&n.value===void 0&&n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:a}),n}const xx=X("$ZodCatch",(n,a)=>{kt.init(n,a),n._zod.optin="optional",ht(n._zod,"optout",()=>a.innerType._zod.optout),ht(n._zod,"values",()=>a.innerType._zod.values),n._zod.parse=(u,s)=>{if(s.direction==="backward")return a.innerType._zod.run(u,s);const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(d=>(u.value=d.value,d.issues.length&&(u.value=a.catchValue({...u,error:{issues:d.issues.map(f=>du(f,s,fu()))},input:u.value}),u.issues=[],u.fallback=!0),u)):(u.value=c.value,c.issues.length&&(u.value=a.catchValue({...u,error:{issues:c.issues.map(d=>du(d,s,fu()))},input:u.value}),u.issues=[],u.fallback=!0),u)}}),zx=X("$ZodPipe",(n,a)=>{kt.init(n,a),ht(n._zod,"values",()=>a.in._zod.values),ht(n._zod,"optin",()=>a.in._zod.optin),ht(n._zod,"optout",()=>a.out._zod.optout),ht(n._zod,"propValues",()=>a.in._zod.propValues),n._zod.parse=(u,s)=>{if(s.direction==="backward"){const d=a.out._zod.run(u,s);return d instanceof Promise?d.then(f=>so(f,a.in,s)):so(d,a.in,s)}const c=a.in._zod.run(u,s);return c instanceof Promise?c.then(d=>so(d,a.out,s)):so(c,a.out,s)}});function so(n,a,u){return n.issues.length?(n.aborted=!0,n):a._zod.run({value:n.value,issues:n.issues,fallback:n.fallback},u)}const Ex=X("$ZodReadonly",(n,a)=>{kt.init(n,a),ht(n._zod,"propValues",()=>a.innerType._zod.propValues),ht(n._zod,"values",()=>a.innerType._zod.values),ht(n._zod,"optin",()=>a.innerType?._zod?.optin),ht(n._zod,"optout",()=>a.innerType?._zod?.optout),n._zod.parse=(u,s)=>{if(s.direction==="backward")return a.innerType._zod.run(u,s);const c=a.innerType._zod.run(u,s);return c instanceof Promise?c.then(O0):O0(c)}});function O0(n){return n.value=Object.freeze(n.value),n}const Tx=X("$ZodCustom",(n,a)=>{In.init(n,a),kt.init(n,a),n._zod.parse=(u,s)=>u,n._zod.check=u=>{const s=u.value,c=a.fn(s);if(c instanceof Promise)return c.then(d=>N0(d,u,s,n));N0(c,u,s,n)}});function N0(n,a,u,s){if(!n){const c={code:"custom",input:u,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(c.params=s._zod.def.params),a.issues.push(Cr(c))}}var j0;class wx{constructor(){this._map=new WeakMap,this._idmap=new Map}add(a,...u){const s=u[0];return this._map.set(a,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.id,a),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(a){const u=this._map.get(a);return u&&typeof u=="object"&&"id"in u&&this._idmap.delete(u.id),this._map.delete(a),this}get(a){const u=a._zod.parent;if(u){const s={...this.get(u)??{}};delete s.id;const c={...s,...this._map.get(a)};return Object.keys(c).length?c:void 0}return this._map.get(a)}has(a){return this._map.has(a)}}function Mx(){return new wx}(j0=globalThis).__zod_globalRegistry??(j0.__zod_globalRegistry=Mx());const Tr=globalThis.__zod_globalRegistry;function Ax(n,a){return new n({type:"string",...Me(a)})}function Ox(n,a){return new n({type:"string",format:"email",check:"string_format",abort:!1,...Me(a)})}function D0(n,a){return new n({type:"string",format:"guid",check:"string_format",abort:!1,...Me(a)})}function Nx(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,...Me(a)})}function jx(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Me(a)})}function Dx(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Me(a)})}function Cx(n,a){return new n({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Me(a)})}function Rx(n,a){return new n({type:"string",format:"url",check:"string_format",abort:!1,...Me(a)})}function Ux(n,a){return new n({type:"string",format:"emoji",check:"string_format",abort:!1,...Me(a)})}function kx(n,a){return new n({type:"string",format:"nanoid",check:"string_format",abort:!1,...Me(a)})}function Zx(n,a){return new n({type:"string",format:"cuid",check:"string_format",abort:!1,...Me(a)})}function Lx(n,a){return new n({type:"string",format:"cuid2",check:"string_format",abort:!1,...Me(a)})}function Hx(n,a){return new n({type:"string",format:"ulid",check:"string_format",abort:!1,...Me(a)})}function Bx(n,a){return new n({type:"string",format:"xid",check:"string_format",abort:!1,...Me(a)})}function qx(n,a){return new n({type:"string",format:"ksuid",check:"string_format",abort:!1,...Me(a)})}function Gx(n,a){return new n({type:"string",format:"ipv4",check:"string_format",abort:!1,...Me(a)})}function Qx(n,a){return new n({type:"string",format:"ipv6",check:"string_format",abort:!1,...Me(a)})}function Yx(n,a){return new n({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Me(a)})}function $x(n,a){return new n({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Me(a)})}function Vx(n,a){return new n({type:"string",format:"base64",check:"string_format",abort:!1,...Me(a)})}function Kx(n,a){return new n({type:"string",format:"base64url",check)DELIM" +R"DELIM(:"string_format",abort:!1,...Me(a)})}function Xx(n,a){return new n({type:"string",format:"e164",check:"string_format",abort:!1,...Me(a)})}function Jx(n,a){return new n({type:"string",format:"jwt",check:"string_format",abort:!1,...Me(a)})}function Fx(n,a){return new n({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Me(a)})}function Wx(n,a){return new n({type:"string",format:"date",check:"string_format",...Me(a)})}function Ix(n,a){return new n({type:"string",format:"time",check:"string_format",precision:null,...Me(a)})}function Px(n,a){return new n({type:"string",format:"duration",check:"string_format",...Me(a)})}function e2(n,a){return new n({type:"number",checks:[],...Me(a)})}function t2(n,a){return new n({type:"number",check:"number_format",abort:!1,format:"safeint",...Me(a)})}function n2(n,a){return new n({type:"boolean",...Me(a)})}function l2(n){return new n({type:"unknown"})}function a2(n,a){return new n({type:"never",...Me(a)})}function C0(n,a){return new fy({check:"less_than",...Me(a),value:n,inclusive:!1})}function Qd(n,a){return new fy({check:"less_than",...Me(a),value:n,inclusive:!0})}function R0(n,a){return new dy({check:"greater_than",...Me(a),value:n,inclusive:!1})}function Yd(n,a){return new dy({check:"greater_than",...Me(a),value:n,inclusive:!0})}function U0(n,a){return new S_({check:"multiple_of",...Me(a),value:n})}function yy(n,a){return new x_({check:"max_length",...Me(a),maximum:n})}function _o(n,a){return new z_({check:"min_length",...Me(a),minimum:n})}function by(n,a){return new E_({check:"length_equals",...Me(a),length:n})}function i2(n,a){return new T_({check:"string_format",format:"regex",...Me(a),pattern:n})}function u2(n){return new w_({check:"string_format",format:"lowercase",...Me(n)})}function s2(n){return new M_({check:"string_format",format:"uppercase",...Me(n)})}function r2(n,a){return new A_({check:"string_format",format:"includes",...Me(a),includes:n})}function c2(n,a){return new O_({check:"string_format",format:"starts_with",...Me(a),prefix:n})}function o2(n,a){return new N_({check:"string_format",format:"ends_with",...Me(a),suffix:n})}function ys(n){return new j_({check:"overwrite",tx:n})}function f2(n){return ys(a=>a.normalize(n))}function d2(){return ys(n=>n.trim())}function h2(){return ys(n=>n.toLowerCase())}function m2(){return ys(n=>n.toUpperCase())}function p2(){return ys(n=>xS(n))}function g2(n,a,u){return new n({type:"array",element:a,...Me(u)})}function v2(n,a,u){return new n({type:"custom",check:"custom",fn:a,...Me(u)})}function y2(n,a){const u=b2(s=>(s.addIssue=c=>{if(typeof c=="string")s.issues.push(Cr(c,s.value,u._zod.def));else{const d=c;d.fatal&&(d.continue=!1),d.code??(d.code="custom"),d.input??(d.input=s.value),d.inst??(d.inst=u),d.continue??(d.continue=!u._zod.def.abort),s.issues.push(Cr(d))}},n(s.value,s)),a);return u}function b2(n,a){const u=new In({check:"custom",...Me(a)});return u._zod.check=n,u}function Sy(n){let a=n?.target??"draft-2020-12";return a==="draft-4"&&(a="draft-04"),a==="draft-7"&&(a="draft-07"),{processors:n.processors??{},metadataRegistry:n?.metadata??Tr,target:a,unrepresentable:n?.unrepresentable??"throw",override:n?.override??(()=>{}),io:n?.io??"output",counter:0,seen:new Map,cycles:n?.cycles??"ref",reused:n?.reused??"inline",external:n?.external??void 0}}function _n(n,a,u={path:[],schemaPath:[]}){var s;const c=n._zod.def,d=a.seen.get(n);if(d)return d.count++,u.schemaPath.includes(n)&&(d.cycle=u.path),d.schema;const f={schema:{},count:1,cycle:void 0,path:u.path};a.seen.set(n,f);const p=n._zod.toJSONSchema?.();if(p)f.schema=p;else{const x={...u,schemaPath:[...u.schemaPath,n],path:u.path};if(n._zod.processJSONSchema)n._zod.processJSONSchema(a,f.schema,x);else{const T=f.schema,w=a.processors[c.type];if(!w)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${c.type}`);w(n,a,T,x)}const S=n._zod.parent;S&&(f.ref||(f.ref=S),_n(S,a,x),a.seen.get(S).isParent=!0)}const g=a.metadataRegistry.get(n);return g&&Object.assign(f.schema,g),a.io==="input"&&Hn(n)&&(delete f.schema.examples,delete f.schema.default),a.io==="input"&&"_prefault"in f.schema&&((s=f.schema).default??(s.default=f.schema._prefault)),delete f.schema._prefault,a.seen.get(n).schema}function _y(n,a){const u=n.seen.get(a);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const f of n.seen.entries()){const p=n.metadataRegistry.get(f[0])?.id;if(p){const g=s.get(p);if(g&&g!==f[0])throw new Error(`Duplicate schema id "${p}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(p,f[0])}}const c=f=>{const p=n.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const S=n.external.registry.get(f[0])?.id,T=n.external.uri??(O=>O);if(S)return{ref:T(S)};const w=f[1].defId??f[1].schema.id??`schema${n.counter++}`;return f[1].defId=w,{defId:w,ref:`${T("__shared")}#/${p}/${w}`}}if(f[1]===u)return{ref:"#"};const v=`#/${p}/`,x=f[1].schema.id??`__schema${n.counter++}`;return{defId:x,ref:v+x}},d=f=>{if(f[1].schema.$ref)return;const p=f[1],{ref:g,defId:v}=c(f);p.def={...p.schema},v&&(p.defId=v);const x=p.schema;for(const S in x)delete x[S];x.$ref=g};if(n.cycles==="throw")for(const f of n.seen.entries()){const p=f[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/ -Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of n.seen.entries()){const p=f[1];if(a===f[0]){d(f);continue}if(n.external){const v=n.external.registry.get(f[0])?.id;if(a!==f[0]&&v){d(f);continue}}if(n.metadataRegistry.get(f[0])?.id){d(f);continue}if(p.cycle){d(f);continue}if(p.count>1&&n.reused==="ref"){d(f);continue}}}function Sy(n,a){const u=n.seen.get(a);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=p=>{const g=n.seen.get(p);if(g.ref===null)return;const v=g.def??g.schema,x={...v},S=g.ref;if(g.ref=null,S){s(S);const w=n.seen.get(S),O=w.schema;if(O.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(v.allOf=v.allOf??[],v.allOf.push(O)):Object.assign(v,O),Object.assign(v,x),p._zod.parent===S)for(const W in v)W==="$ref"||W==="allOf"||W in x||delete v[W];if(O.$ref&&w.def)for(const W in v)W==="$ref"||W==="allOf"||W in w.def&&JSON.stringify(v[W])===JSON.stringify(w.def[W])&&delete v[W]}const T=p._zod.parent;if(T&&T!==S){s(T);const w=n.seen.get(T);if(w?.schema.$ref&&(v.$ref=w.schema.$ref,w.def))for(const O in v)O==="$ref"||O==="allOf"||O in w.def&&JSON.stringify(v[O])===JSON.stringify(w.def[O])&&delete v[O]}n.override({zodSchema:p,jsonSchema:v,path:g.path??[]})};for(const p of[...n.seen.entries()].reverse())s(p[0]);const c={};if(n.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?c.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?c.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){const p=n.external.registry.get(a)?.id;if(!p)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(p)}Object.assign(c,u.def??u.schema);const d=n.metadataRegistry.get(a)?.id;d!==void 0&&c.id===d&&delete c.id;const f=n.external?.defs??{};for(const p of n.seen.entries()){const g=p[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,f[g.defId]=g.def)}n.external||Object.keys(f).length>0&&(n.target==="draft-2020-12"?c.$defs=f:c.definitions=f);try{const p=JSON.parse(JSON.stringify(c));return Object.defineProperty(p,"~standard",{value:{...a["~standard"],jsonSchema:{input:xo(a,"input",n.processors),output:xo(a,"output",n.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function Hn(n,a){const u=a??{seen:new Set};if(u.seen.has(n))return!1;u.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return Hn(s.element,u);if(s.type==="set")return Hn(s.valueType,u);if(s.type==="lazy")return Hn(s.getter(),u);if(s.type==="promise"||s.type==="optional"||s.type==="nonop)DELIM" -R"DELIM(tional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return Hn(s.innerType,u);if(s.type==="intersection")return Hn(s.left,u)||Hn(s.right,u);if(s.type==="record"||s.type==="map")return Hn(s.keyType,u)||Hn(s.valueType,u);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:Hn(s.in,u)||Hn(s.out,u);if(s.type==="object"){for(const c in s.shape)if(Hn(s.shape[c],u))return!0;return!1}if(s.type==="union"){for(const c of s.options)if(Hn(c,u))return!0;return!1}if(s.type==="tuple"){for(const c of s.items)if(Hn(c,u))return!0;return!!(s.rest&&Hn(s.rest,u))}return!1}const v2=(n,a={})=>u=>{const s=yy({...u,processors:a});return _n(n,s),by(s,n),Sy(s,n)},xo=(n,a,u={})=>s=>{const{libraryOptions:c,target:d}=s??{},f=yy({...c??{},target:d,io:a,processors:u});return _n(n,f),by(f,n),Sy(f,n)},y2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},b2=(n,a,u,s)=>{const c=u;c.type="string";const{minimum:d,maximum:f,format:p,patterns:g,contentEncoding:v}=n._zod.bag;if(typeof d=="number"&&(c.minLength=d),typeof f=="number"&&(c.maxLength=f),p&&(c.format=y2[p]??p,c.format===""&&delete c.format,p==="time"&&delete c.format),v&&(c.contentEncoding=v),g&&g.size>0){const x=[...g];x.length===1?c.pattern=x[0].source:x.length>1&&(c.allOf=[...x.map(S=>({...a.target==="draft-07"||a.target==="draft-04"||a.target==="openapi-3.0"?{type:"string"}:{},pattern:S.source}))])}},S2=(n,a,u,s)=>{const c=u,{minimum:d,maximum:f,format:p,multipleOf:g,exclusiveMaximum:v,exclusiveMinimum:x}=n._zod.bag;typeof p=="string"&&p.includes("int")?c.type="integer":c.type="number";const S=typeof x=="number"&&x>=(d??Number.NEGATIVE_INFINITY),T=typeof v=="number"&&v<=(f??Number.POSITIVE_INFINITY),w=a.target==="draft-04"||a.target==="openapi-3.0";S?w?(c.minimum=x,c.exclusiveMinimum=!0):c.exclusiveMinimum=x:typeof d=="number"&&(c.minimum=d),T?w?(c.maximum=v,c.exclusiveMaximum=!0):c.exclusiveMaximum=v:typeof f=="number"&&(c.maximum=f),typeof g=="number"&&(c.multipleOf=g)},_2=(n,a,u,s)=>{u.type="boolean"},x2=(n,a,u,s)=>{u.not={}},z2=(n,a,u,s)=>{},E2=(n,a,u,s)=>{const c=n._zod.def,d=Iv(c.entries);d.every(f=>typeof f=="number")&&(u.type="number"),d.every(f=>typeof f=="string")&&(u.type="string"),u.enum=d},T2=(n,a,u,s)=>{const c=n._zod.def,d=[];for(const f of c.values)if(f===void 0){if(a.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof f=="bigint"){if(a.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");d.push(Number(f))}else d.push(f);if(d.length!==0)if(d.length===1){const f=d[0];u.type=f===null?"null":typeof f,a.target==="draft-04"||a.target==="openapi-3.0"?u.enum=[f]:u.const=f}else d.every(f=>typeof f=="number")&&(u.type="number"),d.every(f=>typeof f=="string")&&(u.type="string"),d.every(f=>typeof f=="boolean")&&(u.type="boolean"),d.every(f=>f===null)&&(u.type="null"),u.enum=d},w2=(n,a,u,s)=>{if(a.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},M2=(n,a,u,s)=>{if(a.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},A2=(n,a,u,s)=>{const c=u,d=n._zod.def,{minimum:f,maximum:p}=n._zod.bag;typeof f=="number"&&(c.minItems=f),typeof p=="number"&&(c.maxItems=p),c.type="array",c.items=_n(d.element,a,{...s,path:[...s.path,"items"]})},O2=(n,a,u,s)=>{const c=u,d=n._zod.def;c.type="object",c.properties={};const f=d.shape;for(const v in f)c.properties[v]=_n(f[v],a,{...s,path:[...s.path,"properties",v]});const p=new Set(Object.keys(f)),g=new Set([...p].filter(v=>{const x=d.shape[v]._zod;return a.io==="input"?x.optin===void 0:x.optout===void 0}));g.size>0&&(c.required=Array.from(g)),d.catchall?._zod.def.type==="never"?c.additionalProperties=!1:d.catchall?d.catchall&&(c.additionalProperties=_n(d.catchall,a,{...s,path:[...s.path,"additionalProperties"]})):a.io==="output"&&(c.additionalProperties=!1)},N2=(n,a,u,s)=>{const c=n._zod.def,d=c.inclusive===!1,f=c.options.map((p,g)=>_n(p,a,{...s,path:[...s.path,d?"oneOf":"anyOf",g]}));d?u.oneOf=f:u.anyOf=f},j2=(n,a,u,s)=>{const c=n._zod.def,d=_n(c.left,a,{...s,path:[...s.path,"allOf",0]}),f=_n(c.right,a,{...s,path:[...s.path,"allOf",1]}),p=v=>"allOf"in v&&Object.keys(v).length===1,g=[...p(d)?d.allOf:[d],...p(f)?f.allOf:[f]];u.allOf=g},D2=(n,a,u,s)=>{const c=n._zod.def,d=_n(c.innerType,a,s),f=a.seen.get(n);a.target==="openapi-3.0"?(f.ref=c.innerType,u.nullable=!0):u.anyOf=[d,{type:"null"}]},C2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType},R2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType,u.default=JSON.parse(JSON.stringify(c.defaultValue))},U2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType,a.io==="input"&&(u._prefault=JSON.parse(JSON.stringify(c.defaultValue)))},k2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType;let f;try{f=c.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}u.default=f},Z2=(n,a,u,s)=>{const c=n._zod.def,d=c.in._zod.traits.has("$ZodTransform"),f=a.io==="input"?d?c.out:c.in:c.out;_n(f,a,s);const p=a.seen.get(n);p.ref=f},L2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType,u.readOnly=!0},_y=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType},H2=X("ZodISODateTime",(n,a)=>{G_.init(n,a),Ot.init(n,a)});function B2(n){return Kx(H2,n)}const q2=X("ZodISODate",(n,a)=>{Q_.init(n,a),Ot.init(n,a)});function G2(n){return Xx(q2,n)}const Q2=X("ZodISOTime",(n,a)=>{Y_.init(n,a),Ot.init(n,a)});function Y2(n){return Jx(Q2,n)}const $2=X("ZodISODuration",(n,a)=>{$_.init(n,a),Ot.init(n,a)});function V2(n){return Fx($2,n)}const K2=(n,a)=>{ly.init(n,a),n.name="ZodError",Object.defineProperties(n,{format:{value:u=>CS(n,u)},flatten:{value:u=>DS(n,u)},addIssue:{value:u=>{n.issues.push(u),n.message=JSON.stringify(n.issues,Pd,2)}},addIssues:{value:u=>{n.issues.push(...u),n.message=JSON.stringify(n.issues,Pd,2)}},isEmpty:{get(){return n.issues.length===0}}})},Ol=X("ZodError",K2,{Parent:Error}),X2=Oh(Ol),J2=Nh(Ol),F2=Oo(Ol),W2=No(Ol),I2=kS(Ol),P2=ZS(Ol),ez=LS(Ol),tz=HS(Ol),nz=BS(Ol),lz=qS(Ol),az=GS(Ol),iz=QS(Ol),R0=new WeakMap;function Lr(n,a,u){const s=Object.getPrototypeOf(n);let c=R0.get(s);if(c||(c=new Set,R0.set(s,c)),!c.has(a)){c.add(a);for(const d in u){const f=u[d];Object.defineProperty(s,d,{configurable:!0,enumerable:!1,get(){const p=f.bind(this);return Object.defineProperty(this,d,{configurable:!0,writable:!0,enumerable:!0,value:p}),p},set(p){Object.defineProperty(this,d,{configurable:!0,writable:!0,enumerable:!0,value:p})}})}}}const Zt=X("ZodType",(n,a)=>(kt.init(n,a),Object.assign(n["~standard"],{jsonSchema:{input:xo(n,"input"),output:xo(n,"output")}}),n.toJSONSchema=v2(n,{}),n.def=a,n.type=a.type,Object.defineProperty(n,"_def",{value:a}),n.parse=(u,s)=>X2(n,u,s,{callee:n.parse}),n.safeParse=(u,s)=>F2(n,u,s),n.parseAsync=async(u,s)=>J2(n,u,s,{callee:n.parseAsync}),n.safeParseAsync=async(u,s)=>W2(n,u,s),n.spa=n.safeParseAsync,n.encode=(u,s)=>I2(n,u,s),n.decode=(u,s)=>P2(n,u,s),n.encodeAsync=async(u,s)=>ez(n,u,s),n.decodeAsync=async(u,s)=>tz(n,u,s),n.safeEncode=(u,s)=>nz(n,u,s),n.safeDecode=(u,s)=>lz(n,u,s),n.safeEncodeAsync=async(u,s)=>az(n,u,s),n.safeDecodeAsync=async(u,s)=>iz(n,u,s),Lr(n,"ZodType",{check(...u){const s=this.def;return this.clone(Ai(s,{checks:[...s.checks??[],...u.map(c=>typeof c=="function"?{_zod:{check:c,def:{check:"custom"},onattach:[]}}:c)]}),{parent:!0})},with(...u){return this.check(...u)},clone(u,s){return Oi(this,u,s)},brand(){return this},register(u,s){return u.add(this,s),this},refine(u,s){return this.check(Wz(u,s))},superRefine(u,s){return this.check(Iz(u,s))},overwrite(u){return this.check(ys(u))},optional(){return L0(this)},exactOptional(){return Lz(this)},nullable(){return H0(this)},nullish(){return )DELIM" -R"DELIM(L0(H0(this))},nonoptional(u){return Yz(this,u)},array(){return Dh(this)},or(u){return Ch([this,u])},and(u){return Cz(this,u)},transform(u){return B0(this,kz(u))},default(u){return qz(this,u)},prefault(u){return Qz(this,u)},catch(u){return Vz(this,u)},pipe(u){return B0(this,u)},readonly(){return Jz(this)},describe(u){const s=this.clone();return Tr.add(s,{description:u}),s},meta(...u){if(u.length===0)return Tr.get(this);const s=this.clone();return Tr.add(s,u[0]),s},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(u){return u(this)}}),Object.defineProperty(n,"description",{get(){return Tr.get(n)?.description},configurable:!0}),n)),xy=X("_ZodString",(n,a)=>{jh.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(s,c,d)=>b2(n,s,c);const u=n._zod.bag;n.format=u.format??null,n.minLength=u.minimum??null,n.maxLength=u.maximum??null,Lr(n,"_ZodString",{regex(...s){return this.check(n2(...s))},includes(...s){return this.check(i2(...s))},startsWith(...s){return this.check(u2(...s))},endsWith(...s){return this.check(s2(...s))},min(...s){return this.check(_o(...s))},max(...s){return this.check(gy(...s))},length(...s){return this.check(vy(...s))},nonempty(...s){return this.check(_o(1,...s))},lowercase(s){return this.check(l2(s))},uppercase(s){return this.check(a2(s))},trim(){return this.check(c2())},normalize(...s){return this.check(r2(...s))},toLowerCase(){return this.check(o2())},toUpperCase(){return this.check(f2())},slugify(){return this.check(d2())}})}),uz=X("ZodString",(n,a)=>{jh.init(n,a),xy.init(n,a),n.email=u=>n.check(wx(sz,u)),n.url=u=>n.check(jx(rz,u)),n.jwt=u=>n.check(Vx(zz,u)),n.emoji=u=>n.check(Dx(cz,u)),n.guid=u=>n.check(N0(U0,u)),n.uuid=u=>n.check(Mx(ro,u)),n.uuidv4=u=>n.check(Ax(ro,u)),n.uuidv6=u=>n.check(Ox(ro,u)),n.uuidv7=u=>n.check(Nx(ro,u)),n.nanoid=u=>n.check(Cx(oz,u)),n.guid=u=>n.check(N0(U0,u)),n.cuid=u=>n.check(Rx(fz,u)),n.cuid2=u=>n.check(Ux(dz,u)),n.ulid=u=>n.check(kx(hz,u)),n.base64=u=>n.check(Qx(Sz,u)),n.base64url=u=>n.check(Yx(_z,u)),n.xid=u=>n.check(Zx(mz,u)),n.ksuid=u=>n.check(Lx(pz,u)),n.ipv4=u=>n.check(Hx(gz,u)),n.ipv6=u=>n.check(Bx(vz,u)),n.cidrv4=u=>n.check(qx(yz,u)),n.cidrv6=u=>n.check(Gx(bz,u)),n.e164=u=>n.check($x(xz,u)),n.datetime=u=>n.check(B2(u)),n.date=u=>n.check(G2(u)),n.time=u=>n.check(Y2(u)),n.duration=u=>n.check(V2(u))});function su(n){return Tx(uz,n)}const Ot=X("ZodStringFormat",(n,a)=>{wt.init(n,a),xy.init(n,a)}),sz=X("ZodEmail",(n,a)=>{C_.init(n,a),Ot.init(n,a)}),U0=X("ZodGUID",(n,a)=>{j_.init(n,a),Ot.init(n,a)}),ro=X("ZodUUID",(n,a)=>{D_.init(n,a),Ot.init(n,a)}),rz=X("ZodURL",(n,a)=>{R_.init(n,a),Ot.init(n,a)}),cz=X("ZodEmoji",(n,a)=>{U_.init(n,a),Ot.init(n,a)}),oz=X("ZodNanoID",(n,a)=>{k_.init(n,a),Ot.init(n,a)}),fz=X("ZodCUID",(n,a)=>{Z_.init(n,a),Ot.init(n,a)}),dz=X("ZodCUID2",(n,a)=>{L_.init(n,a),Ot.init(n,a)}),hz=X("ZodULID",(n,a)=>{H_.init(n,a),Ot.init(n,a)}),mz=X("ZodXID",(n,a)=>{B_.init(n,a),Ot.init(n,a)}),pz=X("ZodKSUID",(n,a)=>{q_.init(n,a),Ot.init(n,a)}),gz=X("ZodIPv4",(n,a)=>{V_.init(n,a),Ot.init(n,a)}),vz=X("ZodIPv6",(n,a)=>{K_.init(n,a),Ot.init(n,a)}),yz=X("ZodCIDRv4",(n,a)=>{X_.init(n,a),Ot.init(n,a)}),bz=X("ZodCIDRv6",(n,a)=>{J_.init(n,a),Ot.init(n,a)}),Sz=X("ZodBase64",(n,a)=>{F_.init(n,a),Ot.init(n,a)}),_z=X("ZodBase64URL",(n,a)=>{I_.init(n,a),Ot.init(n,a)}),xz=X("ZodE164",(n,a)=>{P_.init(n,a),Ot.init(n,a)}),zz=X("ZodJWT",(n,a)=>{tx.init(n,a),Ot.init(n,a)}),zy=X("ZodNumber",(n,a)=>{dy.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(s,c,d)=>S2(n,s,c),Lr(n,"ZodNumber",{gt(s,c){return this.check(D0(s,c))},gte(s,c){return this.check(Yd(s,c))},min(s,c){return this.check(Yd(s,c))},lt(s,c){return this.check(j0(s,c))},lte(s,c){return this.check(Qd(s,c))},max(s,c){return this.check(Qd(s,c))},int(s){return this.check(k0(s))},safe(s){return this.check(k0(s))},positive(s){return this.check(D0(0,s))},nonnegative(s){return this.check(Yd(0,s))},negative(s){return this.check(j0(0,s))},nonpositive(s){return this.check(Qd(0,s))},multipleOf(s,c){return this.check(C0(s,c))},step(s,c){return this.check(C0(s,c))},finite(){return this}});const u=n._zod.bag;n.minValue=Math.max(u.minimum??Number.NEGATIVE_INFINITY,u.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(u.maximum??Number.POSITIVE_INFINITY,u.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(u.format??"").includes("int")||Number.isSafeInteger(u.multipleOf??.5),n.isFinite=!0,n.format=u.format??null});function Ti(n){return Wx(zy,n)}const Ez=X("ZodNumberFormat",(n,a)=>{nx.init(n,a),zy.init(n,a)});function k0(n){return Ix(Ez,n)}const Tz=X("ZodBoolean",(n,a)=>{lx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>_2(n,u,s)});function ls(n){return Px(Tz,n)}const wz=X("ZodUnknown",(n,a)=>{ax.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>z2()});function Z0(){return e2(wz)}const Mz=X("ZodNever",(n,a)=>{ix.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>x2(n,u,s)});function Az(n){return t2(Mz,n)}const Oz=X("ZodArray",(n,a)=>{ux.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>A2(n,u,s,c),n.element=a.element,Lr(n,"ZodArray",{min(u,s){return this.check(_o(u,s))},nonempty(u){return this.check(_o(1,u))},max(u,s){return this.check(gy(u,s))},length(u,s){return this.check(vy(u,s))},unwrap(){return this.element}})});function Dh(n,a){return h2(Oz,n,a)}const Nz=X("ZodObject",(n,a)=>{rx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>O2(n,u,s,c),ht(n,"shape",()=>a.shape),Lr(n,"ZodObject",{keyof(){return Rh(Object.keys(this._zod.def.shape))},catchall(u){return this.clone({...this._zod.def,catchall:u})},passthrough(){return this.clone({...this._zod.def,catchall:Z0()})},loose(){return this.clone({...this._zod.def,catchall:Z0()})},strict(){return this.clone({...this._zod.def,catchall:Az()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(u){return wS(this,u)},safeExtend(u){return MS(this,u)},merge(u){return AS(this,u)},pick(u){return ES(this,u)},omit(u){return TS(this,u)},partial(...u){return OS(Ey,this,u[0])},required(...u){return NS(Ty,this,u[0])}})});function pu(n,a){const u={type:"object",shape:n??{},...Me(a)};return new Nz(u)}const jz=X("ZodUnion",(n,a)=>{cx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>N2(n,u,s,c),n.options=a.options});function Ch(n,a){return new jz({type:"union",options:n,...Me(a)})}const Dz=X("ZodIntersection",(n,a)=>{ox.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>j2(n,u,s,c)});function Cz(n,a){return new Dz({type:"intersection",left:n,right:a})}const th=X("ZodEnum",(n,a)=>{fx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(s,c,d)=>E2(n,s,c),n.enum=a.entries,n.options=Object.values(a.entries);const u=new Set(Object.keys(a.entries));n.extract=(s,c)=>{const d={};for(const f of s)if(u.has(f))d[f]=a.entries[f];else throw new Error(`Key ${f} not found in enum`);return new th({...a,checks:[],...Me(c),entries:d})},n.exclude=(s,c)=>{const d={...a.entries};for(const f of s)if(u.has(f))delete d[f];else throw new Error(`Key ${f} not found in enum`);return new th({...a,checks:[],...Me(c),entries:d})}});function Rh(n,a){const u=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new th({type:"enum",entries:u,...Me(a)})}const Rz=X("ZodLiteral",(n,a)=>{dx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>T2(n,u,s),n.values=new Set(a.values),Object.defineProperty(n,"value",{get(){if(a.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return a.values[0]}})});function go(n,a){return new Rz({type:"literal",values:Array.isArray(n)?n:[n],...Me(a)})}const Uz=X("ZodTransform",(n,a)=>{hx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>M2(n,u),n._zod.parse=(u,s)=>{if(s.direction==="backward")throw new Wv(n.constructor.name);u.addIssue=d=>{if(typeof d=="string")u.issues.push(Cr(d,u.value,a));else{const f=d;f.fatal&&(f.continue=!1),f.code??(f.code="custom"),f.input??(f.input=u.value),f.inst??(f.inst=n),u.issues.push(Cr(f))}};const )DELIM" -R"DELIM(c=a.transform(u.value,u);return c instanceof Promise?c.then(d=>(u.value=d,u.fallback=!0,u)):(u.value=c,u.fallback=!0,u)}});function kz(n){return new Uz({type:"transform",transform:n})}const Ey=X("ZodOptional",(n,a)=>{py.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>_y(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function L0(n){return new Ey({type:"optional",innerType:n})}const Zz=X("ZodExactOptional",(n,a)=>{mx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>_y(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Lz(n){return new Zz({type:"optional",innerType:n})}const Hz=X("ZodNullable",(n,a)=>{px.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>D2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function H0(n){return new Hz({type:"nullable",innerType:n})}const Bz=X("ZodDefault",(n,a)=>{gx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>R2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function qz(n,a){return new Bz({type:"default",innerType:n,get defaultValue(){return typeof a=="function"?a():ey(a)}})}const Gz=X("ZodPrefault",(n,a)=>{vx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>U2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Qz(n,a){return new Gz({type:"prefault",innerType:n,get defaultValue(){return typeof a=="function"?a():ey(a)}})}const Ty=X("ZodNonOptional",(n,a)=>{yx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>C2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Yz(n,a){return new Ty({type:"nonoptional",innerType:n,...Me(a)})}const $z=X("ZodCatch",(n,a)=>{bx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>k2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Vz(n,a){return new $z({type:"catch",innerType:n,catchValue:typeof a=="function"?a:()=>a})}const Kz=X("ZodPipe",(n,a)=>{Sx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>Z2(n,u,s,c),n.in=a.in,n.out=a.out});function B0(n,a){return new Kz({type:"pipe",in:n,out:a})}const Xz=X("ZodReadonly",(n,a)=>{_x.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>L2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Jz(n){return new Xz({type:"readonly",innerType:n})}const Fz=X("ZodCustom",(n,a)=>{xx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>w2(n,u)});function Wz(n,a={}){return m2(Fz,n,a)}function Iz(n,a){return p2(n,a)}const Do=[{id:0,name:"application",label:"Application"},{id:1,name:"news",label:"News"},{id:2,name:"session",label:"Session"},{id:3,name:"protocol",label:"Protocol"},{id:4,name:"proxy",label:"Proxy"},{id:5,name:"remote",label:"Remote"},{id:6,name:"fault",label:"Fault"},{id:7,name:"quitting",label:"Quitting"},{id:8,name:"objects",label:"Objects"},{id:9,name:"verbose",label:"Verbose"}],Rr=[{id:0,name:"header_archived",label:"Header archived",category:"headers",valueKind:"height"},{id:1,name:"header_organized",label:"Header organized",category:"headers",valueKind:"height"},{id:2,name:"header_reorganized",label:"Header reorganized",category:"headers",valueKind:"height"},{id:3,name:"block_archived",label:"Block archived",category:"blocks",valueKind:"height"},{id:4,name:"block_buffered",label:"Block buffered",category:"blocks",valueKind:"height"},{id:5,name:"block_validated",label:"Block validated",category:"blocks",valueKind:"height"},{id:6,name:"block_confirmed",label:"Block confirmed",category:"blocks",valueKind:"height"},{id:7,name:"block_unconfirmable",label:"Block unconfirmable",category:"blocks",valueKind:"height"},{id:8,name:"validate_bypassed",label:"Validation bypassed",category:"blocks",valueKind:"height"},{id:9,name:"confirm_bypassed",label:"Confirmation bypassed",category:"blocks",valueKind:"height"},{id:10,name:"tx_archived",label:"Transaction archived",category:"transactions",valueKind:"count"},{id:11,name:"tx_validated",label:"Transaction validated",category:"transactions",valueKind:"count"},{id:12,name:"tx_invalidated",label:"Transaction invalidated",category:"transactions",valueKind:"count"},{id:13,name:"block_organized",label:"Block organized",category:"chain",valueKind:"height"},{id:14,name:"block_reorganized",label:"Block reorganized",category:"chain",valueKind:"height"},{id:15,name:"template_issued",label:"Mining template issued",category:"mining",valueKind:"count"},{id:16,name:"snapshot_secs",label:"Snapshot",category:"timing",valueKind:"seconds"},{id:17,name:"prune_msecs",label:"Prune",category:"timing",valueKind:"milliseconds"},{id:18,name:"reload_msecs",label:"Store reload",category:"timing",valueKind:"milliseconds"},{id:19,name:"block_usecs",label:"Serve block",category:"timing",valueKind:"microseconds"},{id:20,name:"ancestry_msecs",label:"Serve ancestry",category:"timing",valueKind:"milliseconds"},{id:21,name:"filter_msecs",label:"Serve filter",category:"timing",valueKind:"milliseconds"},{id:22,name:"filterhashes_msecs",label:"Serve filter hashes",category:"timing",valueKind:"milliseconds"},{id:23,name:"filterchecks_msecs",label:"Serve filter checkpoints",category:"timing",valueKind:"milliseconds"},{id:24,name:"ecdsa_secs",label:"ECDSA batch verification",category:"timing",valueKind:"seconds"},{id:25,name:"schnorr_secs",label:"Schnorr batch verification",category:"timing",valueKind:"seconds"},{id:26,name:"silent_secs",label:"Silent payment scan",category:"timing",valueKind:"seconds"},{id:27,name:"unknown",label:"Unknown",category:"chain",valueKind:"unknown"}],Pz=pu({level:Ti().int().nonnegative(),time:Ti().int().nonnegative(),message:su()}),eE=pu({event:Ti().int().nonnegative(),value:Ti().nonnegative(),time:Ti().int().nonnegative()}),tE=pu({previous:Ti().nonnegative()}),nE=Ch([Pz,eE,tE]),lE=2**Do.length-1,aE=2**Rr.length-1;function iE(n){return"level"in n}function uE(n){return"event"in n}function sE(n){return"previous"in n}function rE(n){try{const a=JSON.parse(n),u=nE.safeParse(a);return u.success?u.data:null}catch{return null}}function cu(n){return Rr[n]??{id:n,name:`event_${String(n)}`,label:`Event ${String(n)}`,category:"chain",valueKind:"unknown"}}function q0(n){return Do[n]??{id:n,name:`level_${String(n)}`,label:`Level ${String(n)}`}}function cE(n,a){const u=cu(n);if(u.category!=="timing")return null;switch(u.valueKind){case"seconds":return a*1e3;case"milliseconds":return a;case"microseconds":return a/1e3;default:return null}}const oE=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function os(n,a=2){return new Intl.NumberFormat(void 0,{maximumFractionDigits:a}).format(n)}function ka(n){return oE.format(n)}function Or(n,a=!0){const u=new Date(n);if(!Number.isFinite(u.getTime()))return"Invalid time";const s=u.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});return a?`${s}.${String(u.getMilliseconds()).padStart(3,"0")}`:s}function fE(n){const a=Math.max(0,Math.floor(n/1e3)),u=Math.floor(a/86400),s=Math.floor(a%86400/3600),c=Math.floor(a%3600/60),d=a%60;return u>0?`${String(u)}d ${String(s)}h`:s>0?`${String(s)}h ${String(c)}m`:c>0?`${String(c)}m ${String(d)}s`:`${String(d)}s`}function wy(n,a){switch(cu(n).valueKind){case"height":return`height ${ka(a)}`;case"seconds":return`${os(a)} s`;case"milliseconds":return`${os(a)} ms`;case"microseconds":return`${os(a)} µs`;case"count":return ka(a);default:return String(a)}}function dE(n){return n>=100?`${os(n,0)}/s`:n>=10?`${os(n,1)}/s`:`${os(n,2)}/s`}function hE(n){try{const a=new URL(n),u=a.pathname==="/"?"":a.pathname.replace(/\/$/u,"");return`${a.host}${u}`}catch{return n}}const mE=[{value:"all",label:"All categories"},{value:"headers",label:"Headers"},{value:"blocks",label:"Blocks"},{value:"transactions",label:"Transactions"},{value:"chain",label:"Confirmed chain"},{value:"mining",label:"Mining"},{value:"timing",label:"Timing"}],pE={headers:"bg-violet-500/15 text-violet-300",blocks:"bg-accent/15 text-accent",transactions:"bg-sky-500/15 text-sky-300",chain:"bg-emerald-500/15 text-emerald-300",mining:"bg-amber-500/15 text-amber-300",timing:"bg-cyan-500/15 text-cyan-300"};function gE({events:n,onClear:a}){const[u,s)DELIM" -R"DELIM(]=_e.useState(""),[c,d]=_e.useState("all"),[f,p]=_e.useState(!1),[g,v]=_e.useState([]),x=f?g:n,S=_e.useMemo(()=>{const w=u.trim().toLowerCase();return x.filter(O=>{const Y=cu(O.event);return c==="all"||Y.category===c}).filter(O=>{if(!w)return!0;const Y=cu(O.event);return Y.name.includes(w)||Y.label.toLowerCase().includes(w)||String(O.value).includes(w)}).slice(0,250)},[c,u,x]);function T(){f||v(n),p(w=>!w)}return z.jsxs("section",{className:"space-y-4",children:[z.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Node lifecycle"}),z.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:"Live events"}),z.jsx("p",{className:"text-textMuted mt-1 text-sm",children:"Heights are event payloads; timing values retain their source units."})]}),z.jsxs("div",{className:"flex gap-2",children:[z.jsx("button",{type:"button",onClick:T,className:"border-accent/35 text-accent hover:bg-accent/10 rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:f?"Resume":"Pause"}),z.jsx("button",{type:"button",onClick:a,className:"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:"Clear"})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 flex flex-wrap gap-3 rounded-xl border p-4",children:[z.jsxs("label",{className:"min-w-56 flex-1",children:[z.jsx("span",{className:"sr-only",children:"Search events"}),z.jsx("input",{type:"search",value:u,onChange:w=>{s(w.target.value)},placeholder:"Search event names or values…",className:"border-accent/25 bg-background/70 text-textPrimary placeholder:text-textMuted/60 focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{children:[z.jsx("span",{className:"sr-only",children:"Filter event category"}),z.jsx("select",{value:c,onChange:w=>{d(w.target.value)},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent rounded-lg border px-3 py-2 text-sm focus:ring-0",children:mE.map(w=>z.jsx("option",{value:w.value,children:w.label},w.value))})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 overflow-hidden rounded-xl border",children:[z.jsxs("div",{className:"border-accent/15 text-textMuted flex justify-between border-b px-4 py-3 text-xs",children:[z.jsx("span",{children:f?"Paused snapshot":"Live stream"}),z.jsxs("span",{children:["Showing ",String(S.length)," of ",String(x.length)]})]}),z.jsx("div",{className:"max-h-[65vh] overflow-auto",children:S.length===0?z.jsx("p",{className:"text-textMuted px-4 py-12 text-center text-sm",children:"No matching events."}):z.jsx("ol",{className:"divide-y divide-white/5",children:S.map(w=>{const O=cu(w.event);return z.jsxs("li",{className:"grid items-start gap-2 px-4 py-3 text-xs sm:grid-cols-[8.5rem_10rem_minmax(0,1fr)]",children:[z.jsx("time",{dateTime:new Date(w.time).toISOString(),className:"text-textMuted font-mono tabular-nums",children:Or(w.time)}),z.jsx("span",{className:`w-fit rounded px-2 py-0.5 font-medium ${pE[O.category]}`,children:O.name}),z.jsx("span",{className:"text-textPrimary font-mono tabular-nums",children:wy(w.event,w.value)})]},w.id)})})})]}),z.jsxs("details",{className:"border-accent/20 bg-surface/50 rounded-xl border",children:[z.jsxs("summary",{className:"text-textMuted hover:text-accent cursor-pointer px-4 py-3 text-sm",children:["Event contract (",String(Rr.length)," identifiers)"]}),z.jsx("div",{className:"grid gap-2 border-t border-white/5 p-4 sm:grid-cols-2 lg:grid-cols-3",children:Rr.map(w=>z.jsxs("div",{className:"text-xs",children:[z.jsx("span",{className:"text-textMuted font-mono",children:String(w.id).padStart(2,"0")}),z.jsx("span",{className:"text-textPrimary ml-2",children:w.name})]},w.id))})]})]})}const G0={0:"bg-sky-500/15 text-sky-300",1:"bg-emerald-500/15 text-emerald-300",2:"bg-violet-500/15 text-violet-300",3:"bg-cyan-500/15 text-cyan-300",4:"bg-indigo-500/15 text-indigo-300",5:"bg-blue-500/15 text-blue-300",6:"bg-red-500/20 text-red-300",7:"bg-orange-500/20 text-orange-300",8:"bg-slate-500/20 text-slate-300",9:"bg-zinc-500/20 text-zinc-300"};function vE({logs:n,onClear:a}){const[u,s]=_e.useState(""),[c,d]=_e.useState("all"),[f,p]=_e.useState(!1),[g,v]=_e.useState([]),x=f?g:n,S=_e.useMemo(()=>{const w=u.trim().toLowerCase();return x.filter(O=>c==="all"||O.level===Number(c)).filter(O=>!w||O.message.toLowerCase().includes(w)||q0(O.level).name.includes(w)).slice(0,250)},[c,u,x]);function T(){f||v(n),p(w=>!w)}return z.jsxs("section",{className:"space-y-4",children:[z.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Diagnostic stream"}),z.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:"Node logs"}),z.jsx("p",{className:"text-textMuted mt-1 text-sm",children:"The newest 1,000 messages are retained in this browser session."})]}),z.jsxs("div",{className:"flex gap-2",children:[z.jsx("button",{type:"button",onClick:T,className:"border-accent/35 text-accent hover:bg-accent/10 rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:f?"Resume":"Pause"}),z.jsx("button",{type:"button",onClick:a,className:"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:"Clear"})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 flex flex-wrap gap-3 rounded-xl border p-4",children:[z.jsxs("label",{className:"min-w-56 flex-1",children:[z.jsx("span",{className:"sr-only",children:"Search logs"}),z.jsx("input",{type:"search",value:u,onChange:w=>{s(w.target.value)},placeholder:"Search messages…",className:"border-accent/25 bg-background/70 text-textPrimary placeholder:text-textMuted/60 focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{children:[z.jsx("span",{className:"sr-only",children:"Filter log level"}),z.jsxs("select",{value:c,onChange:w=>{d(w.target.value)},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent rounded-lg border px-3 py-2 text-sm focus:ring-0",children:[z.jsx("option",{value:"all",children:"All levels"}),Do.map(w=>z.jsx("option",{value:w.id,children:w.label},w.id))]})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 overflow-hidden rounded-xl border",children:[z.jsxs("div",{className:"border-accent/15 text-textMuted flex justify-between border-b px-4 py-3 text-xs",children:[z.jsx("span",{children:f?"Paused snapshot":"Live stream"}),z.jsxs("span",{children:["Showing ",String(S.length)," of ",String(x.length)]})]}),z.jsx("div",{className:"max-h-[65vh] overflow-auto",children:S.length===0?z.jsx("p",{className:"text-textMuted px-4 py-12 text-center text-sm",children:"No matching log messages."}):z.jsx("ol",{className:"divide-y divide-white/5",children:S.map(w=>{const O=q0(w.level);return z.jsxs("li",{className:"grid gap-2 px-4 py-3 text-xs sm:grid-cols-[7.5rem_7.5rem_minmax(0,1fr)]",children:[z.jsx("time",{dateTime:new Date(w.time).toISOString(),className:"text-textMuted font-mono tabular-nums",children:Or(w.time,!1)}),z.jsx("span",{className:`w-fit rounded px-2 py-0.5 font-medium ${G0[w.level]??G0[8]}`,children:O.name}),z.jsx("span",{className:"text-textPrimary min-w-0 font-mono leading-5 break-words whitespace-pre-wrap",children:w.message})]},w.id)})})})]})]})}const $d=["line","area","bar"],Q0=["line","step","area"],yE=["line","step","area"],My={"occurrence-count":{id:"occurrence-count",label:"Occurrences per bucket",description:"Number of frames observed in each one-second bucket.",unit:"occurrences",chartTypes:$d},"occurrence-rate":{id:"occurrence-rate",label:")DELIM" -R"DELIM(Occurrence rate",description:"Frames observed per second.",unit:"occurrences-per-second",chartTypes:$d},"cumulative-occurrences":{id:"cumulative-occurrences",label:"Cumulative occurrences",description:"Running number of frames observed during this browser session.",unit:"occurrences",chartTypes:Q0},"payload-latest":{id:"payload-latest",label:"Latest value",description:"Most recently observed payload value.",unit:"count",chartTypes:yE},"payload-average":{id:"payload-average",label:"Average value",description:"Average payload value within each one-second bucket.",unit:"count",chartTypes:["line","area","bar"]},"payload-minimum":{id:"payload-minimum",label:"Minimum value",description:"Minimum payload value within each one-second bucket.",unit:"count",chartTypes:["line","step"]},"payload-maximum":{id:"payload-maximum",label:"Maximum value",description:"Maximum payload value within each one-second bucket.",unit:"count",chartTypes:["line","step"]},"payload-sum":{id:"payload-sum",label:"Value per bucket",description:"Sum of count payloads within each one-second bucket.",unit:"count",chartTypes:["line","area","bar"]},"payload-cumulative":{id:"payload-cumulative",label:"Cumulative value",description:"Running sum of count payloads during this browser session.",unit:"count",chartTypes:Q0},"payload-change-rate":{id:"payload-change-rate",label:"Height change rate",description:"Change in the latest observed height per second.",unit:"height-per-second",chartTypes:$d}},bs=["occurrence-rate","occurrence-count","cumulative-occurrences"],bE=["payload-latest","payload-maximum","payload-change-rate",...bs],SE=["payload-average","payload-latest","payload-minimum","payload-maximum",...bs],_E=["payload-sum","payload-cumulative","payload-latest","payload-average",...bs];function Al(n){return`event:${String(n)}`}function xi(n){return`log:${String(n)}`}const zo="native:top";function xE(n){switch(n){case"height":return"height";case"seconds":case"milliseconds":case"microseconds":return"duration";case"count":return"count";default:return"unknown"}}function zE(n){switch(n){case"height":return bE;case"duration":return SE;case"count":return _E;default:return bs}}function EE(n){switch(n){case"height":return"payload-latest";case"duration":return"payload-average";case"count":return"payload-sum";default:return"occurrence-rate"}}function Ay(n){const a=cu(n),u=xE(a.valueKind);return{id:Al(n),source:"event",sourceId:n,name:a.name,label:a.label,category:a.category,payloadKind:u,allowedMeasures:zE(u),defaultMeasure:EE(u),description:u==="unknown"?"Payload semantics are unknown; occurrence measurements are safe.":`${a.label} event with a ${u} payload.`}}const TE=[...Rr.map(n=>Ay(n.id)),...Do.map(n=>({id:xi(n.id),source:"log",sourceId:n.id,name:n.name,label:`${n.label} logs`,category:"logs",payloadKind:"text",allowedMeasures:bs,defaultMeasure:"occurrence-rate",description:`${n.label} log message volume. Message text is not interpreted as numeric data.`})),{id:zo,source:"native",sourceId:"top",name:"canonical_top",label:"Canonical top",category:"native",payloadKind:"height",allowedMeasures:["payload-latest","payload-maximum","payload-change-rate"],defaultMeasure:"payload-latest",description:"Canonical chain height reported by the native interface."}],Uh=TE,wE=new Map(Uh.map(n=>[n.id,n]));function Za(n){const a=wE.get(n);if(a)return a;const u=/^event:(\d+)$/u.exec(n);return u?Ay(Number(u[1])):{id:n,source:"event",sourceId:-1,name:n,label:n,category:"unknown",payloadKind:"unknown",allowedMeasures:bs,defaultMeasure:"occurrence-rate",description:"Unknown signal; only occurrence measurements are available."}}function Ei(n,a){const u=My[a];if(a.startsWith("occurrence")||a==="cumulative-occurrences")return u;const s=a==="payload-change-rate"?"height-per-second":n.payloadKind==="height"?"height":n.payloadKind==="duration"?"milliseconds":"count";return{...u,unit:s}}function ME(n,a){return n.allowedMeasures.includes(a)}function AE(n,a){return cE(n,a)??a}const OE=3600*1e3,NE=250,jE=1e3,DE=1e3;class Y0{constructor(a){this.capacity=a,this.#e=Array.from({length:a})}capacity;#e;#t=0;#n=0;push(a){this.#e[this.#t]=a,this.#t=(this.#t+1)%this.capacity,this.#n=Math.min(this.#n+1,this.capacity)}clear(){this.#t=0,this.#n=0}newestFirst(){const a=[];for(let u=0;uthis.#z;subscribe=a=>(this.#t.add(a),()=>{this.#t.delete(a)});start(){this.#y||(this.tick(),this.#y=setInterval(()=>{this.tick()},1e3))}stop(){this.#y&&(clearInterval(this.#y),this.#y=null),this.#p&&(clearTimeout(this.#p),this.#p=null)}ingest(a,u=this.#e()){const s=this.#E(u);this.#m+=1,iE(a)?this.#N(a,s):uE(a)?this.#j(a,s):sE(a)&&(this.#b+=1),this.#w()}recordInvalidFrame(){this.#S+=1,this.#w()}recordNativeTop(a,u=this.#e()){const s=this.#E(u),c=this.#r[zo];c?.value===a&&s-c.time<15e3||(this.#M(zo,s,a),this.#A(s),this.#w())}clearLogs(){this.#n.clear(),this.flush()}clearEvents(){this.#l.clear(),this.flush()}reset(){this.#n.clear(),this.#l.clear(),this.#a.clear(),this.#i={},this.#s={},this.#u={},this.#c={},this.#r={},this.#d={},this.#h=this.#E(this.#e()),this.#m=0,this.#g=0,this.#o=0,this.#b=0,this.#S=0,this.#_=null,this.#x=null,this.#v=0,this.#T(this.#h),this.flush()}tick(){const a=this.#E(this.#e());this.#T(a),this.#A(a),this.#w()}flush(){this.#p&&(clearTimeout(this.#p),this.#p=null),this.#z=this.#O();for(const a of this.#t)a()}#N(a,u){this.#g+=1,this.#_=u,this.#v+=1,this.#n.push({...a,id:this.#v,receivedAt:u}),this.#M(xi(a.level),u,null)}#j(a,u){this.#o+=1,this.#x=u,this.#v+=1,this.#l.push({...a,id:this.#v,receivedAt:u}),this.#M(Al(a.event),u,AE(a.event,a.value))}#E(a){return Number.isFinite(a)?(this.#f=Math.max(this.#f,a),this.#f):this.#f}#M(a,u,s){const c=this.#T(u),d=c.signals.get(a)??CE();if(d.count+=1,co(this.#u,a,1),s!==null){d.samples+=1,d.sum+=s,d.minimum=d.minimum===null?s:Math.min(d.minimum,s),d.maximum=d.maximum===null?s:Math.max(d.maximum,s),(d.firstAt===null||u=d.lastAt)&&(d.last=s,d.lastAt=u),co(this.#c,a,s);const f=this.#r[a];(!f||u>=f.time)&&(this.#r[a]={value:s,time:u}),this.#d[a]=Math.max(this.#d[a]??s,s)}c.signals.set(a,d)}#T(a){const u=Math.floor(a/1e3)*1e3,s=this.#a.get(u);if(s)return s;const c={time:u,signals:new Map};return this.#a.set(u,c),c}#A(a){const u=a-OE;for(const[s,c]of this.#a)if(!(s>=u)){for(const[d,f]of c.signals)co(this.#i,d,f.count),co(this.#s,d,f.sum);this.#a.delete(s)}}#w(){this.#p||(this.#p=setTimeout(()=>{this.#p=null,this.flush()},NE))}#O(){const a=[...this.#a.values()].sort((u,s)=>u.time-s.time);return{now:this.#E(this.#e()),sessionStartedAt:this.#h,totalFrames:this.#m,totalLogs:this.#g,totalEvents:this.#o,totalAcks:this.#b,invalidFrames:this.#S,buckets:a.map(u=>({time:u.time,signals:Object.fromEntries([...u.signals].map(([s,c])=>[s,{...c}]))})),priorSignalCounts:{...this.#i},priorSignalSums:{...this.#s},signalTotals:{...this.#u},signalSums:{...this.#c},signalLatest:{...this.#r},signalMaximums:{...this.#d},recentLogs:this.#n.newestFirst(),recentEvents:this.#l.newestFirst(),lastLogAt:this.#_,lastEventAt:this.#x}}}function UE(n,a,u,s,c=n[0]?.time??u){const d=u-s*1e3,f=d<=c,p=f?Math.floor(c/1e3)*1e3:Math.ceil(d/1e3)*1e3,g=f?c:p,v=Math.floor(u/1e3)*1e3,S=n.filter(w=>w.time>=p&&w.time<=v).reduce((w,O)=>w+(O.signals[a]?.count??0),0),T=Math.max(0,(u-g)/1e3);return T>0?S/T:0}function kE(n,a){const u=f=>UE(n.buckets,Al(f),n.now,a,n.sessionStartedAt),s=u(2)+u(14);if(s>0)return{label:"Reorganizing",rate:s};const d=[{label:"Confirming blo)DELIM" -R"DELIM(cks",rate:u(6)},{label:"Validating blocks",rate:u(5)},{label:"Archiving blocks",rate:u(3)},{label:"Synchronizing headers",rate:Math.max(u(0),u(1))}].reduce((f,p)=>p.rate>f.rate?p:f);return d.rate>0?d:{label:"Idle",rate:0}}const ZE={idle:"border-slate-500/40 bg-slate-500/10 text-slate-300",connecting:"border-amber-500/40 bg-amber-500/10 text-amber-300",connected:"border-emerald-500/40 bg-emerald-500/10 text-emerald-300",reconnecting:"border-orange-500/40 bg-orange-500/10 text-orange-300"};function LE({phase:n,label:a}){return z.jsxs("span",{className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs tracking-wide uppercase ${ZE[n]}`,children:[z.jsx("span",{className:"h-2 w-2 rounded-full bg-current","aria-hidden":"true"}),a]})}const HE={orange:"from-accent/25",red:"from-accentSecondary/25",green:"from-emerald-500/20",blue:"from-sky-500/20"};function oo({label:n,value:a,detail:u,accent:s="orange"}){return z.jsxs("article",{className:`border-accent/20 bg-surface/80 rounded-xl border bg-gradient-to-br ${HE[s]} to-transparent p-5`,children:[z.jsx("p",{className:"text-textMuted text-xs font-medium tracking-[0.14em] uppercase",children:n}),z.jsx("p",{className:"text-textPrimary mt-3 text-3xl font-semibold tracking-tight tabular-nums",children:a}),z.jsx("div",{className:"text-textMuted mt-2 min-h-5 text-xs",children:u})]})}const us=16,nh=8,BE=[300,900,3600],lh=["line","step","area","bar"],bn=["#ffa022","#38bdf8","#34d399","#c084fc","#fb7185","#e879f9","#facc15","#60a5fa"],qE=Rh(["occurrence-count","occurrence-rate","cumulative-occurrences","payload-latest","payload-average","payload-minimum","payload-maximum","payload-sum","payload-cumulative","payload-change-rate"]),GE=pu({id:su().min(1).max(100),signalId:su().min(1).max(100),measure:qE,color:su().regex(/^#[\da-f]{6}$/iu),label:su().max(80).optional()}).strict(),Oy=pu({id:su().min(1).max(100),title:su().trim().min(1).max(80),visualization:Rh(lh),range:Ch([go(300),go(900),go(3600)]),series:Dh(GE).min(1).max(nh)}).strict(),QE=pu({version:go(1),charts:Dh(Oy).max(us)}).strict(),Ny={id:"default-sync-pipeline",title:"Sync pipeline",visualization:"line",range:900,series:[dl("sync-header",Al(0),"occurrence-rate",bn[3]),dl("sync-archive",Al(3),"occurrence-rate",bn[0]),dl("sync-validate",Al(5),"occurrence-rate",bn[1]),dl("sync-confirm",Al(6),"occurrence-rate",bn[2])]},YE={id:"default-chain-progress",title:"Chain progress",visualization:"step",range:900,series:[dl("progress-top",zo,"payload-latest",bn[0]),dl("progress-organized",Al(13),"payload-latest",bn[2]),dl("progress-confirmed",Al(6),"payload-latest",bn[1])]},$E={id:"default-log-volume",title:"Log volume",visualization:"bar",range:900,series:[dl("logs-news",xi(1),"occurrence-rate",bn[2]),dl("logs-session",xi(2),"occurrence-rate",bn[3]),dl("logs-protocol",xi(3),"occurrence-rate",bn[1]),dl("logs-remote",xi(5),"occurrence-rate",bn[7]),dl("logs-fault",xi(6),"occurrence-rate",bn[4]),dl("logs-quitting",xi(7),"occurrence-rate",bn[0])]},kh=[{id:"sync-pipeline",label:"Sync pipeline",description:"Header and block lifecycle throughput.",chart:Ny},{id:"chain-progress",label:"Chain progress",description:"Canonical, organized, and confirmed heights.",chart:YE},{id:"log-volume",label:"Log volume",description:"Message rates grouped by log level.",chart:$E}],jy="libbitcoinAdminDashboardCharts";let $0=0;function dl(n,a,u,s){return{id:n,signalId:a,measure:u,color:s}}function Eo(n){return $0+=1,`${n}-${Date.now().toString(36)}-${String($0)}`}function Zh(n,a=!1){return{...n,id:a?Eo("chart"):n.id,series:n.series.map(u=>({...u,id:a?Eo("series"):u.id}))}}function vo(){return kh.map(n=>Zh(n.chart))}function VE(n){const a=kh.find(u=>u.id===n);return Zh(a?.chart??Ny,!0)}function Dy(){return{id:Eo("chart"),title:"Custom chart",visualization:"line",range:900,series:[{id:Eo("series"),signalId:Al(3),measure:"occurrence-rate",color:bn[0]}]}}function KE(n){return{...Zh(n,!0),title:`${n.title} copy`}}function ah(n){const a=new Set(n.series.map(u=>Ei(Za(u.signalId),u.measure).unit));return a.size===1?[...a][0]??null:null}function Cy(n){const a=Oy.safeParse(n);if(!a.success)return a.error.issues[0]?.message??"Invalid chart configuration";for(const u of n.series){const s=Za(u.signalId);if(!ME(s,u.measure))return`${My[u.measure].label} is not valid for ${s.label}.`;const c=Ei(s,u.measure);if(!c.chartTypes.includes(n.visualization))return`${c.label} cannot be displayed as a ${n.visualization} chart.`}return ah(n)===null?"All series on a chart must use compatible units.":null}function XE(n){const a=QE.safeParse(n);return!a.success||new Set(a.data.charts.map(u=>u.id)).size!==a.data.charts.length||a.data.charts.some(u=>new Set(u.series.map(s=>s.id)).size!==u.series.length)?null:a.data.charts.every(u=>Cy(u)===null)?a.data.charts:null}function Ry(){try{return globalThis.window?.localStorage??null}catch{return null}}function JE(n=Ry()){try{const a=n?.getItem(jy);return a?XE(JSON.parse(a))??vo():vo()}catch{return vo()}}function FE(n,a=Ry()){try{a?.setItem(jy,JSON.stringify({version:1,charts:n}))}catch{}}function Lh(n,a){return n.signals[a]}function V0(n,a,u,s){let c=s==="count"?n.priorSignalCounts[a]??0:n.priorSignalSums[a]??0;for(const d of n.buckets){if(d.time>=u)break;const f=Lh(d,a);c+=s==="count"?f?.count??0:f?.sum??0}return c}function WE(n,a,u){let s=null;for(const c of n){if(c.time>=u)break;const d=Lh(c,a);d?.last!==null&&d?.last!==void 0&&d.lastAt!==null&&(s={value:d.last,time:d.lastAt})}return s}function IE(n,a){const u=a<=n.sessionStartedAt?Math.floor(n.sessionStartedAt/1e3)*1e3:Math.ceil(a/1e3)*1e3,s=Math.floor(n.now/1e3)*1e3,c=new Map(n.buckets.map(f=>[f.time,f])),d=[];for(let f=u;f<=s;f+=1e3)d.push(c.get(f)??{time:f,signals:{}});return d}function PE(n,a,u){const s=Math.max(n.time,u),c=Math.min(a,n.time+1e3);return Math.max(0,(c-s)/1e3)}function eT(n,a,u,s){const c=Za(s.signalId);let d=s.measure==="cumulative-occurrences"?V0(n,s.signalId,u,"count"):s.measure==="payload-cumulative"?V0(n,s.signalId,u,"sum"):0,f=WE(n.buckets,s.signalId,u);return a.map(p=>{const g=Lh(p,s.signalId);switch(s.measure){case"occurrence-count":return g?.count??0;case"occurrence-rate":{const v=PE(p,n.now,n.sessionStartedAt);return v>0?(g?.count??0)/v:0}case"cumulative-occurrences":return d+=g?.count??0,d;case"payload-sum":return g&&g.samples>0?g.sum:null;case"payload-cumulative":return d+=g?.sum??0,d;case"payload-average":return g&&g.samples>0?g.sum/g.samples:null;case"payload-minimum":return g?.minimum??null;case"payload-maximum":return g?.maximum??null;case"payload-latest":return g?.last!==null&&g?.last!==void 0&&g.lastAt!==null?(f={value:g.last,time:g.lastAt},g.last):c.payloadKind==="height"?f?.value??null:null;case"payload-change-rate":{if(g?.last===null||g?.last===void 0||g.lastAt===null)return null;const v=f??(g.first!==null&&g.firstAt!==null?{value:g.first,time:g.firstAt}:null);if(f={value:g.last,time:g.lastAt},!v)return null;const x=(g.lastAt-v.time)/1e3;return x>0?(g.last-v.value)/x:null}}})}function tT(n,a){const u=n.now-a.range*1e3,s=IE(n,u),c=s[0]?.time??Math.floor(n.now/1e3)*1e3,d=a.series[0],f=Ei(Za(d.signalId),d.measure).unit,p=a.series.filter(g=>(n.signalTotals[g.signalId]??0)===0).map(g=>g.label??Za(g.signalId).label);return{data:[s.map(g=>g.time/1e3),...a.series.map(g=>eT(n,s,c,g))],unit:f,hasObservedData:p.length({...a}))}}function sT(){const n)DELIM" -R"DELIM(=new Map;for(const a of Uh){const u=n.get(a.category)??[];u.push(a),n.set(a.category,u)}return[...n]}const rT=sT();function cT({chart:n,mode:a,onCancel:u,onSave:s}){const[c,d]=_e.useState(()=>uT(n)),f=Cy(c),p=ah(c);_e.useEffect(()=>{function w(O){O.key==="Escape"&&u()}return globalThis.addEventListener("keydown",w),()=>{globalThis.removeEventListener("keydown",w)}},[u]);const g=_e.useMemo(()=>new Set(lh.filter(w=>c.series.every(O=>Ei(Za(O.signalId),O.measure).chartTypes.includes(w)))),[c.series]);function v(w,O){d(Y=>({...Y,series:Y.series.map((W,F)=>F===w?O:W)}))}function x(w,O){const Y=c.series[w],W=Za(O);v(w,{...Y,signalId:O,measure:W.defaultMeasure})}function S(){if(c.series.length>=nh)return;const w=ah(c),O=Uh.find(F=>F.allowedMeasures.some(B=>w===null||Ei(F,B).unit===w));if(!O)return;const Y=O.allowedMeasures.find(F=>w===null||Ei(O,F).unit===w)??O.defaultMeasure,W={id:`series-${Date.now().toString(36)}-${String(c.series.length+1)}`,signalId:O.id,measure:Y,color:bn[c.series.length%bn.length]??bn[0]};d(F=>({...F,series:[...F.series,W]}))}function T(w){w.preventDefault(),!f&&s({...c,title:c.title.trim()})}return z.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm",role:"presentation",onMouseDown:w=>{w.target===w.currentTarget&&u()},children:z.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"chart-editor-title",className:"border-accent/30 bg-surface max-h-[92vh] w-full max-w-4xl overflow-y-auto rounded-2xl border shadow-2xl shadow-black/60",children:[z.jsxs("header",{className:"border-accent/20 flex items-start justify-between border-b p-5",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Dashboard builder"}),z.jsx("h2",{id:"chart-editor-title",className:"mt-1 text-xl font-semibold",children:a==="add"?"Add chart":"Edit chart"})]}),z.jsx("button",{type:"button",onClick:u,className:"text-textMuted hover:text-accent rounded p-1 text-xl","aria-label":"Close chart editor",children:"×"})]}),a==="add"&&z.jsxs("div",{className:"border-accent/15 border-b p-5",children:[z.jsx("p",{className:"text-textMuted mb-3 text-xs font-medium tracking-wide uppercase",children:"Start from a template"}),z.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-5",children:[kh.map(w=>z.jsxs("button",{type:"button",onClick:()=>{d(VE(w.id))},className:"border-accent/20 bg-background/50 hover:border-accent/60 rounded-lg border p-3 text-left",children:[z.jsx("span",{className:"text-textPrimary block text-sm font-medium",children:w.label}),z.jsx("span",{className:"text-textMuted mt-1 block text-xs leading-4",children:w.description})]},w.id)),z.jsxs("button",{type:"button",onClick:()=>{d(Dy())},className:"border-accent/20 bg-background/50 hover:border-accent/60 rounded-lg border p-3 text-left",children:[z.jsx("span",{className:"text-textPrimary block text-sm font-medium",children:"Custom"}),z.jsx("span",{className:"text-textMuted mt-1 block text-xs leading-4",children:"Begin with one editable series."})]})]})]}),z.jsxs("form",{onSubmit:T,className:"space-y-6 p-5",children:[z.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_11rem_11rem]",children:[z.jsxs("label",{className:"space-y-2",children:[z.jsx("span",{className:"text-sm font-medium",children:"Chart title"}),z.jsx("input",{value:c.title,onChange:w=>{d(O=>({...O,title:w.target.value}))},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{className:"space-y-2",children:[z.jsx("span",{className:"text-sm font-medium",children:"Chart type"}),z.jsx("select",{value:c.visualization,onChange:w=>{d(O=>({...O,visualization:w.target.value}))},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0",children:lh.map(w=>z.jsx("option",{value:w,disabled:!g.has(w),children:iT[w]},w))})]}),z.jsxs("label",{className:"space-y-2",children:[z.jsx("span",{className:"text-sm font-medium",children:"Time range"}),z.jsx("select",{value:c.range,onChange:w=>{d(O=>({...O,range:Number(w.target.value)}))},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0",children:BE.map(w=>z.jsx("option",{value:w,children:aT[w]},w))})]})]}),z.jsxs("section",{className:"space-y-3",children:[z.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[z.jsxs("div",{children:[z.jsx("h3",{className:"font-semibold",children:"Series"}),z.jsxs("p",{className:"text-textMuted mt-1 text-xs",children:["One chart uses one axis unit",p===null?".":`: ${Uy(p)}.`]})]}),z.jsx("button",{type:"button",onClick:S,disabled:c.series.length>=nh,className:"border-accent/35 text-accent hover:bg-accent/10 disabled:text-textMuted rounded-lg border px-3 py-2 text-xs font-medium uppercase disabled:cursor-not-allowed disabled:opacity-50",children:"Add series"})]}),z.jsx("div",{className:"space-y-3",children:c.series.map((w,O)=>{const Y=Za(w.signalId),W=Ei(Y,w.measure);return z.jsxs("article",{className:"border-accent/15 bg-background/35 grid gap-3 rounded-xl border p-4 lg:grid-cols-[minmax(12rem,1.2fr)_minmax(11rem,1fr)_minmax(9rem,0.8fr)_3.5rem_auto]",children:[z.jsxs("label",{className:"space-y-1.5",children:[z.jsxs("span",{className:"text-textMuted text-xs",children:["Signal ",String(O+1)]}),z.jsx("select",{"aria-label":`Signal ${String(O+1)}`,value:w.signalId,onChange:F=>{x(O,F.target.value)},className:"border-accent/25 bg-surface text-textPrimary focus:border-accent w-full rounded-lg border px-2 py-2 text-sm focus:ring-0",children:rT.map(([F,B])=>z.jsx("optgroup",{label:F,children:B.map(I=>z.jsx("option",{value:I.id,children:I.label},I.id))},F))})]}),z.jsxs("label",{className:"space-y-1.5",children:[z.jsx("span",{className:"text-textMuted text-xs",children:"Measurement"}),z.jsx("select",{"aria-label":`Measurement ${String(O+1)}`,value:w.measure,onChange:F=>{v(O,{...w,measure:F.target.value})},className:"border-accent/25 bg-surface text-textPrimary focus:border-accent w-full rounded-lg border px-2 py-2 text-sm focus:ring-0",title:W.description,children:Y.allowedMeasures.map(F=>z.jsx("option",{value:F,children:Ei(Y,F).label},F))})]}),z.jsxs("label",{className:"space-y-1.5",children:[z.jsx("span",{className:"text-textMuted text-xs",children:"Display label"}),z.jsx("input",{"aria-label":`Display label ${String(O+1)}`,value:w.label??"",onChange:F=>{v(O,{...w,label:F.target.value||void 0})},placeholder:Y.label,className:"border-accent/25 bg-surface text-textPrimary placeholder:text-textMuted/50 focus:border-accent w-full rounded-lg border px-2 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{className:"space-y-1.5",children:[z.jsx("span",{className:"text-textMuted text-xs",children:"Color"}),z.jsx("input",{"aria-label":`Series color ${String(O+1)}`,type:"color",value:w.color,onChange:F=>{v(O,{...w,color:F.target.value})},className:"border-accent/25 bg-surface h-10 w-full rounded-lg border p-1"})]}),z.jsx("button",{type:"button",onClick:()=>{d(F=>({...F,series:F.series.filter((B,I)=>I!==O)}))},disabled:c.series.length===1,"aria-label":`Remove series ${String(O+1)}`,className:"text-textMuted self-end rounded-lg px-3 py-2 text-sm hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-30",children:"Remove"})]},w.id)})})]}),f&&z.jsx("p",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-200",children:f}),z.jsxs("div",{className:"flex justify-end gap-2 border-t border-white/5 pt-4",children:[z.jsx("button",{type:"button",onClick:u,className:"text-textMuted hover:text-textPrimary rounded-lg px-4 py-2 text-sm",children:"Cancel"}),z.jsx("button",{type:"submit",disabled:f!==null,className:"bg-accent text-background hover:bg-accent/90 rounded-lg px-4 py-2 text-sm font-semibold disab)DELIM" -R"DELIM(led:cursor-not-allowed disabled:opacity-40",children:a==="add"?"Add chart":"Save changes"})]})]})]})})}const oT=!0,tn="u-",fT="uplot",dT=tn+"hz",hT=tn+"vt",mT=tn+"title",pT=tn+"wrap",gT=tn+"under",vT=tn+"over",yT=tn+"axis",uu=tn+"off",bT=tn+"select",ST=tn+"cursor-x",_T=tn+"cursor-y",xT=tn+"cursor-pt",zT=tn+"legend",ET=tn+"live",TT=tn+"inline",wT=tn+"series",MT=tn+"marker",K0=tn+"label",AT=tn+"value",wr="width",Mr="height",zr="top",X0="bottom",as="left",Vd="right",Hh="#000",J0=Hh+"0",Kd="mousemove",F0="mousedown",Xd="mouseup",W0="mouseenter",I0="mouseleave",P0="dblclick",OT="resize",NT="scroll",ev="change",To="dppxchange",Bh="--",Ss=typeof window<"u",ih=Ss?document:null,fs=Ss?window:null,jT=Ss?navigator:null;let Ie,fo;function uh(){let n=devicePixelRatio;Ie!=n&&(Ie=n,fo&&rh(ev,fo,uh),fo=matchMedia(`(min-resolution: ${Ie-.001}dppx) and (max-resolution: ${Ie+.001}dppx)`),ou(ev,fo,uh),fs.dispatchEvent(new CustomEvent(To)))}function ol(n,a){if(a!=null){let u=n.classList;!u.contains(a)&&u.add(a)}}function sh(n,a){let u=n.classList;u.contains(a)&&u.remove(a)}function zt(n,a,u){n.style[a]=u+"px"}function ql(n,a,u,s){let c=ih.createElement(n);return a!=null&&ol(c,a),u?.insertBefore(c,s),c}function wl(n,a){return ql("div",n,a)}const tv=new WeakMap;function ia(n,a,u,s,c){let d="translate("+a+"px,"+u+"px)",f=tv.get(n);d!=f&&(n.style.transform=d,tv.set(n,d),a<0||u<0||a>s||u>c?ol(n,uu):sh(n,uu))}const nv=new WeakMap;function lv(n,a,u){let s=a+u,c=nv.get(n);s!=c&&(nv.set(n,s),n.style.background=a,n.style.borderColor=u)}const av=new WeakMap;function iv(n,a,u,s){let c=a+""+u,d=av.get(n);c!=d&&(av.set(n,c),n.style.height=u+"px",n.style.width=a+"px",n.style.marginLeft=s?-a/2+"px":0,n.style.marginTop=s?-u/2+"px":0)}const qh={passive:!0},DT={...qh,capture:!0};function ou(n,a,u,s){a.addEventListener(n,u,s?DT:qh)}function rh(n,a,u,s){a.removeEventListener(n,u,qh)}Ss&&uh();function Gl(n,a,u,s){let c;u=u||0,s=s||a.length-1;let d=s<=2147483647;for(;s-u>1;)c=d?u+s>>1:hl((u+s)/2),a[c]{let d=-1,f=-1;for(let p=s;p<=c;p++)if(n(u[p])){d=p;break}for(let p=c;p>=s;p--)if(n(u[p])){f=p;break}return[d,f]}}const Zy=n=>n!=null,Ly=n=>n!=null&&n>0,Co=ky(Zy),CT=ky(Ly);function RT(n,a,u,s=0,c=!1){let d=c?CT:Co,f=c?Ly:Zy;[a,u]=d(n,a,u);let p=n[a],g=n[a];if(a>-1)if(s==1)p=n[a],g=n[u];else if(s==-1)p=n[u],g=n[a];else for(let v=a;v<=u;v++){let x=n[v];f(x)&&(xg&&(g=x))}return[p??gt,g??-gt]}function Ro(n,a,u,s){let c=rv(n),d=rv(a);n==a&&(c==-1?(n*=u,a/=u):(n/=u,a*=u));let f=u==10?La:Hy,p=c==1?hl:Ml,g=d==1?Ml:hl,v=p(f(en(n))),x=g(f(en(a))),S=hs(u,v),T=hs(u,x);return u==10&&(v<0&&(S=vt(S,-v)),x<0&&(T=vt(T,-x))),s||u==2?(n=S*c,a=T*d):(n=Qy(n,S),a=Uo(a,T)),[n,a]}function Gh(n,a,u,s){let c=Ro(n,a,u,s);return n==0&&(c[0]=0),a==0&&(c[1]=0),c}const Qh=.1,uv={mode:3,pad:Qh},Nr={pad:0,soft:null,mode:0},UT={min:Nr,max:Nr};function wo(n,a,u,s){return ko(u)?sv(n,a,u):(Nr.pad=u,Nr.soft=s?0:null,Nr.mode=s?3:0,sv(n,a,UT))}function Je(n,a){return n??a}function kT(n,a,u){for(a=Je(a,0),u=Je(u,n.length-1);a<=u;){if(n[a]!=null)return!0;a++}return!1}function sv(n,a,u){let s=u.min,c=u.max,d=Je(s.pad,0),f=Je(c.pad,0),p=Je(s.hard,-gt),g=Je(c.hard,gt),v=Je(s.soft,gt),x=Je(c.soft,-gt),S=Je(s.mode,0),T=Je(c.mode,0),w=a-n,O=La(w),Y=Bn(en(n),en(a)),W=La(Y),F=en(W-O);(w<1e-24||F>10)&&(w=0,(n==0||a==0)&&(w=1e-24,S==2&&v!=gt&&(d=0),T==2&&x!=-gt&&(f=0)));let B=w||Y||1e3,I=La(B),q=hs(10,hl(I)),ae=B*(w==0?n==0?.1:1:d),ne=vt(Qy(n-ae,q/10),24),le=n>=v&&(S==1||S==3&&ne<=v||S==2&&ne>=v)?v:gt,se=Bn(p,ne=le?le:Ql(le,ne)),Ae=B*(w==0?a==0?.1:1:f),ze=vt(Uo(a+Ae,q/10),24),ee=a<=x&&(T==1||T==3&&ze>=x||T==2&&ze<=x)?x:-gt,ye=Ql(g,ze>ee&&a<=ee?ee:Bn(ee,ze));return se==ye&&se==0&&(ye=100),[se,ye]}const ZT=new Intl.NumberFormat(Ss?jT.language:"en-US"),Yh=n=>ZT.format(n),ml=Math,yo=ml.PI,en=ml.abs,hl=ml.floor,Pt=ml.round,Ml=ml.ceil,Ql=ml.min,Bn=ml.max,hs=ml.pow,rv=ml.sign,La=ml.log10,Hy=ml.log2,LT=(n,a=1)=>ml.sinh(n)*a,Jd=(n,a=1)=>ml.asinh(n/a),gt=1/0;function cv(n){return(La((n^n>>31)-(n>>31))|0)+1}function ch(n,a,u){return Ql(Bn(n,a),u)}function By(n){return typeof n=="function"}function Ge(n){return By(n)?n:()=>n}const HT=()=>{},qy=n=>n,Gy=(n,a)=>a,BT=n=>null,ov=n=>!0,fv=(n,a)=>n==a,qT=/\.\d*?(?=9{6,}|0{6,})/gm,hu=n=>{if($y(n)||Mi.has(n))return n;const a=`${n}`,u=a.match(qT);if(u==null)return n;let s=u[0].length-1;if(a.indexOf("e-")!=-1){let[c,d]=a.split("e");return+`${hu(c)}e${d}`}return vt(n,s)};function au(n,a){return hu(vt(hu(n/a))*a)}function Uo(n,a){return hu(Ml(hu(n/a))*a)}function Qy(n,a){return hu(hl(hu(n/a))*a)}function vt(n,a=0){if($y(n))return n;let u=10**a,s=n*u*(1+Number.EPSILON);return Pt(s)/u}const Mi=new Map;function Yy(n){return((""+n).split(".")[1]||"").length}function Ur(n,a,u,s){let c=[],d=s.map(Yy);for(let f=a;f=0?0:p)+(f>=d[v]?0:d[v]),T=n==10?x:vt(x,S);c.push(T),Mi.set(T,S)}}return c}const jr={},$h=[],ms=[null,null],zi=Array.isArray,$y=Number.isInteger,GT=n=>n===void 0;function dv(n){return typeof n=="string"}function ko(n){let a=!1;if(n!=null){let u=n.constructor;a=u==null||u==Object}return a}function QT(n){return n!=null&&typeof n=="object"}const YT=Object.getPrototypeOf(Uint8Array),Vy="__proto__";function ps(n,a=ko){let u;if(zi(n)){let s=n.find(c=>c!=null);if(zi(s)||a(s)){u=Array(n.length);for(let c=0;cd){for(c=f-1;c>=0&&n[c]==null;)n[c--]=null;for(c=f+1;cf-p)],c=s[0].length,d=new Map;for(let f=0;f"u"?n=>Promise.resolve().then(n):queueMicrotask;function WT(n){let a=n[0],u=a.length,s=Array(u);for(let d=0;da[d]-a[f]);let c=[];for(let d=0;d=s&&n[c]==null;)c--;if(c<=s)return!0;const d=Bn(1,hl((c-s+1)/a));for(let f=n[s],p=s+d;p<=c;p+=d){const g=n[p];if(g!=null){if(g<=f)return!1;f=g}}return!0}const Ky=["January","February","March","April","May","June","July","August","September","October","November","December"],Xy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Jy(n){return n.slice(0,3)}const ew=Xy.map(Jy),tw=Ky.map(Jy),nw={MMMM:Ky,MMM:tw,WWWW:Xy,WWW:ew};function Er(n){return(n<10?"0":"")+n}function lw(n){return(n<10?"00":n<100?"0":"")+n}const aw={YYYY:n=>n.getFullYear(),YY:n=>(n.getFullYear()+"").slice(2),MMMM:(n,a)=>a.MMMM[n.getMonth()],MMM:(n,a)=>a.MMM[n.getMonth()],MM:n=>Er(n.getMonth()+1),M:n=>n.getMonth()+1,DD:n=>Er(n.getDate()),D:n=>n.getDate(),WWWW:(n,a)=>a.WWWW[n.getDay()],WWW:(n,a)=>a.WWW[n.getDay()],HH:n=>Er(n.getHours()),H:n=>n.getHours(),h:n=>{let a=n.getHours();return a==0?12:a>12?a-12:a},AA:n=>n.getHours()>=12?"PM":"AM",aa:n=)DELIM" -R"DELIM(>n.getHours()>=12?"pm":"am",a:n=>n.getHours()>=12?"p":"a",mm:n=>Er(n.getMinutes()),m:n=>n.getMinutes(),ss:n=>Er(n.getSeconds()),s:n=>n.getSeconds(),fff:n=>lw(n.getMilliseconds())};function Vh(n,a){a=a||nw;let u=[],s=/\{([a-z]+)\}|[^{]+/gi,c;for(;c=s.exec(n);)u.push(c[0][0]=="{"?aw[c[1]]:c[0]);return d=>{let f="";for(let p=0;pn%1==0,Mo=[1,2,2.5,5],sw=Ur(10,-32,0,Mo),Wy=Ur(10,0,32,Mo),rw=Wy.filter(Fy),iu=sw.concat(Wy),Kh=` -`,Iy="{YYYY}",hv=Kh+Iy,Py="{M}/{D}",Ar=Kh+Py,ho=Ar+"/{YY}",eb="{aa}",cw="{h}:{mm}",ss=cw+eb,mv=Kh+ss,pv=":{ss}",tt=null;function tb(n){let a=n*1e3,u=a*60,s=u*60,c=s*24,d=c*30,f=c*365,g=(n==1?Ur(10,0,3,Mo).filter(Fy):Ur(10,-3,0,Mo)).concat([a,a*5,a*10,a*15,a*30,u,u*5,u*10,u*15,u*30,s,s*2,s*3,s*4,s*6,s*8,s*12,c,c*2,c*3,c*4,c*5,c*6,c*7,c*8,c*9,c*10,c*15,d,d*2,d*3,d*4,d*6,f,f*2,f*5,f*10,f*25,f*50,f*100]);const v=[[f,Iy,tt,tt,tt,tt,tt,tt,1],[c*28,"{MMM}",hv,tt,tt,tt,tt,tt,1],[c,Py,hv,tt,tt,tt,tt,tt,1],[s,"{h}"+eb,ho,tt,Ar,tt,tt,tt,1],[u,ss,ho,tt,Ar,tt,tt,tt,1],[a,pv,ho+" "+ss,tt,Ar+" "+ss,tt,mv,tt,1],[n,pv+".{fff}",ho+" "+ss,tt,Ar+" "+ss,tt,mv,tt,1]];function x(S){return(T,w,O,Y,W,F)=>{let B=[],I=W>=f,q=W>=d&&W=c?c:W,ze=hl(O)-hl(ne),ee=se+ze+Uo(ne-se,Ae);B.push(ee);let ye=S(ee),ce=ye.getHours()+ye.getMinutes()/u+ye.getSeconds()/s,Ee=W/s,de=T.axes[w]._space,U=F/de;for(;ee=vt(ee+W,n==1?0:3),!(ee>Y);)if(Ee>1){let Q=hl(vt(ce+Ee,6))%24,be=S(ee).getHours()-Q;be>1&&(be=-1),ee-=be*s,ce=(ce+Ee)%24;let A=B[B.length-1];vt((ee-A)/W,3)*U>=.7&&B.push(ee)}else B.push(ee)}return B}}return[g,v,x]}const[ow,fw,dw]=tb(1),[hw,mw,pw]=tb(.001);Ur(2,-53,53,[1]);function gv(n,a){return n.map(u=>u.map((s,c)=>c==0||c==8||s==null?s:a(c==1||u[8]==0?s:u[1]+s)))}function vv(n,a){return(u,s,c,d,f)=>{let p=a.find(O=>f>=O[0])||a[a.length-1],g,v,x,S,T,w;return s.map(O=>{let Y=n(O),W=Y.getFullYear(),F=Y.getMonth(),B=Y.getDate(),I=Y.getHours(),q=Y.getMinutes(),ae=Y.getSeconds(),ne=W!=g&&p[2]||F!=v&&p[3]||B!=x&&p[4]||I!=S&&p[5]||q!=T&&p[6]||ae!=w&&p[7]||p[1];return g=W,v=F,x=B,S=I,T=q,w=ae,ne(Y)})}}function gw(n,a){let u=Vh(a);return(s,c,d,f,p)=>c.map(g=>u(n(g)))}function Fd(n,a,u){return new Date(n,a,u)}function yv(n,a){return a(n)}const vw="{YYYY}-{MM}-{DD} {h}:{mm}{aa}";function bv(n,a){return(u,s,c,d)=>d==null?Bh:a(n(s))}function yw(n,a){let u=n.series[a];return u.width?u.stroke(n,a):u.points.width?u.points.stroke(n,a):null}function bw(n,a){return n.series[a].fill(n,a)}const Sw={show:!0,live:!0,isolate:!1,mount:HT,markers:{show:!0,width:2,stroke:yw,fill:bw,dash:"solid"},idx:null,idxs:null,values:[]};function _w(n,a){let u=n.cursor.points,s=wl(),c=u.size(n,a);zt(s,wr,c),zt(s,Mr,c);let d=c/-2;zt(s,"marginLeft",d),zt(s,"marginTop",d);let f=u.width(n,a,c);return f&&zt(s,"borderWidth",f),s}function xw(n,a){let u=n.series[a].points;return u._fill||u._stroke}function zw(n,a){let u=n.series[a].points;return u._stroke||u._fill}function Ew(n,a){return n.series[a].points.size}const Wd=[0,0];function Tw(n,a,u){return Wd[0]=a,Wd[1]=u,Wd}function mo(n,a,u,s=!0){return c=>{c.button==0&&(!s||c.target==a)&&u(c)}}function Id(n,a,u,s=!0){return c=>{(!s||c.target==a)&&u(c)}}const ww={show:!0,x:!0,y:!0,lock:!1,move:Tw,points:{one:!1,show:_w,size:Ew,width:0,stroke:zw,fill:xw},bind:{mousedown:mo,mouseup:mo,click:mo,dblclick:mo,mousemove:Id,mouseleave:Id,mouseenter:Id},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(n,a)=>{a.stopPropagation(),a.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(n,a,u,s,c)=>s-c,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},nb={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Xh=Jt({},nb,{filter:Gy}),lb=Jt({},Xh,{size:10}),ab=Jt({},nb,{show:!1}),Jh='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',ib="bold "+Jh,ub=1.5,Sv={show:!0,scale:"x",stroke:Hh,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:ib,side:2,grid:Xh,ticks:lb,border:ab,font:Jh,lineGap:ub,rotate:0},Mw="Value",Aw="Time",_v={show:!0,scale:"x",auto:!1,sorted:1,min:gt,max:-gt,idxs:[]};function Ow(n,a,u,s,c){return a.map(d=>d==null?"":Yh(d))}function Nw(n,a,u,s,c,d,f){let p=[],g=Mi.get(c)||0;u=f?u:vt(Uo(u,c),g);for(let v=u;v<=s;v=vt(v+c,g))p.push(Object.is(v,-0)?0:v);return p}function oh(n,a,u,s,c,d,f){const p=[],g=n.scales[n.axes[a].scale].log,v=g==10?La:Hy,x=hl(v(u));c=hs(g,x),g==10&&(c=iu[Gl(c,iu)]);let S=u,T=c*g;g==10&&(T=iu[Gl(T,iu)]);do p.push(S),S=S+c,g==10&&!Mi.has(S)&&(S=vt(S,Mi.get(c))),S>=T&&(c=S,T=c*g,g==10&&(T=iu[Gl(T,iu)]));while(S<=s);return p}function jw(n,a,u,s,c,d,f){let g=n.scales[n.axes[a].scale].asinh,v=s>g?oh(n,a,Bn(g,u),s,c):[g],x=s>=0&&u<=0?[0]:[];return(u<-g?oh(n,a,Bn(g,-s),-u,c):[g]).reverse().map(T=>-T).concat(x,v)}const sb=/./,Dw=/[12357]/,Cw=/[125]/,xv=/1/,fh=(n,a,u,s)=>n.map((c,d)=>a==4&&c==0||d%s==0&&u.test(c.toExponential()[c<0?1:0])?c:null);function Rw(n,a,u,s,c){let d=n.axes[u],f=d.scale,p=n.scales[f],g=n.valToPos,v=d._space,x=g(10,f),S=g(9,f)-x>=v?sb:g(7,f)-x>=v?Dw:g(5,f)-x>=v?Cw:xv;if(S==xv){let T=en(g(1,f)-x);if(Tc,Tv={show:!0,auto:!0,sorted:0,gaps:rb,alpha:1,facets:[Jt({},Ev,{scale:"x"}),Jt({},Ev,{scale:"y"})]},wv={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:rb,alpha:1,points:{show:Lw,filter:null},values:null,min:gt,max:-gt,idxs:[],path:null,clip:null};function Hw(n,a,u,s,c){return u/10}const cb={time:oT,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},Bw=Jt({},cb,{time:!1,ori:1}),Mv={};function ob(n,a){let u=Mv[n];return u||(u={key:n,plots:[],sub(s){u.plots.push(s)},unsub(s){u.plots=u.plots.filter(c=>c!=s)},pub(s,c,d,f,p,g,v){for(let x=0;x{let F=f.pxRound;const B=v.dir*(v.ori==0?1:-1),I=v.ori==0?_s:xs;let q,ae;B==1?(q=u,ae=s):(q=s,ae=u);let ne=F(S(p[q],v,Y,w)),le=F(T(g[q],x,W,O)),se=F(S(p[ae],v,Y,w)),Ae=F(T(d==1?x.max:x.min,x,W,O)),ze=new Path2D(c);return I(ze,se,Ae),I(ze,ne,Ae),I(ze,ne,le),ze})}function Zo(n,a,u,s,c,d){let f=null;if(n.length>0){f=new Path2D;const p=a==0?Bo:Ih;let g=u;for(let S=0;ST[0]){let w=T[0]-g;w>0&&p(f,g,s,w,s+d),g=T[1]}}let v=u+c-g,x=10;v>0&&p(f,g,s-x/2,v,s+d+x)}return f}function Gw(n,a,u){let s=n[n.length-1];s&&s[0]==a?s[1]=u:n.push([a,u])}function Wh(n,a,u,s,c,d,f){let p=[],g=n.length;for(let v=c==1?u:s;v>=u&&v<=s;v+=c)if(a[v]===null){let S=v,T=v;if(c==1)for(;++v<=s&&a[v]===null;)T=v;else for(;--v>=u&&a[v]===null;)T=v;let w=d(n[S]),O=T==S?w:d(n[T]),Y=S-c;w=f<=0&&Y>=0&&Y=0&&F>=0&&F=w&&p.push([w,O])}return p}function Av(n){return n==0?qy:n==1?Pt:a=>au(a,n)}function fb(n){let a=n==0?Lo:Ho,u=n==0?(c,d,f,p,g,v)=>{c.arcTo(d,f,p,g,v)}:(c,d,f,p,g,v)=>{c.arcTo(f,d,g,p,v)},s=n==0?(c,d,f,p,g)=>{c.rect(d,f,p,g)}:(c,d,f,p,g)=>{c.rect(f,d,g,p)};return(c,d,f,p,g,v=0,x=0)=>{v==0&&x==0?s(c,d,f,p,g):(v=Ql(v,p/2,g/2),x=Ql(x,p/2,g/2),a(c,d+v,f),u(c,d+p,f,d+p,f+g,v),u(c,d+p,f+g,d,f+g,x),u(c,d,f+g,d,f,x),u(c,d,f,d+p,f,v),c.closePath())}}const Lo=(n,a,u)=>{n.moveTo(a,u)},Ho=(n,a,u)=>{n.moveTo(u,a)},_s=(n,a,u)=>{n.lineTo(a,u)},xs=(n,a,u)=>{n.lineTo(u,a)},Bo=fb(0),Ih=fb(1),db=(n,a,u,s,c,d)=>{n.arc(a,u,s,c,d)},hb=(n,a,u,s,c,d)=>{n.arc(u,a,s,c,d)},mb=(n,a,u,s,c,d,f)=>{n.bezierCurveTo(a,u,s,c,d,f)},pb=(n,a,u,s,c,d,f)=>{n.bezierCurveTo(u,a,c,s,f,d)};function gb(n){return(a,u,s,c,d)=>gu(a,u,(f,p,g,v,x,S,T,w,O,Y,W)=>{let{pxRound:F,points:B}=f,I,q;v.ori==0?(I=Lo,q=db):(I=Ho,q=hb);const ae=vt(B.width*Ie,3);let ne=(B.size-B.width)/2*Ie,le=vt(ne*2,3),se=new Path2D,Ae=new Path2D,{left:ze,top:ee,width:ye,height:ce}=a.bbox;Bo(Ae,ze-le,ee-le,ye+le*2,ce+le*2);const Ee=de=>{if(g[de]!=null){let U=F(S(p[de],v,Y,w)),Q=F(T(g[de],x,W,O));I(se,U+ne,Q),q(se,U,Q,ne,0,yo*2)}};if(d)d.forEach(Ee);else for(let de=s;de<=c;de++)Ee(de);return{stroke:ae>0?se:null,fill:se,clip:Ae,flags:gs|dh}})}function vb(n){return(a,u,s,c,d,f)=>{s!=c&&(d!=s&&f!=s&&n(a,u,s),d!=c&&f!=c&&n(a,u,c),n(a,u,f))}}const Qw=vb(_s),Yw=vb(xs);function yb(n){const a=Je(n?.alignGaps,0);return(u,s,c,d)=>gu(u,s,(f,p,g,v,x,S,T,w,O,Y,W)=>{[c,d]=Co(g,c,d);let F=f.pxRound,B=ce=>F(S(ce,v,Y,w)),I=ce=>F(T(ce,x,W,O)),q,ae;v.ori==0?(q=_s,ae=Qw):(q=xs,ae=Yw);const ne=v.dir*(v.ori==0?1:-1),le={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:gs},se=le.stroke;let Ae=!1;if(d-c>=Y*4){let ce=G=>u.posToVal(G,v.key,!0),Ee=null,de=null,U,Q,me,Oe=B(p[ne==1?c:d]),be=B(p[c]),A=B(p[d]),L=ce(ne==1?be+1:A-1);for(let G=ne==1?c:d;G>=c&&G<=d;G+=ne){let ie=p[G],pe=(ne==1?ieL)?Oe:B(ie),ge=g[G];pe==Oe?ge!=null?(Q=ge,Ee==null?(q(se,pe,I(Q)),U=Ee=de=Q):Qde&&(de=Q)):ge===null&&(Ae=!0):(Ee!=null&&ae(se,Oe,I(Ee),I(de),I(U),I(Q)),ge!=null?(Q=ge,q(se,pe,I(Q)),Ee=de=U=Q):(Ee=de=null,ge===null&&(Ae=!0)),Oe=pe,L=ce(Oe+ne))}Ee!=null&&Ee!=de&&me!=Oe&&ae(se,Oe,I(Ee),I(de),I(U),I(Q))}else for(let ce=ne==1?c:d;ce>=c&&ce<=d;ce+=ne){let Ee=g[ce];Ee===null?Ae=!0:Ee!=null&&q(se,B(p[ce]),I(Ee))}let[ee,ye]=Fh(u,s);if(f.fill!=null||ee!=0){let ce=le.fill=new Path2D(se),Ee=f.fillTo(u,s,f.min,f.max,ee),de=I(Ee),U=B(p[c]),Q=B(p[d]);ne==-1&&([Q,U]=[U,Q]),q(ce,Q,de),q(ce,U,de)}if(!f.spanGaps){let ce=[];Ae&&ce.push(...Wh(p,g,c,d,ne,B,a)),le.gaps=ce=f.gaps(u,s,c,d,ce),le.clip=Zo(ce,v.ori,w,O,Y,W)}return ye!=0&&(le.band=ye==2?[Ha(u,s,c,d,se,-1),Ha(u,s,c,d,se,1)]:Ha(u,s,c,d,se,ye)),le})}function $w(n){const a=Je(n.align,1),u=Je(n.ascDesc,!1),s=Je(n.alignGaps,0),c=Je(n.extend,!1);return(d,f,p,g)=>gu(d,f,(v,x,S,T,w,O,Y,W,F,B,I)=>{[p,g]=Co(S,p,g);let q=v.pxRound,{left:ae,width:ne}=d.bbox,le=be=>q(O(be,T,B,W)),se=be=>q(Y(be,w,I,F)),Ae=T.ori==0?_s:xs;const ze={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:gs},ee=ze.stroke,ye=T.dir*(T.ori==0?1:-1);let ce=se(S[ye==1?p:g]),Ee=le(x[ye==1?p:g]),de=Ee,U=Ee;c&&a==-1&&(U=ae,Ae(ee,U,ce)),Ae(ee,Ee,ce);for(let be=ye==1?p:g;be>=p&&be<=g;be+=ye){let A=S[be];if(A==null)continue;let L=le(x[be]),G=se(A);a==1?Ae(ee,L,ce):Ae(ee,de,G),Ae(ee,L,G),ce=G,de=L}let Q=de;c&&a==1&&(Q=ae+ne,Ae(ee,Q,ce));let[me,Oe]=Fh(d,f);if(v.fill!=null||me!=0){let be=ze.fill=new Path2D(ee),A=v.fillTo(d,f,v.min,v.max,me),L=se(A);Ae(be,Q,L),Ae(be,U,L)}if(!v.spanGaps){let be=[];be.push(...Wh(x,S,p,g,ye,le,s));let A=v.width*Ie/2,L=u||a==1?A:-A,G=u||a==-1?-A:A;be.forEach(ie=>{ie[0]+=L,ie[1]+=G}),ze.gaps=be=v.gaps(d,f,p,g,be),ze.clip=Zo(be,T.ori,W,F,B,I)}return Oe!=0&&(ze.band=Oe==2?[Ha(d,f,p,g,ee,-1),Ha(d,f,p,g,ee,1)]:Ha(d,f,p,g,ee,Oe)),ze})}function Ov(n,a,u,s,c,d,f=gt){if(n.length>1){let p=null;for(let g=0,v=1/0;g{}),{fill:S,stroke:T}=v;return(w,O,Y,W)=>gu(w,O,(F,B,I,q,ae,ne,le,se,Ae,ze,ee)=>{let ye=F.pxRound,ce=u,Ee=s*Ie,de=p*Ie,U=g*Ie,Q,me;q.ori==0?[Q,me]=d(w,O):[me,Q]=d(w,O);const Oe=q.dir*(q.ori==0?1:-1);let be=q.ori==0?Bo:Ih,A=q.ori==0?x:(oe,lt,Nt,Dl,ra,el,ca)=>{x(oe,lt,Nt,ra,Dl,ca,el)},L=Je(w.bands,$h).find(oe=>oe.series[0]==O),G=L!=null?L.dir:0,ie=F.fillTo(w,O,F.min,F.max,G),xe=ye(le(ie,ae,ee,Ae)),pe,ge,mt,Qe=ze,nt=ye(F.width*Ie),Nn=!1,Pn=null,jn=null,xn=null,Yl=null;S!=null&&(nt==0||T!=null)&&(Nn=!0,Pn=S.values(w,O,Y,W),jn=new Map,new Set(Pn).forEach(oe=>{oe!=null&&jn.set(oe,new Path2D)}),nt>0&&(xn=T.values(w,O,Y,W),Yl=new Map,new Set(xn).forEach(oe=>{oe!=null&&Yl.set(oe,new Path2D)})));let{x0:$l,size:Ni}=v;if($l!=null&&Ni!=null){ce=1,B=$l.values(w,O,Y,W),$l.unit==2&&(B=B.map(Nt=>w.posToVal(se+Nt*ze,q.key,!0)));let oe=Ni.values(w,O,Y,W);Ni.unit==2?ge=oe[0]*ze:ge=ne(oe[0],q,ze,se)-ne(0,q,ze,se),Qe=Ov(B,I,ne,q,ze,se,Qe),mt=Qe-ge+Ee}else Qe=Ov(B,I,ne,q,ze,se,Qe),mt=Qe*f+Ee,ge=Qe-mt;mt<1&&(mt=0),nt>=ge/2&&(nt=0),mt<5&&(ye=qy);let ji=mt>0,Nl=Qe-mt-(ji?nt:0);ge=ye(ch(Nl,U,de)),pe=(ce==0?ge/2:ce==Oe?0:ge)-ce*Oe*((ce==0?Ee/2:0)+(ji?nt/2:0));const Ft={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Vl=Nn?null:new Path2D;let jl=null;if(L!=null)jl=w.data[L.series[1]];else{let{y0:oe,y1:lt}=v;oe!=null&<!=null&&(I=lt.values(w,O,Y,W),jl=oe.values(w,O,Y,W))}let sa=Q*ge,Te=me*ge;for(let oe=Oe==1?Y:W;oe>=Y&&oe<=W;oe+=Oe){let lt=I[oe];if(lt==null)continue;if(jl!=null){let rt=jl[oe]??0;if(lt-rt==0)continue;xe=le(rt,ae,ee,Ae)}let Nt=q.distr!=2||v!=null?B[oe]:oe,Dl=ne(Nt,q,ze,se),ra=le(Je(lt,ie),ae,ee,Ae),el=ye(Dl-pe),ca=ye(Bn(ra,xe)),Dn=ye(Ql(ra,xe)),nn=ca-Dn;if(lt!=null){let rt=lt<0?Te:sa,Qt=lt<0?sa:Te;Nn?(nt>0&&xn[oe]!=null&&be(Yl.get(xn[oe]),el,Dn+hl(nt/2),ge,Bn(0,nn-nt),rt,Qt),Pn[oe]!=null&&be(jn.get(Pn[oe]),el,Dn+hl(nt/2),ge,Bn(0,nn-nt),rt,Qt)):be(Vl,el,Dn+hl(nt/2),ge,Bn(0,nn-nt),rt,Qt),A(w,O,oe,el-nt/2,Dn,ge+nt,nn)}}return nt>0?Ft.stroke=Nn?Yl:Vl:Nn||(Ft._fill=F.width==0?F._fill:F._stroke??F._fill,Ft.width=0),Ft.fill=Nn?jn:Vl,Ft})}function Kw(n,a){const u=Je(a?.alignGaps,0);return(s,c,d,f)=>gu(s,c,(p,g,v,x,S,T,w,O,Y,W,F)=>{[d,f]=Co(v,d,f);let B=p.pxRound,I=Q=>B(T(Q,x,W,O)),q=Q=>B(w(Q,S,F,Y)),ae,ne,le;x.ori==0?(ae=Lo,le=_s,ne=mb):(ae=Ho,le=xs,ne=pb);const se=x.dir*(x.ori==0?1:-1);let Ae=I(g[se==1?d:f]),ze=Ae,ee=[],ye=[];for(let Q=se==1?d:f;Q>=d&&Q<=f;Q+=se)if(v[Q]!=null){let Oe=g[Q],be=I(Oe);ee.push(ze=be),ye.push(q(v[Q]))}const ce={stroke:n(ee,ye,ae,le,ne,B),fill:null,clip:null,band:null,gaps:null,flags:gs},Ee=ce.stroke;let[de,U]=Fh(s,c);if(p.fill!=null||de!=0){let Q=ce.fill=new Path2D(Ee),me=p.fillTo(s,c,p.min,p.max,de),Oe=q(me);le(Q,ze,Oe),le(Q,Ae,Oe)}if(!p.spanGaps){let Q=[];Q.push(...Wh(g,v,d,f,se,I,u)),ce.gaps=Q=p.gaps(s,c,d,f,Q),ce.clip=Zo(Q,x.ori,O,Y,W,F)}return U!=0&&(ce.band=U==2?[Ha(s,c,d,f,Ee,-1),Ha)DELIM" -R"DELIM((s,c,d,f,Ee,1)]:Ha(s,c,d,f,Ee,U)),ce})}function Xw(n){return Kw(Jw,n)}function Jw(n,a,u,s,c,d){const f=n.length;if(f<2)return null;const p=new Path2D;if(u(p,n[0],a[0]),f==2)s(p,n[1],a[1]);else{let g=Array(f),v=Array(f-1),x=Array(f-1),S=Array(f-1);for(let T=0;T0!=v[T]>0?g[T]=0:(g[T]=3*(S[T-1]+S[T])/((2*S[T]+S[T-1])/v[T-1]+(S[T]+2*S[T-1])/v[T]),isFinite(g[T])||(g[T]=0));g[f-1]=v[f-2];for(let T=0;T{cn.pxRatio=Ie}));const Fw=yb(),Ww=gb();function jv(n,a,u,s){return(s?[n[0],n[1]].concat(n.slice(2)):[n[0]].concat(n.slice(1))).map((d,f)=>mh(d,f,a,u))}function Iw(n,a){return n.map((u,s)=>s==0?{}:Jt({},a,u))}function mh(n,a,u,s){return Jt({},a==0?u:s,n)}function bb(n,a,u){return a==null?ms:[a,u]}const Pw=bb;function e3(n,a,u){return a==null?ms:wo(a,u,Qh,!0)}function Sb(n,a,u,s){return a==null?ms:Ro(a,u,n.scales[s].log,!1)}const t3=Sb;function _b(n,a,u,s){return a==null?ms:Gh(a,u,n.scales[s].log,!1)}const n3=_b;function l3(n,a,u,s,c){let d=Bn(cv(n),cv(a)),f=a-n,p=Gl(c/s*f,u);do{let g=u[p],v=s*g/f;if(v>=c&&d+(g<5?Mi.get(g):0)<=17)return[g,v]}while(++p(a=Pt((u=+c)*Ie))+"px"),[n,a,u]}function a3(n){n.show&&[n.font,n.labelFont].forEach(a=>{let u=vt(a[2]*Ie,1);a[0]=a[0].replace(/[0-9.]+px/,u+"px"),a[1]=u})}function cn(n,a,u){const s={mode:Je(n.mode,1)},c=s.mode;function d(m,y,_,E){let N=y.valToPct(m);return E+_*(y.dir==-1?1-N:N)}function f(m,y,_,E){let N=y.valToPct(m);return E+_*(y.dir==-1?N:1-N)}function p(m,y,_,E){return y.ori==0?d(m,y,_,E):f(m,y,_,E)}s.valToPosH=d,s.valToPosV=f;let g=!1;s.status=0;const v=s.root=wl(fT);if(n.id!=null&&(v.id=n.id),ol(v,n.class),n.title){let m=wl(mT,v);m.textContent=n.title}const x=ql("canvas"),S=s.ctx=x.getContext("2d"),T=wl(pT,v);ou("click",T,m=>{m.target===O&&(Pe!=kn||at!=Il)&&Ve.click(s,m)},!0);const w=s.under=wl(gT,T);T.appendChild(x);const O=s.over=wl(vT,T);n=ps(n);const Y=+Je(n.pxAlign,1),W=Av(Y);(n.plugins||[]).forEach(m=>{m.opts&&(n=m.opts(s,n)||n)});const F=n.ms||.001,B=s.series=c==1?jv(n.series||[],_v,wv,!1):Iw(n.series||[null],Tv),I=s.axes=jv(n.axes||[],Sv,zv,!0),q=s.scales={},ae=s.bands=n.bands||[];ae.forEach(m=>{m.fill=Ge(m.fill||null),m.dir=Je(m.dir,-1)});const ne=c==2?B[1].facets[0].scale:B[0].scale,le={axes:js,series:Go},se=(n.drawOrder||["axes","series"]).map(m=>le[m]);function Ae(m){const y=m.distr==3?_=>La(_>0?_:m.clamp(s,_,m.min,m.max,m.key)):m.distr==4?_=>Jd(_,m.asinh):m.distr==100?_=>m.fwd(_):_=>_;return _=>{let E=y(_),{_min:N,_max:C}=m,V=C-N;return(E-N)/V}}function ze(m){let y=q[m];if(y==null){let _=(n.scales||jr)[m]||jr;if(_.from!=null){ze(_.from);let E=Jt({},q[_.from],_,{key:m});E.valToPct=Ae(E),q[m]=E}else{y=q[m]=Jt({},m==ne?cb:Bw,_),y.key=m;let E=y.time,N=y.range,C=zi(N);if((m!=ne||c==2&&!E)&&(C&&(N[0]==null||N[1]==null)&&(N={min:N[0]==null?uv:{mode:1,hard:N[0],soft:N[0]},max:N[1]==null?uv:{mode:1,hard:N[1],soft:N[1]}},C=!1),!C&&ko(N))){let V=N;N=(P,te,ue)=>te==null?ms:wo(te,ue,V)}y.range=Ge(N||(E?Pw:m==ne?y.distr==3?t3:y.distr==4?n3:bb:y.distr==3?Sb:y.distr==4?_b:e3)),y.auto=Ge(C?!1:y.auto),y.clamp=Ge(y.clamp||Hw),y._min=y._max=null,y.valToPct=Ae(y)}}}ze("x"),ze("y"),c==1&&B.forEach(m=>{ze(m.scale)}),I.forEach(m=>{ze(m.scale)});for(let m in n.scales)ze(m);const ee=q[ne],ye=ee.distr;let ce,Ee;ee.ori==0?(ol(v,dT),ce=d,Ee=f):(ol(v,hT),ce=f,Ee=d);const de={};for(let m in q){let y=q[m];(y.min!=null||y.max!=null)&&(de[m]={min:y.min,max:y.max},y.min=y.max=null)}const U=n.tzDate||(m=>new Date(Pt(m/F))),Q=n.fmtDate||Vh,me=F==1?dw(U):pw(U),Oe=vv(U,gv(F==1?fw:mw,Q)),be=bv(U,yv(vw,Q)),A=[],L=s.legend=Jt({},Sw,n.legend),G=s.cursor=Jt({},ww,{drag:{y:c==2}},n.cursor),ie=L.show,xe=G.show,pe=L.markers;L.idxs=A,pe.width=Ge(pe.width),pe.dash=Ge(pe.dash),pe.stroke=Ge(pe.stroke),pe.fill=Ge(pe.fill);let ge,mt,Qe,nt=[],Nn=[],Pn,jn=!1,xn={};if(L.live){const m=B[1]?B[1].values:null;jn=m!=null,Pn=jn?m(s,1,0):{_:0};for(let y in Pn)xn[y]=Bh}if(ie)if(ge=ql("table",zT,v),Qe=ql("tbody",null,ge),L.mount(s,ge),jn){mt=ql("thead",null,ge,Qe);let m=ql("tr",null,mt);ql("th",null,m);for(var Yl in Pn)ql("th",K0,m).textContent=Yl}else ol(ge,TT),L.live&&ol(ge,ET);const $l={show:!0},Ni={show:!1};function ji(m,y){if(y==0&&(jn||!L.live||c==2))return ms;let _=[],E=ql("tr",wT,Qe,Qe.childNodes[y]);ol(E,m.class),m.show||ol(E,uu);let N=ql("th",null,E);if(pe.show){let P=wl(MT,N);if(y>0){let te=pe.width(s,y);te&&(P.style.border=te+"px "+pe.dash(s,y)+" "+pe.stroke(s,y)),P.style.background=pe.fill(s,y)}}let C=wl(K0,N);m.label instanceof HTMLElement?C.appendChild(m.label):C.textContent=m.label,y>0&&(pe.show||(C.style.color=m.width>0?pe.stroke(s,y):pe.fill(s,y)),Ft("click",N,P=>{if(G._lock)return;tl(P);let te=B.indexOf(m);if((P.ctrlKey||P.metaKey)!=L.isolate){let ue=B.some((re,fe)=>fe>0&&fe!=te&&re.show);B.forEach((re,fe)=>{fe>0&&Zn(fe,ue?fe==te?$l:Ni:$l,!0,Dt.setSeries)})}else Zn(te,{show:!m.show},!0,Dt.setSeries)},!1),da&&Ft(W0,N,P=>{G._lock||(tl(P),Zn(B.indexOf(m),Wa,!0,Dt.setSeries))},!1));for(var V in Pn){let P=ql("td",AT,E);P.textContent="--",_.push(P)}return[E,_]}const Nl=new Map;function Ft(m,y,_,E=!0){const N=Nl.get(y)||{},C=G.bind[m](s,y,_,E);C&&(ou(m,y,N[m]=C),Nl.set(y,N))}function Vl(m,y,_){const E=Nl.get(y)||{};for(let N in E)(m==null||N==m)&&(rh(N,y,E[N]),delete E[N]);m==null&&Nl.delete(y)}let jl=0,sa=0,Te=0,oe=0,lt=0,Nt=0,Dl=lt,ra=Nt,el=Te,ca=oe,Dn=0,nn=0,rt=0,Qt=0;s.bbox={};let on=!1,vu=!1,Ba=!1,oa=!1,fa=!1,fn=!1;function qa(m,y,_){(_||m!=s.width||y!=s.height)&&Kl(m,y),$a(!1),Ba=!0,vu=!0,Wl()}function Kl(m,y){s.width=jl=Te=m,s.height=sa=oe=y,lt=Nt=0,Br(),zs();let _=s.bbox;Dn=_.left=au(lt*Ie,.5),nn=_.top=au(Nt*Ie,.5),rt=_.width=au(Te*Ie,.5),Qt=_.height=au(oe*Ie,.5)}const yu=3;function Di(){let m=!1,y=0;for(;!m;){y++;let _=Yr(y),E=$r(y);m=y==yu||_&&E,m||(Kl(s.width,s.height),vu=!0)}}function qo({width:m,height:y}){qa(m,y)}s.setSize=qo;function Br(){let m=!1,y=!1,_=!1,E=!1;I.forEach((N,C)=>{if(N.show&&N._show){let{side:V,_size:P}=N,te=V%2,ue=N.label!=null?N.labelSize:0,re=P+ue;re>0&&(te?(Te-=re,V==3?(lt+=re,E=!0):_=!0):(oe-=re,V==0?(Nt+=re,m=!0):y=!0))}}),qn[0]=m,qn[1]=_,qn[2]=y,qn[3]=E,Te-=Rl[1]+Rl[3],lt+=Rl[3],oe-=Rl[2]+Rl[0],Nt+=Rl[0]}function zs(){let m=lt+Te,y=Nt+oe,_=lt,E=Nt;function N(C,V){switch(C){case 1:return m+=V,m-V;case 2:return y+=V,y-V;case 3:return _-=V,_+V;case 0:return E-=V,E+V}}I.forEach((C,V)=>{if(C.show&&C._show){let P=C.side;C._pos=N(P,C._size),C.label!=null&&(C._lpos=N(P,C.labelSize))}})}if(G.dataIdx==null){let m=G.hover,y=m.skip=new Set(m.skip??[]);y.add(void 0);let _=m.prox=Ge(m.prox),E=m.bias??=0;G.dataIdx=(N,C,V,P)=>{if(C==0)return V;let te=V,ue=_(N,C,V,P)??gt,re=ue>=0&&ue0;)y.has(Ce[Se])||(Ue=Se);if(E==0||E==1)for(Se=V;Ne==null&&Se++ue&&(te=null);return te}}const tl=m=>{G.event=m};G.idxs=A,G._lock=!1;let ln=G.points;ln.show=Ge(ln.show),ln.size=Ge(ln.size),ln.stroke=Ge(ln.stroke),ln.width=Ge(ln.width),ln.fill=Ge(ln.fill);const nl=s.focus=Jt({},n.focus||{alpha:.3},G.focus),da=nl.prox>=0,ha=da&&ln.one;let zn=[],Xl=[],ma=[];function Es(m,y){let _=ln.show(s,y);if(_ instanceof HTMLElement)return ol(_,xT),ol(_,m.class),ia(_,-10,-10,Te,oe),O.insertBefore(_,zn[y]),_}function Cl(m,y){if(c==1||y>0){let _=c==1&&q[m.scale].time,E=m.value;m.value=_?dv(E)?bv(U,yv(E,Q)):E||be:E||kw,m.label=m.label||(_?Aw:Mw)}if(ha||y>0)DELIM" -R"DELIM(){m.width=m.width==null?1:m.width,m.paths=m.paths||Fw||BT,m.fillTo=Ge(m.fillTo||qw),m.pxAlign=+Je(m.pxAlign,Y),m.pxRound=Av(m.pxAlign),m.stroke=Ge(m.stroke||null),m.fill=Ge(m.fill||null),m._stroke=m._fill=m._paths=m._focus=null;let _=Zw(Bn(1,m.width),1),E=m.points=Jt({},{size:_,width:Bn(1,_*.2),stroke:m.stroke,space:_*2,paths:Ww,_stroke:null,_fill:null},m.points);E.show=Ge(E.show),E.filter=Ge(E.filter),E.fill=Ge(E.fill),E.stroke=Ge(E.stroke),E.paths=Ge(E.paths),E.pxAlign=m.pxAlign}if(ie){let _=ji(m,y);nt.splice(y,0,_[0]),Nn.splice(y,0,_[1]),L.values.push(null)}if(xe){A.splice(y,0,null);let _=null;ha?y==0&&(_=Es(m,y)):y>0&&(_=Es(m,y)),zn.splice(y,0,_),Xl.splice(y,0,0),ma.splice(y,0,0)}Ht("addSeries",y)}function Wt(m,y){y=y??B.length,m=c==1?mh(m,y,_v,wv):mh(m,y,{},Tv),B.splice(y,0,m),Cl(B[y],y)}s.addSeries=Wt;function En(m){if(B.splice(m,1),ie){L.values.splice(m,1),Nn.splice(m,1);let y=nt.splice(m,1)[0];Vl(null,y.firstChild),y.remove()}xe&&(A.splice(m,1),zn.splice(m,1)[0].remove(),Xl.splice(m,1),ma.splice(m,1)),Ht("delSeries",m)}s.delSeries=En;const qn=[!1,!1,!1,!1];function Ts(m,y){if(m._show=m.show,m.show){let _=m.side%2,E=q[m.scale];E==null&&(m.scale=_?B[1].scale:ne,E=q[m.scale]);let N=E.time;m.size=Ge(m.size),m.space=Ge(m.space),m.rotate=Ge(m.rotate),zi(m.incrs)&&m.incrs.forEach(V=>{!Mi.has(V)&&Mi.set(V,Yy(V))}),m.incrs=Ge(m.incrs||(E.distr==2?rw:N?F==1?ow:hw:iu)),m.splits=Ge(m.splits||(N&&E.distr==1?me:E.distr==3?oh:E.distr==4?jw:Nw)),m.stroke=Ge(m.stroke),m.grid.stroke=Ge(m.grid.stroke),m.ticks.stroke=Ge(m.ticks.stroke),m.border.stroke=Ge(m.border.stroke);let C=m.values;m.values=zi(C)&&!zi(C[0])?Ge(C):N?zi(C)?vv(U,gv(C,Q)):dv(C)?gw(U,C):C||Oe:C||Ow,m.filter=Ge(m.filter||(E.distr>=3&&E.log==10?Rw:E.distr==3&&E.log==2?Uw:Gy)),m.font=Dv(m.font),m.labelFont=Dv(m.labelFont),m._size=m.size(s,null,y,0),m._space=m._rotate=m._incrs=m._found=m._splits=m._values=null,m._size>0&&(qn[y]=!0,m._el=wl(yT,T))}}function Ci(m,y,_,E){let[N,C,V,P]=_,te=y%2,ue=0;return te==0&&(P||C)&&(ue=y==0&&!N||y==2&&!V?Pt(Sv.size/3):0),te==1&&(N||V)&&(ue=y==1&&!C||y==3&&!P?Pt(zv.size/2):0),ue}const qr=s.padding=(n.padding||[Ci,Ci,Ci,Ci]).map(m=>Ge(Je(m,Ci))),Rl=s._padding=qr.map((m,y)=>m(s,y,qn,0));let Mt,jt=null,bt=null;const Ul=c==1?B[0].idxs:null;let dn=null,pl=!1;function Lt(m,y){if(a=m??[],s.data=s._data=a,c==2){Mt=0;for(let _=1;_=0,fn=!0,Wl()}}s.setData=Lt;function bu(){pl=!0;let m,y;c==1&&(Mt>0?(jt=Ul[0]=0,bt=Ul[1]=Mt-1,m=a[0][jt],y=a[0][bt],ye==2?(m=jt,y=bt):m==y&&(ye==3?[m,y]=Ro(m,m,ee.log,!1):ye==4?[m,y]=Gh(m,m,ee.log,!1):ee.time?y=m+Pt(86400/F):[m,y]=wo(m,y,Qh,!0))):(jt=Ul[0]=m=null,bt=Ul[1]=y=null)),Qn(ne,m,y)}let Ri,Gn,Jl,ws,Su,_u,Ms,Ga,Qa,Et;function Cn(m,y,_,E,N,C){m??=J0,_??=$h,E??="butt",N??=J0,C??="round",m!=Ri&&(S.strokeStyle=Ri=m),N!=Gn&&(S.fillStyle=Gn=N),y!=Jl&&(S.lineWidth=Jl=y),C!=Su&&(S.lineJoin=Su=C),E!=_u&&(S.lineCap=_u=E),_!=ws&&S.setLineDash(ws=_)}function As(m,y,_,E){y!=Gn&&(S.fillStyle=Gn=y),m!=Ms&&(S.font=Ms=m),_!=Ga&&(S.textAlign=Ga=_),E!=Qa&&(S.textBaseline=Qa=E)}function Os(m,y,_,E,N=0){if(E.length>0&&m.auto(s,pl)&&(y==null||y.min==null)){let C=Je(jt,0),V=Je(bt,E.length-1),P=_.min==null?RT(E,C,V,N,m.distr==3):[_.min,_.max];m.min=Ql(m.min,_.min=P[0]),m.max=Bn(m.max,_.max=P[1])}}const xu={min:null,max:null};function Gr(){for(let E in q){let N=q[E];de[E]==null&&(N.min==null||de[ne]!=null&&N.auto(s,pl))&&(de[E]=xu)}for(let E in q){let N=q[E];de[E]==null&&N.from!=null&&de[N.from]!=null&&(de[E]=xu)}de[ne]!=null&&$a(!0);let m={};for(let E in de){let N=de[E];if(N!=null){let C=m[E]=ps(q[E],QT);if(N.min!=null)Jt(C,N);else if(E!=ne||c==2)if(Mt==0&&C.from==null){let V=C.range(s,null,null,E);C.min=V[0],C.max=V[1]}else C.min=gt,C.max=-gt}}if(Mt>0){B.forEach((E,N)=>{if(c==1){let C=E.scale,V=de[C];if(V==null)return;let P=m[C];if(N==0){let te=P.range(s,P.min,P.max,C);P.min=te[0],P.max=te[1],jt=Gl(P.min,a[0]),bt=Gl(P.max,a[0]),bt-jt>1&&(a[0][jt]P.max&&bt--),E.min=dn[jt],E.max=dn[bt]}else E.show&&E.auto&&Os(P,V,E,a[N],E.sorted);E.idxs[0]=jt,E.idxs[1]=bt}else if(N>0&&E.show&&E.auto){let[C,V]=E.facets,P=C.scale,te=V.scale,[ue,re]=a[N],fe=m[P],De=m[te];fe!=null&&Os(fe,de[P],C,ue,C.sorted),De!=null&&Os(De,de[te],V,re,V.sorted),E.min=V.min,E.max=V.max}});for(let E in m){let N=m[E],C=de[E];if(N.from==null&&(C==null||C.min==null)){let V=N.range(s,N.min==gt?null:N.min,N.max==-gt?null:N.max,E);N.min=V[0],N.max=V[1]}}}for(let E in m){let N=m[E];if(N.from!=null){let C=m[N.from];if(C.min==null)N.min=N.max=null;else{let V=N.range(s,C.min,C.max,E);N.min=V[0],N.max=V[1]}}}let y={},_=!1;for(let E in m){let N=m[E],C=q[E];if(C.min!=N.min||C.max!=N.max){C.min=N.min,C.max=N.max;let V=C.distr;C._min=V==3?La(C.min):V==4?Jd(C.min,C.asinh):V==100?C.fwd(C.min):C.min,C._max=V==3?La(C.max):V==4?Jd(C.max,C.asinh):V==100?C.fwd(C.max):C.max,y[E]=_=!0}}if(_){B.forEach((E,N)=>{c==2?N>0&&y.y&&(E._paths=null):y[E.scale]&&(E._paths=null)});for(let E in y)Ba=!0,Ht("setScale",E);xe&&G.left>=0&&(oa=fn=!0)}for(let E in de)de[E]=null}function zu(m){let y=ch(jt-1,0,Mt-1),_=ch(bt+1,0,Mt-1);for(;m[y]==null&&y>0;)y--;for(;m[_]==null&&_0){let m=B.some(y=>y._focus)&&Et!=nl.alpha;m&&(S.globalAlpha=Et=nl.alpha),B.forEach((y,_)=>{if(_>0&&y.show&&(Rn(_,!1),Rn(_,!0),y._paths==null)){let E=Et;Et!=y.alpha&&(S.globalAlpha=Et=y.alpha);let N=c==2?[0,a[_][0].length-1]:zu(a[_]);y._paths=y.paths(s,_,N[0],N[1]),Et!=E&&(S.globalAlpha=Et=E)}}),B.forEach((y,_)=>{if(_>0&&y.show){let E=Et;Et!=y.alpha&&(S.globalAlpha=Et=y.alpha),y._paths!=null&&Eu(_,!1);{let N=y._paths!=null?y._paths.gaps:null,C=y.points.show(s,_,jt,bt,N),V=y.points.filter(s,_,C,N);(C||V)&&(y.points._paths=y.points.paths(s,_,jt,bt,V),Eu(_,!0))}Et!=E&&(S.globalAlpha=Et=E),Ht("drawSeries",_)}}),m&&(S.globalAlpha=Et=1)}}function Rn(m,y){let _=y?B[m].points:B[m];_._stroke=_.stroke(s,m),_._fill=_.fill(s,m)}function Eu(m,y){let _=y?B[m].points:B[m],{stroke:E,fill:N,clip:C,flags:V,_stroke:P=_._stroke,_fill:te=_._fill,_width:ue=_.width}=_._paths;ue=vt(ue*Ie,3);let re=null,fe=ue%2/2;y&&te==null&&(te=ue>0?"#fff":P);let De=_.pxAlign==1&&fe>0;if(De&&S.translate(fe,fe),!y){let $e=Dn-ue/2,Ce=nn-ue/2,Ue=rt+ue,Ne=Qt+ue;re=new Path2D,re.rect($e,Ce,Ue,Ne)}y?Fl(P,ue,_.dash,_.cap,te,E,N,V,C):Qr(m,P,ue,_.dash,_.cap,te,E,N,V,re,C),De&&S.translate(-fe,-fe)}function Qr(m,y,_,E,N,C,V,P,te,ue,re){let fe=!1;te!=0&&ae.forEach((De,$e)=>{if(De.series[0]==m){let Ce=B[De.series[1]],Ue=a[De.series[1]],Ne=(Ce._paths||jr).band;zi(Ne)&&(Ne=De.dir==1?Ne[0]:Ne[1]);let Se,ct=null;Ce.show&&Ne&&kT(Ue,jt,bt)?(ct=De.fill(s,$e)||C,Se=Ce._paths.clip):Ne=null,Fl(y,_,E,N,ct,V,P,te,ue,re,Se,Ne),fe=!0}}),fe||Fl(y,_,E,N,C,V,P,te,ue,re)}const Tu=gs|dh;function Fl(m,y,_,E,N,C,V,P,te,ue,re,fe){Cn(m,y,_,E,N),(te||ue||fe)&&(S.save(),te&&S.clip(te),ue&&S.clip(ue)),fe?(P&Tu)==Tu?(S.clip(fe),re&&S.clip(re),ki(N,V),Ui(m,C,y)):P&dh?(ki(N,V),S.clip(fe),Ui(m,C,y)):P&gs&&(S.save(),S.clip(fe),re&&S.clip(re),ki(N,V),S.restore(),Ui(m,C,y)):(ki(N,V),Ui(m,C,y)),(te||ue||fe)&&S.restore()}function Ui(m,y,_){_>0&&(y instanceof Map?y.forEach((E,N)=>{S.strokeStyle=Ri=N,S.stroke(E)}):y!=null&&m&&S.stroke(y))}function ki(m,y){y instanceof Map?y.forEach((_,E)=>{S.fillStyle=Gn=E,S.fill(_)}):y!=null&&m&&S.fill(y)}function Ya(m,y,_,E){let N=I[m],C;if(E<=0)C=[0,0];else{let V=N._space=N.space(s,m,y,_,E),P=N._incrs=N.incrs(s,m,y,_,E,V);C=l3(y,_,P,E,V)}return N._found=C}function Ns(m,y,_,E,N,C,V,P,te,ue){let re=V%2/2;Y==1&&S.translate(re,re),Cn(P,V,te,ue,P),S.beginPath();let fe,De,$e,Ce,Ue=N+(E==0||E==3?-C:C);_==0?(De=N,Ce=Ue):(fe=N,$e=Ue);for(let Ne=0;Ne{if(!_.show)return;let N=q[_.scale];if(N.min==null){_._show&&(y=!1,_._show=!1,$a(!1));return}else _._show||(y=!1,_._show=!0,$a(!1));let C=_.side,V=C%2,{min:P,max:te}=N,[ue,re]=Ya(E,P,te,V==0?Te:oe);if(re==0)return;let fe=N.distr==2,De=_._splits=_.splits(s,E,P,te,ue,re,fe),$e=N.distr==2?De.map(Se=>dn[Se]):De,Ce=N.distr==2?dn[De[1]]-dn[De[0]]:ue,Ue=_._values=_.values(s,_.filter(s,$e,E,re,Ce),E,re,Ce);_._rotate=C==2?_.rotate(s,Ue,E,re):0;let Ne=_._size;_._size=Ml(_.size(s,Ue,E,m)),Ne!=null&&_._size!=Ne&&(y=!1)}),y}function $r(m){let y=!0;return qr.forEach((_,E)=>{let N=_(s,E,qn,m);N!=Rl[E]&&(y=!1),Rl[E]=N}),y}function js(){for(let m=0;mdn[sn]):$e,Ue=re.distr==2?dn[$e[1]]-dn[$e[0]]:te,Ne=y.ticks,Se=y.border,ct=Ne.show?Ne.size:0,St=Pt(ct*Ie),Ct=Pt((y.alignTo==2?y._size-ct-y.gap:y.gap)*Ie),et=y._rotate*-yo/180,it=W(y._pos*Ie),hn=(St+Ct)*P,Bt=it+hn;C=E==0?Bt:0,N=E==1?Bt:0;let wn=y.font[0],Yn=y.align==1?as:y.align==2?Vd:et>0?as:et<0?Vd:E==0?"center":_==3?Vd:as,an=et||E==1?"middle":_==2?zr:X0;As(wn,V,Yn,an);let Yt=y.font[1]*y.lineGap,Mn=$e.map(sn=>W(p(sn,re,fe,De))),$n=y._values;for(let sn=0;sn<$n.length;sn++){let An=$n[sn];if(An!=null){E==0?N=Mn[sn]:C=Mn[sn],An=""+An;let ea=An.indexOf(` -`)==-1?[An]:An.split(/\n/gm);for(let mn=0;mn{_>0&&(y._paths=null,m&&(c==1?(y.min=null,y.max=null):y.facets.forEach(E=>{E.min=null,E.max=null})))})}let wu=!1,Va=!1,Un=[];function Ds(){Va=!1;for(let m=0;m0&&queueMicrotask(Ds)}s.batch=Ka;function pa(){if(on&&(Gr(),on=!1),Ba&&(Di(),Ba=!1),vu){if(zt(w,as,lt),zt(w,zr,Nt),zt(w,wr,Te),zt(w,Mr,oe),zt(O,as,lt),zt(O,zr,Nt),zt(O,wr,Te),zt(O,Mr,oe),zt(T,wr,jl),zt(T,Mr,sa),x.width=Pt(jl*Ie),x.height=Pt(sa*Ie),I.forEach(({_el:m,_show:y,_size:_,_pos:E,side:N})=>{if(m!=null)if(y){let C=N===3||N===0?_:0,V=N%2==1;zt(m,V?"left":"top",E-C),zt(m,V?"width":"height",_),zt(m,V?"top":"left",V?Nt:lt),zt(m,V?"height":"width",V?oe:Te),sh(m,uu)}else ol(m,uu)}),Ri=Gn=Jl=Su=_u=Ms=Ga=Qa=ws=null,Et=1,qi(!0),lt!=Dl||Nt!=ra||Te!=el||oe!=ca){$a(!1);let m=Te/el,y=oe/ca;if(xe&&!oa&&G.left>=0){G.left*=m,G.top*=y,gl&&ia(gl,Pt(G.left),0,Te,oe),Tn&&ia(Tn,0,Pt(G.top),Te,oe);for(let _=0;_=0&&Fe.width>0){Fe.left*=m,Fe.width*=m,Fe.top*=y,Fe.height*=y;for(let _ in Ls)zt(Ja,_,Fe[_])}Dl=lt,ra=Nt,el=Te,ca=oe}Ht("setSize"),vu=!1}jl>0&&sa>0&&(S.clearRect(0,0,x.width,x.height),Ht("drawClear"),se.forEach(m=>m()),Ht("draw")),Fe.show&&fa&&(Fa(Fe),fa=!1),xe&&oa&&(va(null,!0,!1),oa=!1),L.show&&L.live&&fn&&(ks(),fn=!1),g||(g=!0,s.status=1,Ht("ready")),pl=!1,wu=!1}s.redraw=(m,y)=>{Ba=y||!1,m!==!1?Qn(ne,ee.min,ee.max):Wl()};function Mu(m,y){let _=q[m];if(_.from==null){if(Mt==0){let E=_.range(s,y.min,y.max,m);y.min=E[0],y.max=E[1]}if(y.min>y.max){let E=y.min;y.min=y.max,y.max=E}if(Mt>1&&y.min!=null&&y.max!=null&&y.max-y.min<1e-16)return;m==ne&&_.distr==2&&Mt>0&&(y.min=Gl(y.min,a[0]),y.max=Gl(y.max,a[0]),y.min==y.max&&y.max++),de[m]=y,on=!0,Wl()}}s.setScale=Mu;let Zi,Au,gl,Tn,Ou,Xa,kn,Il,Li,Cs,Pe,at,kl=!1;const Ve=G.drag;let yt=Ve.x,At=Ve.y;xe&&(G.x&&(Zi=wl(ST,O)),G.y&&(Au=wl(_T,O)),ee.ori==0?(gl=Zi,Tn=Au):(gl=Au,Tn=Zi),Pe=G.left,at=G.top);const Fe=s.select=Jt({show:!0,over:!0,left:0,width:0,top:0,height:0},n.select),Ja=Fe.show?wl(bT,Fe.over?O:w):null;function Fa(m,y){if(Fe.show){for(let _ in m)Fe[_]=m[_],_ in Ls&&zt(Ja,_,m[_]);y!==!1&&Ht("setSelect")}}s.setSelect=Fa;function Rs(m){if(B[m].show)ie&&sh(nt[m],uu);else if(ie&&ol(nt[m],uu),xe){let _=ha?zn[0]:zn[m];_!=null&&ia(_,-10,-10,Te,oe)}}function Qn(m,y,_){Mu(m,{min:y,max:_})}function Zn(m,y,_,E){y.focus!=null&&Vo(m),y.show!=null&&B.forEach((N,C)=>{C>0&&(m==C||m==null)&&(N.show=y.show,Rs(C),c==2?(Qn(N.facets[0].scale,null,null),Qn(N.facets[1].scale,null,null)):Qn(N.scale,null,null),Wl())}),_!==!1&&Ht("setSeries",m,y),E&&Pa("setSeries",s,m,y)}s.setSeries=Zn;function Vr(m,y){Jt(ae[m],y)}function Qo(m,y){m.fill=Ge(m.fill||null),m.dir=Je(m.dir,-1),y=y??ae.length,ae.splice(y,0,m)}function Yo(m){m==null?ae.length=0:ae.splice(m,1)}s.addBand=Qo,s.setBand=Vr,s.delBand=Yo;function $o(m,y){B[m].alpha=y,xe&&zn[m]!=null&&(zn[m].style.opacity=y),ie&&nt[m]&&(nt[m].style.opacity=y)}let ll,Pl,ga;const Wa={focus:!0};function Vo(m){if(m!=ga){let y=m==null,_=nl.alpha!=1;B.forEach((E,N)=>{if(c==1||N>0){let C=y||N==0||N==m;E._focus=y?null:C,_&&$o(N,C?1:nl.alpha)}}),ga=m,_&&Wl()}}ie&&da&&Ft(I0,ge,m=>{G._lock||(tl(m),ga!=null&&Zn(null,Wa,!0,Dt.setSeries))});function vl(m,y,_){let E=q[y];_&&(m=m/Ie-(E.ori==1?Nt:lt));let N=Te;E.ori==1&&(N=oe,m=N-m),E.dir==-1&&(m=N-m);let C=E._min,V=E._max,P=m/N,te=C+(V-C)*P,ue=E.distr;return ue==3?hs(10,te):ue==4?LT(te,E.asinh):ue==100?E.bwd(te):te}function Kr(m,y){let _=vl(m,ne,y);return Gl(_,a[0],jt,bt)}s.valToIdx=m=>Gl(m,a[0]),s.posToIdx=Kr,s.posToVal=vl,s.valToPos=(m,y,_)=>q[y].ori==0?d(m,q[y],_?rt:Te,_?Dn:0):f(m,q[y],_?Qt:oe,_?nn:0),s.setCursor=(m,y,_)=>{Pe=m.left,at=m.top,va(null,y,_)};function Xr(m,y){zt(Ja,as,Fe.left=m),zt(Ja,wr,Fe.width=y)}function Jr(m,y){zt(Ja,zr,Fe.top=m),zt(Ja,Mr,Fe.height=y)}let Hi=ee.ori==0?Xr:Jr,Bi=ee.ori==1?Xr:Jr;function Us(){if(ie&&L.live)for(let m=c==2?1:0;m{A[E]=_}):GT(m.idx)||A.fill(m.idx),L.idx=A[0]),ie&&L.live){for(let _=0;_0||c==1&&!jn)&&Ko(_,A[_]);Us()}fn=!1,y!==!1&&Ht("setLegend")}s.setLegend=ks;function Ko(m,y){let _=B[m],E=m==0&&ye==2?dn:a[m],N;jn?N=_.values(s,m,y)??xn:(N=_.value(s,y==null?null:E[y],m,y),N=N==null?xn:{_:N}),L.values[m]=N}function va(m,y,_){Li=Pe,Cs=at,[Pe,at]=G.move(s,Pe,at),G.left=Pe,G.top=at,xe&&(gl&&ia(gl,Pt(Pe),0,Te,oe),Tn&&ia(Tn,0,Pt(at),Te,oe));let E,N=jt>bt;ll=gt,Pl=null;let C=ee.ori==0?Te:oe,V=ee.ori==1?Te:oe;if(Pe<0||Mt==0||N){E=G.idx=null;for(let P=0;P0&&ct.show){let hn=et==null?-10:et==E?ue:ce(c==1?a[0][et]:a[Se][0][et],ee,C,0),Bt=it==null?-10:Ee(it,c==1?q[ct.scale]:q[ct.facets[1].scale],V,0);if(da&&it!=null){let wn=ee.ori==1?Pe:at,Yn=en(nl.dist(s,Se,et,Bt,wn));if(Yn=0?1:-1,$n=Yt>=0?1:-1;$n==Mn&&($n==1?an==1?it>=Yt:it<=Yt:an==1?it<=Yt:it>=Yt)&&(ll=Yn,Pl=Se)}else ll=Yn,Pl=Se}}if(fn||ha){let wn,Yn;ee.ori==0?(wn=hn,Yn=Bt):(wn=Bt,Yn=hn);let an,Yt,)DELIM" -R"DELIM(Mn,$n,un,sn,An=!0,ea=ln.bbox;if(ea!=null){An=!1;let mn=ea(s,Se);Mn=mn.left,$n=mn.top,an=mn.width,Yt=mn.height}else Mn=wn,$n=Yn,an=Yt=ln.size(s,Se);if(sn=ln.fill(s,Se),un=ln.stroke(s,Se),ha)Se==Pl&&ll<=nl.prox&&(re=Mn,fe=$n,De=an,$e=Yt,Ce=An,Ue=sn,Ne=un);else{let mn=zn[Se];mn!=null&&(Xl[Se]=Mn,ma[Se]=$n,iv(mn,an,Yt,An),lv(mn,sn,un),ia(mn,Ml(Mn),Ml($n),Te,oe))}}}}if(ha){let Se=nl.prox,ct=ga==null?ll<=Se:ll>Se||Pl!=ga;if(fn||ct){let St=zn[0];St!=null&&(Xl[0]=re,ma[0]=fe,iv(St,De,$e,Ce),lv(St,Ue,Ne),ia(St,Ml(re),Ml(fe),Te,oe))}}}if(Fe.show&&kl)if(m!=null){let[P,te]=Dt.scales,[ue,re]=Dt.match,[fe,De]=m.cursor.sync.scales,$e=m.cursor.drag;if(yt=$e._x,At=$e._y,yt||At){let{left:Ce,top:Ue,width:Ne,height:Se}=m.select,ct=m.scales[fe].ori,St=m.posToVal,Ct,et,it,hn,Bt,wn=P!=null&&ue(P,fe),Yn=te!=null&&re(te,De);wn&&yt?(ct==0?(Ct=Ce,et=Ne):(Ct=Ue,et=Se),it=q[P],hn=ce(St(Ct,fe),it,C,0),Bt=ce(St(Ct+et,fe),it,C,0),Hi(Ql(hn,Bt),en(Bt-hn))):Hi(0,C),Yn&&At?(ct==1?(Ct=Ce,et=Ne):(Ct=Ue,et=Se),it=q[te],hn=Ee(St(Ct,De),it,V,0),Bt=Ee(St(Ct+et,De),it,V,0),Bi(Ql(hn,Bt),en(Bt-hn))):Bi(0,V)}else Hs()}else{let P=en(Li-Ou),te=en(Cs-Xa);if(ee.ori==1){let De=P;P=te,te=De}yt=Ve.x&&P>=Ve.dist,At=Ve.y&&te>=Ve.dist;let ue=Ve.uni;ue!=null?yt&&At&&(yt=P>=ue,At=te>=ue,!yt&&!At&&(te>P?At=!0:yt=!0)):Ve.x&&Ve.y&&(yt||At)&&(yt=At=!0);let re,fe;yt&&(ee.ori==0?(re=kn,fe=Pe):(re=Il,fe=at),Hi(Ql(re,fe),en(fe-re)),At||Bi(0,V)),At&&(ee.ori==1?(re=kn,fe=Pe):(re=Il,fe=at),Bi(Ql(re,fe),en(fe-re)),yt||Hi(0,C)),!yt&&!At&&(Hi(0,0),Bi(0,0))}if(Ve._x=yt,Ve._y=At,m==null){if(_){if(tc!=null){let[P,te]=Dt.scales;Dt.values[0]=P!=null?vl(ee.ori==0?Pe:at,P):null,Dt.values[1]=te!=null?vl(ee.ori==1?Pe:at,te):null}Pa(Kd,s,Pe,at,Te,oe,E)}if(da){let P=_&&Dt.setSeries,te=nl.prox;ga==null?ll<=te&&Zn(Pl,Wa,!0,P):ll>te?Zn(null,Wa,!0,P):Pl!=ga&&Zn(Pl,Wa,!0,P)}}fn&&(L.idx=E,ks()),y!==!1&&Ht("setCursor")}let Zl=null;Object.defineProperty(s,"rect",{get(){return Zl==null&&qi(!1),Zl}});function qi(m=!1){m?Zl=null:(Zl=O.getBoundingClientRect(),Ht("syncRect",Zl))}function Fr(m,y,_,E,N,C,V){G._lock||kl&&m!=null&&m.movementX==0&&m.movementY==0||(Zs(m,y,_,E,N,C,V,!1,m!=null),m!=null?va(null,!0,!0):va(y,!0,!1))}function Zs(m,y,_,E,N,C,V,P,te){if(Zl==null&&qi(!1),tl(m),m!=null)_=m.clientX-Zl.left,E=m.clientY-Zl.top;else{if(_<0||E<0){Pe=-10,at=-10;return}let[ue,re]=Dt.scales,fe=y.cursor.sync,[De,$e]=fe.values,[Ce,Ue]=fe.scales,[Ne,Se]=Dt.match,ct=y.axes[0].side%2==1,St=ee.ori==0?Te:oe,Ct=ee.ori==1?Te:oe,et=ct?C:N,it=ct?N:C,hn=ct?E:_,Bt=ct?_:E;if(Ce!=null?_=Ne(ue,Ce)?p(De,q[ue],St,0):-10:_=St*(hn/et),Ue!=null?E=Se(re,Ue)?p($e,q[re],Ct,0):-10:E=Ct*(Bt/it),ee.ori==1){let wn=_;_=E,E=wn}}te&&(y==null||y.cursor.event.type==Kd)&&((_<=1||_>=Te-1)&&(_=au(_,Te)),(E<=1||E>=oe-1)&&(E=au(E,oe))),P?(Ou=_,Xa=E,[kn,Il]=G.move(s,_,E)):(Pe=_,at=E)}const Ls={width:0,height:0,left:0,top:0};function Hs(){Fa(Ls,!1)}let Wr,Ir,Pr,ec;function Nu(m,y,_,E,N,C,V){kl=!0,yt=At=Ve._x=Ve._y=!1,Zs(m,y,_,E,N,C,V,!0,!1),m!=null&&(Ft(Xd,ih,Ia,!1),Pa(F0,s,kn,Il,Te,oe,null));let{left:P,top:te,width:ue,height:re}=Fe;Wr=P,Ir=te,Pr=ue,ec=re}function Ia(m,y,_,E,N,C,V){kl=Ve._x=Ve._y=!1,Zs(m,y,_,E,N,C,V,!1,!0);let{left:P,top:te,width:ue,height:re}=Fe,fe=ue>0||re>0,De=Wr!=P||Ir!=te||Pr!=ue||ec!=re;if(fe&&De&&Fa(Fe),Ve.setScale&&fe&&De){let $e=P,Ce=ue,Ue=te,Ne=re;if(ee.ori==1&&($e=te,Ce=re,Ue=P,Ne=ue),yt&&Qn(ne,vl($e,ne),vl($e+Ce,ne)),At)for(let Se in q){let ct=q[Se];Se!=ne&&ct.from==null&&ct.min!=gt&&Qn(Se,vl(Ue+Ne,Se),vl(Ue,Se))}Hs()}else G.lock&&(G._lock=!G._lock,va(y,!0,m!=null));m!=null&&(Vl(Xd,ih),Pa(Xd,s,Pe,at,Te,oe,null))}function Xo(m,y,_,E,N,C,V){if(G._lock)return;tl(m);let P=kl;if(kl){let te=!0,ue=!0,re=10,fe,De;ee.ori==0?(fe=yt,De=At):(fe=At,De=yt),fe&&De&&(te=Pe<=re||Pe>=Te-re,ue=at<=re||at>=oe-re),fe&&te&&(Pe=Pe{let N=Dt.match[2];_=N(s,y,_),_!=-1&&Zn(_,E,!0,!1)},xe&&(Ft(F0,O,Nu),Ft(Kd,O,Fr),Ft(W0,O,m=>{tl(m),qi(!1)}),Ft(I0,O,Xo),Ft(P0,O,Bs),hh.add(s),s.syncRect=qi);const Gi=s.hooks=n.hooks||{};function Ht(m,y,_){Va?Un.push([m,y,_]):m in Gi&&Gi[m].forEach(E=>{E.call(null,s,y,_)})}(n.plugins||[]).forEach(m=>{for(let y in m.hooks)Gi[y]=(Gi[y]||[]).concat(m.hooks[y])});const ba=(m,y,_)=>_,Dt=Jt({key:null,setSeries:!1,filters:{pub:ov,sub:ov},scales:[ne,B[1]?B[1].scale:null],match:[fv,fv,ba],values:[null,null]},G.sync);Dt.match.length==2&&Dt.match.push(ba),G.sync=Dt;const tc=Dt.key,Gs=ob(tc);function Pa(m,y,_,E,N,C,V){Dt.filters.pub(m,y,_,E,N,C,V)&&Gs.pub(m,y,_,E,N,C,V)}Gs.sub(s);function nc(m,y,_,E,N,C,V){Dt.filters.sub(m,y,_,E,N,C,V)&&ya[m](null,y,_,E,N,C,V)}s.pub=nc;function Qi(){Gs.unsub(s),hh.delete(s),Nl.clear(),rh(To,fs,qs),v.remove(),ge?.remove(),Ht("destroy")}s.destroy=Qi;function Sa(){Ht("init",n,a),Lt(a||n.data,!1),de[ne]?Mu(ne,de[ne]):bu(),fa=Fe.show&&(Fe.width>0||Fe.height>0),oa=fn=!0,qa(n.width,n.height)}return B.forEach(Cl),I.forEach(Ts),u?u instanceof HTMLElement?(u.appendChild(v),Sa()):u(s,Sa):Sa(),s}cn.assign=Jt;cn.fmtNum=Yh;cn.rangeNum=wo;cn.rangeLog=Ro;cn.rangeAsinh=Gh;cn.orient=gu;cn.pxRatio=Ie;cn.join=JT;cn.fmtDate=Vh,cn.tzDate=uw;cn.sync=ob;{cn.addGap=Gw,cn.clipGaps=Zo;let n=cn.paths={points:gb};n.linear=yb,n.stepped=$w,n.bars=Vw,n.spline=Xw}function i3({data:n,series:a,height:u=280,emptyMessage:s="Waiting for live data…",valueSuffix:c="",zeroBased:d=!0,valueFormatter:f=s3,visualization:p="line",forceEmpty:g=!1}){const v=_e.useRef(null),x=_e.useRef(null),S=_e.useMemo(()=>u3(n),[n]),T=_e.useRef(S),w=!g&&n[0]?.length>0;return _e.useLayoutEffect(()=>{const O=v.current;if(!O)return;const Y={width:Math.max(240,O.clientWidth),height:u,padding:[12,8,0,0],cursor:{drag:{x:!0,y:!1,setScale:!0},focus:{prox:24}},legend:{show:!0,live:!0},scales:{x:{time:!0},y:{auto:!0,...d?{range:(B,I,q)=>[Math.min(0,I),q===0?1:q*1.08]}:{range:(B,I,q)=>{const ae=q-I,ne=ae===0?Math.max(1,Math.abs(q)*5e-4):ae*.08;return[I-ne,q+ne]}}}},axes:[{stroke:"#9f9f98",grid:{stroke:"#ffffff12",width:1},ticks:{stroke:"#ffffff20",width:1},font:"11px system-ui"},{size:72,stroke:"#9f9f98",grid:{stroke:"#ffffff12",width:1},ticks:{stroke:"#ffffff20",width:1},font:"11px system-ui",values:(B,I)=>I.map(q=>`${f(q)}${c}`)}],series:[{},...a.map(B=>{const I=p==="step"?cn.paths.stepped?.({align:1}):p==="bar"?cn.paths.bars?.({size:[.72,48,2]}):void 0;return{label:B.label,stroke:B.color,fill:p==="area"||p==="bar"?B.fill??`${B.color}24`:B.fill,width:B.width??2,paths:I,points:{show:p==="line"?B.points??!1:!1},value:(q,ae)=>ae===null?"—":`${f(ae)}${c}`}})]},W=new cn(Y,T.current,O);x.current=W;const F=new ResizeObserver(B=>{const I=B[0]?.contentRect.width;I&&I>0&&W.setSize({width:Math.round(I),height:u})});return F.observe(O),()=>{F.disconnect(),W.destroy(),x.current=null}},[u,a,f,c,p,d]),_e.useEffect(()=>{x.current?.setData(S)},[S]),z.jsxs("div",{className:"relative min-w-0",children:[z.jsx("div",{ref:v,className:"min-w-0 overflow-hidden"}),!w&&z.jsx("div",{className:"bg-surface text-textMuted pointer-events-none absolute inset-0 z-10 flex items-center justify-center text-sm",children:s})]})}function u3(n){const a=n[0];if(a.length>=2)return n;const u=Date.now()/1e3,s=a[0]??u,c=[s-1,s],d=n.slice(1).map(f=>{const p=f[0]??null;return[p,p]});return[c,...d]}function s3(n){return Math.abs(n)>=1e6?`${(n/1e6).toFixed(1)}m`:Math.abs(n)>=1e3?`${(n/1e3).toFixed(1)}k`:Math.abs(n)>=10?n.toFixed(0):Math.abs(n)>=1?n.toFixed(1):n.toFixed(2)}const r3={300:"5m",900:"15m",3600:"1h"},c3=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),o3=new Intl.NumberFormat(void 0,{maximumFractionDigits:2});function f3(n){return c3.format(n)}function d3(n){return o3.format(n)}function h3(n){return n==="height"||n==="occurrences"?f3:d3}function m3({metrics:n}){const[a,u]=_e.useSta)DELIM" -R"DELIM(te(JE),[s,c]=_e.useState(null),[d,f]=_e.useState(!1);_e.useEffect(()=>{FE(a)},[a]);function p(x){u(S=>s?.mode==="add"?S.length>=us?S:[...S,x]:S.map(T=>T.id===x.id?x:T)),c(null)}function g(x,S){u(T=>{const w=x+S;if(w<0||w>=T.length)return T;const O=[...T],Y=O[x],W=O[w];return O[x]=W,O[w]=Y,O})}function v(){if(!d){f(!0);return}u(vo()),f(!1)}return z.jsxs("section",{className:"space-y-4",children:[z.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Live telemetry"}),z.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:"Custom charts"}),z.jsxs("p",{className:"text-textMuted mt-1 text-sm",children:["Session data only · ",String(a.length)," of ",String(us)," charts"]})]}),z.jsxs("div",{className:"flex flex-wrap gap-2",children:[z.jsx("button",{type:"button",onClick:()=>{f(!1),c({mode:"add",chart:Dy()})},disabled:a.length>=us,className:"bg-accent text-background hover:bg-accent/90 rounded-lg px-4 py-2 text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-40",children:"Add chart"}),z.jsx("button",{type:"button",onClick:v,onBlur:()=>{f(!1)},className:`rounded-lg border px-4 py-2 text-sm ${d?"border-amber-400/60 text-amber-200":"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary"}`,children:d?"Confirm reset":"Reset defaults"})]})]}),a.length===0?z.jsxs("div",{className:"border-accent/20 bg-surface/60 rounded-xl border border-dashed px-6 py-16 text-center",children:[z.jsx("p",{className:"text-textPrimary font-medium",children:"No charts in this dashboard."}),z.jsx("p",{className:"text-textMuted mt-2 text-sm",children:"Add a custom chart or start from a template."})]}):z.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:a.map((x,S)=>z.jsx(p3,{chart:x,metrics:n,canMoveEarlier:S>0,canMoveLater:S{u(T=>T.filter(w=>w.id!==x.id))},onDuplicate:()=>{u(T=>T.length>=us?T:[...T,KE(x)])},onEdit:()=>{c({mode:"edit",chart:x})},onMoveEarlier:()=>{g(S,-1)},onMoveLater:()=>{g(S,1)}},x.id))}),s&&z.jsx(cT,{chart:s.chart,mode:s.mode,onCancel:()=>{c(null)},onSave:p},`${s.mode}-${s.chart.id}`)]})}function p3({chart:n,metrics:a,canMoveEarlier:u,canMoveLater:s,canDuplicate:c,onDelete:d,onDuplicate:f,onEdit:p,onMoveEarlier:g,onMoveLater:v}){const[x,S]=_e.useState(null),[T,w]=_e.useState(0),O=_e.useMemo(()=>tT(x??a,n),[n,a,x]),Y=_e.useMemo(()=>n.series.map(B=>({label:B.label??Za(B.signalId).label,color:B.color})),[n.series]),W=h3(O.unit),F=`Waiting for ${n.series.length===1?Y[0]?.label?.toLowerCase():"the selected signals"}…`;return z.jsxs("article",{className:"border-accent/20 bg-surface/70 min-w-0 overflow-hidden rounded-xl border",children:[z.jsx("header",{className:"border-accent/15 space-y-3 border-b px-4 py-4 sm:px-5",children:z.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[z.jsxs("div",{className:"min-w-0",children:[z.jsx("h3",{className:"truncate font-semibold",title:n.title,children:n.title}),z.jsxs("p",{className:"text-textMuted mt-1 text-xs",children:[Uy(O.unit)," · ",r3[n.range]," · ",n.visualization,x?" · paused":""]})]}),z.jsxs("div",{className:"flex flex-wrap justify-end gap-1 text-xs",children:[z.jsx(lu,{label:x?"Resume chart":"Pause chart",onClick:()=>{S(B=>B?null:a)},children:x?"Resume":"Pause"}),z.jsx(lu,{label:"Reset chart zoom",onClick:()=>{w(B=>B+1)},children:"Reset zoom"}),z.jsx(lu,{label:"Edit chart",onClick:p,children:"Edit"}),z.jsx(lu,{label:"Duplicate chart",onClick:f,disabled:!c,children:"Duplicate"}),z.jsx(lu,{label:`Move ${n.title} earlier`,onClick:g,disabled:!u,children:"←"}),z.jsx(lu,{label:`Move ${n.title} later`,onClick:v,disabled:!s,children:"→"}),z.jsx(lu,{label:"Delete chart",onClick:d,danger:!0,children:"Delete"})]})]})}),z.jsx("div",{className:"min-w-0 p-3 sm:p-5",children:z.jsx(i3,{data:O.data,series:Y,visualization:n.visualization,zeroBased:lT(O.unit),valueFormatter:W,valueSuffix:nT(O.unit),forceEmpty:!O.hasObservedData,emptyMessage:F},T)}),O.unobservedLabels.length>0&&O.hasObservedData&&z.jsxs("footer",{className:"border-accent/10 text-textMuted border-t px-5 py-2 text-[11px]",children:["Not observed this session: ",O.unobservedLabels.join(", ")]})]})}function lu({label:n,children:a,onClick:u,disabled:s=!1,danger:c=!1}){return z.jsx("button",{type:"button","aria-label":n,onClick:u,disabled:s,className:`rounded px-2 py-1.5 disabled:cursor-not-allowed disabled:opacity-30 ${c?"text-textMuted hover:bg-red-500/10 hover:text-red-300":"text-textMuted hover:text-textPrimary hover:bg-white/5"}`,children:a})}const g3=[{event:0,label:"Header archived"},{event:3,label:"Block archived"},{event:5,label:"Block validated"},{event:6,label:"Block confirmed"},{event:13,label:"Block organized"},{event:14,label:"Block reorganized"}];function v3({adminStatus:n,endpoints:a,metrics:u,native:s}){const c=kE(u,10),d=s.configuration,f=Al(6),p=[n.error?`Admin: ${n.error}`:null,s.status.error?`Native: ${s.status.error}`:null,s.transport==="none"&&s.restError?`Native REST: ${s.restError}`:null,u.invalidFrames>0?`${String(u.invalidFrames)} malformed admin frame${u.invalidFrames===1?"":"s"} ignored`:null].filter(g=>g!==null);return z.jsxs("div",{className:"space-y-8",children:[p.length>0&&z.jsxs("section",{className:"rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3",children:[z.jsx("p",{className:"text-sm font-medium text-amber-300",children:"Transport notice"}),z.jsx("ul",{className:"text-textMuted mt-1 space-y-1 text-xs",children:p.map(g=>z.jsx("li",{children:g},g))})]}),z.jsxs("section",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[z.jsx(oo,{label:"Canonical top",value:s.top===null?"—":ka(s.top),detail:s.transport==="none"?"Waiting for native API":`via ${s.transport==="websocket"?"native WebSocket":"REST fallback"}`,accent:"orange"}),z.jsx(oo,{label:"Current activity",value:c.label,detail:c.rate>0?`${dE(c.rate)} over the last 10 seconds`:"No lifecycle events in the last 10 seconds",accent:"green"}),z.jsx(oo,{label:"Highest confirmed",value:u.signalMaximums[f]===void 0?"—":ka(u.signalMaximums[f]),detail:`${ka(u.signalTotals[f]??0)} confirmations observed`,accent:"blue"}),z.jsx(oo,{label:"Collection uptime",value:fE(u.now-u.sessionStartedAt),detail:`${ka(u.totalEvents)} events · ${ka(u.totalLogs)} logs`,accent:"red"})]}),z.jsxs("section",{className:"grid gap-4 lg:grid-cols-2",children:[z.jsx(Cv,{title:"Admin stream",endpoint:a.adminUrl,status:n,detail:n.lastMessageAt?`Last frame ${Or(n.lastMessageAt)}`:"Waiting for the first frame"}),z.jsx(Cv,{title:"Native interface",endpoint:a.nativeUrl,status:s.status,detail:s.receivedAt?`Last state ${Or(s.receivedAt)} · ${s.transport}`:"Waiting for node state"})]}),z.jsx(m3,{metrics:u}),z.jsxs("section",{className:"grid gap-4 xl:grid-cols-[1.1fr_0.9fr]",children:[z.jsxs("div",{className:"border-accent/20 bg-surface/70 rounded-xl border",children:[z.jsxs("header",{className:"border-accent/15 border-b px-5 py-4",children:[z.jsx("p",{className:"text-accentSecondary text-xs tracking-wide uppercase",children:"Lifecycle heights"}),z.jsx("h2",{className:"mt-1 font-semibold",children:"Highest observed event values"})]}),z.jsx("div",{className:"grid gap-px bg-white/5 sm:grid-cols-2 lg:grid-cols-3",children:g3.map(({event:g,label:v})=>{const x=u.signalMaximums[Al(g)];return z.jsxs("div",{className:"bg-surface px-5 py-4",children:[z.jsx("p",{className:"text-textMuted text-xs",children:v}),z.jsx("p",{className:"text-textPrimary mt-2 font-mono text-lg tabular-nums",children:x===void 0?"—":ka(x)})]},g)})})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 rounded-xl border",children:[z.jsxs("header",{className:"border-accent/15 border-b px-5 py-4",children:[z.jsx("p",{className:"text-accentSecondary text-xs tracking-wide uppercase",children:"Capabilities"}),z.jsx("h2",{className:"mt-1 f)DELIM" -R"DELIM(ont-semibold",children:"Native configuration"})]}),d?z.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-4 p-5 text-sm",children:[z.jsx(is,{label:"Address index",enabled:d.address}),z.jsx(is,{label:"Client filters",enabled:d.filter}),z.jsx(is,{label:"Turbo",enabled:d.turbo}),z.jsx(is,{label:"Witness",enabled:d.witness}),z.jsx(is,{label:"Retarget",enabled:d.retarget}),z.jsx(is,{label:"Difficulty",enabled:d.difficult}),z.jsxs("div",{className:"col-span-2 border-t border-white/5 pt-3",children:[z.jsx("span",{className:"text-textMuted",children:"Pruned below"}),z.jsx("span",{className:"text-textPrimary float-right font-mono",children:d.pruned>0?ka(d.pruned):"Not pruned"})]})]}):z.jsx("p",{className:"text-textMuted px-5 py-10 text-center text-sm",children:"Waiting for native configuration."})]})]}),z.jsx("section",{children:z.jsxs("div",{className:"border-accent/20 bg-surface/70 rounded-xl border",children:[z.jsx("header",{className:"border-accent/15 border-b px-5 py-4",children:z.jsx("p",{className:"text-accentSecondary text-xs tracking-wide uppercase",children:"Recent events"})}),u.recentEvents.length===0?z.jsx(y3,{text:"No events observed yet."}):z.jsx("ul",{className:"divide-y divide-white/5",children:u.recentEvents.slice(0,6).map(g=>z.jsxs("li",{className:"flex items-center gap-3 px-5 py-3 text-xs",children:[z.jsx("time",{className:"text-textMuted w-24 shrink-0 font-mono",children:Or(g.time)}),z.jsx("span",{className:"text-textPrimary min-w-0 flex-1 truncate font-mono",children:cu(g.event).name}),z.jsx("span",{className:"text-accent tabular-nums",children:wy(g.event,g.value)})]},g.id))})]})})]})}function Cv({title:n,endpoint:a,status:u,detail:s}){return z.jsxs("article",{className:"border-accent/20 bg-surface/70 min-w-0 rounded-xl border p-5",children:[z.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-textMuted text-xs tracking-wide uppercase",children:n}),z.jsx("p",{className:"text-textPrimary mt-2 font-mono text-sm break-all",children:hE(a)})]}),z.jsx(LE,{phase:u.phase,label:u.phase})]}),z.jsxs("div",{className:"text-textMuted mt-4 flex flex-wrap justify-between gap-2 border-t border-white/5 pt-3 text-xs",children:[z.jsx("span",{children:s}),z.jsxs("span",{children:[String(u.reconnects)," reconnect",u.reconnects===1?"":"s"]})]})]})}function is({label:n,enabled:a}){return z.jsxs("div",{className:"flex items-center justify-between gap-3",children:[z.jsx("span",{className:"text-textMuted",children:n}),z.jsx("span",{className:a?"text-emerald-300":"text-textMuted",children:a?"Enabled":"Disabled"})]})}function y3({text:n}){return z.jsx("p",{className:"text-textMuted px-5 py-10 text-center text-sm",children:n})}var Hr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(n){return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},b3=class extends Hr{#e;#t;#n;constructor(){super(),this.#n=n=>{if(typeof window<"u"&&window.addEventListener){const a=()=>n();return window.addEventListener("visibilitychange",a,!1),()=>{window.removeEventListener("visibilitychange",a)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(n){this.#n=n,this.#t?.(),this.#t=n(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()})}setFocused(n){this.#e!==n&&(this.#e=n,this.onFocus())}onFocus(){const n=this.isFocused();this.listeners.forEach(a=>{a(n)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Ph=new b3,S3={setTimeout:(n,a)=>setTimeout(n,a),clearTimeout:n=>clearTimeout(n),setInterval:(n,a)=>setInterval(n,a),clearInterval:n=>clearInterval(n)},_3=class{#e=S3;#t=!1;setTimeoutProvider(n){this.#e=n}setTimeout(n,a){return this.#e.setTimeout(n,a)}clearTimeout(n){this.#e.clearTimeout(n)}setInterval(n,a){return this.#e.setInterval(n,a)}clearInterval(n){this.#e.clearInterval(n)}},ru=new _3;function x3(n){setTimeout(n,0)}var z3=typeof window>"u"||"Deno"in globalThis;function Wn(){}function E3(n,a){return typeof n=="function"?n(a):n}function ph(n){return typeof n=="number"&&n>=0&&n!==1/0}function xb(n,a){return Math.max(n+(a||0)-Date.now(),0)}function wi(n,a){return typeof n=="function"?n(a):n}function fl(n,a){return typeof n=="function"?n(a):n}function Rv(n,a){const{type:u="all",exact:s,fetchStatus:c,predicate:d,queryKey:f,stale:p}=n;if(f){if(s){if(a.queryHash!==em(f,a.options))return!1}else if(!vs(a.queryKey,f))return!1}if(u!=="all"){const g=a.isActive();if(u==="active"&&!g||u==="inactive"&&g)return!1}return!(typeof p=="boolean"&&a.isStale()!==p||c&&c!==a.state.fetchStatus||d&&!d(a))}function Uv(n,a){const{exact:u,status:s,predicate:c,mutationKey:d}=n;if(d){if(!a.options.mutationKey)return!1;if(u){if(kr(a.options.mutationKey)!==kr(d))return!1}else if(!vs(a.options.mutationKey,d))return!1}return!(s&&a.state.status!==s||c&&!c(a))}function em(n,a){return(a?.queryKeyHashFn||kr)(n)}function kr(n){return JSON.stringify(n,(a,u)=>vh(u)?Object.keys(u).sort().reduce((s,c)=>(s[c]=u[c],s),{}):u)}function vs(n,a){if(n===a)return!0;if(typeof n!=typeof a)return!1;if(n&&a&&typeof n=="object"&&typeof a=="object"){if(Array.isArray(n)&&Array.isArray(a)){for(let s=0;s500)return a;const s=kv(n)&&kv(a);if(!s&&!(vh(n)&&vh(a)))return a;const d=(s?n:Object.keys(n)).length,f=s?a:Object.keys(a),p=f.length,g=s?new Array(p):{};let v=0;for(let x=0;x{ru.setTimeout(a,n)})}function yh(n,a,u){return typeof u.structuralSharing=="function"?u.structuralSharing(n,a):u.structuralSharing!==!1?zb(n,a):a}function M3(n,a,u=0){const s=[...n,a];return u&&s.length>u?s.slice(1):s}function A3(n,a,u=0){const s=[a,...n];return u&&s.length>u?s.slice(0,-1):s}var tm=Symbol();function Eb(n,a){return!n.queryFn&&a?.initialPromise?()=>a.initialPromise:!n.queryFn||n.queryFn===tm?()=>Promise.reject(new Error(`Missing queryFn: '${n.queryHash}'`)):n.queryFn}function Tb(n,a){return typeof n=="function"?n(...a):!!n}function O3(n,a,u){let s=!1,c;return Object.defineProperty(n,"signal",{enumerable:!0,get:()=>(c??=a(),s||(s=!0,c.aborted?u():c.addEventListener("abort",u,{once:!0})),c)}),n}var Zr=(()=>{let n=()=>z3;return{isServer(){return n()},setIsServer(a){n=a}}})();function bh(){let n,a;const u=new Promise((c,d)=>{n=c,a=d});u.status="pending",u.catch(()=>{});function s(c){Object.assign(u,c),delete u.resolve,delete u.reject}return u.resolve=c=>{s({status:"fulfilled",value:c}),n(c)},u.reject=c=>{s({status:"rejected",reason:c}),a(c)},u}var N3=x3;function j3(){let n=[],a=0,u=p=>{p()},s=p=>{p()},c=N3;const d=p=>{a?n.push(p):c(()=>{u(p)})},f=()=>{const p=n;n=[],p.length&&c(()=>{s(()=>{p.forEach(g=>{u(g)})})})};return{batch:p=>{let g;a++;try{g=p()}finally{a--,a||f()}return g},batchCalls:p=>(...g)=>{d(()=>{p(...g)})},schedule:d,setNotifyFunction:p=>{u=p},setBatchNotifyFunction:p=>{s=p},setScheduler:p=>{c=p}}}var Sn=j3(),D3=c)DELIM" -R"DELIM(lass extends Hr{#e=!0;#t;#n;constructor(){super(),this.#n=n=>{if(typeof window<"u"&&window.addEventListener){const a=()=>n(!0),u=()=>n(!1);return window.addEventListener("online",a,!1),window.addEventListener("offline",u,!1),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",u)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(n){this.#n=n,this.#t?.(),this.#t=n(this.setOnline.bind(this))}setOnline(n){this.#e!==n&&(this.#e=n,this.listeners.forEach(u=>{u(n)}))}isOnline(){return this.#e}},Ao=new D3;function C3(n){return Math.min(1e3*2**n,3e4)}function wb(n){return(n??"online")==="online"?Ao.isOnline():!0}var Sh=class extends Error{constructor(n){super("CancelledError"),this.revert=n?.revert,this.silent=n?.silent}};function Mb(n){let a=!1,u=0,s;const c=bh(),d=()=>c.status!=="pending",f=Y=>{if(!d()){const W=new Sh(Y);T(W),n.onCancel?.(W)}},p=()=>{a=!0},g=()=>{a=!1},v=()=>Ph.isFocused()&&(n.networkMode==="always"||Ao.isOnline())&&n.canRun(),x=()=>wb(n.networkMode)&&n.canRun(),S=Y=>{d()||(s?.(),c.resolve(Y))},T=Y=>{d()||(s?.(),c.reject(Y))},w=()=>new Promise(Y=>{s=W=>{(d()||v())&&Y(W)},n.onPause?.()}).then(()=>{s=void 0,d()||n.onContinue?.()}),O=()=>{if(d())return;let Y;const W=u===0?n.initialPromise:void 0;try{Y=W??n.fn()}catch(F){Y=Promise.reject(F)}Promise.resolve(Y).then(S).catch(F=>{if(d())return;const B=n.retry??(Zr.isServer()?0:3),I=n.retryDelay??C3,q=typeof I=="function"?I(u,F):I,ae=B===!0||typeof B=="number"&&uv()?void 0:w()).then(()=>{a?T(F):O()})})};return{promise:c,status:()=>c.status,cancel:f,continue:()=>(s?.(),c),cancelRetry:p,continueRetry:g,canStart:x,start:()=>(x()?O():w().then(O),c)}}var Ab=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ph(this.gcTime)&&(this.#e=ru.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(n){this.gcTime=Math.max(this.gcTime||0,n??(Zr.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(ru.clearTimeout(this.#e),this.#e=void 0)}};function R3(n){return{onFetch:(a,u)=>{const s=a.options,c=a.fetchOptions?.meta?.fetchMore?.direction,d=a.state.data?.pages||[],f=a.state.data?.pageParams||[];let p={pages:[],pageParams:[]},g=0;const v=async()=>{let x=!1;const S=O=>{O3(O,()=>a.signal,()=>x=!0)},T=Eb(a.options,a.fetchOptions),w=async(O,Y,W)=>{if(x)return Promise.reject(a.signal.reason);if(Y==null&&O.pages.length)return Promise.resolve(O);const B=(()=>{const ne={client:a.client,queryKey:a.queryKey,pageParam:Y,direction:W?"backward":"forward",meta:a.options.meta};return S(ne),ne})(),I=await T(B),{maxPages:q}=a.options,ae=W?A3:M3;return{pages:ae(O.pages,I,q),pageParams:ae(O.pageParams,Y,q)}};if(c&&d.length){const O=c==="backward",Y=O?U3:Lv,W={pages:d,pageParams:f},F=Y(s,W);p=await w(W,F,O)}else{const O=n??d.length;do{const Y=g===0?f[0]??s.initialPageParam:Lv(s,p);if(g>0&&Y==null)break;p=await w(p,Y),g++}while(ga.options.persister?.(v,{client:a.client,queryKey:a.queryKey,meta:a.options.meta,signal:a.signal},u):a.fetchFn=v}}}function Lv(n,{pages:a,pageParams:u}){const s=a.length-1;return a.length>0?n.getNextPageParam(a[s],a,u[s],u):void 0}function U3(n,{pages:a,pageParams:u}){return a.length>0?n.getPreviousPageParam?.(a[0],a,u[0],u):void 0}var k3=class extends Ab{#e;#t;#n;#l;#a;#i;#s;#u;constructor(n){super(),this.#u=!1,this.#s=n.defaultOptions,this.setOptions(n.options),this.observers=[],this.#a=n.client,this.#l=this.#a.getQueryCache(),this.queryKey=n.queryKey,this.queryHash=n.queryHash,this.#t=Bv(this.options),this.state=n.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(n){if(this.options={...this.#s,...n},n?._type&&(this.#e=n._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const a=Bv(this.options);a.data!==void 0&&(this.setState(Hv(a.data,a.dataUpdatedAt)),this.#t=a)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#l.remove(this)}setData(n,a){const u=yh(this.state.data,n,this.options);return this.#r({data:u,type:"success",dataUpdatedAt:a?.updatedAt,manual:a?.manual}),u}setState(n){this.#r({type:"setState",state:n})}cancel(n){const a=this.#i?.promise;return this.#i?.cancel(n),a?a.then(Wn).catch(Wn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(n=>fl(n.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===tm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(n=>wi(n.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(n=>n.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(n=0){return this.state.data===void 0?!0:n==="static"?!1:this.state.isInvalidated?!0:!xb(this.state.dataUpdatedAt,n)}onFocus(){this.observers.find(a=>a.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(a=>a.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(n){this.observers.includes(n)||(this.observers.push(n),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",query:this,observer:n}))}removeObserver(n){this.observers.includes(n)&&(this.observers=this.observers.filter(a=>a!==n),this.observers.length||(this.#i&&(this.#u||this.#c()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:n}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#r({type:"invalidate"})}async fetch(n,a){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&a?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(n&&this.setOptions(n),!this.options.queryFn){const g=this.observers.find(v=>v.options.queryFn);g&&this.setOptions(g.options)}const u=new AbortController,s=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(this.#u=!0,u.signal)})},c=()=>{const g=Eb(this.options,a),x=(()=>{const S={client:this.#a,queryKey:this.queryKey,meta:this.meta};return s(S),S})();return this.#u=!1,this.options.persister?this.options.persister(g,x,this):g(x)},f=(()=>{const g={fetchOptions:a,options:this.options,queryKey:this.queryKey,client:this.#a,state:this.state,fetchFn:c};return s(g),g})();(this.#e==="infinite"?R3(this.options.pages):this.options.behavior)?.onFetch(f,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==f.fetchOptions?.meta)&&this.#r({type:"fetch",meta:f.fetchOptions?.meta}),this.#i=Mb({initialPromise:a?.initialPromise,fn:f.fetchFn,onCancel:g=>{g instanceof Sh&&g.revert&&this.setState({...this.#n,fetchStatus:"idle"}),u.abort()},onFail:(g,v)=>{this.#r({type:"failed",failureCount:g,error:v})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:f.options.retry,retryDelay:f.options.retryDelay,networkMode:f.options.networkMode,canRun:()=>!0});try{const g=await this.#i.start();if(g===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(g),this.#l.config.onSuccess?.(g,this),this.#l.config.onSettled?.(g,this.state.error,this),g}catch(g){if(g instanceof Sh){if(g.silent)return this.#i.promise;if(g.revert){if(this.state.data===void 0)throw g;return this.state.data}}throw this.#r({type:"error",error:g}),this.#l.config.onError?.(g,this),this.#)DELIM" -R"DELIM(l.config.onSettled?.(this.state.data,g,this),g}finally{this.scheduleGc()}}#r(n){const a=u=>{switch(n.type){case"failed":return{...u,fetchFailureCount:n.failureCount,fetchFailureReason:n.error};case"pause":return{...u,fetchStatus:"paused"};case"continue":return{...u,fetchStatus:"fetching"};case"fetch":return{...u,...Ob(u.data,this.options),fetchMeta:n.meta??null};case"success":const s={...u,...Hv(n.data,n.dataUpdatedAt),dataUpdateCount:u.dataUpdateCount+1,...!n.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=n.manual?s:void 0,s;case"error":const c=n.error;return{...u,error:c,errorUpdateCount:u.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:u.fetchFailureCount+1,fetchFailureReason:c,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...u,isInvalidated:!0};case"setState":return{...u,...n.state}}};this.state=a(this.state),Sn.batch(()=>{this.observers.forEach(u=>{u.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:n})})}};function Ob(n,a){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:wb(a.networkMode)?"fetching":"paused",...n===void 0&&{error:null,status:"pending"}}}function Hv(n,a){return{data:n,dataUpdatedAt:a??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Bv(n){const a=typeof n.initialData=="function"?n.initialData():n.initialData,u=a!==void 0,s=u?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:a,dataUpdateCount:0,dataUpdatedAt:u?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:u?"success":"pending",fetchStatus:"idle"}}var Z3=class extends Hr{constructor(n,a){super(),this.options=a,this.#e=n,this.#u=null,this.#s=bh(),this.bindMethods(),this.setOptions(a)}#e;#t=void 0;#n=void 0;#l=void 0;#a;#i;#s;#u;#c;#r;#d;#h;#f;#m;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),qv(this.#t,this.options)?this.#o():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return _h(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return _h(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#p(),this.#t.removeObserver(this)}setOptions(n){const a=this.options,u=this.#t;if(this.options=this.#e.defaultQueryOptions(n),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof fl(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#y(),this.#t.setOptions(this.options),a._defaulted&&!gh(this.options,a)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const s=this.hasListeners();s&&Gv(this.#t,u,this.options,a)&&this.#o(),this.updateResult(),s&&(this.#t!==u||fl(this.options.enabled,this.#t)!==fl(a.enabled,this.#t)||wi(this.options.staleTime,this.#t)!==wi(a.staleTime,this.#t))&&this.#b();const c=this.#S();s&&(this.#t!==u||fl(this.options.enabled,this.#t)!==fl(a.enabled,this.#t)||c!==this.#m)&&this.#_(c)}getOptimisticResult(n){const a=this.#e.getQueryCache().build(this.#e,n),u=this.createResult(a,n);return H3(this,u)&&(this.#l=u,this.#i=this.options,this.#a=this.#t.state),u}getCurrentResult(){return this.#l}trackResult(n,a){return new Proxy(n,{get:(u,s)=>(this.trackProp(s),a?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#s.status==="pending"&&this.#s.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(u,s))})}trackProp(n){this.#g.add(n)}getCurrentQuery(){return this.#t}refetch({...n}={}){return this.fetch({...n})}fetchOptimistic(n){const a=this.#e.defaultQueryOptions(n),u=this.#e.getQueryCache().build(this.#e,a);return u.fetch().then(()=>this.createResult(u,a))}fetch(n){return this.#o({...n,cancelRefetch:n.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#l))}#o(n){this.#y();let a=this.#t.fetch(this.options,n);return n?.throwOnError||(a=a.catch(Wn)),a}#b(){this.#v();const n=wi(this.options.staleTime,this.#t);if(Zr.isServer()||this.#l.isStale||!ph(n))return;const u=xb(this.#l.dataUpdatedAt,n)+1;this.#h=ru.setTimeout(()=>{this.#l.isStale||this.updateResult()},u)}#S(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#_(n){this.#p(),this.#m=n,!(Zr.isServer()||fl(this.options.enabled,this.#t)===!1||!ph(this.#m)||this.#m===0)&&(this.#f=ru.setInterval(()=>{(this.options.refetchIntervalInBackground||Ph.isFocused())&&this.#o()},this.#m))}#x(){this.#b(),this.#_(this.#S())}#v(){this.#h!==void 0&&(ru.clearTimeout(this.#h),this.#h=void 0)}#p(){this.#f!==void 0&&(ru.clearInterval(this.#f),this.#f=void 0)}createResult(n,a){const u=this.#t,s=this.options,c=this.#l,d=this.#a,f=this.#i,g=n!==u?n.state:this.#n,{state:v}=n;let x={...v},S=!1,T;if(a._optimisticResults){const se=this.hasListeners(),Ae=!se&&qv(n,a),ze=se&&Gv(n,u,a,s);(Ae||ze)&&(x={...x,...Ob(v.data,n.options)}),a._optimisticResults==="isRestoring"&&(x.fetchStatus="idle")}let{error:w,errorUpdatedAt:O,status:Y}=x;T=x.data;let W=!1;if(a.placeholderData!==void 0&&T===void 0&&Y==="pending"){let se;c?.isPlaceholderData&&a.placeholderData===f?.placeholderData?(se=c.data,W=!0):se=typeof a.placeholderData=="function"?a.placeholderData(this.#d?.state.data,this.#d):a.placeholderData,se!==void 0&&(Y="success",T=yh(c?.data,se,a),S=!0)}if(a.select&&T!==void 0&&!W)if(c&&T===d?.data&&a.select===this.#c)T=this.#r;else try{this.#c=a.select,T=a.select(T),T=yh(c?.data,T,a),this.#r=T,this.#u=null}catch(se){this.#u=se}this.#u&&(w=this.#u,T=this.#r,O=Date.now(),Y="error");const F=x.fetchStatus==="fetching",B=Y==="pending",I=Y==="error",q=B&&F,ae=T!==void 0,le={status:Y,fetchStatus:x.fetchStatus,isPending:B,isSuccess:Y==="success",isError:I,isInitialLoading:q,isLoading:q,data:T,dataUpdatedAt:x.dataUpdatedAt,error:w,errorUpdatedAt:O,failureCount:x.fetchFailureCount,failureReason:x.fetchFailureReason,errorUpdateCount:x.errorUpdateCount,isFetched:n.isFetched(),isFetchedAfterMount:x.dataUpdateCount>g.dataUpdateCount||x.errorUpdateCount>g.errorUpdateCount,isFetching:F,isRefetching:F&&!B,isLoadingError:I&&!ae,isPaused:x.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:I&&ae,isStale:nm(n,a),refetch:this.refetch,promise:this.#s,isEnabled:fl(a.enabled,n)!==!1};if(this.options.experimental_prefetchInRender){const se=le.data!==void 0,Ae=le.status==="error"&&!se,ze=ce=>{Ae?ce.reject(le.error):se&&ce.resolve(le.data)},ee=()=>{const ce=this.#s=le.promise=bh();ze(ce)},ye=this.#s;switch(ye.status){case"pending":n.queryHash===u.queryHash&&ze(ye);break;case"fulfilled":(Ae||le.data!==ye.value)&&ee();break;case"rejected":(!Ae||le.error!==ye.reason)&&ee();break}}return le}updateResult(){const n=this.#l,a=this.createResult(this.#t,this.options);if(this.#a=this.#t.state,this.#i=this.options,this.#a.data!==void 0&&(this.#d=this.#t),gh(a,n))return;this.#l=a;const u=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,c=typeof s=="function"?s():s;if(c==="all"||!c&&!this.#g.size)return!0;const d=new Set(c??this.#g);return this.options.throwOnError&&d.add("error"),Object.keys(this.#l).some(f=>{const p=f;return this.#l[p]!==n[p]&&d.has(p)})};this.#z({listeners:u()})}#y(){const n=this.#e.getQueryCache().build(this.#e,this.options);if(n===this.#t)return;const a=this.#t;this.#t=n,this.#n=n.state,this.hasListeners()&&(a?.removeObserver(this),n.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#z(n){Sn.batch(()=>{n.listeners&&this.listeners.forEach(a=>{a(this.#l)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function L3(n,a){return fl(a.enabled,n)!==!1&&n.)DELIM" -R"DELIM(state.data===void 0&&!(n.state.status==="error"&&fl(a.retryOnMount,n)===!1)}function qv(n,a){return L3(n,a)||n.state.data!==void 0&&_h(n,a,a.refetchOnMount)}function _h(n,a,u){if(fl(a.enabled,n)!==!1&&wi(a.staleTime,n)!=="static"){const s=typeof u=="function"?u(n):u;return s==="always"||s!==!1&&nm(n,a)}return!1}function Gv(n,a,u,s){return(n!==a||fl(s.enabled,n)===!1)&&(!u.suspense||n.state.status!=="error")&&nm(n,u)}function nm(n,a){return fl(a.enabled,n)!==!1&&n.isStaleByTime(wi(a.staleTime,n))}function H3(n,a){return!gh(n.getCurrentResult(),a)}var B3=class extends Ab{#e;#t;#n;#l;constructor(n){super(),this.#e=n.client,this.mutationId=n.mutationId,this.#n=n.mutationCache,this.#t=[],this.state=n.state||q3(),this.setOptions(n.options),this.scheduleGc()}setOptions(n){this.options=n,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(n){this.#t.includes(n)||(this.#t.push(n),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:n}))}removeObserver(n){this.#t=this.#t.filter(a=>a!==n),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:n})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#l?.continue()??this.execute(this.state.variables)}async execute(n){const a=()=>{this.#a({type:"continue"})},u={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#l=Mb({fn:()=>this.options.mutationFn?this.options.mutationFn(n,u):Promise.reject(new Error("No mutationFn found")),onFail:(d,f)=>{this.#a({type:"failed",failureCount:d,error:f})},onPause:()=>{this.#a({type:"pause"})},onContinue:a,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const s=this.state.status==="pending",c=!this.#l.canStart();try{if(s)a();else{this.#a({type:"pending",variables:n,isPaused:c}),this.#n.config.onMutate&&await this.#n.config.onMutate(n,this,u);const f=await this.options.onMutate?.(n,u);f!==this.state.context&&this.#a({type:"pending",context:f,variables:n,isPaused:c})}const d=await this.#l.start();return await this.#n.config.onSuccess?.(d,n,this.state.context,this,u),await this.options.onSuccess?.(d,n,this.state.context,u),await this.#n.config.onSettled?.(d,null,this.state.variables,this.state.context,this,u),await this.options.onSettled?.(d,null,n,this.state.context,u),this.#a({type:"success",data:d}),d}catch(d){try{await this.#n.config.onError?.(d,n,this.state.context,this,u)}catch(f){Promise.reject(f)}try{await this.options.onError?.(d,n,this.state.context,u)}catch(f){Promise.reject(f)}try{await this.#n.config.onSettled?.(void 0,d,this.state.variables,this.state.context,this,u)}catch(f){Promise.reject(f)}try{await this.options.onSettled?.(void 0,d,n,this.state.context,u)}catch(f){Promise.reject(f)}throw this.#a({type:"error",error:d}),d}finally{this.#n.runNext(this)}}#a(n){const a=u=>{switch(n.type){case"failed":return{...u,failureCount:n.failureCount,failureReason:n.error};case"pause":return{...u,isPaused:!0};case"continue":return{...u,isPaused:!1};case"pending":return{...u,context:n.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:n.isPaused,status:"pending",variables:n.variables,submittedAt:Date.now()};case"success":return{...u,data:n.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...u,data:void 0,error:n.error,failureCount:u.failureCount+1,failureReason:n.error,isPaused:!1,status:"error"}}};this.state=a(this.state),Sn.batch(()=>{this.#t.forEach(u=>{u.onMutationUpdate(n)}),this.#n.notify({mutation:this,type:"updated",action:n})})}};function q3(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var G3=class extends Hr{constructor(n={}){super(),this.config=n,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(n,a,u){const s=new B3({client:n,mutationCache:this,mutationId:++this.#n,options:n.defaultMutationOptions(a),state:u});return this.add(s),s}add(n){this.#e.add(n);const a=po(n);if(typeof a=="string"){const u=this.#t.get(a);u?u.push(n):this.#t.set(a,[n])}this.notify({type:"added",mutation:n})}remove(n){if(this.#e.delete(n)){const a=po(n);if(typeof a=="string"){const u=this.#t.get(a);if(u)if(u.length>1){const s=u.indexOf(n);s!==-1&&u.splice(s,1)}else u[0]===n&&this.#t.delete(a)}}this.notify({type:"removed",mutation:n})}canRun(n){const a=po(n);if(typeof a=="string"){const s=this.#t.get(a)?.find(c=>c.state.status==="pending");return!s||s===n}else return!0}runNext(n){const a=po(n);return typeof a=="string"?this.#t.get(a)?.find(s=>s!==n&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Sn.batch(()=>{this.#e.forEach(n=>{this.notify({type:"removed",mutation:n})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(n){const a={exact:!0,...n};return this.getAll().find(u=>Uv(a,u))}findAll(n={}){return this.getAll().filter(a=>Uv(n,a))}notify(n){Sn.batch(()=>{this.listeners.forEach(a=>{a(n)})})}resumePausedMutations(){const n=this.getAll().filter(a=>a.state.isPaused);return Sn.batch(()=>Promise.all(n.map(a=>a.continue().catch(Wn))))}};function po(n){return n.options.scope?.id}var Q3=class extends Hr{constructor(n={}){super(),this.config=n,this.#e=new Map}#e;build(n,a,u){const s=a.queryKey,c=a.queryHash??em(s,a);let d=this.get(c);return d||(d=new k3({client:n,queryKey:s,queryHash:c,options:n.defaultQueryOptions(a),state:u,defaultOptions:n.getQueryDefaults(s)}),this.add(d)),d}add(n){this.#e.has(n.queryHash)||(this.#e.set(n.queryHash,n),this.notify({type:"added",query:n}))}remove(n){const a=this.#e.get(n.queryHash);a&&(n.destroy(),a===n&&this.#e.delete(n.queryHash),this.notify({type:"removed",query:n}))}clear(){Sn.batch(()=>{this.getAll().forEach(n=>{this.remove(n)})})}get(n){return this.#e.get(n)}getAll(){return[...this.#e.values()]}find(n){const a={exact:!0,...n};return this.getAll().find(u=>Rv(a,u))}findAll(n={}){const a=this.getAll();return Object.keys(n).length>0?a.filter(u=>Rv(n,u)):a}notify(n){Sn.batch(()=>{this.listeners.forEach(a=>{a(n)})})}onFocus(){Sn.batch(()=>{this.getAll().forEach(n=>{n.onFocus()})})}onOnline(){Sn.batch(()=>{this.getAll().forEach(n=>{n.onOnline()})})}},Y3=class{#e;#t;#n;#l;#a;#i;#s;#u;constructor(n={}){this.#e=n.queryCache||new Q3,this.#t=n.mutationCache||new G3,this.#n=n.defaultOptions||{},this.#l=new Map,this.#a=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#s=Ph.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#u=Ao.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#s?.(),this.#s=void 0,this.#u?.(),this.#u=void 0)}isFetching(n){return this.#e.findAll({...n,fetchStatus:"fetching"}).length}isMutating(n){return this.#t.findAll({...n,status:"pending"}).length}getQueryData(n){const a=this.defaultQueryOptions({queryKey:n});return this.#e.get(a.queryHash)?.state.data}ensureQueryData(n){const a=this.defaultQueryOptions(n),u=this.#e.build(this,a),s=u.state.data;return s===void 0?this.fetchQuery(n):(n.revalidateIfStale&&u.isStaleByTime(wi(a.staleTime,u))&&this.prefetchQuery(a),Promise.resolve(s))}getQueriesData(n){return this.#e.findAll(n).map(({queryKey:a,state:u})=>{const s=u.data;return[a,s]})}setQueryData(n,a,u){const s=this.defaultQueryOptions({queryKey:n}),d=this.#e.get(s.queryHash)?.state.data,f=E3(a,d);if(f!==void 0)return this.#e.build(this,s).setData(f,{...u,manual:!0})}setQueriesData(n,a,u){return Sn.batch(()=>this.#e.findAll(n).map(({queryKey:s})=>[s,this.setQueryData(s,a,u)]))}getQueryState(n){const a=this.defaultQueryOptions({queryKey:n});return this.#e.get(a.queryHash)?.state}removeQueries(n){const a=this.#e;Sn.batch(()=>{a.findAll(n).forEach(u=>{a.remove(u)})})}resetQueries(n,a){const u=this.#e;return Sn.batch(()=>(u.findAll(n).forEach(s=>{s.reset()}))DELIM" -R"DELIM(,this.refetchQueries({type:"active",...n},a)))}cancelQueries(n,a={}){const u={revert:!0,...a},s=Sn.batch(()=>this.#e.findAll(n).map(c=>c.cancel(u)));return Promise.all(s).then(Wn).catch(Wn)}invalidateQueries(n,a={}){return Sn.batch(()=>(this.#e.findAll(n).forEach(u=>{u.invalidate()}),n?.refetchType==="none"?Promise.resolve():this.refetchQueries({...n,type:n?.refetchType??n?.type??"active"},a)))}refetchQueries(n,a={}){const u={...a,cancelRefetch:a.cancelRefetch??!0},s=Sn.batch(()=>this.#e.findAll(n).filter(c=>!c.isDisabled()&&!c.isStatic()).map(c=>{let d=c.fetch(void 0,u);return u.throwOnError||(d=d.catch(Wn)),c.state.fetchStatus==="paused"?Promise.resolve():d}));return Promise.all(s).then(Wn)}fetchQuery(n){const a=this.defaultQueryOptions(n);a.retry===void 0&&(a.retry=!1);const u=this.#e.build(this,a);return u.isStaleByTime(wi(a.staleTime,u))?u.fetch(a):Promise.resolve(u.state.data)}prefetchQuery(n){return this.fetchQuery(n).then(Wn).catch(Wn)}fetchInfiniteQuery(n){return n._type="infinite",this.fetchQuery(n)}prefetchInfiniteQuery(n){return this.fetchInfiniteQuery(n).then(Wn).catch(Wn)}ensureInfiniteQueryData(n){return n._type="infinite",this.ensureQueryData(n)}resumePausedMutations(){return Ao.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(n){this.#n=n}setQueryDefaults(n,a){this.#l.set(kr(n),{queryKey:n,defaultOptions:a})}getQueryDefaults(n){const a=[...this.#l.values()],u={};return a.forEach(s=>{vs(n,s.queryKey)&&Object.assign(u,s.defaultOptions)}),u}setMutationDefaults(n,a){this.#a.set(kr(n),{mutationKey:n,defaultOptions:a})}getMutationDefaults(n){const a=[...this.#a.values()],u={};return a.forEach(s=>{vs(n,s.mutationKey)&&Object.assign(u,s.defaultOptions)}),u}defaultQueryOptions(n){if(n._defaulted)return n;const a={...this.#n.queries,...this.getQueryDefaults(n.queryKey),...n,_defaulted:!0};return a.queryHash||(a.queryHash=em(a.queryKey,a)),a.refetchOnReconnect===void 0&&(a.refetchOnReconnect=a.networkMode!=="always"),a.throwOnError===void 0&&(a.throwOnError=!!a.suspense),!a.networkMode&&a.persister&&(a.networkMode="offlineFirst"),a.queryFn===tm&&(a.enabled=!1),a}defaultMutationOptions(n){return n?._defaulted?n:{...this.#n.mutations,...n?.mutationKey&&this.getMutationDefaults(n.mutationKey),...n,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Nb=_e.createContext(void 0),$3=n=>{const a=_e.useContext(Nb);if(!a)throw new Error("No QueryClient set, use QueryClientProvider to set one");return a},V3=({client:n,children:a})=>(_e.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]),z.jsx(Nb.Provider,{value:n,children:a})),jb=_e.createContext(!1),K3=()=>_e.useContext(jb);jb.Provider;function X3(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}var J3=_e.createContext(X3()),F3=()=>_e.useContext(J3),W3=(n,a,u)=>{const s=u?.state.error&&typeof n.throwOnError=="function"?Tb(n.throwOnError,[u.state.error,u]):n.throwOnError;(n.suspense||n.experimental_prefetchInRender||s)&&(a.isReset()||(n.retryOnMount=!1))},I3=n=>{_e.useEffect(()=>{n.clearReset()},[n])},P3=({result:n,errorResetBoundary:a,throwOnError:u,query:s,suspense:c})=>n.isError&&!a.isReset()&&!n.isFetching&&s&&(c&&n.data===void 0||Tb(u,[n.error,s])),eM=n=>{if(n.suspense){const u=c=>c==="static"?c:Math.max(c??1e3,1e3),s=n.staleTime;n.staleTime=typeof s=="function"?(...c)=>u(s(...c)):u(s),typeof n.gcTime=="number"&&(n.gcTime=Math.max(n.gcTime,1e3))}},tM=(n,a)=>n.isLoading&&n.isFetching&&!a,nM=(n,a)=>n?.suspense&&a.isPending,Qv=(n,a,u)=>a.fetchOptimistic(n).catch(()=>{u.clearReset()});function lM(n,a,u){const s=K3(),c=F3(),d=$3(),f=d.defaultQueryOptions(n);d.getDefaultOptions().queries?._experimental_beforeQuery?.(f);const p=d.getQueryCache().get(f.queryHash),g=n.subscribed!==!1;f._optimisticResults=s?"isRestoring":g?"optimistic":void 0,eM(f),W3(f,c,p),I3(c);const v=!d.getQueryCache().get(f.queryHash),[x]=_e.useState(()=>new a(d,f)),S=x.getOptimisticResult(f),T=!s&&g;if(_e.useSyncExternalStore(_e.useCallback(w=>{const O=T?x.subscribe(Sn.batchCalls(w)):Wn;return x.updateResult(),O},[x,T]),()=>x.getCurrentResult(),()=>x.getCurrentResult()),_e.useEffect(()=>{x.setOptions(f)},[f,x]),nM(f,S))throw Qv(f,x,c);if(P3({result:S,errorResetBoundary:c,throwOnError:f.throwOnError,query:p,suspense:f.suspense}))throw S.error;return d.getDefaultOptions().queries?._experimental_afterQuery?.(f,S),f.experimental_prefetchInRender&&!Zr.isServer()&&tM(S,s)&&(v?Qv(f,x,c):p?.promise)?.catch(Wn).finally(()=>{x.updateResult()}),f.notifyOnChangeProps?S:x.trackResult(S)}function aM(n,a){return lM(n,Z3)}const Yv={phase:"idle",attempt:0,reconnects:0,connectedAt:null,lastMessageAt:null,error:null};class Db{#e;#t=Yv;#n=null;#l=new Set;#a=null;#i=null;#s=null;#u;#c=!1;constructor(a){this.#e={...a,connectTimeoutMs:a.connectTimeoutMs??5e3,retryMinimumMs:a.retryMinimumMs??1e3,retryMaximumMs:a.retryMaximumMs??3e4,heartbeatMs:a.heartbeatMs??24e4,jitterRatio:a.jitterRatio??.2,now:a.now??Date.now,random:a.random??Math.random,webSocketFactory:a.webSocketFactory??(u=>new WebSocket(u))},this.#u=this.#e.retryMinimumMs}getStatus=()=>this.#t;subscribeStatus=a=>(this.#l.add(a),()=>{this.#l.delete(a)});start(){this.#c||(this.#c=!0,this.#u=this.#e.retryMinimumMs,this.#r())}stop(){this.#c=!1,this.#g();const a=this.#n;if(this.#n=null,a)try{a.readyState===1&&this.#e.onBeforeStop?.(a),a.close()}catch{}this.#o(Yv)}send(a){if(this.#n?.readyState!==1)return!1;try{return this.#n.send(a),!0}catch{return!1}}#r(){if(!this.#c||this.#n)return;const a=this.#t.reconnects>0;this.#o({...this.#t,phase:a?"reconnecting":"connecting",attempt:this.#t.attempt+1,error:null});let u;try{u=this.#e.webSocketFactory(this.#e.url),this.#n=u}catch(s){this.#o({...this.#t,error:uM(s)}),this.#d();return}this.#a=setTimeout(()=>{if(this.#n===u){this.#o({...this.#t,error:"Connection timed out"});try{u.close()}catch{this.#n=null,this.#d()}}},this.#e.connectTimeoutMs),u.addEventListener("open",()=>{this.#n!==u||!this.#c||(this.#f(),this.#u=this.#e.retryMinimumMs,this.#o({...this.#t,phase:"connected",connectedAt:this.#e.now(),error:null}),this.#e.onOpen?.(u),this.#h(u))}),u.addEventListener("message",s=>{if(this.#n!==u||!this.#c)return;const c=iM(s.data);if(c===null)return;const d=this.#e.now();(this.#t.lastMessageAt===null||d-this.#t.lastMessageAt>=1e3)&&this.#o({...this.#t,lastMessageAt:d}),this.#e.onMessage(c)}),u.addEventListener("error",()=>{if(!(this.#n!==u||!this.#c)){this.#o({...this.#t,error:"WebSocket connection failed"});try{u.close()}catch{this.#n=null,this.#d()}}}),u.addEventListener("close",()=>{this.#n===u&&(this.#n=null,this.#f(),this.#m(),this.#c&&this.#d())})}#d(){if(!this.#c||this.#i)return;const a=1+(this.#e.random()*2-1)*this.#e.jitterRatio,u=Math.max(0,Math.round(this.#u*a));this.#u=Math.min(this.#u*2,this.#e.retryMaximumMs),this.#o({...this.#t,phase:"reconnecting",reconnects:this.#t.reconnects+1,connectedAt:null}),this.#i=setTimeout(()=>{this.#i=null,this.#r()},u)}#h(a){this.#m(),!(!this.#e.onHeartbeat||this.#e.heartbeatMs<=0)&&(this.#s=setInterval(()=>{this.#n===a&&a.readyState===1&&this.#e.onHeartbeat?.(a)},this.#e.heartbeatMs))}#f(){this.#a&&(clearTimeout(this.#a),this.#a=null)}#m(){this.#s&&(clearInterval(this.#s),this.#s=null)}#g(){this.#f(),this.#m(),this.#i&&(clearTimeout(this.#i),this.#i=null)}#o(a){this.#t=a;for(const u of this.#l)u()}}function iM(n){return typeof n=="string"?n:n instanceof ArrayBuffer?new TextDecoder().decode(n):null}function uM(n){return n instanceof Error?n.message:"Unable to create WebSocket"}class sM{#e;#t;#n=new Set;#l=new Set;#a;constructor(a,u={}){this.#e=u.logFilter??lE,this.#t=u.eventFilter??aE,this.#a=new Db({url:Jv(a),webSocketFactory:u.webSocketFactory,retryMinimumMs:u.retryMinimumMs,retryMaximumMs:u.retryMaximumMs,jitterRatio:u.jitterRatio,onOpen:s=>{this.#i(s)},onHeartbeat:s=>{this.#i(s)},onBeforeStop:s=>{s.send("/v1/log/subscribe?filter=0"),s.send("/v1/event/subscribe?filter=)DELIM" -R"DELIM(0")},onMessage:s=>{const c=rE(s);if(!c){for(const d of this.#l)d(s);return}for(const d of this.#n)d(c)}})}getStatus=()=>this.#a.getStatus();subscribeStatus=a=>this.#a.subscribeStatus(a);start(){this.#a.start()}stop(){this.#a.stop()}subscribeFrames(a){return this.#n.add(a),()=>{this.#n.delete(a)}}subscribeInvalidFrames(a){return this.#l.add(a),()=>{this.#l.delete(a)}}setFilters(a,u){this.#e=a,this.#t=u,this.#a.send(`/v1/log/subscribe?filter=${String(a)}`),this.#a.send(`/v1/event/subscribe?filter=${String(u)}`)}#i(a){a.send(`/v1/log/subscribe?filter=${String(this.#e)}`),a.send(`/v1/event/subscribe?filter=${String(this.#t)}`)}}const Cb=pu({address:ls(),filter:ls(),turbo:ls(),witness:ls(),retarget:ls(),difficult:ls(),pruned:Ti().int().nonnegative()}),Rb=Ti().int().nonnegative();function rM(n){try{const a=JSON.parse(n),u=Cb.safeParse(a);if(u.success)return{type:"configuration",payload:u.data};const s=Rb.safeParse(a);return s.success?{type:"top",payload:s.data}:null}catch{return null}}function $v(n,a){return new URL(a,`${n.replace(/\/+$/u,"")}/`).toString()}async function Vv(n,a){const u=await fetch(n,{headers:{Accept:"application/json"},signal:a});if(!u.ok)throw new Error(`Native API request failed with status ${String(u.status)}`);return await u.json()}async function cM(n,a){const[u,s]=await Promise.all([Vv($v(n,"/v1/configuration?format=json"),a),Vv($v(n,"/v1/top?format=json"),a)]),c=Cb.parse(u),d=Rb.parse(s);return{configuration:c,top:d,receivedAt:Date.now()}}const oM=15e3,fM={configuration:null,top:null,receivedAt:null,invalidFrames:0};class dM{#e=fM;#t=new Set;#n;#l;constructor(a,u={}){this.#l=u.now??Date.now,this.#n=new Db({url:Jv(a),webSocketFactory:u.webSocketFactory,retryMinimumMs:u.retryMinimumMs,retryMaximumMs:u.retryMaximumMs,jitterRatio:u.jitterRatio,heartbeatMs:u.topPollIntervalMs??oM,now:this.#l,onOpen:s=>{s.send("/v1/configuration?format=json"),s.send("/v1/top/subscribe?format=json")},onHeartbeat:s=>{s.send("/v1/top?format=json")},onBeforeStop:s=>{s.send("/v1/top/subscribe?format=json&stop=true")},onMessage:s=>{const c=rM(s);if(!c){this.#i({...this.#e,invalidFrames:this.#e.invalidFrames+1});return}this.#a(c)}})}getStatus=()=>this.#n.getStatus();subscribeStatus=a=>this.#n.subscribeStatus(a);getState=()=>this.#e;subscribeState=a=>(this.#t.add(a),()=>{this.#t.delete(a)});start(){this.#n.start()}stop(){this.#n.stop()}#a(a){const u=this.#l();this.#i(a.type==="top"?{...this.#e,top:a.payload,receivedAt:u}:{...this.#e,configuration:a.payload,receivedAt:u})}#i(a){this.#e=a;for(const u of this.#t)u()}}function hM(n,a){const u=_e.useMemo(()=>new sM(n),[n]),s=_e.useSyncExternalStore(u.subscribeStatus,u.getStatus,u.getStatus);return _e.useEffect(()=>{const c=u.subscribeFrames(f=>{a.ingest(f)}),d=u.subscribeInvalidFrames(()=>{a.recordInvalidFrame()});return u.start(),()=>{c(),d(),u.stop()}},[u,a]),s}function mM(n,a){const u=_e.useMemo(()=>new dM(n),[n]),s=_e.useMemo(()=>hS(n),[n]),c=_e.useSyncExternalStore(u.subscribeStatus,u.getStatus,u.getStatus),d=_e.useSyncExternalStore(u.subscribeState,u.getState,u.getState);_e.useEffect(()=>(u.start(),()=>{u.stop()}),[u]);const f=aM({queryKey:["native-snapshot",n],queryFn:({signal:S})=>cM(n,S),enabled:s&&c.phase!=="connected",refetchInterval:15e3,retry:!1}),p=d.top??f.data?.top??null,g=d.configuration??f.data?.configuration??null,v=d.receivedAt??f.data?.receivedAt??null,x=c.phase==="connected"&&(d.top!==null||d.configuration!==null)?"websocket":f.isSuccess?"rest":"none";return _e.useEffect(()=>{p!==null&&a.recordNativeTop(p,v??Date.now())},[a,v,p]),{status:c,live:d,top:p,configuration:g,receivedAt:v,transport:x,restError:f.error instanceof Error?f.error.message:null}}const pM=[{id:"overview",label:"Overview"},{id:"logs",label:"Logs"},{id:"events",label:"Events"}];function gM(){const n=_e.useMemo(()=>new RE,[]),[a,u]=_e.useState(mS),[s,c]=_e.useState("overview"),[d,f]=_e.useState(!1),p=_e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot),g=hM(a.adminUrl,n),v=mM(a.nativeUrl,n);_e.useEffect(()=>(n.start(),()=>{n.stop()}),[n]);function x(T){pS(T),n.reset(),u(T),f(!1)}function S(){gS();const T=Fv();n.reset(),u(T),f(!1)}return z.jsxs("div",{className:"bg-background text-textPrimary min-h-screen",children:[z.jsx("header",{className:"border-accent/25 bg-surface/95 sticky top-0 z-40 border-b backdrop-blur",children:z.jsx("div",{className:"mx-auto max-w-[96rem] px-4 sm:px-6",children:z.jsxs("div",{className:"flex min-h-16 flex-wrap items-center gap-x-6 gap-y-2 py-3",children:[z.jsxs("button",{type:"button",onClick:()=>{c("overview")},className:"mr-auto text-left",children:[z.jsx("p",{className:"text-accentSecondary text-[10px] font-medium tracking-[0.2em] uppercase",children:"Libbitcoin Server"}),z.jsx("h1",{className:"text-accent text-lg font-semibold tracking-tight",children:"Admin Dashboard"})]}),z.jsx("nav",{className:"order-3 flex w-full items-center gap-1 sm:order-none sm:w-auto",children:pM.map(T=>z.jsxs("button",{type:"button",onClick:()=>{c(T.id)},className:`rounded-lg px-3 py-2 text-sm transition ${s===T.id?"bg-accent/15 text-accent":"text-textMuted hover:text-textPrimary hover:bg-white/5"}`,children:[T.label,T.id==="logs"&&p.totalLogs>0&&z.jsx("span",{className:"bg-background/60 ml-2 rounded px-1.5 py-0.5 text-[10px] tabular-nums",children:p.totalLogs>999?"999+":String(p.totalLogs)}),T.id==="events"&&p.totalEvents>0&&z.jsx("span",{className:"bg-background/60 ml-2 rounded px-1.5 py-0.5 text-[10px] tabular-nums",children:p.totalEvents>999?"999+":String(p.totalEvents)})]},T.id))}),z.jsxs("div",{className:"flex items-center gap-3",children:[z.jsxs("div",{className:"hidden items-center gap-2 lg:flex","aria-label":"Connection summary",children:[z.jsx(Kv,{connected:g.phase==="connected",label:"Admin"}),z.jsx(Kv,{connected:v.transport!=="none",label:"Native"})]}),z.jsx("button",{type:"button",onClick:()=>{f(!0)},className:"border-accent/30 text-textMuted hover:border-accent hover:text-accent rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:"Endpoints"})]})]})})}),z.jsxs("main",{className:"mx-auto max-w-[96rem] min-w-0 px-4 py-8 sm:px-6",children:[s==="overview"&&z.jsx(v3,{adminStatus:g,endpoints:a,metrics:p,native:v}),s==="logs"&&z.jsx(vE,{logs:p.recentLogs,onClear:()=>{n.clearLogs()}}),s==="events"&&z.jsx(gE,{events:p.recentEvents,onClear:()=>{n.clearEvents()}})]}),d&&z.jsx(vS,{configuration:a,onClose:()=>{f(!1)},onReset:S,onSave:x},`${a.adminUrl}|${a.nativeUrl}`)]})}function Kv({connected:n,label:a}){return z.jsxs("span",{className:"text-textMuted inline-flex items-center gap-1.5 text-xs",children:[z.jsx("span",{className:`h-2 w-2 rounded-full ${n?"bg-emerald-400":"bg-amber-400"}`,"aria-hidden":"true"}),a]})}function vM({children:n}){const[a]=_e.useState(()=>new Y3({defaultOptions:{queries:{staleTime:1e4,refetchOnWindowFocus:!1,retry:1}}}));return z.jsxs(V3,{client:a,children:[n,null]})}const Ub=document.querySelector("#root");if(!Ub)throw new Error("Root element not found");fS.createRoot(Ub).render(z.jsx(lS.StrictMode,{children:z.jsx(vM,{children:z.jsx(gM,{})})})); +Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const f of n.seen.entries()){const p=f[1];if(a===f[0]){d(f);continue}if(n.external){const v=n.external.registry.get(f[0])?.id;if(a!==f[0]&&v){d(f);continue}}if(n.metadataRegistry.get(f[0])?.id){d(f);continue}if(p.cycle){d(f);continue}if(p.count>1&&n.reused==="ref"){d(f);continue}}}function xy(n,a){const u=n.seen.get(a);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=p=>{const g=n.seen.get(p);if(g.ref===null)return;const v=g.def??g.schema,x={...v},S=g.ref;if(g.ref=null,S){s(S);const w=n.seen.get(S),O=w.schema;if(O.$ref&&(n.target==="draft-07"||n.target==="draft-04"||n.target==="openapi-3.0")?(v.allOf=v.allOf??[],v.allOf.push(O)):Object.assign(v,O),Object.assign(v,x),p._zod.parent===S)for(const W in v)W==="$ref"||W==="allOf"||W in x||delete v[W];if(O.$ref&&w.def)for(const W in v)W==="$ref"||W==="allOf"||W in w.def&&JSON.stringify(v[W])===JSON.stringify(w.def[W])&&delete v[W]}const T=p._zod.parent;if(T&&T!==S){s(T);const w=n.seen.get(T);if(w?.schema.$ref&&(v.$ref=w.schema.$ref,w.def))for(const O in v)O==="$ref"||O==="allOf"||O in w.def&&JSON.stringify(v[O])===JSON.stringify(w.def[O])&&delete v[O]}n.override({zodSchema:p,jsonSchema:v,path:g.path??[]})};for(const p of[...n.seen.entries()].reverse())s(p[0]);const c={};if(n.target==="draft-2020-12"?c.$schema="https://json-schema.org/draft/2020-12/schema":n.target==="draft-07"?c.$schema="http://json-schema.org/draft-07/schema#":n.target==="draft-04"?c.$schema="http://json-schema.org/draft-04/schema#":n.target,n.external?.uri){const p=n.external.registry.get(a)?.id;if(!p)throw new Error("Schema is missing an `id` property");c.$id=n.external.uri(p)}Object.assign(c,u.def??u.schema);const d=n.metadataRegistry.get(a)?.id;d!==void 0&&c.id===d&&delete c.id;const f=n.external?.defs??{};for(const p of n.seen.entries()){const g=p[1];g.def&&g.defId&&(g.def.id===g.defId&&delete g.def.id,f[g.defId]=g.def)}n.external||Object.keys(f).length>0&&(n.target==="draft-2020-12"?c.$defs=f:c.definitions=f);try{const p=JSON.parse(JSON.stringify(c));return Object.defineProperty(p,"~standard",{value:{...a["~standard"],jsonSchema:{input:xo(a,"input",n.processors),output:xo(a,"output",n.processors)}},enumerable:!1,writable:!1}),p}catch{throw new Error("Error converting schema to JSON.")}}function Hn(n,a){const u=a??{seen:new Set};if(u.seen.has(n))return!1;u.seen.add(n);const s=n._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return Hn(s.element,u);if(s.type==="set")return Hn(s.valueType,u);if(s.type==="lazy")return Hn(s.getter(),u);if(s.type==="pr)DELIM" +R"DELIM(omise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return Hn(s.innerType,u);if(s.type==="intersection")return Hn(s.left,u)||Hn(s.right,u);if(s.type==="record"||s.type==="map")return Hn(s.keyType,u)||Hn(s.valueType,u);if(s.type==="pipe")return n._zod.traits.has("$ZodCodec")?!0:Hn(s.in,u)||Hn(s.out,u);if(s.type==="object"){for(const c in s.shape)if(Hn(s.shape[c],u))return!0;return!1}if(s.type==="union"){for(const c of s.options)if(Hn(c,u))return!0;return!1}if(s.type==="tuple"){for(const c of s.items)if(Hn(c,u))return!0;return!!(s.rest&&Hn(s.rest,u))}return!1}const S2=(n,a={})=>u=>{const s=Sy({...u,processors:a});return _n(n,s),_y(s,n),xy(s,n)},xo=(n,a,u={})=>s=>{const{libraryOptions:c,target:d}=s??{},f=Sy({...c??{},target:d,io:a,processors:u});return _n(n,f),_y(f,n),xy(f,n)},_2={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},x2=(n,a,u,s)=>{const c=u;c.type="string";const{minimum:d,maximum:f,format:p,patterns:g,contentEncoding:v}=n._zod.bag;if(typeof d=="number"&&(c.minLength=d),typeof f=="number"&&(c.maxLength=f),p&&(c.format=_2[p]??p,c.format===""&&delete c.format,p==="time"&&delete c.format),v&&(c.contentEncoding=v),g&&g.size>0){const x=[...g];x.length===1?c.pattern=x[0].source:x.length>1&&(c.allOf=[...x.map(S=>({...a.target==="draft-07"||a.target==="draft-04"||a.target==="openapi-3.0"?{type:"string"}:{},pattern:S.source}))])}},z2=(n,a,u,s)=>{const c=u,{minimum:d,maximum:f,format:p,multipleOf:g,exclusiveMaximum:v,exclusiveMinimum:x}=n._zod.bag;typeof p=="string"&&p.includes("int")?c.type="integer":c.type="number";const S=typeof x=="number"&&x>=(d??Number.NEGATIVE_INFINITY),T=typeof v=="number"&&v<=(f??Number.POSITIVE_INFINITY),w=a.target==="draft-04"||a.target==="openapi-3.0";S?w?(c.minimum=x,c.exclusiveMinimum=!0):c.exclusiveMinimum=x:typeof d=="number"&&(c.minimum=d),T?w?(c.maximum=v,c.exclusiveMaximum=!0):c.exclusiveMaximum=v:typeof f=="number"&&(c.maximum=f),typeof g=="number"&&(c.multipleOf=g)},E2=(n,a,u,s)=>{u.type="boolean"},T2=(n,a,u,s)=>{u.not={}},w2=(n,a,u,s)=>{},M2=(n,a,u,s)=>{const c=n._zod.def,d=ey(c.entries);d.every(f=>typeof f=="number")&&(u.type="number"),d.every(f=>typeof f=="string")&&(u.type="string"),u.enum=d},A2=(n,a,u,s)=>{const c=n._zod.def,d=[];for(const f of c.values)if(f===void 0){if(a.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof f=="bigint"){if(a.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");d.push(Number(f))}else d.push(f);if(d.length!==0)if(d.length===1){const f=d[0];u.type=f===null?"null":typeof f,a.target==="draft-04"||a.target==="openapi-3.0"?u.enum=[f]:u.const=f}else d.every(f=>typeof f=="number")&&(u.type="number"),d.every(f=>typeof f=="string")&&(u.type="string"),d.every(f=>typeof f=="boolean")&&(u.type="boolean"),d.every(f=>f===null)&&(u.type="null"),u.enum=d},O2=(n,a,u,s)=>{if(a.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},N2=(n,a,u,s)=>{if(a.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},j2=(n,a,u,s)=>{const c=u,d=n._zod.def,{minimum:f,maximum:p}=n._zod.bag;typeof f=="number"&&(c.minItems=f),typeof p=="number"&&(c.maxItems=p),c.type="array",c.items=_n(d.element,a,{...s,path:[...s.path,"items"]})},D2=(n,a,u,s)=>{const c=u,d=n._zod.def;c.type="object",c.properties={};const f=d.shape;for(const v in f)c.properties[v]=_n(f[v],a,{...s,path:[...s.path,"properties",v]});const p=new Set(Object.keys(f)),g=new Set([...p].filter(v=>{const x=d.shape[v]._zod;return a.io==="input"?x.optin===void 0:x.optout===void 0}));g.size>0&&(c.required=Array.from(g)),d.catchall?._zod.def.type==="never"?c.additionalProperties=!1:d.catchall?d.catchall&&(c.additionalProperties=_n(d.catchall,a,{...s,path:[...s.path,"additionalProperties"]})):a.io==="output"&&(c.additionalProperties=!1)},C2=(n,a,u,s)=>{const c=n._zod.def,d=c.inclusive===!1,f=c.options.map((p,g)=>_n(p,a,{...s,path:[...s.path,d?"oneOf":"anyOf",g]}));d?u.oneOf=f:u.anyOf=f},R2=(n,a,u,s)=>{const c=n._zod.def,d=_n(c.left,a,{...s,path:[...s.path,"allOf",0]}),f=_n(c.right,a,{...s,path:[...s.path,"allOf",1]}),p=v=>"allOf"in v&&Object.keys(v).length===1,g=[...p(d)?d.allOf:[d],...p(f)?f.allOf:[f]];u.allOf=g},U2=(n,a,u,s)=>{const c=n._zod.def,d=_n(c.innerType,a,s),f=a.seen.get(n);a.target==="openapi-3.0"?(f.ref=c.innerType,u.nullable=!0):u.anyOf=[d,{type:"null"}]},k2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType},Z2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType,u.default=JSON.parse(JSON.stringify(c.defaultValue))},L2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType,a.io==="input"&&(u._prefault=JSON.parse(JSON.stringify(c.defaultValue)))},H2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType;let f;try{f=c.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}u.default=f},B2=(n,a,u,s)=>{const c=n._zod.def,d=c.in._zod.traits.has("$ZodTransform"),f=a.io==="input"?d?c.out:c.in:c.out;_n(f,a,s);const p=a.seen.get(n);p.ref=f},q2=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType,u.readOnly=!0},zy=(n,a,u,s)=>{const c=n._zod.def;_n(c.innerType,a,s);const d=a.seen.get(n);d.ref=c.innerType},G2=X("ZodISODateTime",(n,a)=>{$_.init(n,a),Ot.init(n,a)});function Q2(n){return Fx(G2,n)}const Y2=X("ZodISODate",(n,a)=>{V_.init(n,a),Ot.init(n,a)});function $2(n){return Wx(Y2,n)}const V2=X("ZodISOTime",(n,a)=>{K_.init(n,a),Ot.init(n,a)});function K2(n){return Ix(V2,n)}const X2=X("ZodISODuration",(n,a)=>{X_.init(n,a),Ot.init(n,a)});function J2(n){return Px(X2,n)}const F2=(n,a)=>{iy.init(n,a),n.name="ZodError",Object.defineProperties(n,{format:{value:u=>kS(n,u)},flatten:{value:u=>US(n,u)},addIssue:{value:u=>{n.issues.push(u),n.message=JSON.stringify(n.issues,Pd,2)}},addIssues:{value:u=>{n.issues.push(...u),n.message=JSON.stringify(n.issues,Pd,2)}},isEmpty:{get(){return n.issues.length===0}}})},Ol=X("ZodError",F2,{Parent:Error}),W2=Nh(Ol),I2=jh(Ol),P2=Oo(Ol),ez=No(Ol),tz=HS(Ol),nz=BS(Ol),lz=qS(Ol),az=GS(Ol),iz=QS(Ol),uz=YS(Ol),sz=$S(Ol),rz=VS(Ol),k0=new WeakMap;function Lr(n,a,u){const s=Object.getPrototypeOf(n);let c=k0.get(s);if(c||(c=new Set,k0.set(s,c)),!c.has(a)){c.add(a);for(const d in u){const f=u[d];Object.defineProperty(s,d,{configurable:!0,enumerable:!1,get(){const p=f.bind(this);return Object.defineProperty(this,d,{configurable:!0,writable:!0,enumerable:!0,value:p}),p},set(p){Object.defineProperty(this,d,{configurable:!0,writable:!0,enumerable:!0,value:p})}})}}}const Zt=X("ZodType",(n,a)=>(kt.init(n,a),Object.assign(n["~standard"],{jsonSchema:{input:xo(n,"input"),output:xo(n,"output")}}),n.toJSONSchema=S2(n,{}),n.def=a,n.type=a.type,Object.defineProperty(n,"_def",{value:a}),n.parse=(u,s)=>W2(n,u,s,{callee:n.parse}),n.safeParse=(u,s)=>P2(n,u,s),n.parseAsync=async(u,s)=>I2(n,u,s,{callee:n.parseAsync}),n.safeParseAsync=async(u,s)=>ez(n,u,s),n.spa=n.safeParseAsync,n.encode=(u,s)=>tz(n,u,s),n.decode=(u,s)=>nz(n,u,s),n.encodeAsync=async(u,s)=>lz(n,u,s),n.decodeAsync=async(u,s)=>az(n,u,s),n.safeEncode=(u,s)=>iz(n,u,s),n.safeDecode=(u,s)=>uz(n,u,s),n.safeEncodeAsync=async(u,s)=>sz(n,u,s),n.safeDecodeAsync=async(u,s)=>rz(n,u,s),Lr(n,"ZodType",{check(...u){const s=this.def;return this.clone(Ai(s,{checks:[...s.checks??[],...u.map(c=>typeof c=="function"?{_zod:{check:c,def:{check:"custom"},onattach:[]}}:c)]}),{parent:!0})},with(...u){return this.check(...u)},clone(u,s){return Oi(this,u,s)},brand(){return this},register(u,s){return u.add(this,s),this},refine(u,s){return this.check(eE(u,s))},superRefine(u,s){return this.check(tE(u,s))},overwrite(u){return this.check(ys(u))},optional(){return B0(this)},exactOptional(){return qz(this)},n)DELIM" +R"DELIM(ullable(){return q0(this)},nullish(){return B0(q0(this))},nonoptional(u){return Kz(this,u)},array(){return Ch(this)},or(u){return Rh([this,u])},and(u){return kz(this,u)},transform(u){return G0(this,Hz(u))},default(u){return Yz(this,u)},prefault(u){return Vz(this,u)},catch(u){return Jz(this,u)},pipe(u){return G0(this,u)},readonly(){return Iz(this)},describe(u){const s=this.clone();return Tr.add(s,{description:u}),s},meta(...u){if(u.length===0)return Tr.get(this);const s=this.clone();return Tr.add(s,u[0]),s},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(u){return u(this)}}),Object.defineProperty(n,"description",{get(){return Tr.get(n)?.description},configurable:!0}),n)),Ey=X("_ZodString",(n,a)=>{Dh.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(s,c,d)=>x2(n,s,c);const u=n._zod.bag;n.format=u.format??null,n.minLength=u.minimum??null,n.maxLength=u.maximum??null,Lr(n,"_ZodString",{regex(...s){return this.check(i2(...s))},includes(...s){return this.check(r2(...s))},startsWith(...s){return this.check(c2(...s))},endsWith(...s){return this.check(o2(...s))},min(...s){return this.check(_o(...s))},max(...s){return this.check(yy(...s))},length(...s){return this.check(by(...s))},nonempty(...s){return this.check(_o(1,...s))},lowercase(s){return this.check(u2(s))},uppercase(s){return this.check(s2(s))},trim(){return this.check(d2())},normalize(...s){return this.check(f2(...s))},toLowerCase(){return this.check(h2())},toUpperCase(){return this.check(m2())},slugify(){return this.check(p2())}})}),cz=X("ZodString",(n,a)=>{Dh.init(n,a),Ey.init(n,a),n.email=u=>n.check(Ox(oz,u)),n.url=u=>n.check(Rx(fz,u)),n.jwt=u=>n.check(Jx(wz,u)),n.emoji=u=>n.check(Ux(dz,u)),n.guid=u=>n.check(D0(Z0,u)),n.uuid=u=>n.check(Nx(ro,u)),n.uuidv4=u=>n.check(jx(ro,u)),n.uuidv6=u=>n.check(Dx(ro,u)),n.uuidv7=u=>n.check(Cx(ro,u)),n.nanoid=u=>n.check(kx(hz,u)),n.guid=u=>n.check(D0(Z0,u)),n.cuid=u=>n.check(Zx(mz,u)),n.cuid2=u=>n.check(Lx(pz,u)),n.ulid=u=>n.check(Hx(gz,u)),n.base64=u=>n.check(Vx(zz,u)),n.base64url=u=>n.check(Kx(Ez,u)),n.xid=u=>n.check(Bx(vz,u)),n.ksuid=u=>n.check(qx(yz,u)),n.ipv4=u=>n.check(Gx(bz,u)),n.ipv6=u=>n.check(Qx(Sz,u)),n.cidrv4=u=>n.check(Yx(_z,u)),n.cidrv6=u=>n.check($x(xz,u)),n.e164=u=>n.check(Xx(Tz,u)),n.datetime=u=>n.check(Q2(u)),n.date=u=>n.check($2(u)),n.time=u=>n.check(K2(u)),n.duration=u=>n.check(J2(u))});function su(n){return Ax(cz,n)}const Ot=X("ZodStringFormat",(n,a)=>{wt.init(n,a),Ey.init(n,a)}),oz=X("ZodEmail",(n,a)=>{k_.init(n,a),Ot.init(n,a)}),Z0=X("ZodGUID",(n,a)=>{R_.init(n,a),Ot.init(n,a)}),ro=X("ZodUUID",(n,a)=>{U_.init(n,a),Ot.init(n,a)}),fz=X("ZodURL",(n,a)=>{Z_.init(n,a),Ot.init(n,a)}),dz=X("ZodEmoji",(n,a)=>{L_.init(n,a),Ot.init(n,a)}),hz=X("ZodNanoID",(n,a)=>{H_.init(n,a),Ot.init(n,a)}),mz=X("ZodCUID",(n,a)=>{B_.init(n,a),Ot.init(n,a)}),pz=X("ZodCUID2",(n,a)=>{q_.init(n,a),Ot.init(n,a)}),gz=X("ZodULID",(n,a)=>{G_.init(n,a),Ot.init(n,a)}),vz=X("ZodXID",(n,a)=>{Q_.init(n,a),Ot.init(n,a)}),yz=X("ZodKSUID",(n,a)=>{Y_.init(n,a),Ot.init(n,a)}),bz=X("ZodIPv4",(n,a)=>{J_.init(n,a),Ot.init(n,a)}),Sz=X("ZodIPv6",(n,a)=>{F_.init(n,a),Ot.init(n,a)}),_z=X("ZodCIDRv4",(n,a)=>{W_.init(n,a),Ot.init(n,a)}),xz=X("ZodCIDRv6",(n,a)=>{I_.init(n,a),Ot.init(n,a)}),zz=X("ZodBase64",(n,a)=>{P_.init(n,a),Ot.init(n,a)}),Ez=X("ZodBase64URL",(n,a)=>{tx.init(n,a),Ot.init(n,a)}),Tz=X("ZodE164",(n,a)=>{nx.init(n,a),Ot.init(n,a)}),wz=X("ZodJWT",(n,a)=>{ax.init(n,a),Ot.init(n,a)}),Ty=X("ZodNumber",(n,a)=>{my.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(s,c,d)=>z2(n,s,c),Lr(n,"ZodNumber",{gt(s,c){return this.check(R0(s,c))},gte(s,c){return this.check(Yd(s,c))},min(s,c){return this.check(Yd(s,c))},lt(s,c){return this.check(C0(s,c))},lte(s,c){return this.check(Qd(s,c))},max(s,c){return this.check(Qd(s,c))},int(s){return this.check(L0(s))},safe(s){return this.check(L0(s))},positive(s){return this.check(R0(0,s))},nonnegative(s){return this.check(Yd(0,s))},negative(s){return this.check(C0(0,s))},nonpositive(s){return this.check(Qd(0,s))},multipleOf(s,c){return this.check(U0(s,c))},step(s,c){return this.check(U0(s,c))},finite(){return this}});const u=n._zod.bag;n.minValue=Math.max(u.minimum??Number.NEGATIVE_INFINITY,u.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,n.maxValue=Math.min(u.maximum??Number.POSITIVE_INFINITY,u.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,n.isInt=(u.format??"").includes("int")||Number.isSafeInteger(u.multipleOf??.5),n.isFinite=!0,n.format=u.format??null});function Ti(n){return e2(Ty,n)}const Mz=X("ZodNumberFormat",(n,a)=>{ix.init(n,a),Ty.init(n,a)});function L0(n){return t2(Mz,n)}const Az=X("ZodBoolean",(n,a)=>{ux.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>E2(n,u,s)});function ls(n){return n2(Az,n)}const Oz=X("ZodUnknown",(n,a)=>{sx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>w2()});function H0(){return l2(Oz)}const Nz=X("ZodNever",(n,a)=>{rx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>T2(n,u,s)});function jz(n){return a2(Nz,n)}const Dz=X("ZodArray",(n,a)=>{cx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>j2(n,u,s,c),n.element=a.element,Lr(n,"ZodArray",{min(u,s){return this.check(_o(u,s))},nonempty(u){return this.check(_o(1,u))},max(u,s){return this.check(yy(u,s))},length(u,s){return this.check(by(u,s))},unwrap(){return this.element}})});function Ch(n,a){return g2(Dz,n,a)}const Cz=X("ZodObject",(n,a)=>{fx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>D2(n,u,s,c),ht(n,"shape",()=>a.shape),Lr(n,"ZodObject",{keyof(){return Uh(Object.keys(this._zod.def.shape))},catchall(u){return this.clone({...this._zod.def,catchall:u})},passthrough(){return this.clone({...this._zod.def,catchall:H0()})},loose(){return this.clone({...this._zod.def,catchall:H0()})},strict(){return this.clone({...this._zod.def,catchall:jz()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(u){return OS(this,u)},safeExtend(u){return NS(this,u)},merge(u){return jS(this,u)},pick(u){return MS(this,u)},omit(u){return AS(this,u)},partial(...u){return DS(wy,this,u[0])},required(...u){return CS(My,this,u[0])}})});function pu(n,a){const u={type:"object",shape:n??{},...Me(a)};return new Cz(u)}const Rz=X("ZodUnion",(n,a)=>{dx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>C2(n,u,s,c),n.options=a.options});function Rh(n,a){return new Rz({type:"union",options:n,...Me(a)})}const Uz=X("ZodIntersection",(n,a)=>{hx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>R2(n,u,s,c)});function kz(n,a){return new Uz({type:"intersection",left:n,right:a})}const th=X("ZodEnum",(n,a)=>{mx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(s,c,d)=>M2(n,s,c),n.enum=a.entries,n.options=Object.values(a.entries);const u=new Set(Object.keys(a.entries));n.extract=(s,c)=>{const d={};for(const f of s)if(u.has(f))d[f]=a.entries[f];else throw new Error(`Key ${f} not found in enum`);return new th({...a,checks:[],...Me(c),entries:d})},n.exclude=(s,c)=>{const d={...a.entries};for(const f of s)if(u.has(f))delete d[f];else throw new Error(`Key ${f} not found in enum`);return new th({...a,checks:[],...Me(c),entries:d})}});function Uh(n,a){const u=Array.isArray(n)?Object.fromEntries(n.map(s=>[s,s])):n;return new th({type:"enum",entries:u,...Me(a)})}const Zz=X("ZodLiteral",(n,a)=>{px.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>A2(n,u,s),n.values=new Set(a.values),Object.defineProperty(n,"value",{get(){if(a.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return a.values[0]}})});function go(n,a){return new Zz({type:"literal",values:Array.isArray(n)?n:[n],...Me(a)})}const Lz=X("ZodTransform",(n,a)=>{gx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>N2(n,u),n._zod.parse=(u,s)=>{if(s.direction==="backward")throw new Pv(n.constructor.name);u.addIssue=d=>{if(typeof d=="string")u.issues.push(Cr(d,u.value,a));else{const f=d;f.fatal&&(f.continue=!1),f.code??(f.code="custom"),f.input??(f.input=u.value),f.in)DELIM" +R"DELIM(st??(f.inst=n),u.issues.push(Cr(f))}};const c=a.transform(u.value,u);return c instanceof Promise?c.then(d=>(u.value=d,u.fallback=!0,u)):(u.value=c,u.fallback=!0,u)}});function Hz(n){return new Lz({type:"transform",transform:n})}const wy=X("ZodOptional",(n,a)=>{vy.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>zy(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function B0(n){return new wy({type:"optional",innerType:n})}const Bz=X("ZodExactOptional",(n,a)=>{vx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>zy(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function qz(n){return new Bz({type:"optional",innerType:n})}const Gz=X("ZodNullable",(n,a)=>{yx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>U2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function q0(n){return new Gz({type:"nullable",innerType:n})}const Qz=X("ZodDefault",(n,a)=>{bx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>Z2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType,n.removeDefault=n.unwrap});function Yz(n,a){return new Qz({type:"default",innerType:n,get defaultValue(){return typeof a=="function"?a():ny(a)}})}const $z=X("ZodPrefault",(n,a)=>{Sx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>L2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Vz(n,a){return new $z({type:"prefault",innerType:n,get defaultValue(){return typeof a=="function"?a():ny(a)}})}const My=X("ZodNonOptional",(n,a)=>{_x.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>k2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Kz(n,a){return new My({type:"nonoptional",innerType:n,...Me(a)})}const Xz=X("ZodCatch",(n,a)=>{xx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>H2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType,n.removeCatch=n.unwrap});function Jz(n,a){return new Xz({type:"catch",innerType:n,catchValue:typeof a=="function"?a:()=>a})}const Fz=X("ZodPipe",(n,a)=>{zx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>B2(n,u,s,c),n.in=a.in,n.out=a.out});function G0(n,a){return new Fz({type:"pipe",in:n,out:a})}const Wz=X("ZodReadonly",(n,a)=>{Ex.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>q2(n,u,s,c),n.unwrap=()=>n._zod.def.innerType});function Iz(n){return new Wz({type:"readonly",innerType:n})}const Pz=X("ZodCustom",(n,a)=>{Tx.init(n,a),Zt.init(n,a),n._zod.processJSONSchema=(u,s,c)=>O2(n,u)});function eE(n,a={}){return v2(Pz,n,a)}function tE(n,a){return y2(n,a)}const Do=[{id:0,name:"application",label:"Application"},{id:1,name:"news",label:"News"},{id:2,name:"session",label:"Session"},{id:3,name:"protocol",label:"Protocol"},{id:4,name:"proxy",label:"Proxy"},{id:5,name:"remote",label:"Remote"},{id:6,name:"fault",label:"Fault"},{id:7,name:"quitting",label:"Quitting"},{id:8,name:"objects",label:"Objects"},{id:9,name:"verbose",label:"Verbose"}],Rr=[{id:0,name:"header_archived",label:"Header archived",category:"headers",valueKind:"height"},{id:1,name:"header_organized",label:"Header organized",category:"headers",valueKind:"height"},{id:2,name:"header_reorganized",label:"Header reorganized",category:"headers",valueKind:"height"},{id:3,name:"block_archived",label:"Block archived",category:"blocks",valueKind:"height"},{id:4,name:"block_buffered",label:"Block buffered",category:"blocks",valueKind:"height"},{id:5,name:"block_validated",label:"Block validated",category:"blocks",valueKind:"height"},{id:6,name:"block_confirmed",label:"Block confirmed",category:"blocks",valueKind:"height"},{id:7,name:"block_unconfirmable",label:"Block unconfirmable",category:"blocks",valueKind:"height"},{id:8,name:"validate_bypassed",label:"Validation bypassed",category:"blocks",valueKind:"height"},{id:9,name:"confirm_bypassed",label:"Confirmation bypassed",category:"blocks",valueKind:"height"},{id:10,name:"tx_archived",label:"Transaction archived",category:"transactions",valueKind:"count"},{id:11,name:"tx_validated",label:"Transaction validated",category:"transactions",valueKind:"count"},{id:12,name:"tx_invalidated",label:"Transaction invalidated",category:"transactions",valueKind:"count"},{id:13,name:"block_organized",label:"Block organized",category:"chain",valueKind:"height"},{id:14,name:"block_reorganized",label:"Block reorganized",category:"chain",valueKind:"height"},{id:15,name:"template_issued",label:"Mining template issued",category:"mining",valueKind:"count"},{id:16,name:"snapshot_secs",label:"Snapshot",category:"timing",valueKind:"seconds"},{id:17,name:"prune_msecs",label:"Prune",category:"timing",valueKind:"milliseconds"},{id:18,name:"reload_msecs",label:"Store reload",category:"timing",valueKind:"milliseconds"},{id:19,name:"block_usecs",label:"Serve block",category:"timing",valueKind:"microseconds"},{id:20,name:"ancestry_msecs",label:"Serve ancestry",category:"timing",valueKind:"milliseconds"},{id:21,name:"filter_msecs",label:"Serve filter",category:"timing",valueKind:"milliseconds"},{id:22,name:"filterhashes_msecs",label:"Serve filter hashes",category:"timing",valueKind:"milliseconds"},{id:23,name:"filterchecks_msecs",label:"Serve filter checkpoints",category:"timing",valueKind:"milliseconds"},{id:24,name:"ecdsa_secs",label:"ECDSA batch verification",category:"timing",valueKind:"seconds"},{id:25,name:"schnorr_secs",label:"Schnorr batch verification",category:"timing",valueKind:"seconds"},{id:26,name:"silent_secs",label:"Silent payment scan",category:"timing",valueKind:"seconds"},{id:27,name:"unknown",label:"Unknown",category:"chain",valueKind:"unknown"}],nE=pu({level:Ti().int().nonnegative(),time:Ti().int().nonnegative(),message:su()}),lE=pu({event:Ti().int().nonnegative(),value:Ti().nonnegative(),time:Ti().int().nonnegative()}),aE=pu({previous:Ti().nonnegative()}),iE=Rh([nE,lE,aE]),uE=2**Do.length-1,sE=2**Rr.length-1;function rE(n){return"level"in n}function cE(n){return"event"in n}function oE(n){return"previous"in n}function fE(n){try{const a=JSON.parse(n),u=iE.safeParse(a);return u.success?u.data:null}catch{return null}}function cu(n){return Rr[n]??{id:n,name:`event_${String(n)}`,label:`Event ${String(n)}`,category:"chain",valueKind:"unknown"}}function Q0(n){return Do[n]??{id:n,name:`level_${String(n)}`,label:`Level ${String(n)}`}}function dE(n,a){const u=cu(n);if(u.category!=="timing")return null;switch(u.valueKind){case"seconds":return a*1e3;case"milliseconds":return a;case"microseconds":return a/1e3;default:return null}}const hE=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function os(n,a=2){return new Intl.NumberFormat(void 0,{maximumFractionDigits:a}).format(n)}function ka(n){return hE.format(n)}function Or(n,a=!0){const u=new Date(n);if(!Number.isFinite(u.getTime()))return"Invalid time";const s=u.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});return a?`${s}.${String(u.getMilliseconds()).padStart(3,"0")}`:s}function mE(n){const a=Math.max(0,Math.floor(n/1e3)),u=Math.floor(a/86400),s=Math.floor(a%86400/3600),c=Math.floor(a%3600/60),d=a%60;return u>0?`${String(u)}d ${String(s)}h`:s>0?`${String(s)}h ${String(c)}m`:c>0?`${String(c)}m ${String(d)}s`:`${String(d)}s`}function Ay(n,a){switch(cu(n).valueKind){case"height":return`height ${ka(a)}`;case"seconds":return`${os(a)} s`;case"milliseconds":return`${os(a)} ms`;case"microseconds":return`${os(a)} µs`;case"count":return ka(a);default:return String(a)}}function pE(n){return n>=100?`${os(n,0)}/s`:n>=10?`${os(n,1)}/s`:`${os(n,2)}/s`}function gE(n){try{const a=new URL(n),u=a.pathname==="/"?"":a.pathname.replace(/\/$/u,"");return`${a.host}${u}`}catch{return n}}const vE=[{value:"all",label:"All categories"},{value:"headers",label:"Headers"},{value:"blocks",label:"Blocks"},{value:"transactions",label:"Transactions"},{value:"chain",label:"Confirmed chain"},{value:"mining",label:"Mining"},{value:"timing",label:"Timing"}],yE={headers:"bg-violet-500/15 text-violet-300",blocks:"bg-accent/15 text-accent",transactions:"bg-sky-500/15 text-sky-300",chain:"bg-emerald-500/15 text-emerald-300",mining:"bg-amber-500/15 text-amber-300",timing:"bg-cyan-500/15 text-cyan-300"})DELIM" +R"DELIM(;function bE({events:n,onClear:a}){const[u,s]=_e.useState(""),[c,d]=_e.useState("all"),[f,p]=_e.useState(!1),[g,v]=_e.useState([]),x=f?g:n,S=_e.useMemo(()=>{const w=u.trim().toLowerCase();return x.filter(O=>{const Y=cu(O.event);return c==="all"||Y.category===c}).filter(O=>{if(!w)return!0;const Y=cu(O.event);return Y.name.includes(w)||Y.label.toLowerCase().includes(w)||String(O.value).includes(w)}).slice(0,250)},[c,u,x]);function T(){f||v(n),p(w=>!w)}return z.jsxs("section",{className:"space-y-4",children:[z.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Node lifecycle"}),z.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:"Live events"}),z.jsx("p",{className:"text-textMuted mt-1 text-sm",children:"Heights are event payloads; timing values retain their source units."})]}),z.jsxs("div",{className:"flex gap-2",children:[z.jsx("button",{type:"button",onClick:T,className:"border-accent/35 text-accent hover:bg-accent/10 rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:f?"Resume":"Pause"}),z.jsx("button",{type:"button",onClick:a,className:"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:"Clear"})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 flex flex-wrap gap-3 rounded-xl border p-4",children:[z.jsxs("label",{className:"min-w-56 flex-1",children:[z.jsx("span",{className:"sr-only",children:"Search events"}),z.jsx("input",{type:"search",value:u,onChange:w=>{s(w.target.value)},placeholder:"Search event names or values…",className:"border-accent/25 bg-background/70 text-textPrimary placeholder:text-textMuted/60 focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{children:[z.jsx("span",{className:"sr-only",children:"Filter event category"}),z.jsx("select",{value:c,onChange:w=>{d(w.target.value)},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent rounded-lg border px-3 py-2 text-sm focus:ring-0",children:vE.map(w=>z.jsx("option",{value:w.value,children:w.label},w.value))})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 overflow-hidden rounded-xl border",children:[z.jsxs("div",{className:"border-accent/15 text-textMuted flex justify-between border-b px-4 py-3 text-xs",children:[z.jsx("span",{children:f?"Paused snapshot":"Live stream"}),z.jsxs("span",{children:["Showing ",String(S.length)," of ",String(x.length)]})]}),z.jsx("div",{className:"max-h-[65vh] overflow-auto",children:S.length===0?z.jsx("p",{className:"text-textMuted px-4 py-12 text-center text-sm",children:"No matching events."}):z.jsx("ol",{className:"divide-y divide-white/5",children:S.map(w=>{const O=cu(w.event);return z.jsxs("li",{className:"grid items-start gap-2 px-4 py-3 text-xs sm:grid-cols-[8.5rem_10rem_minmax(0,1fr)]",children:[z.jsx("time",{dateTime:new Date(w.time).toISOString(),className:"text-textMuted font-mono tabular-nums",children:Or(w.time)}),z.jsx("span",{className:`w-fit rounded px-2 py-0.5 font-medium ${yE[O.category]}`,children:O.name}),z.jsx("span",{className:"text-textPrimary font-mono tabular-nums",children:Ay(w.event,w.value)})]},w.id)})})})]}),z.jsxs("details",{className:"border-accent/20 bg-surface/50 rounded-xl border",children:[z.jsxs("summary",{className:"text-textMuted hover:text-accent cursor-pointer px-4 py-3 text-sm",children:["Event contract (",String(Rr.length)," identifiers)"]}),z.jsx("div",{className:"grid gap-2 border-t border-white/5 p-4 sm:grid-cols-2 lg:grid-cols-3",children:Rr.map(w=>z.jsxs("div",{className:"text-xs",children:[z.jsx("span",{className:"text-textMuted font-mono",children:String(w.id).padStart(2,"0")}),z.jsx("span",{className:"text-textPrimary ml-2",children:w.name})]},w.id))})]})]})}const Y0={0:"bg-sky-500/15 text-sky-300",1:"bg-emerald-500/15 text-emerald-300",2:"bg-violet-500/15 text-violet-300",3:"bg-cyan-500/15 text-cyan-300",4:"bg-indigo-500/15 text-indigo-300",5:"bg-blue-500/15 text-blue-300",6:"bg-red-500/20 text-red-300",7:"bg-orange-500/20 text-orange-300",8:"bg-slate-500/20 text-slate-300",9:"bg-zinc-500/20 text-zinc-300"};function SE({logs:n,onClear:a}){const[u,s]=_e.useState(""),[c,d]=_e.useState("all"),[f,p]=_e.useState(!1),[g,v]=_e.useState([]),x=f?g:n,S=_e.useMemo(()=>{const w=u.trim().toLowerCase();return x.filter(O=>c==="all"||O.level===Number(c)).filter(O=>!w||O.message.toLowerCase().includes(w)||Q0(O.level).name.includes(w)).slice(0,250)},[c,u,x]);function T(){f||v(n),p(w=>!w)}return z.jsxs("section",{className:"space-y-4",children:[z.jsxs("header",{className:"flex flex-wrap items-end justify-between gap-4",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Diagnostic stream"}),z.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:"Node logs"}),z.jsx("p",{className:"text-textMuted mt-1 text-sm",children:"The newest 1,000 messages are retained in this browser session."})]}),z.jsxs("div",{className:"flex gap-2",children:[z.jsx("button",{type:"button",onClick:T,className:"border-accent/35 text-accent hover:bg-accent/10 rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:f?"Resume":"Pause"}),z.jsx("button",{type:"button",onClick:a,className:"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:"Clear"})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 flex flex-wrap gap-3 rounded-xl border p-4",children:[z.jsxs("label",{className:"min-w-56 flex-1",children:[z.jsx("span",{className:"sr-only",children:"Search logs"}),z.jsx("input",{type:"search",value:u,onChange:w=>{s(w.target.value)},placeholder:"Search messages…",className:"border-accent/25 bg-background/70 text-textPrimary placeholder:text-textMuted/60 focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{children:[z.jsx("span",{className:"sr-only",children:"Filter log level"}),z.jsxs("select",{value:c,onChange:w=>{d(w.target.value)},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent rounded-lg border px-3 py-2 text-sm focus:ring-0",children:[z.jsx("option",{value:"all",children:"All levels"}),Do.map(w=>z.jsx("option",{value:w.id,children:w.label},w.id))]})]})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 overflow-hidden rounded-xl border",children:[z.jsxs("div",{className:"border-accent/15 text-textMuted flex justify-between border-b px-4 py-3 text-xs",children:[z.jsx("span",{children:f?"Paused snapshot":"Live stream"}),z.jsxs("span",{children:["Showing ",String(S.length)," of ",String(x.length)]})]}),z.jsx("div",{className:"max-h-[65vh] overflow-auto",children:S.length===0?z.jsx("p",{className:"text-textMuted px-4 py-12 text-center text-sm",children:"No matching log messages."}):z.jsx("ol",{className:"divide-y divide-white/5",children:S.map(w=>{const O=Q0(w.level);return z.jsxs("li",{className:"grid gap-2 px-4 py-3 text-xs sm:grid-cols-[7.5rem_7.5rem_minmax(0,1fr)]",children:[z.jsx("time",{dateTime:new Date(w.time).toISOString(),className:"text-textMuted font-mono tabular-nums",children:Or(w.time,!1)}),z.jsx("span",{className:`w-fit rounded px-2 py-0.5 font-medium ${Y0[w.level]??Y0[8]}`,children:O.name}),z.jsx("span",{className:"text-textPrimary min-w-0 font-mono leading-5 break-words whitespace-pre-wrap",children:w.message})]},w.id)})})})]})]})}const $d=["line","area","bar"],$0=["line","step","area"],_E=["line","step","area"],Oy={"occurrence-count":{id:"occurrence-count",label:"Occurrences per bucket",description:"Number of frames observed in each one-second bucket.",unit:"occurrences",chartTypes:$d},"oc)DELIM" +R"DELIM(currence-rate":{id:"occurrence-rate",label:"Occurrence rate",description:"Frames observed per second.",unit:"occurrences-per-second",chartTypes:$d},"cumulative-occurrences":{id:"cumulative-occurrences",label:"Cumulative occurrences",description:"Running number of frames observed during this browser session.",unit:"occurrences",chartTypes:$0},"payload-latest":{id:"payload-latest",label:"Latest value",description:"Most recently observed payload value.",unit:"count",chartTypes:_E},"payload-average":{id:"payload-average",label:"Average value",description:"Average payload value within each one-second bucket.",unit:"count",chartTypes:["line","area","bar"]},"payload-minimum":{id:"payload-minimum",label:"Minimum value",description:"Minimum payload value within each one-second bucket.",unit:"count",chartTypes:["line","step"]},"payload-maximum":{id:"payload-maximum",label:"Maximum value",description:"Maximum payload value within each one-second bucket.",unit:"count",chartTypes:["line","step"]},"payload-sum":{id:"payload-sum",label:"Value per bucket",description:"Sum of count payloads within each one-second bucket.",unit:"count",chartTypes:["line","area","bar"]},"payload-cumulative":{id:"payload-cumulative",label:"Cumulative value",description:"Running sum of count payloads during this browser session.",unit:"count",chartTypes:$0},"payload-change-rate":{id:"payload-change-rate",label:"Height change rate",description:"Change in the latest observed height per second.",unit:"height-per-second",chartTypes:$d}},bs=["occurrence-rate","occurrence-count","cumulative-occurrences"],xE=["payload-latest","payload-maximum","payload-change-rate",...bs],zE=["payload-average","payload-latest","payload-minimum","payload-maximum",...bs],EE=["payload-sum","payload-cumulative","payload-latest","payload-average",...bs];function Al(n){return`event:${String(n)}`}function xi(n){return`log:${String(n)}`}const zo="native:top";function TE(n){switch(n){case"height":return"height";case"seconds":case"milliseconds":case"microseconds":return"duration";case"count":return"count";default:return"unknown"}}function wE(n){switch(n){case"height":return xE;case"duration":return zE;case"count":return EE;default:return bs}}function ME(n){switch(n){case"height":return"payload-latest";case"duration":return"payload-average";case"count":return"payload-sum";default:return"occurrence-rate"}}function Ny(n){const a=cu(n),u=TE(a.valueKind);return{id:Al(n),source:"event",sourceId:n,name:a.name,label:a.label,category:a.category,payloadKind:u,allowedMeasures:wE(u),defaultMeasure:ME(u),description:u==="unknown"?"Payload semantics are unknown; occurrence measurements are safe.":`${a.label} event with a ${u} payload.`}}const AE=[...Rr.map(n=>Ny(n.id)),...Do.map(n=>({id:xi(n.id),source:"log",sourceId:n.id,name:n.name,label:`${n.label} logs`,category:"logs",payloadKind:"text",allowedMeasures:bs,defaultMeasure:"occurrence-rate",description:`${n.label} log message volume. Message text is not interpreted as numeric data.`})),{id:zo,source:"native",sourceId:"top",name:"canonical_top",label:"Canonical top",category:"native",payloadKind:"height",allowedMeasures:["payload-latest","payload-maximum","payload-change-rate"],defaultMeasure:"payload-latest",description:"Canonical chain height reported by the native interface."}],kh=AE,OE=new Map(kh.map(n=>[n.id,n]));function Za(n){const a=OE.get(n);if(a)return a;const u=/^event:(\d+)$/u.exec(n);return u?Ny(Number(u[1])):{id:n,source:"event",sourceId:-1,name:n,label:n,category:"unknown",payloadKind:"unknown",allowedMeasures:bs,defaultMeasure:"occurrence-rate",description:"Unknown signal; only occurrence measurements are available."}}function Ei(n,a){const u=Oy[a];if(a.startsWith("occurrence")||a==="cumulative-occurrences")return u;const s=a==="payload-change-rate"?"height-per-second":n.payloadKind==="height"?"height":n.payloadKind==="duration"?"milliseconds":"count";return{...u,unit:s}}function NE(n,a){return n.allowedMeasures.includes(a)}function jE(n,a){return dE(n,a)??a}const DE=3600*1e3,CE=250,RE=1e3,UE=1e3;class V0{constructor(a){this.capacity=a,this.#e=Array.from({length:a})}capacity;#e;#t=0;#n=0;push(a){this.#e[this.#t]=a,this.#t=(this.#t+1)%this.capacity,this.#n=Math.min(this.#n+1,this.capacity)}clear(){this.#t=0,this.#n=0}newestFirst(){const a=[];for(let u=0;uthis.#z;subscribe=a=>(this.#t.add(a),()=>{this.#t.delete(a)});start(){this.#y||(this.tick(),this.#y=setInterval(()=>{this.tick()},1e3))}stop(){this.#y&&(clearInterval(this.#y),this.#y=null),this.#p&&(clearTimeout(this.#p),this.#p=null)}ingest(a,u=this.#e()){const s=this.#E(u);this.#m+=1,rE(a)?this.#N(a,s):cE(a)?this.#j(a,s):oE(a)&&(this.#b+=1),this.#w()}recordInvalidFrame(){this.#S+=1,this.#w()}recordNativeTop(a,u=this.#e()){const s=this.#E(u),c=this.#r[zo];c?.value===a&&s-c.time<15e3||(this.#M(zo,s,a),this.#A(s),this.#w())}clearLogs(){this.#n.clear(),this.flush()}clearEvents(){this.#l.clear(),this.flush()}reset(){this.#n.clear(),this.#l.clear(),this.#a.clear(),this.#i={},this.#s={},this.#u={},this.#c={},this.#r={},this.#d={},this.#h=this.#E(this.#e()),this.#m=0,this.#g=0,this.#o=0,this.#b=0,this.#S=0,this.#_=null,this.#x=null,this.#v=0,this.#T(this.#h),this.flush()}tick(){const a=this.#E(this.#e());this.#T(a),this.#A(a),this.#w()}flush(){this.#p&&(clearTimeout(this.#p),this.#p=null),this.#z=this.#O();for(const a of this.#t)a()}#N(a,u){this.#g+=1,this.#_=u,this.#v+=1,this.#n.push({...a,id:this.#v,receivedAt:u}),this.#M(xi(a.level),u,null)}#j(a,u){this.#o+=1,this.#x=u,this.#v+=1,this.#l.push({...a,id:this.#v,receivedAt:u}),this.#M(Al(a.event),u,jE(a.event,a.value))}#E(a){return Number.isFinite(a)?(this.#f=Math.max(this.#f,a),this.#f):this.#f}#M(a,u,s){const c=this.#T(u),d=c.signals.get(a)??kE();if(d.count+=1,co(this.#u,a,1),s!==null){d.samples+=1,d.sum+=s,d.minimum=d.minimum===null?s:Math.min(d.minimum,s),d.maximum=d.maximum===null?s:Math.max(d.maximum,s),(d.firstAt===null||u=d.lastAt)&&(d.last=s,d.lastAt=u),co(this.#c,a,s);const f=this.#r[a];(!f||u>=f.time)&&(this.#r[a]={value:s,time:u}),this.#d[a]=Math.max(this.#d[a]??s,s)}c.signals.set(a,d)}#T(a){const u=Math.floor(a/1e3)*1e3,s=this.#a.get(u);if(s)return s;const c={time:u,signals:new Map};return this.#a.set(u,c),c}#A(a){const u=a-DE;for(const[s,c]of this.#a)if(!(s>=u)){for(const[d,f]of c.signals)co(this.#i,d,f.count),co(this.#s,d,f.sum);this.#a.delete(s)}}#w(){this.#p||(this.#p=setTimeout(()=>{this.#p=null,this.flush()},CE))}#O(){const a=[...this.#a.values()].sort((u,s)=>u.time-s.time);return{now:this.#E(this.#e()),sessionStartedAt:this.#h,totalFrames:this.#m,totalLogs:this.#g,totalEvents:this.#o,totalAcks:this.#b,invalidFrames:this.#S,buckets:a.map(u=>({time:u.time,signals:Object.fromEntries([...u.signals].map(([s,c])=>[s,{...c}]))})),priorSignalCounts:{...this.#i},priorSignalSums:{...this.#s},signalTotals:{...this.#u},signalSums:{...this.#c},signalLatest:{...this.#r},signalMaximums:{...this.#d},recentLogs:this.#n.newestFirst(),recentEvents:this.#l.newestFirst(),lastLogAt:this.#_,lastEventAt:this.#x}}}function LE(n,a,u,s,c=n[0]?.time??u){const d=u-s*1e3,f=d<=c,p=f?Math.floor(c/1e3)*1e3:Math.ceil(d/1e3)*1e3,g=f?c:p,v=Math.floor(u/1e3)*1e3,S=n.filter(w=>w.time>=p&&w.time<=v).reduce((w,O)=>w+(O.signals[a]?.count??0),0),T=Math.max(0,(u-g)/1e3);return T>0?S/T:0}function HE(n,a){const u=f=>LE(n.buckets,Al(f),n.now,a,n.sessionStartedAt),s=u(2)+u(14);if(s>0)return{label:"Reorganiz)DELIM" +R"DELIM(ing",rate:s};const d=[{label:"Confirming blocks",rate:u(6)},{label:"Validating blocks",rate:u(5)},{label:"Archiving blocks",rate:u(3)},{label:"Synchronizing headers",rate:Math.max(u(0),u(1))}].reduce((f,p)=>p.rate>f.rate?p:f);return d.rate>0?d:{label:"Idle",rate:0}}const BE={idle:"border-slate-500/40 bg-slate-500/10 text-slate-300",connecting:"border-amber-500/40 bg-amber-500/10 text-amber-300",connected:"border-emerald-500/40 bg-emerald-500/10 text-emerald-300",reconnecting:"border-orange-500/40 bg-orange-500/10 text-orange-300"};function qE({phase:n,label:a}){return z.jsxs("span",{className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs tracking-wide uppercase ${BE[n]}`,children:[z.jsx("span",{className:"h-2 w-2 rounded-full bg-current","aria-hidden":"true"}),a]})}const GE={orange:"from-accent/25",red:"from-accentSecondary/25",green:"from-emerald-500/20",blue:"from-sky-500/20"};function oo({label:n,value:a,detail:u,accent:s="orange"}){return z.jsxs("article",{className:`border-accent/20 bg-surface/80 rounded-xl border bg-gradient-to-br ${GE[s]} to-transparent p-5`,children:[z.jsx("p",{className:"text-textMuted text-xs font-medium tracking-[0.14em] uppercase",children:n}),z.jsx("p",{className:"text-textPrimary mt-3 text-3xl font-semibold tracking-tight tabular-nums",children:a}),z.jsx("div",{className:"text-textMuted mt-2 min-h-5 text-xs",children:u})]})}const us=16,nh=8,Zh=80,QE=[300,900,3600],lh=["line","step","area","bar"],bn=["#ffa022","#38bdf8","#34d399","#c084fc","#fb7185","#e879f9","#facc15","#60a5fa"],YE=Uh(["occurrence-count","occurrence-rate","cumulative-occurrences","payload-latest","payload-average","payload-minimum","payload-maximum","payload-sum","payload-cumulative","payload-change-rate"]),$E=pu({id:su().min(1).max(100),signalId:su().min(1).max(100),measure:YE,color:su().regex(/^#[\da-f]{6}$/iu),label:su().max(80).optional()}).strict(),jy=pu({id:su().min(1).max(100),title:su().trim().min(1).max(Zh),visualization:Uh(lh),range:Rh([go(300),go(900),go(3600)]),series:Ch($E).min(1).max(nh)}).strict(),VE=pu({version:go(1),charts:Ch(jy).max(us)}).strict(),Dy={id:"default-sync-pipeline",title:"Sync pipeline",visualization:"line",range:900,series:[dl("sync-header",Al(0),"occurrence-rate",bn[3]),dl("sync-archive",Al(3),"occurrence-rate",bn[0]),dl("sync-validate",Al(5),"occurrence-rate",bn[1]),dl("sync-confirm",Al(6),"occurrence-rate",bn[2])]},KE={id:"default-chain-progress",title:"Chain progress",visualization:"step",range:900,series:[dl("progress-top",zo,"payload-latest",bn[0]),dl("progress-organized",Al(13),"payload-latest",bn[2]),dl("progress-confirmed",Al(6),"payload-latest",bn[1])]},XE={id:"default-log-volume",title:"Log volume",visualization:"bar",range:900,series:[dl("logs-news",xi(1),"occurrence-rate",bn[2]),dl("logs-session",xi(2),"occurrence-rate",bn[3]),dl("logs-protocol",xi(3),"occurrence-rate",bn[1]),dl("logs-remote",xi(5),"occurrence-rate",bn[7]),dl("logs-fault",xi(6),"occurrence-rate",bn[4]),dl("logs-quitting",xi(7),"occurrence-rate",bn[0])]},Lh=[{id:"sync-pipeline",label:"Sync pipeline",description:"Header and block lifecycle throughput.",chart:Dy},{id:"chain-progress",label:"Chain progress",description:"Canonical, organized, and confirmed heights.",chart:KE},{id:"log-volume",label:"Log volume",description:"Message rates grouped by log level.",chart:XE}],Cy="libbitcoinAdminDashboardCharts";let K0=0;function dl(n,a,u,s){return{id:n,signalId:a,measure:u,color:s}}function Eo(n){return K0+=1,`${n}-${Date.now().toString(36)}-${String(K0)}`}function Hh(n,a=!1){return{...n,id:a?Eo("chart"):n.id,series:n.series.map(u=>({...u,id:a?Eo("series"):u.id}))}}function vo(){return Lh.map(n=>Hh(n.chart))}function JE(n){const a=Lh.find(u=>u.id===n);return Hh(a?.chart??Dy,!0)}function Ry(){return{id:Eo("chart"),title:"Custom chart",visualization:"line",range:900,series:[{id:Eo("series"),signalId:Al(3),measure:"occurrence-rate",color:bn[0]}]}}function FE(n){const a=" copy",u=`${n.title.slice(0,Zh-a.length).trimEnd()}${a}`;return{...Hh(n,!0),title:u}}function ah(n){const a=new Set(n.series.map(u=>Ei(Za(u.signalId),u.measure).unit));return a.size===1?[...a][0]??null:null}function Uy(n){const a=jy.safeParse(n);if(!a.success)return a.error.issues[0]?.message??"Invalid chart configuration";for(const u of n.series){const s=Za(u.signalId);if(!NE(s,u.measure))return`${Oy[u.measure].label} is not valid for ${s.label}.`;const c=Ei(s,u.measure);if(!c.chartTypes.includes(n.visualization))return`${c.label} cannot be displayed as a ${n.visualization} chart.`}return ah(n)===null?"All series on a chart must use compatible units.":null}function ky(n){const a=VE.safeParse(n);return!a.success||new Set(a.data.charts.map(u=>u.id)).size!==a.data.charts.length||a.data.charts.some(u=>new Set(u.series.map(s=>s.id)).size!==u.series.length)?null:a.data.charts.every(u=>Uy(u)===null)?a.data.charts:null}function Zy(){try{return globalThis.window?.localStorage??null}catch{return null}}function WE(n=Zy()){try{const a=n?.getItem(Cy);return a?ky(JSON.parse(a))??vo():vo()}catch{return vo()}}function IE(n,a=Zy()){try{const u={version:1,charts:n};if(!ky(u))return;a?.setItem(Cy,JSON.stringify(u))}catch{}}function Bh(n,a){return n.signals[a]}function X0(n,a,u,s){let c=s==="count"?n.priorSignalCounts[a]??0:n.priorSignalSums[a]??0;for(const d of n.buckets){if(d.time>=u)break;const f=Bh(d,a);c+=s==="count"?f?.count??0:f?.sum??0}return c}function PE(n,a,u){let s=null;for(const c of n){if(c.time>=u)break;const d=Bh(c,a);d?.last!==null&&d?.last!==void 0&&d.lastAt!==null&&(s={value:d.last,time:d.lastAt})}return s}function eT(n,a){const u=a<=n.sessionStartedAt?Math.floor(n.sessionStartedAt/1e3)*1e3:Math.ceil(a/1e3)*1e3,s=Math.floor(n.now/1e3)*1e3,c=new Map(n.buckets.map(f=>[f.time,f])),d=[];for(let f=u;f<=s;f+=1e3)d.push(c.get(f)??{time:f,signals:{}});return d}function tT(n,a,u){const s=Math.max(n.time,u),c=Math.min(a,n.time+1e3);return Math.max(0,(c-s)/1e3)}function nT(n,a,u,s){const c=Za(s.signalId);let d=s.measure==="cumulative-occurrences"?X0(n,s.signalId,u,"count"):s.measure==="payload-cumulative"?X0(n,s.signalId,u,"sum"):0,f=PE(n.buckets,s.signalId,u);return a.map(p=>{const g=Bh(p,s.signalId);switch(s.measure){case"occurrence-count":return g?.count??0;case"occurrence-rate":{const v=tT(p,n.now,n.sessionStartedAt);return v>0?(g?.count??0)/v:0}case"cumulative-occurrences":return d+=g?.count??0,d;case"payload-sum":return g&&g.samples>0?g.sum:null;case"payload-cumulative":return d+=g?.sum??0,d;case"payload-average":return g&&g.samples>0?g.sum/g.samples:null;case"payload-minimum":return g?.minimum??null;case"payload-maximum":return g?.maximum??null;case"payload-latest":return g?.last!==null&&g?.last!==void 0&&g.lastAt!==null?(f={value:g.last,time:g.lastAt},g.last):c.payloadKind==="height"?f?.value??null:null;case"payload-change-rate":{if(g?.last===null||g?.last===void 0||g.lastAt===null)return null;const v=f??(g.first!==null&&g.firstAt!==null?{value:g.first,time:g.firstAt}:null);if(f={value:g.last,time:g.lastAt},!v)return null;const x=(g.lastAt-v.time)/1e3;return x>0?(g.last-v.value)/x:null}}})}function lT(n,a){const u=n.now-a.range*1e3,s=eT(n,u),c=s[0]?.time??Math.floor(n.now/1e3)*1e3,d=a.series[0],f=Ei(Za(d.signalId),d.measure).unit,p=a.series.filter(g=>(n.signalTotals[g.signalId]??0)===0).map(g=>g.label??Za(g.signalId).label);return{data:[s.map(g=>g.time/1e3),...a.series.map(g=>nT(n,s,c,g))],unit:f,hasObservedData:p.length({...a}))}}function cT(){const n=new Map;for(const a of kh){const u=n.get(a.category)??[];u.push(a),n.set(a.category,u)}return[...n]}const oT=cT();function fT({chart:n,mode:a,onCancel:u,onSave:s}){const[c,d]=_e.useState(()=>rT(n)),f=Uy(c),p=ah(c);_e.useEffect(()=>{function w(O){O.key==="Escape"&&u()}return globalThis.addEventListener("keydown",w),()=>{globalThis.removeEventListener("keydown",w)}},[u]);const g=_e.useMemo(()=>new Set(lh.filter(w=>c.series.every(O=>Ei(Za(O.signalId),O.measure).chartTypes.includes(w)))),[c.series]);function v(w,O){d(Y=>({...Y,series:Y.series.map((W,F)=>F===w?O:W)}))}function x(w,O){const Y=c.series[w],W=Za(O);v(w,{...Y,signalId:O,measure:W.defaultMeasure})}function S(){if(c.series.length>=nh)return;const w=ah(c),O=kh.find(F=>F.allowedMeasures.some(B=>w===null||Ei(F,B).unit===w));if(!O)return;const Y=O.allowedMeasures.find(F=>w===null||Ei(O,F).unit===w)??O.defaultMeasure,W={id:`series-${Date.now().toString(36)}-${String(c.series.length+1)}`,signalId:O.id,measure:Y,color:bn[c.series.length%bn.length]??bn[0]};d(F=>({...F,series:[...F.series,W]}))}function T(w){w.preventDefault(),!f&&s({...c,title:c.title.trim()})}return z.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm",role:"presentation",onMouseDown:w=>{w.target===w.currentTarget&&u()},children:z.jsxs("section",{role:"dialog","aria-modal":"true","aria-labelledby":"chart-editor-title",className:"border-accent/30 bg-surface max-h-[92vh] w-full max-w-4xl overflow-y-auto rounded-2xl border shadow-2xl shadow-black/60",children:[z.jsxs("header",{className:"border-accent/20 flex items-start justify-between border-b p-5",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Dashboard builder"}),z.jsx("h2",{id:"chart-editor-title",className:"mt-1 text-xl font-semibold",children:a==="add"?"Add chart":"Edit chart"})]}),z.jsx("button",{type:"button",onClick:u,className:"text-textMuted hover:text-accent rounded p-1 text-xl","aria-label":"Close chart editor",children:"×"})]}),a==="add"&&z.jsxs("div",{className:"border-accent/15 border-b p-5",children:[z.jsx("p",{className:"text-textMuted mb-3 text-xs font-medium tracking-wide uppercase",children:"Start from a template"}),z.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-5",children:[Lh.map(w=>z.jsxs("button",{type:"button",onClick:()=>{d(JE(w.id))},className:"border-accent/20 bg-background/50 hover:border-accent/60 rounded-lg border p-3 text-left",children:[z.jsx("span",{className:"text-textPrimary block text-sm font-medium",children:w.label}),z.jsx("span",{className:"text-textMuted mt-1 block text-xs leading-4",children:w.description})]},w.id)),z.jsxs("button",{type:"button",onClick:()=>{d(Ry())},className:"border-accent/20 bg-background/50 hover:border-accent/60 rounded-lg border p-3 text-left",children:[z.jsx("span",{className:"text-textPrimary block text-sm font-medium",children:"Custom"}),z.jsx("span",{className:"text-textMuted mt-1 block text-xs leading-4",children:"Begin with one editable series."})]})]})]}),z.jsxs("form",{onSubmit:T,className:"space-y-6 p-5",children:[z.jsxs("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_11rem_11rem]",children:[z.jsxs("label",{className:"space-y-2",children:[z.jsx("span",{className:"text-sm font-medium",children:"Chart title"}),z.jsx("input",{value:c.title,maxLength:Zh,onChange:w=>{d(O=>({...O,title:w.target.value}))},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{className:"space-y-2",children:[z.jsx("span",{className:"text-sm font-medium",children:"Chart type"}),z.jsx("select",{value:c.visualization,onChange:w=>{d(O=>({...O,visualization:w.target.value}))},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0",children:lh.map(w=>z.jsx("option",{value:w,disabled:!g.has(w),children:sT[w]},w))})]}),z.jsxs("label",{className:"space-y-2",children:[z.jsx("span",{className:"text-sm font-medium",children:"Time range"}),z.jsx("select",{value:c.range,onChange:w=>{d(O=>({...O,range:Number(w.target.value)}))},className:"border-accent/25 bg-background/70 text-textPrimary focus:border-accent w-full rounded-lg border px-3 py-2 text-sm focus:ring-0",children:QE.map(w=>z.jsx("option",{value:w,children:uT[w]},w))})]})]}),z.jsxs("section",{className:"space-y-3",children:[z.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[z.jsxs("div",{children:[z.jsx("h3",{className:"font-semibold",children:"Series"}),z.jsxs("p",{className:"text-textMuted mt-1 text-xs",children:["One chart uses one axis unit",p===null?".":`: ${Ly(p)}.`]})]}),z.jsx("button",{type:"button",onClick:S,disabled:c.series.length>=nh,className:"border-accent/35 text-accent hover:bg-accent/10 disabled:text-textMuted rounded-lg border px-3 py-2 text-xs font-medium uppercase disabled:cursor-not-allowed disabled:opacity-50",children:"Add series"})]}),z.jsx("div",{className:"space-y-3",children:c.series.map((w,O)=>{const Y=Za(w.signalId),W=Ei(Y,w.measure);return z.jsxs("article",{className:"border-accent/15 bg-background/35 grid gap-3 rounded-xl border p-4 lg:grid-cols-[minmax(12rem,1.2fr)_minmax(11rem,1fr)_minmax(9rem,0.8fr)_3.5rem_auto]",children:[z.jsxs("label",{className:"space-y-1.5",children:[z.jsxs("span",{className:"text-textMuted text-xs",children:["Signal ",String(O+1)]}),z.jsx("select",{"aria-label":`Signal ${String(O+1)}`,value:w.signalId,onChange:F=>{x(O,F.target.value)},className:"border-accent/25 bg-surface text-textPrimary focus:border-accent w-full rounded-lg border px-2 py-2 text-sm focus:ring-0",children:oT.map(([F,B])=>z.jsx("optgroup",{label:F,children:B.map(I=>z.jsx("option",{value:I.id,children:I.label},I.id))},F))})]}),z.jsxs("label",{className:"space-y-1.5",children:[z.jsx("span",{className:"text-textMuted text-xs",children:"Measurement"}),z.jsx("select",{"aria-label":`Measurement ${String(O+1)}`,value:w.measure,onChange:F=>{v(O,{...w,measure:F.target.value})},className:"border-accent/25 bg-surface text-textPrimary focus:border-accent w-full rounded-lg border px-2 py-2 text-sm focus:ring-0",title:W.description,children:Y.allowedMeasures.map(F=>z.jsx("option",{value:F,children:Ei(Y,F).label},F))})]}),z.jsxs("label",{className:"space-y-1.5",children:[z.jsx("span",{className:"text-textMuted text-xs",children:"Display label"}),z.jsx("input",{"aria-label":`Display label ${String(O+1)}`,value:w.label??"",onChange:F=>{v(O,{...w,label:F.target.value||void 0})},placeholder:Y.label,className:"border-accent/25 bg-surface text-textPrimary placeholder:text-textMuted/50 focus:border-accent w-full rounded-lg border px-2 py-2 text-sm focus:ring-0"})]}),z.jsxs("label",{className:"space-y-1.5",children:[z.jsx("span",{className:"text-textMuted text-xs",children:"Color"}),z.jsx("input",{"aria-label":`Series color ${String(O+1)}`,type:"color",value:w.color,onChange:F=>{v(O,{...w,color:F.target.value})},className:"border-accent/25 bg-surface h-10 w-full rounded-lg border p-1"})]}),z.jsx("button",{type:"button",onClick:()=>{d(F=>({...F,series:F.series.filter((B,I)=>I!==O)}))},disabled:c.series.length===1,"aria-label":`Remove series ${String(O+1)}`,className:"text-textMuted self-end rounded-lg px-3 py-2 text-sm hover:text-red-300 disabled:cursor-not-allowed disabled:opacity-30",children:"Remove"})]},w.id)})})]}),f&&z.jsx("p",{className:"rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-200",children:f}),z.jsxs("div",{className:"flex justify-end gap-2 border-t border-white/5 pt-4",children:[z.jsx("button",{type:"button",onClick:u,className:"text-textMuted hover:text-textPrimary rounded-lg px-4 py-2 text-sm",children:"Cancel"}),z.jsx("butto)DELIM" +R"DELIM(n",{type:"submit",disabled:f!==null,className:"bg-accent text-background hover:bg-accent/90 rounded-lg px-4 py-2 text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-40",children:a==="add"?"Add chart":"Save changes"})]})]})]})})}const dT=!0,tn="u-",hT="uplot",mT=tn+"hz",pT=tn+"vt",gT=tn+"title",vT=tn+"wrap",yT=tn+"under",bT=tn+"over",ST=tn+"axis",uu=tn+"off",_T=tn+"select",xT=tn+"cursor-x",zT=tn+"cursor-y",ET=tn+"cursor-pt",TT=tn+"legend",wT=tn+"live",MT=tn+"inline",AT=tn+"series",OT=tn+"marker",J0=tn+"label",NT=tn+"value",wr="width",Mr="height",zr="top",F0="bottom",as="left",Vd="right",qh="#000",W0=qh+"0",Kd="mousemove",I0="mousedown",Xd="mouseup",P0="mouseenter",ev="mouseleave",tv="dblclick",jT="resize",DT="scroll",nv="change",To="dppxchange",Gh="--",Ss=typeof window<"u",ih=Ss?document:null,fs=Ss?window:null,CT=Ss?navigator:null;let Ie,fo;function uh(){let n=devicePixelRatio;Ie!=n&&(Ie=n,fo&&rh(nv,fo,uh),fo=matchMedia(`(min-resolution: ${Ie-.001}dppx) and (max-resolution: ${Ie+.001}dppx)`),ou(nv,fo,uh),fs.dispatchEvent(new CustomEvent(To)))}function ol(n,a){if(a!=null){let u=n.classList;!u.contains(a)&&u.add(a)}}function sh(n,a){let u=n.classList;u.contains(a)&&u.remove(a)}function zt(n,a,u){n.style[a]=u+"px"}function ql(n,a,u,s){let c=ih.createElement(n);return a!=null&&ol(c,a),u?.insertBefore(c,s),c}function wl(n,a){return ql("div",n,a)}const lv=new WeakMap;function ia(n,a,u,s,c){let d="translate("+a+"px,"+u+"px)",f=lv.get(n);d!=f&&(n.style.transform=d,lv.set(n,d),a<0||u<0||a>s||u>c?ol(n,uu):sh(n,uu))}const av=new WeakMap;function iv(n,a,u){let s=a+u,c=av.get(n);s!=c&&(av.set(n,s),n.style.background=a,n.style.borderColor=u)}const uv=new WeakMap;function sv(n,a,u,s){let c=a+""+u,d=uv.get(n);c!=d&&(uv.set(n,c),n.style.height=u+"px",n.style.width=a+"px",n.style.marginLeft=s?-a/2+"px":0,n.style.marginTop=s?-u/2+"px":0)}const Qh={passive:!0},RT={...Qh,capture:!0};function ou(n,a,u,s){a.addEventListener(n,u,s?RT:Qh)}function rh(n,a,u,s){a.removeEventListener(n,u,Qh)}Ss&&uh();function Gl(n,a,u,s){let c;u=u||0,s=s||a.length-1;let d=s<=2147483647;for(;s-u>1;)c=d?u+s>>1:hl((u+s)/2),a[c]{let d=-1,f=-1;for(let p=s;p<=c;p++)if(n(u[p])){d=p;break}for(let p=c;p>=s;p--)if(n(u[p])){f=p;break}return[d,f]}}const By=n=>n!=null,qy=n=>n!=null&&n>0,Co=Hy(By),UT=Hy(qy);function kT(n,a,u,s=0,c=!1){let d=c?UT:Co,f=c?qy:By;[a,u]=d(n,a,u);let p=n[a],g=n[a];if(a>-1)if(s==1)p=n[a],g=n[u];else if(s==-1)p=n[u],g=n[a];else for(let v=a;v<=u;v++){let x=n[v];f(x)&&(xg&&(g=x))}return[p??gt,g??-gt]}function Ro(n,a,u,s){let c=ov(n),d=ov(a);n==a&&(c==-1?(n*=u,a/=u):(n/=u,a*=u));let f=u==10?La:Gy,p=c==1?hl:Ml,g=d==1?Ml:hl,v=p(f(en(n))),x=g(f(en(a))),S=hs(u,v),T=hs(u,x);return u==10&&(v<0&&(S=vt(S,-v)),x<0&&(T=vt(T,-x))),s||u==2?(n=S*c,a=T*d):(n=Vy(n,S),a=Uo(a,T)),[n,a]}function Yh(n,a,u,s){let c=Ro(n,a,u,s);return n==0&&(c[0]=0),a==0&&(c[1]=0),c}const $h=.1,rv={mode:3,pad:$h},Nr={pad:0,soft:null,mode:0},ZT={min:Nr,max:Nr};function wo(n,a,u,s){return ko(u)?cv(n,a,u):(Nr.pad=u,Nr.soft=s?0:null,Nr.mode=s?3:0,cv(n,a,ZT))}function Je(n,a){return n??a}function LT(n,a,u){for(a=Je(a,0),u=Je(u,n.length-1);a<=u;){if(n[a]!=null)return!0;a++}return!1}function cv(n,a,u){let s=u.min,c=u.max,d=Je(s.pad,0),f=Je(c.pad,0),p=Je(s.hard,-gt),g=Je(c.hard,gt),v=Je(s.soft,gt),x=Je(c.soft,-gt),S=Je(s.mode,0),T=Je(c.mode,0),w=a-n,O=La(w),Y=Bn(en(n),en(a)),W=La(Y),F=en(W-O);(w<1e-24||F>10)&&(w=0,(n==0||a==0)&&(w=1e-24,S==2&&v!=gt&&(d=0),T==2&&x!=-gt&&(f=0)));let B=w||Y||1e3,I=La(B),q=hs(10,hl(I)),ae=B*(w==0?n==0?.1:1:d),ne=vt(Vy(n-ae,q/10),24),le=n>=v&&(S==1||S==3&&ne<=v||S==2&&ne>=v)?v:gt,se=Bn(p,ne=le?le:Ql(le,ne)),Ae=B*(w==0?a==0?.1:1:f),ze=vt(Uo(a+Ae,q/10),24),ee=a<=x&&(T==1||T==3&&ze>=x||T==2&&ze<=x)?x:-gt,ye=Ql(g,ze>ee&&a<=ee?ee:Bn(ee,ze));return se==ye&&se==0&&(ye=100),[se,ye]}const HT=new Intl.NumberFormat(Ss?CT.language:"en-US"),Vh=n=>HT.format(n),ml=Math,yo=ml.PI,en=ml.abs,hl=ml.floor,Pt=ml.round,Ml=ml.ceil,Ql=ml.min,Bn=ml.max,hs=ml.pow,ov=ml.sign,La=ml.log10,Gy=ml.log2,BT=(n,a=1)=>ml.sinh(n)*a,Jd=(n,a=1)=>ml.asinh(n/a),gt=1/0;function fv(n){return(La((n^n>>31)-(n>>31))|0)+1}function ch(n,a,u){return Ql(Bn(n,a),u)}function Qy(n){return typeof n=="function"}function Ge(n){return Qy(n)?n:()=>n}const qT=()=>{},Yy=n=>n,$y=(n,a)=>a,GT=n=>null,dv=n=>!0,hv=(n,a)=>n==a,QT=/\.\d*?(?=9{6,}|0{6,})/gm,hu=n=>{if(Xy(n)||Mi.has(n))return n;const a=`${n}`,u=a.match(QT);if(u==null)return n;let s=u[0].length-1;if(a.indexOf("e-")!=-1){let[c,d]=a.split("e");return+`${hu(c)}e${d}`}return vt(n,s)};function au(n,a){return hu(vt(hu(n/a))*a)}function Uo(n,a){return hu(Ml(hu(n/a))*a)}function Vy(n,a){return hu(hl(hu(n/a))*a)}function vt(n,a=0){if(Xy(n))return n;let u=10**a,s=n*u*(1+Number.EPSILON);return Pt(s)/u}const Mi=new Map;function Ky(n){return((""+n).split(".")[1]||"").length}function Ur(n,a,u,s){let c=[],d=s.map(Ky);for(let f=a;f=0?0:p)+(f>=d[v]?0:d[v]),T=n==10?x:vt(x,S);c.push(T),Mi.set(T,S)}}return c}const jr={},Kh=[],ms=[null,null],zi=Array.isArray,Xy=Number.isInteger,YT=n=>n===void 0;function mv(n){return typeof n=="string"}function ko(n){let a=!1;if(n!=null){let u=n.constructor;a=u==null||u==Object}return a}function $T(n){return n!=null&&typeof n=="object"}const VT=Object.getPrototypeOf(Uint8Array),Jy="__proto__";function ps(n,a=ko){let u;if(zi(n)){let s=n.find(c=>c!=null);if(zi(s)||a(s)){u=Array(n.length);for(let c=0;cd){for(c=f-1;c>=0&&n[c]==null;)n[c--]=null;for(c=f+1;cf-p)],c=s[0].length,d=new Map;for(let f=0;f"u"?n=>Promise.resolve().then(n):queueMicrotask;function PT(n){let a=n[0],u=a.length,s=Array(u);for(let d=0;da[d]-a[f]);let c=[];for(let d=0;d=s&&n[c]==null;)c--;if(c<=s)return!0;const d=Bn(1,hl((c-s+1)/a));for(let f=n[s],p=s+d;p<=c;p+=d){const g=n[p];if(g!=null){if(g<=f)return!1;f=g}}return!0}const Fy=["January","February","March","April","May","June","July","August","September","October","November","December"],Wy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Iy(n){return n.slice(0,3)}const nw=Wy.map(Iy),lw=Fy.map(Iy),aw={MMMM:Fy,MMM:lw,WWWW:Wy,WWW:nw};function Er(n){return(n<10?"0":"")+n}function iw(n){return(n<10?"00":n<100?"0":"")+n}const uw={YYYY:n=>n.getFullYear(),YY:n=>(n.getFullYear()+"").slice(2),MMMM:(n,a)=>a.MMMM[n.getMonth()],MMM:(n,a)=>a.MMM[n.getMonth()],MM:n=>Er(n.getMonth()+1),M:n=>n.getMonth()+1,DD:n=>Er(n.getDate()),D:n=>n.getDate(),WWWW:(n,a)=>a.WWWW[n.getDay()],WWW:(n,a)=>a.WWW[n.ge)DELIM" +R"DELIM(tDay()],HH:n=>Er(n.getHours()),H:n=>n.getHours(),h:n=>{let a=n.getHours();return a==0?12:a>12?a-12:a},AA:n=>n.getHours()>=12?"PM":"AM",aa:n=>n.getHours()>=12?"pm":"am",a:n=>n.getHours()>=12?"p":"a",mm:n=>Er(n.getMinutes()),m:n=>n.getMinutes(),ss:n=>Er(n.getSeconds()),s:n=>n.getSeconds(),fff:n=>iw(n.getMilliseconds())};function Xh(n,a){a=a||aw;let u=[],s=/\{([a-z]+)\}|[^{]+/gi,c;for(;c=s.exec(n);)u.push(c[0][0]=="{"?uw[c[1]]:c[0]);return d=>{let f="";for(let p=0;pn%1==0,Mo=[1,2,2.5,5],cw=Ur(10,-32,0,Mo),eb=Ur(10,0,32,Mo),ow=eb.filter(Py),iu=cw.concat(eb),Jh=` +`,tb="{YYYY}",pv=Jh+tb,nb="{M}/{D}",Ar=Jh+nb,ho=Ar+"/{YY}",lb="{aa}",fw="{h}:{mm}",ss=fw+lb,gv=Jh+ss,vv=":{ss}",tt=null;function ab(n){let a=n*1e3,u=a*60,s=u*60,c=s*24,d=c*30,f=c*365,g=(n==1?Ur(10,0,3,Mo).filter(Py):Ur(10,-3,0,Mo)).concat([a,a*5,a*10,a*15,a*30,u,u*5,u*10,u*15,u*30,s,s*2,s*3,s*4,s*6,s*8,s*12,c,c*2,c*3,c*4,c*5,c*6,c*7,c*8,c*9,c*10,c*15,d,d*2,d*3,d*4,d*6,f,f*2,f*5,f*10,f*25,f*50,f*100]);const v=[[f,tb,tt,tt,tt,tt,tt,tt,1],[c*28,"{MMM}",pv,tt,tt,tt,tt,tt,1],[c,nb,pv,tt,tt,tt,tt,tt,1],[s,"{h}"+lb,ho,tt,Ar,tt,tt,tt,1],[u,ss,ho,tt,Ar,tt,tt,tt,1],[a,vv,ho+" "+ss,tt,Ar+" "+ss,tt,gv,tt,1],[n,vv+".{fff}",ho+" "+ss,tt,Ar+" "+ss,tt,gv,tt,1]];function x(S){return(T,w,O,Y,W,F)=>{let B=[],I=W>=f,q=W>=d&&W=c?c:W,ze=hl(O)-hl(ne),ee=se+ze+Uo(ne-se,Ae);B.push(ee);let ye=S(ee),ce=ye.getHours()+ye.getMinutes()/u+ye.getSeconds()/s,Ee=W/s,de=T.axes[w]._space,U=F/de;for(;ee=vt(ee+W,n==1?0:3),!(ee>Y);)if(Ee>1){let Q=hl(vt(ce+Ee,6))%24,be=S(ee).getHours()-Q;be>1&&(be=-1),ee-=be*s,ce=(ce+Ee)%24;let A=B[B.length-1];vt((ee-A)/W,3)*U>=.7&&B.push(ee)}else B.push(ee)}return B}}return[g,v,x]}const[dw,hw,mw]=ab(1),[pw,gw,vw]=ab(.001);Ur(2,-53,53,[1]);function yv(n,a){return n.map(u=>u.map((s,c)=>c==0||c==8||s==null?s:a(c==1||u[8]==0?s:u[1]+s)))}function bv(n,a){return(u,s,c,d,f)=>{let p=a.find(O=>f>=O[0])||a[a.length-1],g,v,x,S,T,w;return s.map(O=>{let Y=n(O),W=Y.getFullYear(),F=Y.getMonth(),B=Y.getDate(),I=Y.getHours(),q=Y.getMinutes(),ae=Y.getSeconds(),ne=W!=g&&p[2]||F!=v&&p[3]||B!=x&&p[4]||I!=S&&p[5]||q!=T&&p[6]||ae!=w&&p[7]||p[1];return g=W,v=F,x=B,S=I,T=q,w=ae,ne(Y)})}}function yw(n,a){let u=Xh(a);return(s,c,d,f,p)=>c.map(g=>u(n(g)))}function Fd(n,a,u){return new Date(n,a,u)}function Sv(n,a){return a(n)}const bw="{YYYY}-{MM}-{DD} {h}:{mm}{aa}";function _v(n,a){return(u,s,c,d)=>d==null?Gh:a(n(s))}function Sw(n,a){let u=n.series[a];return u.width?u.stroke(n,a):u.points.width?u.points.stroke(n,a):null}function _w(n,a){return n.series[a].fill(n,a)}const xw={show:!0,live:!0,isolate:!1,mount:qT,markers:{show:!0,width:2,stroke:Sw,fill:_w,dash:"solid"},idx:null,idxs:null,values:[]};function zw(n,a){let u=n.cursor.points,s=wl(),c=u.size(n,a);zt(s,wr,c),zt(s,Mr,c);let d=c/-2;zt(s,"marginLeft",d),zt(s,"marginTop",d);let f=u.width(n,a,c);return f&&zt(s,"borderWidth",f),s}function Ew(n,a){let u=n.series[a].points;return u._fill||u._stroke}function Tw(n,a){let u=n.series[a].points;return u._stroke||u._fill}function ww(n,a){return n.series[a].points.size}const Wd=[0,0];function Mw(n,a,u){return Wd[0]=a,Wd[1]=u,Wd}function mo(n,a,u,s=!0){return c=>{c.button==0&&(!s||c.target==a)&&u(c)}}function Id(n,a,u,s=!0){return c=>{(!s||c.target==a)&&u(c)}}const Aw={show:!0,x:!0,y:!0,lock:!1,move:Mw,points:{one:!1,show:zw,size:ww,width:0,stroke:Tw,fill:Ew},bind:{mousedown:mo,mouseup:mo,click:mo,dblclick:mo,mousemove:Id,mouseleave:Id,mouseenter:Id},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(n,a)=>{a.stopPropagation(),a.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(n,a,u,s,c)=>s-c,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},ib={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Fh=Jt({},ib,{filter:$y}),ub=Jt({},Fh,{size:10}),sb=Jt({},ib,{show:!1}),Wh='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',rb="bold "+Wh,cb=1.5,xv={show:!0,scale:"x",stroke:qh,space:50,gap:5,alignTo:1,size:50,labelGap:0,labelSize:30,labelFont:rb,side:2,grid:Fh,ticks:ub,border:sb,font:Wh,lineGap:cb,rotate:0},Ow="Value",Nw="Time",zv={show:!0,scale:"x",auto:!1,sorted:1,min:gt,max:-gt,idxs:[]};function jw(n,a,u,s,c){return a.map(d=>d==null?"":Vh(d))}function Dw(n,a,u,s,c,d,f){let p=[],g=Mi.get(c)||0;u=f?u:vt(Uo(u,c),g);for(let v=u;v<=s;v=vt(v+c,g))p.push(Object.is(v,-0)?0:v);return p}function oh(n,a,u,s,c,d,f){const p=[],g=n.scales[n.axes[a].scale].log,v=g==10?La:Gy,x=hl(v(u));c=hs(g,x),g==10&&(c=iu[Gl(c,iu)]);let S=u,T=c*g;g==10&&(T=iu[Gl(T,iu)]);do p.push(S),S=S+c,g==10&&!Mi.has(S)&&(S=vt(S,Mi.get(c))),S>=T&&(c=S,T=c*g,g==10&&(T=iu[Gl(T,iu)]));while(S<=s);return p}function Cw(n,a,u,s,c,d,f){let g=n.scales[n.axes[a].scale].asinh,v=s>g?oh(n,a,Bn(g,u),s,c):[g],x=s>=0&&u<=0?[0]:[];return(u<-g?oh(n,a,Bn(g,-s),-u,c):[g]).reverse().map(T=>-T).concat(x,v)}const ob=/./,Rw=/[12357]/,Uw=/[125]/,Ev=/1/,fh=(n,a,u,s)=>n.map((c,d)=>a==4&&c==0||d%s==0&&u.test(c.toExponential()[c<0?1:0])?c:null);function kw(n,a,u,s,c){let d=n.axes[u],f=d.scale,p=n.scales[f],g=n.valToPos,v=d._space,x=g(10,f),S=g(9,f)-x>=v?ob:g(7,f)-x>=v?Rw:g(5,f)-x>=v?Uw:Ev;if(S==Ev){let T=en(g(1,f)-x);if(Tc,Mv={show:!0,auto:!0,sorted:0,gaps:fb,alpha:1,facets:[Jt({},wv,{scale:"x"}),Jt({},wv,{scale:"y"})]},Av={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:fb,alpha:1,points:{show:Bw,filter:null},values:null,min:gt,max:-gt,idxs:[],path:null,clip:null};function qw(n,a,u,s,c){return u/10}const db={time:dT,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},Gw=Jt({},db,{time:!1,ori:1}),Ov={};function hb(n,a){let u=Ov[n];return u||(u={key:n,plots:[],sub(s){u.plots.push(s)},unsub(s){u.plots=u.plots.filter(c=>c!=s)},pub(s,c,d,f,p,g,v){for(let x=0;x{let F=f.pxRound;const B=v.dir*(v.ori==0?1:-1),I=v.ori==0?_s:xs;let q,ae;B==1?(q=u,ae=s):(q=s,ae=u);let ne=F(S(p[q],v,Y,w)),le=F(T(g[q],x,W,O)),se=F(S(p[ae],v,Y,w)),Ae=F(T(d==1?x.max:x.min,x,W,O)),ze=new Path2D(c);return I(ze,se,Ae),I(ze,ne,Ae),I(ze,ne,le),ze})}function Zo(n,a,u,s,c,d){let f=null;if(n.length>0){f=new Path2D;const p=a==0?Bo:em;let g=u;for(let S=0;ST[0]){let w=T[0]-g;w>0&&p(f,g,s,w,s+d),g=T[1]}}let v=u+c-g,x=10;v>0&&p(f,g,s-x/2,v,s+d+x)}return f}function Yw(n,a,u){let s=n[n.length-1];s&&s[0]==a?s[1]=u:n.push([a,u])}function Ph(n,a,u,s,c,d,f){let p=[],g=n.length;for(let v=c==1?u:s;v>=u&&v<=s;v+=c)if(a[v]===null){let S=v,T=v;if(c==1)for(;++v<=s&&a[v]===null;)T=v;else for(;--v>=u&&a[v]===null;)T=v;let w=d(n[S]),O=T==S?w:d(n[T]),Y=S-c;w=f<=0&&Y>=0&&Y=0&&F>=0&&F=w&&p.push([w,O])}return p}function Nv(n){return n==0?Yy:n==1?Pt:a=>au(a,n)}function mb(n){let a=n==0?Lo:Ho,u=n==0?(c,d,f,p,g,v)=>{c.arcTo(d,f,p,g,v)}:(c,d,f,p,g,v)=>{c.arcTo(f,d,g,p,v)},s=n==0?(c,d,f,p,g)=>{c.rect(d,f,p,g)}:(c,d,f,p,g)=>{c.rect(f,d,g,p)};return(c,d,f,p,g,v=0,x=0)=>{v==0&&x==0?s(c,d,f,p,g):(v=Ql(v,p/2,g/2),x=Ql(x,p/2,g/2),a(c,d+v,f),u(c,d+p,f,d+p,f+g,v),u(c,d+p,f+g,d,f+g,x),u(c,d,f+g,d,f,x),u(c,d,f,d+p,f,v),c.closePath())}}const Lo=(n,a,u)=>{n.moveTo(a,u)},Ho=(n,a,u)=>{n.moveTo(u,a)},_s=(n,a,u)=>{n.lineTo(a,u)},xs=(n,a,u)=>{n.lineTo(u,a)},Bo=mb(0),em=mb(1),pb=(n,a,u,s,c,d)=>{n.arc(a,u,s,c,d)},gb=(n,a,u,s,c,d)=>{n.arc(u,a,s,c,d)},vb=(n,a,u,s,c,d,f)=>{n.bezierCurveTo(a,u,s,c,d,f)},yb=(n,a,u,s,c,d,f)=>{n.bezierCurveTo(u,a,c,s,f,d)};function bb(n){return(a,u,s,c,d)=>gu(a,u,(f,p,g,v,x,S,T,w,O,Y,W)=>{let{pxRound:F,points:B}=f,I,q;v.ori==0?(I=Lo,q=pb):(I=Ho,q=gb);const ae=vt(B.width*Ie,3);let ne=(B.size-B.width)/2*Ie,le=vt(ne*2,3),se=new Path2D,Ae=new Path2D,{left:ze,top:ee,width:ye,height:ce}=a.bbox;Bo(Ae,ze-le,ee-le,ye+le*2,ce+le*2);const Ee=de=>{if(g[de]!=null){let U=F(S(p[de],v,Y,w)),Q=F(T(g[de],x,W,O));I(se,U+ne,Q),q(se,U,Q,ne,0,yo*2)}};if(d)d.forEach(Ee);else for(let de=s;de<=c;de++)Ee(de);return{stroke:ae>0?se:null,fill:se,clip:Ae,flags:gs|dh}})}function Sb(n){return(a,u,s,c,d,f)=>{s!=c&&(d!=s&&f!=s&&n(a,u,s),d!=c&&f!=c&&n(a,u,c),n(a,u,f))}}const $w=Sb(_s),Vw=Sb(xs);function _b(n){const a=Je(n?.alignGaps,0);return(u,s,c,d)=>gu(u,s,(f,p,g,v,x,S,T,w,O,Y,W)=>{[c,d]=Co(g,c,d);let F=f.pxRound,B=ce=>F(S(ce,v,Y,w)),I=ce=>F(T(ce,x,W,O)),q,ae;v.ori==0?(q=_s,ae=$w):(q=xs,ae=Vw);const ne=v.dir*(v.ori==0?1:-1),le={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:gs},se=le.stroke;let Ae=!1;if(d-c>=Y*4){let ce=G=>u.posToVal(G,v.key,!0),Ee=null,de=null,U,Q,me,Oe=B(p[ne==1?c:d]),be=B(p[c]),A=B(p[d]),L=ce(ne==1?be+1:A-1);for(let G=ne==1?c:d;G>=c&&G<=d;G+=ne){let ie=p[G],pe=(ne==1?ieL)?Oe:B(ie),ge=g[G];pe==Oe?ge!=null?(Q=ge,Ee==null?(q(se,pe,I(Q)),U=Ee=de=Q):Qde&&(de=Q)):ge===null&&(Ae=!0):(Ee!=null&&ae(se,Oe,I(Ee),I(de),I(U),I(Q)),ge!=null?(Q=ge,q(se,pe,I(Q)),Ee=de=U=Q):(Ee=de=null,ge===null&&(Ae=!0)),Oe=pe,L=ce(Oe+ne))}Ee!=null&&Ee!=de&&me!=Oe&&ae(se,Oe,I(Ee),I(de),I(U),I(Q))}else for(let ce=ne==1?c:d;ce>=c&&ce<=d;ce+=ne){let Ee=g[ce];Ee===null?Ae=!0:Ee!=null&&q(se,B(p[ce]),I(Ee))}let[ee,ye]=Ih(u,s);if(f.fill!=null||ee!=0){let ce=le.fill=new Path2D(se),Ee=f.fillTo(u,s,f.min,f.max,ee),de=I(Ee),U=B(p[c]),Q=B(p[d]);ne==-1&&([Q,U]=[U,Q]),q(ce,Q,de),q(ce,U,de)}if(!f.spanGaps){let ce=[];Ae&&ce.push(...Ph(p,g,c,d,ne,B,a)),le.gaps=ce=f.gaps(u,s,c,d,ce),le.clip=Zo(ce,v.ori,w,O,Y,W)}return ye!=0&&(le.band=ye==2?[Ha(u,s,c,d,se,-1),Ha(u,s,c,d,se,1)]:Ha(u,s,c,d,se,ye)),le})}function Kw(n){const a=Je(n.align,1),u=Je(n.ascDesc,!1),s=Je(n.alignGaps,0),c=Je(n.extend,!1);return(d,f,p,g)=>gu(d,f,(v,x,S,T,w,O,Y,W,F,B,I)=>{[p,g]=Co(S,p,g);let q=v.pxRound,{left:ae,width:ne}=d.bbox,le=be=>q(O(be,T,B,W)),se=be=>q(Y(be,w,I,F)),Ae=T.ori==0?_s:xs;const ze={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:gs},ee=ze.stroke,ye=T.dir*(T.ori==0?1:-1);let ce=se(S[ye==1?p:g]),Ee=le(x[ye==1?p:g]),de=Ee,U=Ee;c&&a==-1&&(U=ae,Ae(ee,U,ce)),Ae(ee,Ee,ce);for(let be=ye==1?p:g;be>=p&&be<=g;be+=ye){let A=S[be];if(A==null)continue;let L=le(x[be]),G=se(A);a==1?Ae(ee,L,ce):Ae(ee,de,G),Ae(ee,L,G),ce=G,de=L}let Q=de;c&&a==1&&(Q=ae+ne,Ae(ee,Q,ce));let[me,Oe]=Ih(d,f);if(v.fill!=null||me!=0){let be=ze.fill=new Path2D(ee),A=v.fillTo(d,f,v.min,v.max,me),L=se(A);Ae(be,Q,L),Ae(be,U,L)}if(!v.spanGaps){let be=[];be.push(...Ph(x,S,p,g,ye,le,s));let A=v.width*Ie/2,L=u||a==1?A:-A,G=u||a==-1?-A:A;be.forEach(ie=>{ie[0]+=L,ie[1]+=G}),ze.gaps=be=v.gaps(d,f,p,g,be),ze.clip=Zo(be,T.ori,W,F,B,I)}return Oe!=0&&(ze.band=Oe==2?[Ha(d,f,p,g,ee,-1),Ha(d,f,p,g,ee,1)]:Ha(d,f,p,g,ee,Oe)),ze})}function jv(n,a,u,s,c,d,f=gt){if(n.length>1){let p=null;for(let g=0,v=1/0;g{}),{fill:S,stroke:T}=v;return(w,O,Y,W)=>gu(w,O,(F,B,I,q,ae,ne,le,se,Ae,ze,ee)=>{let ye=F.pxRound,ce=u,Ee=s*Ie,de=p*Ie,U=g*Ie,Q,me;q.ori==0?[Q,me]=d(w,O):[me,Q]=d(w,O);const Oe=q.dir*(q.ori==0?1:-1);let be=q.ori==0?Bo:em,A=q.ori==0?x:(oe,lt,Nt,Dl,ra,el,ca)=>{x(oe,lt,Nt,ra,Dl,ca,el)},L=Je(w.bands,Kh).find(oe=>oe.series[0]==O),G=L!=null?L.dir:0,ie=F.fillTo(w,O,F.min,F.max,G),xe=ye(le(ie,ae,ee,Ae)),pe,ge,mt,Qe=ze,nt=ye(F.width*Ie),Nn=!1,Pn=null,jn=null,xn=null,Yl=null;S!=null&&(nt==0||T!=null)&&(Nn=!0,Pn=S.values(w,O,Y,W),jn=new Map,new Set(Pn).forEach(oe=>{oe!=null&&jn.set(oe,new Path2D)}),nt>0&&(xn=T.values(w,O,Y,W),Yl=new Map,new Set(xn).forEach(oe=>{oe!=null&&Yl.set(oe,new Path2D)})));let{x0:$l,size:Ni}=v;if($l!=null&&Ni!=null){ce=1,B=$l.values(w,O,Y,W),$l.unit==2&&(B=B.map(Nt=>w.posToVal(se+Nt*ze,q.key,!0)));let oe=Ni.values(w,O,Y,W);Ni.unit==2?ge=oe[0]*ze:ge=ne(oe[0],q,ze,se)-ne(0,q,ze,se),Qe=jv(B,I,ne,q,ze,se,Qe),mt=Qe-ge+Ee}else Qe=jv(B,I,ne,q,ze,se,Qe),mt=Qe*f+Ee,ge=Qe-mt;mt<1&&(mt=0),nt>=ge/2&&(nt=0),mt<5&&(ye=Yy);let ji=mt>0,Nl=Qe-mt-(ji?nt:0);ge=ye(ch(Nl,U,de)),pe=(ce==0?ge/2:ce==Oe?0:ge)-ce*Oe*((ce==0?Ee/2:0)+(ji?nt/2:0));const Ft={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},Vl=Nn?null:new Path2D;let jl=null;if(L!=null)jl=w.data[L.series[1]];else{let{y0:oe,y1:lt}=v;oe!=null&<!=null&&(I=lt.values(w,O,Y,W),jl=oe.values(w,O,Y,W))}let sa=Q*ge,Te=me*ge;for(let oe=Oe==1?Y:W;oe>=Y&&oe<=W;oe+=Oe){let lt=I[oe];if(lt==null)continue;if(jl!=null){let rt=jl[oe]??0;if(lt-rt==0)continue;xe=le(rt,ae,ee,Ae)}let Nt=q.distr!=2||v!=null?B[oe]:oe,Dl=ne(Nt,q,ze,se),ra=le(Je(lt,ie),ae,ee,Ae),el=ye(Dl-pe),ca=ye(Bn(ra,xe)),Dn=ye(Ql(ra,xe)),nn=ca-Dn;if(lt!=null){let rt=lt<0?Te:sa,Qt=lt<0?sa:Te;Nn?(nt>0&&xn[oe]!=null&&be(Yl.get(xn[oe]),el,Dn+hl(nt/2),ge,Bn(0,nn-nt),rt,Qt),Pn[oe]!=null&&be(jn.get(Pn[oe]),el,Dn+hl(nt/2),ge,Bn(0,nn-nt),rt,Qt)):be(Vl,el,Dn+hl(nt/2),ge,Bn(0,nn-nt),rt,Qt),A(w,O,oe,el-nt/2,Dn,ge+nt,nn)}}return nt>0?Ft.stroke=Nn?Yl:Vl:Nn||(Ft._fill=F.width==0?F._fill:F._stroke??F._fill,Ft.width=0),Ft.fill=Nn?jn:Vl,Ft})}function Jw(n,a){const u=Je(a?.alignGaps,0);return(s,c,d,f)=>gu(s,c,(p,g,v,x,S,T,w,O,Y,W,F)=>{[d,f]=Co(v,d,f);let B=p.pxRound,I=Q=>B(T(Q,x,W,O)),q=Q=>B(w(Q,S,F,Y)),ae,ne,le;x.ori==0?(ae=Lo,le=_s,ne=vb):(ae=Ho,le=xs,ne=yb);const se=x.dir*(x.ori==0?1:-1);let Ae=I(g[se==1?d:f]),ze=Ae,ee=[],ye=[];for(let Q=se==1?d:f;Q>=d&&Q<=f;Q+=se)if(v[Q]!=null){let Oe=g[Q],be=I(Oe);ee.push(ze=be),ye.push(q(v[Q]))}const ce={stroke:n(ee,ye,ae,le,ne,B),fill:null,clip:null,band:null,gaps:null,flags:gs},Ee=ce.stroke;let[de,U]=Ih(s,c);if(p.fill!=null||de!=0){let Q=ce.fill=new Path2D(Ee),me=p.fillTo(s,c,p.min,p.max,de),Oe=q(me);le(Q,ze,Oe),le(Q,Ae,Oe)}if(!p.spanGaps){let)DELIM" +R"DELIM( Q=[];Q.push(...Ph(g,v,d,f,se,I,u)),ce.gaps=Q=p.gaps(s,c,d,f,Q),ce.clip=Zo(Q,x.ori,O,Y,W,F)}return U!=0&&(ce.band=U==2?[Ha(s,c,d,f,Ee,-1),Ha(s,c,d,f,Ee,1)]:Ha(s,c,d,f,Ee,U)),ce})}function Fw(n){return Jw(Ww,n)}function Ww(n,a,u,s,c,d){const f=n.length;if(f<2)return null;const p=new Path2D;if(u(p,n[0],a[0]),f==2)s(p,n[1],a[1]);else{let g=Array(f),v=Array(f-1),x=Array(f-1),S=Array(f-1);for(let T=0;T0!=v[T]>0?g[T]=0:(g[T]=3*(S[T-1]+S[T])/((2*S[T]+S[T-1])/v[T-1]+(S[T]+2*S[T-1])/v[T]),isFinite(g[T])||(g[T]=0));g[f-1]=v[f-2];for(let T=0;T{cn.pxRatio=Ie}));const Iw=_b(),Pw=bb();function Cv(n,a,u,s){return(s?[n[0],n[1]].concat(n.slice(2)):[n[0]].concat(n.slice(1))).map((d,f)=>mh(d,f,a,u))}function e3(n,a){return n.map((u,s)=>s==0?{}:Jt({},a,u))}function mh(n,a,u,s){return Jt({},a==0?u:s,n)}function xb(n,a,u){return a==null?ms:[a,u]}const t3=xb;function n3(n,a,u){return a==null?ms:wo(a,u,$h,!0)}function zb(n,a,u,s){return a==null?ms:Ro(a,u,n.scales[s].log,!1)}const l3=zb;function Eb(n,a,u,s){return a==null?ms:Yh(a,u,n.scales[s].log,!1)}const a3=Eb;function i3(n,a,u,s,c){let d=Bn(fv(n),fv(a)),f=a-n,p=Gl(c/s*f,u);do{let g=u[p],v=s*g/f;if(v>=c&&d+(g<5?Mi.get(g):0)<=17)return[g,v]}while(++p(a=Pt((u=+c)*Ie))+"px"),[n,a,u]}function u3(n){n.show&&[n.font,n.labelFont].forEach(a=>{let u=vt(a[2]*Ie,1);a[0]=a[0].replace(/[0-9.]+px/,u+"px"),a[1]=u})}function cn(n,a,u){const s={mode:Je(n.mode,1)},c=s.mode;function d(m,y,_,E){let N=y.valToPct(m);return E+_*(y.dir==-1?1-N:N)}function f(m,y,_,E){let N=y.valToPct(m);return E+_*(y.dir==-1?N:1-N)}function p(m,y,_,E){return y.ori==0?d(m,y,_,E):f(m,y,_,E)}s.valToPosH=d,s.valToPosV=f;let g=!1;s.status=0;const v=s.root=wl(hT);if(n.id!=null&&(v.id=n.id),ol(v,n.class),n.title){let m=wl(gT,v);m.textContent=n.title}const x=ql("canvas"),S=s.ctx=x.getContext("2d"),T=wl(vT,v);ou("click",T,m=>{m.target===O&&(Pe!=kn||at!=Il)&&Ve.click(s,m)},!0);const w=s.under=wl(yT,T);T.appendChild(x);const O=s.over=wl(bT,T);n=ps(n);const Y=+Je(n.pxAlign,1),W=Nv(Y);(n.plugins||[]).forEach(m=>{m.opts&&(n=m.opts(s,n)||n)});const F=n.ms||.001,B=s.series=c==1?Cv(n.series||[],zv,Av,!1):e3(n.series||[null],Mv),I=s.axes=Cv(n.axes||[],xv,Tv,!0),q=s.scales={},ae=s.bands=n.bands||[];ae.forEach(m=>{m.fill=Ge(m.fill||null),m.dir=Je(m.dir,-1)});const ne=c==2?B[1].facets[0].scale:B[0].scale,le={axes:js,series:Go},se=(n.drawOrder||["axes","series"]).map(m=>le[m]);function Ae(m){const y=m.distr==3?_=>La(_>0?_:m.clamp(s,_,m.min,m.max,m.key)):m.distr==4?_=>Jd(_,m.asinh):m.distr==100?_=>m.fwd(_):_=>_;return _=>{let E=y(_),{_min:N,_max:C}=m,V=C-N;return(E-N)/V}}function ze(m){let y=q[m];if(y==null){let _=(n.scales||jr)[m]||jr;if(_.from!=null){ze(_.from);let E=Jt({},q[_.from],_,{key:m});E.valToPct=Ae(E),q[m]=E}else{y=q[m]=Jt({},m==ne?db:Gw,_),y.key=m;let E=y.time,N=y.range,C=zi(N);if((m!=ne||c==2&&!E)&&(C&&(N[0]==null||N[1]==null)&&(N={min:N[0]==null?rv:{mode:1,hard:N[0],soft:N[0]},max:N[1]==null?rv:{mode:1,hard:N[1],soft:N[1]}},C=!1),!C&&ko(N))){let V=N;N=(P,te,ue)=>te==null?ms:wo(te,ue,V)}y.range=Ge(N||(E?t3:m==ne?y.distr==3?l3:y.distr==4?a3:xb:y.distr==3?zb:y.distr==4?Eb:n3)),y.auto=Ge(C?!1:y.auto),y.clamp=Ge(y.clamp||qw),y._min=y._max=null,y.valToPct=Ae(y)}}}ze("x"),ze("y"),c==1&&B.forEach(m=>{ze(m.scale)}),I.forEach(m=>{ze(m.scale)});for(let m in n.scales)ze(m);const ee=q[ne],ye=ee.distr;let ce,Ee;ee.ori==0?(ol(v,mT),ce=d,Ee=f):(ol(v,pT),ce=f,Ee=d);const de={};for(let m in q){let y=q[m];(y.min!=null||y.max!=null)&&(de[m]={min:y.min,max:y.max},y.min=y.max=null)}const U=n.tzDate||(m=>new Date(Pt(m/F))),Q=n.fmtDate||Xh,me=F==1?mw(U):vw(U),Oe=bv(U,yv(F==1?hw:gw,Q)),be=_v(U,Sv(bw,Q)),A=[],L=s.legend=Jt({},xw,n.legend),G=s.cursor=Jt({},Aw,{drag:{y:c==2}},n.cursor),ie=L.show,xe=G.show,pe=L.markers;L.idxs=A,pe.width=Ge(pe.width),pe.dash=Ge(pe.dash),pe.stroke=Ge(pe.stroke),pe.fill=Ge(pe.fill);let ge,mt,Qe,nt=[],Nn=[],Pn,jn=!1,xn={};if(L.live){const m=B[1]?B[1].values:null;jn=m!=null,Pn=jn?m(s,1,0):{_:0};for(let y in Pn)xn[y]=Gh}if(ie)if(ge=ql("table",TT,v),Qe=ql("tbody",null,ge),L.mount(s,ge),jn){mt=ql("thead",null,ge,Qe);let m=ql("tr",null,mt);ql("th",null,m);for(var Yl in Pn)ql("th",J0,m).textContent=Yl}else ol(ge,MT),L.live&&ol(ge,wT);const $l={show:!0},Ni={show:!1};function ji(m,y){if(y==0&&(jn||!L.live||c==2))return ms;let _=[],E=ql("tr",AT,Qe,Qe.childNodes[y]);ol(E,m.class),m.show||ol(E,uu);let N=ql("th",null,E);if(pe.show){let P=wl(OT,N);if(y>0){let te=pe.width(s,y);te&&(P.style.border=te+"px "+pe.dash(s,y)+" "+pe.stroke(s,y)),P.style.background=pe.fill(s,y)}}let C=wl(J0,N);m.label instanceof HTMLElement?C.appendChild(m.label):C.textContent=m.label,y>0&&(pe.show||(C.style.color=m.width>0?pe.stroke(s,y):pe.fill(s,y)),Ft("click",N,P=>{if(G._lock)return;tl(P);let te=B.indexOf(m);if((P.ctrlKey||P.metaKey)!=L.isolate){let ue=B.some((re,fe)=>fe>0&&fe!=te&&re.show);B.forEach((re,fe)=>{fe>0&&Zn(fe,ue?fe==te?$l:Ni:$l,!0,Dt.setSeries)})}else Zn(te,{show:!m.show},!0,Dt.setSeries)},!1),da&&Ft(P0,N,P=>{G._lock||(tl(P),Zn(B.indexOf(m),Wa,!0,Dt.setSeries))},!1));for(var V in Pn){let P=ql("td",NT,E);P.textContent="--",_.push(P)}return[E,_]}const Nl=new Map;function Ft(m,y,_,E=!0){const N=Nl.get(y)||{},C=G.bind[m](s,y,_,E);C&&(ou(m,y,N[m]=C),Nl.set(y,N))}function Vl(m,y,_){const E=Nl.get(y)||{};for(let N in E)(m==null||N==m)&&(rh(N,y,E[N]),delete E[N]);m==null&&Nl.delete(y)}let jl=0,sa=0,Te=0,oe=0,lt=0,Nt=0,Dl=lt,ra=Nt,el=Te,ca=oe,Dn=0,nn=0,rt=0,Qt=0;s.bbox={};let on=!1,vu=!1,Ba=!1,oa=!1,fa=!1,fn=!1;function qa(m,y,_){(_||m!=s.width||y!=s.height)&&Kl(m,y),$a(!1),Ba=!0,vu=!0,Wl()}function Kl(m,y){s.width=jl=Te=m,s.height=sa=oe=y,lt=Nt=0,Br(),zs();let _=s.bbox;Dn=_.left=au(lt*Ie,.5),nn=_.top=au(Nt*Ie,.5),rt=_.width=au(Te*Ie,.5),Qt=_.height=au(oe*Ie,.5)}const yu=3;function Di(){let m=!1,y=0;for(;!m;){y++;let _=Yr(y),E=$r(y);m=y==yu||_&&E,m||(Kl(s.width,s.height),vu=!0)}}function qo({width:m,height:y}){qa(m,y)}s.setSize=qo;function Br(){let m=!1,y=!1,_=!1,E=!1;I.forEach((N,C)=>{if(N.show&&N._show){let{side:V,_size:P}=N,te=V%2,ue=N.label!=null?N.labelSize:0,re=P+ue;re>0&&(te?(Te-=re,V==3?(lt+=re,E=!0):_=!0):(oe-=re,V==0?(Nt+=re,m=!0):y=!0))}}),qn[0]=m,qn[1]=_,qn[2]=y,qn[3]=E,Te-=Rl[1]+Rl[3],lt+=Rl[3],oe-=Rl[2]+Rl[0],Nt+=Rl[0]}function zs(){let m=lt+Te,y=Nt+oe,_=lt,E=Nt;function N(C,V){switch(C){case 1:return m+=V,m-V;case 2:return y+=V,y-V;case 3:return _-=V,_+V;case 0:return E-=V,E+V}}I.forEach((C,V)=>{if(C.show&&C._show){let P=C.side;C._pos=N(P,C._size),C.label!=null&&(C._lpos=N(P,C.labelSize))}})}if(G.dataIdx==null){let m=G.hover,y=m.skip=new Set(m.skip??[]);y.add(void 0);let _=m.prox=Ge(m.prox),E=m.bias??=0;G.dataIdx=(N,C,V,P)=>{if(C==0)return V;let te=V,ue=_(N,C,V,P)??gt,re=ue>=0&&ue0;)y.has(Ce[Se])||(Ue=Se);if(E==0||E==1)for(Se=V;Ne==null&&Se++ue&&(te=null);return te}}const tl=m=>{G.event=m};G.idxs=A,G._lock=!1;let ln=G.points;ln.show=Ge(ln.show),ln.size=Ge(ln.size),ln.stroke=Ge(ln.stroke),ln.width=Ge(ln.width),ln.fill=Ge(ln.fill);const nl=s.focus=Jt({},n.focus||{alpha:.3},G.focus),da=nl.prox>=0,ha=da&&ln.one;let zn=[],Xl=[],ma=[];function Es(m,y){let _=ln.show(s,y);if(_ instanceof HTMLElement)return ol(_,ET),ol(_,m.class),ia(_,-10,-10,Te,oe),O.insertBefore(_,zn[y]),_}function)DELIM" +R"DELIM( Cl(m,y){if(c==1||y>0){let _=c==1&&q[m.scale].time,E=m.value;m.value=_?mv(E)?_v(U,Sv(E,Q)):E||be:E||Lw,m.label=m.label||(_?Nw:Ow)}if(ha||y>0){m.width=m.width==null?1:m.width,m.paths=m.paths||Iw||GT,m.fillTo=Ge(m.fillTo||Qw),m.pxAlign=+Je(m.pxAlign,Y),m.pxRound=Nv(m.pxAlign),m.stroke=Ge(m.stroke||null),m.fill=Ge(m.fill||null),m._stroke=m._fill=m._paths=m._focus=null;let _=Hw(Bn(1,m.width),1),E=m.points=Jt({},{size:_,width:Bn(1,_*.2),stroke:m.stroke,space:_*2,paths:Pw,_stroke:null,_fill:null},m.points);E.show=Ge(E.show),E.filter=Ge(E.filter),E.fill=Ge(E.fill),E.stroke=Ge(E.stroke),E.paths=Ge(E.paths),E.pxAlign=m.pxAlign}if(ie){let _=ji(m,y);nt.splice(y,0,_[0]),Nn.splice(y,0,_[1]),L.values.push(null)}if(xe){A.splice(y,0,null);let _=null;ha?y==0&&(_=Es(m,y)):y>0&&(_=Es(m,y)),zn.splice(y,0,_),Xl.splice(y,0,0),ma.splice(y,0,0)}Ht("addSeries",y)}function Wt(m,y){y=y??B.length,m=c==1?mh(m,y,zv,Av):mh(m,y,{},Mv),B.splice(y,0,m),Cl(B[y],y)}s.addSeries=Wt;function En(m){if(B.splice(m,1),ie){L.values.splice(m,1),Nn.splice(m,1);let y=nt.splice(m,1)[0];Vl(null,y.firstChild),y.remove()}xe&&(A.splice(m,1),zn.splice(m,1)[0].remove(),Xl.splice(m,1),ma.splice(m,1)),Ht("delSeries",m)}s.delSeries=En;const qn=[!1,!1,!1,!1];function Ts(m,y){if(m._show=m.show,m.show){let _=m.side%2,E=q[m.scale];E==null&&(m.scale=_?B[1].scale:ne,E=q[m.scale]);let N=E.time;m.size=Ge(m.size),m.space=Ge(m.space),m.rotate=Ge(m.rotate),zi(m.incrs)&&m.incrs.forEach(V=>{!Mi.has(V)&&Mi.set(V,Ky(V))}),m.incrs=Ge(m.incrs||(E.distr==2?ow:N?F==1?dw:pw:iu)),m.splits=Ge(m.splits||(N&&E.distr==1?me:E.distr==3?oh:E.distr==4?Cw:Dw)),m.stroke=Ge(m.stroke),m.grid.stroke=Ge(m.grid.stroke),m.ticks.stroke=Ge(m.ticks.stroke),m.border.stroke=Ge(m.border.stroke);let C=m.values;m.values=zi(C)&&!zi(C[0])?Ge(C):N?zi(C)?bv(U,yv(C,Q)):mv(C)?yw(U,C):C||Oe:C||jw,m.filter=Ge(m.filter||(E.distr>=3&&E.log==10?kw:E.distr==3&&E.log==2?Zw:$y)),m.font=Rv(m.font),m.labelFont=Rv(m.labelFont),m._size=m.size(s,null,y,0),m._space=m._rotate=m._incrs=m._found=m._splits=m._values=null,m._size>0&&(qn[y]=!0,m._el=wl(ST,T))}}function Ci(m,y,_,E){let[N,C,V,P]=_,te=y%2,ue=0;return te==0&&(P||C)&&(ue=y==0&&!N||y==2&&!V?Pt(xv.size/3):0),te==1&&(N||V)&&(ue=y==1&&!C||y==3&&!P?Pt(Tv.size/2):0),ue}const qr=s.padding=(n.padding||[Ci,Ci,Ci,Ci]).map(m=>Ge(Je(m,Ci))),Rl=s._padding=qr.map((m,y)=>m(s,y,qn,0));let Mt,jt=null,bt=null;const Ul=c==1?B[0].idxs:null;let dn=null,pl=!1;function Lt(m,y){if(a=m??[],s.data=s._data=a,c==2){Mt=0;for(let _=1;_=0,fn=!0,Wl()}}s.setData=Lt;function bu(){pl=!0;let m,y;c==1&&(Mt>0?(jt=Ul[0]=0,bt=Ul[1]=Mt-1,m=a[0][jt],y=a[0][bt],ye==2?(m=jt,y=bt):m==y&&(ye==3?[m,y]=Ro(m,m,ee.log,!1):ye==4?[m,y]=Yh(m,m,ee.log,!1):ee.time?y=m+Pt(86400/F):[m,y]=wo(m,y,$h,!0))):(jt=Ul[0]=m=null,bt=Ul[1]=y=null)),Qn(ne,m,y)}let Ri,Gn,Jl,ws,Su,_u,Ms,Ga,Qa,Et;function Cn(m,y,_,E,N,C){m??=W0,_??=Kh,E??="butt",N??=W0,C??="round",m!=Ri&&(S.strokeStyle=Ri=m),N!=Gn&&(S.fillStyle=Gn=N),y!=Jl&&(S.lineWidth=Jl=y),C!=Su&&(S.lineJoin=Su=C),E!=_u&&(S.lineCap=_u=E),_!=ws&&S.setLineDash(ws=_)}function As(m,y,_,E){y!=Gn&&(S.fillStyle=Gn=y),m!=Ms&&(S.font=Ms=m),_!=Ga&&(S.textAlign=Ga=_),E!=Qa&&(S.textBaseline=Qa=E)}function Os(m,y,_,E,N=0){if(E.length>0&&m.auto(s,pl)&&(y==null||y.min==null)){let C=Je(jt,0),V=Je(bt,E.length-1),P=_.min==null?kT(E,C,V,N,m.distr==3):[_.min,_.max];m.min=Ql(m.min,_.min=P[0]),m.max=Bn(m.max,_.max=P[1])}}const xu={min:null,max:null};function Gr(){for(let E in q){let N=q[E];de[E]==null&&(N.min==null||de[ne]!=null&&N.auto(s,pl))&&(de[E]=xu)}for(let E in q){let N=q[E];de[E]==null&&N.from!=null&&de[N.from]!=null&&(de[E]=xu)}de[ne]!=null&&$a(!0);let m={};for(let E in de){let N=de[E];if(N!=null){let C=m[E]=ps(q[E],$T);if(N.min!=null)Jt(C,N);else if(E!=ne||c==2)if(Mt==0&&C.from==null){let V=C.range(s,null,null,E);C.min=V[0],C.max=V[1]}else C.min=gt,C.max=-gt}}if(Mt>0){B.forEach((E,N)=>{if(c==1){let C=E.scale,V=de[C];if(V==null)return;let P=m[C];if(N==0){let te=P.range(s,P.min,P.max,C);P.min=te[0],P.max=te[1],jt=Gl(P.min,a[0]),bt=Gl(P.max,a[0]),bt-jt>1&&(a[0][jt]P.max&&bt--),E.min=dn[jt],E.max=dn[bt]}else E.show&&E.auto&&Os(P,V,E,a[N],E.sorted);E.idxs[0]=jt,E.idxs[1]=bt}else if(N>0&&E.show&&E.auto){let[C,V]=E.facets,P=C.scale,te=V.scale,[ue,re]=a[N],fe=m[P],De=m[te];fe!=null&&Os(fe,de[P],C,ue,C.sorted),De!=null&&Os(De,de[te],V,re,V.sorted),E.min=V.min,E.max=V.max}});for(let E in m){let N=m[E],C=de[E];if(N.from==null&&(C==null||C.min==null)){let V=N.range(s,N.min==gt?null:N.min,N.max==-gt?null:N.max,E);N.min=V[0],N.max=V[1]}}}for(let E in m){let N=m[E];if(N.from!=null){let C=m[N.from];if(C.min==null)N.min=N.max=null;else{let V=N.range(s,C.min,C.max,E);N.min=V[0],N.max=V[1]}}}let y={},_=!1;for(let E in m){let N=m[E],C=q[E];if(C.min!=N.min||C.max!=N.max){C.min=N.min,C.max=N.max;let V=C.distr;C._min=V==3?La(C.min):V==4?Jd(C.min,C.asinh):V==100?C.fwd(C.min):C.min,C._max=V==3?La(C.max):V==4?Jd(C.max,C.asinh):V==100?C.fwd(C.max):C.max,y[E]=_=!0}}if(_){B.forEach((E,N)=>{c==2?N>0&&y.y&&(E._paths=null):y[E.scale]&&(E._paths=null)});for(let E in y)Ba=!0,Ht("setScale",E);xe&&G.left>=0&&(oa=fn=!0)}for(let E in de)de[E]=null}function zu(m){let y=ch(jt-1,0,Mt-1),_=ch(bt+1,0,Mt-1);for(;m[y]==null&&y>0;)y--;for(;m[_]==null&&_0){let m=B.some(y=>y._focus)&&Et!=nl.alpha;m&&(S.globalAlpha=Et=nl.alpha),B.forEach((y,_)=>{if(_>0&&y.show&&(Rn(_,!1),Rn(_,!0),y._paths==null)){let E=Et;Et!=y.alpha&&(S.globalAlpha=Et=y.alpha);let N=c==2?[0,a[_][0].length-1]:zu(a[_]);y._paths=y.paths(s,_,N[0],N[1]),Et!=E&&(S.globalAlpha=Et=E)}}),B.forEach((y,_)=>{if(_>0&&y.show){let E=Et;Et!=y.alpha&&(S.globalAlpha=Et=y.alpha),y._paths!=null&&Eu(_,!1);{let N=y._paths!=null?y._paths.gaps:null,C=y.points.show(s,_,jt,bt,N),V=y.points.filter(s,_,C,N);(C||V)&&(y.points._paths=y.points.paths(s,_,jt,bt,V),Eu(_,!0))}Et!=E&&(S.globalAlpha=Et=E),Ht("drawSeries",_)}}),m&&(S.globalAlpha=Et=1)}}function Rn(m,y){let _=y?B[m].points:B[m];_._stroke=_.stroke(s,m),_._fill=_.fill(s,m)}function Eu(m,y){let _=y?B[m].points:B[m],{stroke:E,fill:N,clip:C,flags:V,_stroke:P=_._stroke,_fill:te=_._fill,_width:ue=_.width}=_._paths;ue=vt(ue*Ie,3);let re=null,fe=ue%2/2;y&&te==null&&(te=ue>0?"#fff":P);let De=_.pxAlign==1&&fe>0;if(De&&S.translate(fe,fe),!y){let $e=Dn-ue/2,Ce=nn-ue/2,Ue=rt+ue,Ne=Qt+ue;re=new Path2D,re.rect($e,Ce,Ue,Ne)}y?Fl(P,ue,_.dash,_.cap,te,E,N,V,C):Qr(m,P,ue,_.dash,_.cap,te,E,N,V,re,C),De&&S.translate(-fe,-fe)}function Qr(m,y,_,E,N,C,V,P,te,ue,re){let fe=!1;te!=0&&ae.forEach((De,$e)=>{if(De.series[0]==m){let Ce=B[De.series[1]],Ue=a[De.series[1]],Ne=(Ce._paths||jr).band;zi(Ne)&&(Ne=De.dir==1?Ne[0]:Ne[1]);let Se,ct=null;Ce.show&&Ne&<(Ue,jt,bt)?(ct=De.fill(s,$e)||C,Se=Ce._paths.clip):Ne=null,Fl(y,_,E,N,ct,V,P,te,ue,re,Se,Ne),fe=!0}}),fe||Fl(y,_,E,N,C,V,P,te,ue,re)}const Tu=gs|dh;function Fl(m,y,_,E,N,C,V,P,te,ue,re,fe){Cn(m,y,_,E,N),(te||ue||fe)&&(S.save(),te&&S.clip(te),ue&&S.clip(ue)),fe?(P&Tu)==Tu?(S.clip(fe),re&&S.clip(re),ki(N,V),Ui(m,C,y)):P&dh?(ki(N,V),S.clip(fe),Ui(m,C,y)):P&gs&&(S.save(),S.clip(fe),re&&S.clip(re),ki(N,V),S.restore(),Ui(m,C,y)):(ki(N,V),Ui(m,C,y)),(te||ue||fe)&&S.restore()}function Ui(m,y,_){_>0&&(y instanceof Map?y.forEach((E,N)=>{S.strokeStyle=Ri=N,S.stroke(E)}):y!=null&&m&&S.stroke(y))}function ki(m,y){y instanceof Map?y.forEach((_,E)=>{S.fillStyle=Gn=E,S.fill(_)}):y!=null&&m&&S.fill(y)}function Ya(m,y,_,E){let N=I[m],C;if(E<=0)C=[0,0];else{let V=N._space=N.space(s,m,y,_,E),P=N._incrs=N.incrs(s,m,y,_,E,V);C=i3(y,_,P,E,V)}return N._found=C}function Ns(m,y,_,E,N,C,V,P,te,ue){let re=V%2/2;Y==1&&S.translate(re,re),Cn(P,V,te,ue,P),S.beginPath();let fe,De,$e,Ce,Ue=N+(E==0||E==3?-C:C);_==0?(De=N,Ce=Ue):(fe=N,$e=Ue);for(let Ne=0;)DELIM" +R"DELIM(Ne{if(!_.show)return;let N=q[_.scale];if(N.min==null){_._show&&(y=!1,_._show=!1,$a(!1));return}else _._show||(y=!1,_._show=!0,$a(!1));let C=_.side,V=C%2,{min:P,max:te}=N,[ue,re]=Ya(E,P,te,V==0?Te:oe);if(re==0)return;let fe=N.distr==2,De=_._splits=_.splits(s,E,P,te,ue,re,fe),$e=N.distr==2?De.map(Se=>dn[Se]):De,Ce=N.distr==2?dn[De[1]]-dn[De[0]]:ue,Ue=_._values=_.values(s,_.filter(s,$e,E,re,Ce),E,re,Ce);_._rotate=C==2?_.rotate(s,Ue,E,re):0;let Ne=_._size;_._size=Ml(_.size(s,Ue,E,m)),Ne!=null&&_._size!=Ne&&(y=!1)}),y}function $r(m){let y=!0;return qr.forEach((_,E)=>{let N=_(s,E,qn,m);N!=Rl[E]&&(y=!1),Rl[E]=N}),y}function js(){for(let m=0;mdn[sn]):$e,Ue=re.distr==2?dn[$e[1]]-dn[$e[0]]:te,Ne=y.ticks,Se=y.border,ct=Ne.show?Ne.size:0,St=Pt(ct*Ie),Ct=Pt((y.alignTo==2?y._size-ct-y.gap:y.gap)*Ie),et=y._rotate*-yo/180,it=W(y._pos*Ie),hn=(St+Ct)*P,Bt=it+hn;C=E==0?Bt:0,N=E==1?Bt:0;let wn=y.font[0],Yn=y.align==1?as:y.align==2?Vd:et>0?as:et<0?Vd:E==0?"center":_==3?Vd:as,an=et||E==1?"middle":_==2?zr:F0;As(wn,V,Yn,an);let Yt=y.font[1]*y.lineGap,Mn=$e.map(sn=>W(p(sn,re,fe,De))),$n=y._values;for(let sn=0;sn<$n.length;sn++){let An=$n[sn];if(An!=null){E==0?N=Mn[sn]:C=Mn[sn],An=""+An;let ea=An.indexOf(` +`)==-1?[An]:An.split(/\n/gm);for(let mn=0;mn{_>0&&(y._paths=null,m&&(c==1?(y.min=null,y.max=null):y.facets.forEach(E=>{E.min=null,E.max=null})))})}let wu=!1,Va=!1,Un=[];function Ds(){Va=!1;for(let m=0;m0&&queueMicrotask(Ds)}s.batch=Ka;function pa(){if(on&&(Gr(),on=!1),Ba&&(Di(),Ba=!1),vu){if(zt(w,as,lt),zt(w,zr,Nt),zt(w,wr,Te),zt(w,Mr,oe),zt(O,as,lt),zt(O,zr,Nt),zt(O,wr,Te),zt(O,Mr,oe),zt(T,wr,jl),zt(T,Mr,sa),x.width=Pt(jl*Ie),x.height=Pt(sa*Ie),I.forEach(({_el:m,_show:y,_size:_,_pos:E,side:N})=>{if(m!=null)if(y){let C=N===3||N===0?_:0,V=N%2==1;zt(m,V?"left":"top",E-C),zt(m,V?"width":"height",_),zt(m,V?"top":"left",V?Nt:lt),zt(m,V?"height":"width",V?oe:Te),sh(m,uu)}else ol(m,uu)}),Ri=Gn=Jl=Su=_u=Ms=Ga=Qa=ws=null,Et=1,qi(!0),lt!=Dl||Nt!=ra||Te!=el||oe!=ca){$a(!1);let m=Te/el,y=oe/ca;if(xe&&!oa&&G.left>=0){G.left*=m,G.top*=y,gl&&ia(gl,Pt(G.left),0,Te,oe),Tn&&ia(Tn,0,Pt(G.top),Te,oe);for(let _=0;_=0&&Fe.width>0){Fe.left*=m,Fe.width*=m,Fe.top*=y,Fe.height*=y;for(let _ in Ls)zt(Ja,_,Fe[_])}Dl=lt,ra=Nt,el=Te,ca=oe}Ht("setSize"),vu=!1}jl>0&&sa>0&&(S.clearRect(0,0,x.width,x.height),Ht("drawClear"),se.forEach(m=>m()),Ht("draw")),Fe.show&&fa&&(Fa(Fe),fa=!1),xe&&oa&&(va(null,!0,!1),oa=!1),L.show&&L.live&&fn&&(ks(),fn=!1),g||(g=!0,s.status=1,Ht("ready")),pl=!1,wu=!1}s.redraw=(m,y)=>{Ba=y||!1,m!==!1?Qn(ne,ee.min,ee.max):Wl()};function Mu(m,y){let _=q[m];if(_.from==null){if(Mt==0){let E=_.range(s,y.min,y.max,m);y.min=E[0],y.max=E[1]}if(y.min>y.max){let E=y.min;y.min=y.max,y.max=E}if(Mt>1&&y.min!=null&&y.max!=null&&y.max-y.min<1e-16)return;m==ne&&_.distr==2&&Mt>0&&(y.min=Gl(y.min,a[0]),y.max=Gl(y.max,a[0]),y.min==y.max&&y.max++),de[m]=y,on=!0,Wl()}}s.setScale=Mu;let Zi,Au,gl,Tn,Ou,Xa,kn,Il,Li,Cs,Pe,at,kl=!1;const Ve=G.drag;let yt=Ve.x,At=Ve.y;xe&&(G.x&&(Zi=wl(xT,O)),G.y&&(Au=wl(zT,O)),ee.ori==0?(gl=Zi,Tn=Au):(gl=Au,Tn=Zi),Pe=G.left,at=G.top);const Fe=s.select=Jt({show:!0,over:!0,left:0,width:0,top:0,height:0},n.select),Ja=Fe.show?wl(_T,Fe.over?O:w):null;function Fa(m,y){if(Fe.show){for(let _ in m)Fe[_]=m[_],_ in Ls&&zt(Ja,_,m[_]);y!==!1&&Ht("setSelect")}}s.setSelect=Fa;function Rs(m){if(B[m].show)ie&&sh(nt[m],uu);else if(ie&&ol(nt[m],uu),xe){let _=ha?zn[0]:zn[m];_!=null&&ia(_,-10,-10,Te,oe)}}function Qn(m,y,_){Mu(m,{min:y,max:_})}function Zn(m,y,_,E){y.focus!=null&&Vo(m),y.show!=null&&B.forEach((N,C)=>{C>0&&(m==C||m==null)&&(N.show=y.show,Rs(C),c==2?(Qn(N.facets[0].scale,null,null),Qn(N.facets[1].scale,null,null)):Qn(N.scale,null,null),Wl())}),_!==!1&&Ht("setSeries",m,y),E&&Pa("setSeries",s,m,y)}s.setSeries=Zn;function Vr(m,y){Jt(ae[m],y)}function Qo(m,y){m.fill=Ge(m.fill||null),m.dir=Je(m.dir,-1),y=y??ae.length,ae.splice(y,0,m)}function Yo(m){m==null?ae.length=0:ae.splice(m,1)}s.addBand=Qo,s.setBand=Vr,s.delBand=Yo;function $o(m,y){B[m].alpha=y,xe&&zn[m]!=null&&(zn[m].style.opacity=y),ie&&nt[m]&&(nt[m].style.opacity=y)}let ll,Pl,ga;const Wa={focus:!0};function Vo(m){if(m!=ga){let y=m==null,_=nl.alpha!=1;B.forEach((E,N)=>{if(c==1||N>0){let C=y||N==0||N==m;E._focus=y?null:C,_&&$o(N,C?1:nl.alpha)}}),ga=m,_&&Wl()}}ie&&da&&Ft(ev,ge,m=>{G._lock||(tl(m),ga!=null&&Zn(null,Wa,!0,Dt.setSeries))});function vl(m,y,_){let E=q[y];_&&(m=m/Ie-(E.ori==1?Nt:lt));let N=Te;E.ori==1&&(N=oe,m=N-m),E.dir==-1&&(m=N-m);let C=E._min,V=E._max,P=m/N,te=C+(V-C)*P,ue=E.distr;return ue==3?hs(10,te):ue==4?BT(te,E.asinh):ue==100?E.bwd(te):te}function Kr(m,y){let _=vl(m,ne,y);return Gl(_,a[0],jt,bt)}s.valToIdx=m=>Gl(m,a[0]),s.posToIdx=Kr,s.posToVal=vl,s.valToPos=(m,y,_)=>q[y].ori==0?d(m,q[y],_?rt:Te,_?Dn:0):f(m,q[y],_?Qt:oe,_?nn:0),s.setCursor=(m,y,_)=>{Pe=m.left,at=m.top,va(null,y,_)};function Xr(m,y){zt(Ja,as,Fe.left=m),zt(Ja,wr,Fe.width=y)}function Jr(m,y){zt(Ja,zr,Fe.top=m),zt(Ja,Mr,Fe.height=y)}let Hi=ee.ori==0?Xr:Jr,Bi=ee.ori==1?Xr:Jr;function Us(){if(ie&&L.live)for(let m=c==2?1:0;m{A[E]=_}):YT(m.idx)||A.fill(m.idx),L.idx=A[0]),ie&&L.live){for(let _=0;_0||c==1&&!jn)&&Ko(_,A[_]);Us()}fn=!1,y!==!1&&Ht("setLegend")}s.setLegend=ks;function Ko(m,y){let _=B[m],E=m==0&&ye==2?dn:a[m],N;jn?N=_.values(s,m,y)??xn:(N=_.value(s,y==null?null:E[y],m,y),N=N==null?xn:{_:N}),L.values[m]=N}function va(m,y,_){Li=Pe,Cs=at,[Pe,at]=G.move(s,Pe,at),G.left=Pe,G.top=at,xe&&(gl&&ia(gl,Pt(Pe),0,Te,oe),Tn&&ia(Tn,0,Pt(at),Te,oe));let E,N=jt>bt;ll=gt,Pl=null;let C=ee.ori==0?Te:oe,V=ee.ori==1?Te:oe;if(Pe<0||Mt==0||N){E=G.idx=null;for(let P=0;P0&&ct.show){let hn=et==null?-10:et==E?ue:ce(c==1?a[0][et]:a[Se][0][et],ee,C,0),Bt=it==null?-10:Ee(it,c==1?q[ct.scale]:q[ct.facets[1].scale],V,0);if(da&&it!=null){let wn=ee.ori==1?Pe:at,Yn=en(nl.dist(s,Se,et,Bt,wn));if(Yn=0?1:-1,$n=Yt>=0?1:-1;$n==Mn&&($n==1?an=)DELIM" +R"DELIM(=1?it>=Yt:it<=Yt:an==1?it<=Yt:it>=Yt)&&(ll=Yn,Pl=Se)}else ll=Yn,Pl=Se}}if(fn||ha){let wn,Yn;ee.ori==0?(wn=hn,Yn=Bt):(wn=Bt,Yn=hn);let an,Yt,Mn,$n,un,sn,An=!0,ea=ln.bbox;if(ea!=null){An=!1;let mn=ea(s,Se);Mn=mn.left,$n=mn.top,an=mn.width,Yt=mn.height}else Mn=wn,$n=Yn,an=Yt=ln.size(s,Se);if(sn=ln.fill(s,Se),un=ln.stroke(s,Se),ha)Se==Pl&&ll<=nl.prox&&(re=Mn,fe=$n,De=an,$e=Yt,Ce=An,Ue=sn,Ne=un);else{let mn=zn[Se];mn!=null&&(Xl[Se]=Mn,ma[Se]=$n,sv(mn,an,Yt,An),iv(mn,sn,un),ia(mn,Ml(Mn),Ml($n),Te,oe))}}}}if(ha){let Se=nl.prox,ct=ga==null?ll<=Se:ll>Se||Pl!=ga;if(fn||ct){let St=zn[0];St!=null&&(Xl[0]=re,ma[0]=fe,sv(St,De,$e,Ce),iv(St,Ue,Ne),ia(St,Ml(re),Ml(fe),Te,oe))}}}if(Fe.show&&kl)if(m!=null){let[P,te]=Dt.scales,[ue,re]=Dt.match,[fe,De]=m.cursor.sync.scales,$e=m.cursor.drag;if(yt=$e._x,At=$e._y,yt||At){let{left:Ce,top:Ue,width:Ne,height:Se}=m.select,ct=m.scales[fe].ori,St=m.posToVal,Ct,et,it,hn,Bt,wn=P!=null&&ue(P,fe),Yn=te!=null&&re(te,De);wn&&yt?(ct==0?(Ct=Ce,et=Ne):(Ct=Ue,et=Se),it=q[P],hn=ce(St(Ct,fe),it,C,0),Bt=ce(St(Ct+et,fe),it,C,0),Hi(Ql(hn,Bt),en(Bt-hn))):Hi(0,C),Yn&&At?(ct==1?(Ct=Ce,et=Ne):(Ct=Ue,et=Se),it=q[te],hn=Ee(St(Ct,De),it,V,0),Bt=Ee(St(Ct+et,De),it,V,0),Bi(Ql(hn,Bt),en(Bt-hn))):Bi(0,V)}else Hs()}else{let P=en(Li-Ou),te=en(Cs-Xa);if(ee.ori==1){let De=P;P=te,te=De}yt=Ve.x&&P>=Ve.dist,At=Ve.y&&te>=Ve.dist;let ue=Ve.uni;ue!=null?yt&&At&&(yt=P>=ue,At=te>=ue,!yt&&!At&&(te>P?At=!0:yt=!0)):Ve.x&&Ve.y&&(yt||At)&&(yt=At=!0);let re,fe;yt&&(ee.ori==0?(re=kn,fe=Pe):(re=Il,fe=at),Hi(Ql(re,fe),en(fe-re)),At||Bi(0,V)),At&&(ee.ori==1?(re=kn,fe=Pe):(re=Il,fe=at),Bi(Ql(re,fe),en(fe-re)),yt||Hi(0,C)),!yt&&!At&&(Hi(0,0),Bi(0,0))}if(Ve._x=yt,Ve._y=At,m==null){if(_){if(tc!=null){let[P,te]=Dt.scales;Dt.values[0]=P!=null?vl(ee.ori==0?Pe:at,P):null,Dt.values[1]=te!=null?vl(ee.ori==1?Pe:at,te):null}Pa(Kd,s,Pe,at,Te,oe,E)}if(da){let P=_&&Dt.setSeries,te=nl.prox;ga==null?ll<=te&&Zn(Pl,Wa,!0,P):ll>te?Zn(null,Wa,!0,P):Pl!=ga&&Zn(Pl,Wa,!0,P)}}fn&&(L.idx=E,ks()),y!==!1&&Ht("setCursor")}let Zl=null;Object.defineProperty(s,"rect",{get(){return Zl==null&&qi(!1),Zl}});function qi(m=!1){m?Zl=null:(Zl=O.getBoundingClientRect(),Ht("syncRect",Zl))}function Fr(m,y,_,E,N,C,V){G._lock||kl&&m!=null&&m.movementX==0&&m.movementY==0||(Zs(m,y,_,E,N,C,V,!1,m!=null),m!=null?va(null,!0,!0):va(y,!0,!1))}function Zs(m,y,_,E,N,C,V,P,te){if(Zl==null&&qi(!1),tl(m),m!=null)_=m.clientX-Zl.left,E=m.clientY-Zl.top;else{if(_<0||E<0){Pe=-10,at=-10;return}let[ue,re]=Dt.scales,fe=y.cursor.sync,[De,$e]=fe.values,[Ce,Ue]=fe.scales,[Ne,Se]=Dt.match,ct=y.axes[0].side%2==1,St=ee.ori==0?Te:oe,Ct=ee.ori==1?Te:oe,et=ct?C:N,it=ct?N:C,hn=ct?E:_,Bt=ct?_:E;if(Ce!=null?_=Ne(ue,Ce)?p(De,q[ue],St,0):-10:_=St*(hn/et),Ue!=null?E=Se(re,Ue)?p($e,q[re],Ct,0):-10:E=Ct*(Bt/it),ee.ori==1){let wn=_;_=E,E=wn}}te&&(y==null||y.cursor.event.type==Kd)&&((_<=1||_>=Te-1)&&(_=au(_,Te)),(E<=1||E>=oe-1)&&(E=au(E,oe))),P?(Ou=_,Xa=E,[kn,Il]=G.move(s,_,E)):(Pe=_,at=E)}const Ls={width:0,height:0,left:0,top:0};function Hs(){Fa(Ls,!1)}let Wr,Ir,Pr,ec;function Nu(m,y,_,E,N,C,V){kl=!0,yt=At=Ve._x=Ve._y=!1,Zs(m,y,_,E,N,C,V,!0,!1),m!=null&&(Ft(Xd,ih,Ia,!1),Pa(I0,s,kn,Il,Te,oe,null));let{left:P,top:te,width:ue,height:re}=Fe;Wr=P,Ir=te,Pr=ue,ec=re}function Ia(m,y,_,E,N,C,V){kl=Ve._x=Ve._y=!1,Zs(m,y,_,E,N,C,V,!1,!0);let{left:P,top:te,width:ue,height:re}=Fe,fe=ue>0||re>0,De=Wr!=P||Ir!=te||Pr!=ue||ec!=re;if(fe&&De&&Fa(Fe),Ve.setScale&&fe&&De){let $e=P,Ce=ue,Ue=te,Ne=re;if(ee.ori==1&&($e=te,Ce=re,Ue=P,Ne=ue),yt&&Qn(ne,vl($e,ne),vl($e+Ce,ne)),At)for(let Se in q){let ct=q[Se];Se!=ne&&ct.from==null&&ct.min!=gt&&Qn(Se,vl(Ue+Ne,Se),vl(Ue,Se))}Hs()}else G.lock&&(G._lock=!G._lock,va(y,!0,m!=null));m!=null&&(Vl(Xd,ih),Pa(Xd,s,Pe,at,Te,oe,null))}function Xo(m,y,_,E,N,C,V){if(G._lock)return;tl(m);let P=kl;if(kl){let te=!0,ue=!0,re=10,fe,De;ee.ori==0?(fe=yt,De=At):(fe=At,De=yt),fe&&De&&(te=Pe<=re||Pe>=Te-re,ue=at<=re||at>=oe-re),fe&&te&&(Pe=Pe{let N=Dt.match[2];_=N(s,y,_),_!=-1&&Zn(_,E,!0,!1)},xe&&(Ft(I0,O,Nu),Ft(Kd,O,Fr),Ft(P0,O,m=>{tl(m),qi(!1)}),Ft(ev,O,Xo),Ft(tv,O,Bs),hh.add(s),s.syncRect=qi);const Gi=s.hooks=n.hooks||{};function Ht(m,y,_){Va?Un.push([m,y,_]):m in Gi&&Gi[m].forEach(E=>{E.call(null,s,y,_)})}(n.plugins||[]).forEach(m=>{for(let y in m.hooks)Gi[y]=(Gi[y]||[]).concat(m.hooks[y])});const ba=(m,y,_)=>_,Dt=Jt({key:null,setSeries:!1,filters:{pub:dv,sub:dv},scales:[ne,B[1]?B[1].scale:null],match:[hv,hv,ba],values:[null,null]},G.sync);Dt.match.length==2&&Dt.match.push(ba),G.sync=Dt;const tc=Dt.key,Gs=hb(tc);function Pa(m,y,_,E,N,C,V){Dt.filters.pub(m,y,_,E,N,C,V)&&Gs.pub(m,y,_,E,N,C,V)}Gs.sub(s);function nc(m,y,_,E,N,C,V){Dt.filters.sub(m,y,_,E,N,C,V)&&ya[m](null,y,_,E,N,C,V)}s.pub=nc;function Qi(){Gs.unsub(s),hh.delete(s),Nl.clear(),rh(To,fs,qs),v.remove(),ge?.remove(),Ht("destroy")}s.destroy=Qi;function Sa(){Ht("init",n,a),Lt(a||n.data,!1),de[ne]?Mu(ne,de[ne]):bu(),fa=Fe.show&&(Fe.width>0||Fe.height>0),oa=fn=!0,qa(n.width,n.height)}return B.forEach(Cl),I.forEach(Ts),u?u instanceof HTMLElement?(u.appendChild(v),Sa()):u(s,Sa):Sa(),s}cn.assign=Jt;cn.fmtNum=Vh;cn.rangeNum=wo;cn.rangeLog=Ro;cn.rangeAsinh=Yh;cn.orient=gu;cn.pxRatio=Ie;cn.join=WT;cn.fmtDate=Xh,cn.tzDate=rw;cn.sync=hb;{cn.addGap=Yw,cn.clipGaps=Zo;let n=cn.paths={points:bb};n.linear=_b,n.stepped=Kw,n.bars=Xw,n.spline=Fw}function s3({data:n,series:a,height:u=280,emptyMessage:s="Waiting for live data…",valueSuffix:c="",zeroBased:d=!0,valueFormatter:f=c3,visualization:p="line",forceEmpty:g=!1}){const v=_e.useRef(null),x=_e.useRef(null),S=_e.useMemo(()=>r3(n),[n]),T=_e.useRef(S),w=!g&&n[0]?.length>0;return _e.useLayoutEffect(()=>{const O=v.current;if(!O)return;const Y={width:Math.max(240,O.clientWidth),height:u,padding:[12,8,0,0],cursor:{drag:{x:!0,y:!1,setScale:!0},focus:{prox:24}},legend:{show:!0,live:!0},scales:{x:{time:!0},y:{auto:!0,...d?{range:(B,I,q)=>[Math.min(0,I),q===0?1:q*1.08]}:{range:(B,I,q)=>{const ae=q-I,ne=ae===0?Math.max(1,Math.abs(q)*5e-4):ae*.08;return[I-ne,q+ne]}}}},axes:[{stroke:"#9f9f98",grid:{stroke:"#ffffff12",width:1},ticks:{stroke:"#ffffff20",width:1},font:"11px system-ui"},{size:72,stroke:"#9f9f98",grid:{stroke:"#ffffff12",width:1},ticks:{stroke:"#ffffff20",width:1},font:"11px system-ui",values:(B,I)=>I.map(q=>`${f(q)}${c}`)}],series:[{},...a.map(B=>{const I=p==="step"?cn.paths.stepped?.({align:1}):p==="bar"?cn.paths.bars?.({size:[.72,48,2]}):void 0;return{label:B.label,stroke:B.color,fill:p==="area"||p==="bar"?B.fill??`${B.color}24`:B.fill,width:B.width??2,paths:I,points:{show:p==="line"?B.points??!1:!1},value:(q,ae)=>ae===null?"—":`${f(ae)}${c}`}})]},W=new cn(Y,T.current,O);x.current=W;const F=new ResizeObserver(B=>{const I=B[0]?.contentRect.width;I&&I>0&&W.setSize({width:Math.round(I),height:u})});return F.observe(O),()=>{F.disconnect(),W.destroy(),x.current=null}},[u,a,f,c,p,d]),_e.useEffect(()=>{x.current?.setData(S)},[S]),z.jsxs("div",{className:"relative min-w-0",children:[z.jsx("div",{ref:v,className:"min-w-0 overflow-hidden"}),!w&&z.jsx("div",{className:"bg-surface text-textMuted pointer-events-none absolute inset-0 z-10 flex items-center justify-center text-sm",children:s})]})}function r3(n){const a=n[0];if(a.length>=2)return n;const u=Date.now()/1e3,s=a[0]??u,c=[s-1,s],d=n.slice(1).map(f=>{const p=f[0]??null;return[p,p]});return[c,...d]}function c3(n){return Math.abs(n)>=1e6?`${(n/1e6).toFixed(1)}m`:Math.abs(n)>=1e3?`${(n/1e3).toFixed(1)}k`:Math.abs(n)>=10?n.toFixed(0):Math.abs(n)>=1?n.toFixed(1):n.toFixed(2)}const o3={300:"5m",900:"15m",3600:"1h"},f3=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),d3=new Intl.NumberFormat(void 0,{maximumFractionDigits:2});function h3(n){return f3.format(n)})DELIM" +R"DELIM(function m3(n){return d3.format(n)}function p3(n){return n==="height"||n==="occurrences"?h3:m3}function g3({metrics:n}){const[a,u]=_e.useState(WE),[s,c]=_e.useState(null),[d,f]=_e.useState(!1);_e.useEffect(()=>{IE(a)},[a]);function p(x){u(S=>s?.mode==="add"?S.length>=us?S:[...S,x]:S.map(T=>T.id===x.id?x:T)),c(null)}function g(x,S){u(T=>{const w=x+S;if(w<0||w>=T.length)return T;const O=[...T],Y=O[x],W=O[w];return O[x]=W,O[w]=Y,O})}function v(){if(!d){f(!0);return}u(vo()),f(!1)}return z.jsxs("section",{className:"space-y-4",children:[z.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-accentSecondary text-xs font-medium tracking-[0.16em] uppercase",children:"Live telemetry"}),z.jsx("h2",{className:"mt-1 text-2xl font-semibold",children:"Custom charts"}),z.jsxs("p",{className:"text-textMuted mt-1 text-sm",children:["Session data only · ",String(a.length)," of ",String(us)," charts"]})]}),z.jsxs("div",{className:"flex flex-wrap gap-2",children:[z.jsx("button",{type:"button",onClick:()=>{f(!1),c({mode:"add",chart:Ry()})},disabled:a.length>=us,className:"bg-accent text-background hover:bg-accent/90 rounded-lg px-4 py-2 text-sm font-semibold disabled:cursor-not-allowed disabled:opacity-40",children:"Add chart"}),z.jsx("button",{type:"button",onClick:v,onBlur:()=>{f(!1)},className:`rounded-lg border px-4 py-2 text-sm ${d?"border-amber-400/60 text-amber-200":"border-textMuted/25 text-textMuted hover:border-accentSecondary hover:text-accentSecondary"}`,children:d?"Confirm reset":"Reset defaults"})]})]}),a.length===0?z.jsxs("div",{className:"border-accent/20 bg-surface/60 rounded-xl border border-dashed px-6 py-16 text-center",children:[z.jsx("p",{className:"text-textPrimary font-medium",children:"No charts in this dashboard."}),z.jsx("p",{className:"text-textMuted mt-2 text-sm",children:"Add a custom chart or start from a template."})]}):z.jsx("div",{className:"grid gap-4 xl:grid-cols-2",children:a.map((x,S)=>z.jsx(v3,{chart:x,metrics:n,canMoveEarlier:S>0,canMoveLater:S{u(T=>T.filter(w=>w.id!==x.id))},onDuplicate:()=>{u(T=>T.length>=us?T:[...T,FE(x)])},onEdit:()=>{c({mode:"edit",chart:x})},onMoveEarlier:()=>{g(S,-1)},onMoveLater:()=>{g(S,1)}},x.id))}),s&&z.jsx(fT,{chart:s.chart,mode:s.mode,onCancel:()=>{c(null)},onSave:p},`${s.mode}-${s.chart.id}`)]})}function v3({chart:n,metrics:a,canMoveEarlier:u,canMoveLater:s,canDuplicate:c,onDelete:d,onDuplicate:f,onEdit:p,onMoveEarlier:g,onMoveLater:v}){const[x,S]=_e.useState(null),[T,w]=_e.useState(0),O=_e.useMemo(()=>lT(x??a,n),[n,a,x]),Y=_e.useMemo(()=>n.series.map(B=>({label:B.label??Za(B.signalId).label,color:B.color})),[n.series]),W=p3(O.unit),F=`Waiting for ${n.series.length===1?Y[0]?.label?.toLowerCase():"the selected signals"}…`;return z.jsxs("article",{className:"border-accent/20 bg-surface/70 min-w-0 overflow-hidden rounded-xl border",children:[z.jsx("header",{className:"border-accent/15 space-y-3 border-b px-4 py-4 sm:px-5",children:z.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[z.jsxs("div",{className:"min-w-0",children:[z.jsx("h3",{className:"truncate font-semibold",title:n.title,children:n.title}),z.jsxs("p",{className:"text-textMuted mt-1 text-xs",children:[Ly(O.unit)," · ",o3[n.range]," · ",n.visualization,x?" · paused":""]})]}),z.jsxs("div",{className:"flex flex-wrap justify-end gap-1 text-xs",children:[z.jsx(lu,{label:x?"Resume chart":"Pause chart",onClick:()=>{S(B=>B?null:a)},children:x?"Resume":"Pause"}),z.jsx(lu,{label:"Reset chart zoom",onClick:()=>{w(B=>B+1)},children:"Reset zoom"}),z.jsx(lu,{label:"Edit chart",onClick:p,children:"Edit"}),z.jsx(lu,{label:"Duplicate chart",onClick:f,disabled:!c,children:"Duplicate"}),z.jsx(lu,{label:`Move ${n.title} earlier`,onClick:g,disabled:!u,children:"←"}),z.jsx(lu,{label:`Move ${n.title} later`,onClick:v,disabled:!s,children:"→"}),z.jsx(lu,{label:"Delete chart",onClick:d,danger:!0,children:"Delete"})]})]})}),z.jsx("div",{className:"min-w-0 p-3 sm:p-5",children:z.jsx(s3,{data:O.data,series:Y,visualization:n.visualization,zeroBased:iT(O.unit),valueFormatter:W,valueSuffix:aT(O.unit),forceEmpty:!O.hasObservedData,emptyMessage:F},T)}),O.unobservedLabels.length>0&&O.hasObservedData&&z.jsxs("footer",{className:"border-accent/10 text-textMuted border-t px-5 py-2 text-[11px]",children:["Not observed this session: ",O.unobservedLabels.join(", ")]})]})}function lu({label:n,children:a,onClick:u,disabled:s=!1,danger:c=!1}){return z.jsx("button",{type:"button","aria-label":n,onClick:u,disabled:s,className:`rounded px-2 py-1.5 disabled:cursor-not-allowed disabled:opacity-30 ${c?"text-textMuted hover:bg-red-500/10 hover:text-red-300":"text-textMuted hover:text-textPrimary hover:bg-white/5"}`,children:a})}const y3=[{event:0,label:"Header archived"},{event:3,label:"Block archived"},{event:5,label:"Block validated"},{event:6,label:"Block confirmed"},{event:13,label:"Block organized"},{event:14,label:"Block reorganized"}];function b3({adminStatus:n,endpoints:a,metrics:u,native:s}){const c=HE(u,10),d=s.configuration,f=Al(6),p=[n.error?`Admin: ${n.error}`:null,s.status.error?`Native: ${s.status.error}`:null,s.transport==="none"&&s.restError?`Native REST: ${s.restError}`:null,u.invalidFrames>0?`${String(u.invalidFrames)} malformed admin frame${u.invalidFrames===1?"":"s"} ignored`:null].filter(g=>g!==null);return z.jsxs("div",{className:"space-y-8",children:[p.length>0&&z.jsxs("section",{className:"rounded-xl border border-amber-500/30 bg-amber-500/10 px-4 py-3",children:[z.jsx("p",{className:"text-sm font-medium text-amber-300",children:"Transport notice"}),z.jsx("ul",{className:"text-textMuted mt-1 space-y-1 text-xs",children:p.map(g=>z.jsx("li",{children:g},g))})]}),z.jsxs("section",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[z.jsx(oo,{label:"Canonical top",value:s.top===null?"—":ka(s.top),detail:s.transport==="none"?"Waiting for native API":`via ${s.transport==="websocket"?"native WebSocket":"REST fallback"}`,accent:"orange"}),z.jsx(oo,{label:"Current activity",value:c.label,detail:c.rate>0?`${pE(c.rate)} over the last 10 seconds`:"No lifecycle events in the last 10 seconds",accent:"green"}),z.jsx(oo,{label:"Highest confirmed",value:u.signalMaximums[f]===void 0?"—":ka(u.signalMaximums[f]),detail:`${ka(u.signalTotals[f]??0)} confirmations observed`,accent:"blue"}),z.jsx(oo,{label:"Collection uptime",value:mE(u.now-u.sessionStartedAt),detail:`${ka(u.totalEvents)} events · ${ka(u.totalLogs)} logs`,accent:"red"})]}),z.jsxs("section",{className:"grid gap-4 lg:grid-cols-2",children:[z.jsx(Uv,{title:"Admin stream",endpoint:a.adminUrl,status:n,detail:n.lastMessageAt?`Last frame ${Or(n.lastMessageAt)}`:"Waiting for the first frame"}),z.jsx(Uv,{title:"Native interface",endpoint:a.nativeUrl,status:s.status,detail:s.receivedAt?`Last state ${Or(s.receivedAt)} · ${s.transport}`:"Waiting for node state"})]}),z.jsx(g3,{metrics:u}),z.jsxs("section",{className:"grid gap-4 xl:grid-cols-[1.1fr_0.9fr]",children:[z.jsxs("div",{className:"border-accent/20 bg-surface/70 rounded-xl border",children:[z.jsxs("header",{className:"border-accent/15 border-b px-5 py-4",children:[z.jsx("p",{className:"text-accentSecondary text-xs tracking-wide uppercase",children:"Lifecycle heights"}),z.jsx("h2",{className:"mt-1 font-semibold",children:"Highest observed event values"})]}),z.jsx("div",{className:"grid gap-px bg-white/5 sm:grid-cols-2 lg:grid-cols-3",children:y3.map(({event:g,label:v})=>{const x=u.signalMaximums[Al(g)];return z.jsxs("div",{className:"bg-surface px-5 py-4",children:[z.jsx("p",{className:"text-textMuted text-xs",children:v}),z.jsx("p",{className:"text-textPrimary mt-2 font-mono text-lg tabular-nums",children:x===void 0?"—":ka(x)})]},g)})})]}),z.jsxs("div",{className:"border-accent/20 bg-surface/70 rounded-xl border",children:[z.jsxs("header",{className:"border-accent/15 border-b px-5 py-4",c)DELIM" +R"DELIM(hildren:[z.jsx("p",{className:"text-accentSecondary text-xs tracking-wide uppercase",children:"Capabilities"}),z.jsx("h2",{className:"mt-1 font-semibold",children:"Native configuration"})]}),d?z.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-4 p-5 text-sm",children:[z.jsx(is,{label:"Address index",enabled:d.address}),z.jsx(is,{label:"Client filters",enabled:d.filter}),z.jsx(is,{label:"Turbo",enabled:d.turbo}),z.jsx(is,{label:"Witness",enabled:d.witness}),z.jsx(is,{label:"Retarget",enabled:d.retarget}),z.jsx(is,{label:"Difficulty",enabled:d.difficult}),z.jsxs("div",{className:"col-span-2 border-t border-white/5 pt-3",children:[z.jsx("span",{className:"text-textMuted",children:"Pruned below"}),z.jsx("span",{className:"text-textPrimary float-right font-mono",children:d.pruned>0?ka(d.pruned):"Not pruned"})]})]}):z.jsx("p",{className:"text-textMuted px-5 py-10 text-center text-sm",children:"Waiting for native configuration."})]})]}),z.jsx("section",{children:z.jsxs("div",{className:"border-accent/20 bg-surface/70 rounded-xl border",children:[z.jsx("header",{className:"border-accent/15 border-b px-5 py-4",children:z.jsx("p",{className:"text-accentSecondary text-xs tracking-wide uppercase",children:"Recent events"})}),u.recentEvents.length===0?z.jsx(S3,{text:"No events observed yet."}):z.jsx("ul",{className:"divide-y divide-white/5",children:u.recentEvents.slice(0,6).map(g=>z.jsxs("li",{className:"flex items-center gap-3 px-5 py-3 text-xs",children:[z.jsx("time",{className:"text-textMuted w-24 shrink-0 font-mono",children:Or(g.time)}),z.jsx("span",{className:"text-textPrimary min-w-0 flex-1 truncate font-mono",children:cu(g.event).name}),z.jsx("span",{className:"text-accent tabular-nums",children:Ay(g.event,g.value)})]},g.id))})]})})]})}function Uv({title:n,endpoint:a,status:u,detail:s}){return z.jsxs("article",{className:"border-accent/20 bg-surface/70 min-w-0 rounded-xl border p-5",children:[z.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[z.jsxs("div",{children:[z.jsx("p",{className:"text-textMuted text-xs tracking-wide uppercase",children:n}),z.jsx("p",{className:"text-textPrimary mt-2 font-mono text-sm break-all",children:gE(a)})]}),z.jsx(qE,{phase:u.phase,label:u.phase})]}),z.jsxs("div",{className:"text-textMuted mt-4 flex flex-wrap justify-between gap-2 border-t border-white/5 pt-3 text-xs",children:[z.jsx("span",{children:s}),z.jsxs("span",{children:[String(u.reconnects)," reconnect",u.reconnects===1?"":"s"]})]})]})}function is({label:n,enabled:a}){return z.jsxs("div",{className:"flex items-center justify-between gap-3",children:[z.jsx("span",{className:"text-textMuted",children:n}),z.jsx("span",{className:a?"text-emerald-300":"text-textMuted",children:a?"Enabled":"Disabled"})]})}function S3({text:n}){return z.jsx("p",{className:"text-textMuted px-5 py-10 text-center text-sm",children:n})}var Hr=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(n){return this.listeners.add(n),this.onSubscribe(),()=>{this.listeners.delete(n),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},_3=class extends Hr{#e;#t;#n;constructor(){super(),this.#n=n=>{if(typeof window<"u"&&window.addEventListener){const a=()=>n();return window.addEventListener("visibilitychange",a,!1),()=>{window.removeEventListener("visibilitychange",a)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(n){this.#n=n,this.#t?.(),this.#t=n(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()})}setFocused(n){this.#e!==n&&(this.#e=n,this.onFocus())}onFocus(){const n=this.isFocused();this.listeners.forEach(a=>{a(n)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},tm=new _3,x3={setTimeout:(n,a)=>setTimeout(n,a),clearTimeout:n=>clearTimeout(n),setInterval:(n,a)=>setInterval(n,a),clearInterval:n=>clearInterval(n)},z3=class{#e=x3;#t=!1;setTimeoutProvider(n){this.#e=n}setTimeout(n,a){return this.#e.setTimeout(n,a)}clearTimeout(n){this.#e.clearTimeout(n)}setInterval(n,a){return this.#e.setInterval(n,a)}clearInterval(n){this.#e.clearInterval(n)}},ru=new z3;function E3(n){setTimeout(n,0)}var T3=typeof window>"u"||"Deno"in globalThis;function Wn(){}function w3(n,a){return typeof n=="function"?n(a):n}function ph(n){return typeof n=="number"&&n>=0&&n!==1/0}function Tb(n,a){return Math.max(n+(a||0)-Date.now(),0)}function wi(n,a){return typeof n=="function"?n(a):n}function fl(n,a){return typeof n=="function"?n(a):n}function kv(n,a){const{type:u="all",exact:s,fetchStatus:c,predicate:d,queryKey:f,stale:p}=n;if(f){if(s){if(a.queryHash!==nm(f,a.options))return!1}else if(!vs(a.queryKey,f))return!1}if(u!=="all"){const g=a.isActive();if(u==="active"&&!g||u==="inactive"&&g)return!1}return!(typeof p=="boolean"&&a.isStale()!==p||c&&c!==a.state.fetchStatus||d&&!d(a))}function Zv(n,a){const{exact:u,status:s,predicate:c,mutationKey:d}=n;if(d){if(!a.options.mutationKey)return!1;if(u){if(kr(a.options.mutationKey)!==kr(d))return!1}else if(!vs(a.options.mutationKey,d))return!1}return!(s&&a.state.status!==s||c&&!c(a))}function nm(n,a){return(a?.queryKeyHashFn||kr)(n)}function kr(n){return JSON.stringify(n,(a,u)=>vh(u)?Object.keys(u).sort().reduce((s,c)=>(s[c]=u[c],s),{}):u)}function vs(n,a){if(n===a)return!0;if(typeof n!=typeof a)return!1;if(n&&a&&typeof n=="object"&&typeof a=="object"){if(Array.isArray(n)&&Array.isArray(a)){for(let s=0;s500)return a;const s=Lv(n)&&Lv(a);if(!s&&!(vh(n)&&vh(a)))return a;const d=(s?n:Object.keys(n)).length,f=s?a:Object.keys(a),p=f.length,g=s?new Array(p):{};let v=0;for(let x=0;x{ru.setTimeout(a,n)})}function yh(n,a,u){return typeof u.structuralSharing=="function"?u.structuralSharing(n,a):u.structuralSharing!==!1?wb(n,a):a}function O3(n,a,u=0){const s=[...n,a];return u&&s.length>u?s.slice(1):s}function N3(n,a,u=0){const s=[a,...n];return u&&s.length>u?s.slice(0,-1):s}var lm=Symbol();function Mb(n,a){return!n.queryFn&&a?.initialPromise?()=>a.initialPromise:!n.queryFn||n.queryFn===lm?()=>Promise.reject(new Error(`Missing queryFn: '${n.queryHash}'`)):n.queryFn}function Ab(n,a){return typeof n=="function"?n(...a):!!n}function j3(n,a,u){let s=!1,c;return Object.defineProperty(n,"signal",{enumerable:!0,get:()=>(c??=a(),s||(s=!0,c.aborted?u():c.addEventListener("abort",u,{once:!0})),c)}),n}var Zr=(()=>{let n=()=>T3;return{isServer(){return n()},setIsServer(a){n=a}}})();function bh(){let n,a;const u=new Promise((c,d)=>{n=c,a=d});u.status="pending",u.catch(()=>{});function s(c){Object.assign(u,c),delete u.resolve,delete u.reject}return u.resolve=c=>{s({status:"fulfilled",value:c}),n(c)},u.reject=c=>{s({status:"rejected",reason:c}),a(c)},u}var D3=E3;function C3(){let n=[],a=0,u=p=>{p()},s=p=>{p()},c=D3;const d=p=>{a?n.push(p):c(()=>{u(p)})},f=()=>{const p=n;n=[],p.length&&c(()=>{s(()=>{p.forEach(g=>{u(g)})})})};return{batch:p=>{let g;a++;try{g=p()}finally{a--,a||f()}return g},batchCalls)DELIM" +R"DELIM(:p=>(...g)=>{d(()=>{p(...g)})},schedule:d,setNotifyFunction:p=>{u=p},setBatchNotifyFunction:p=>{s=p},setScheduler:p=>{c=p}}}var Sn=C3(),R3=class extends Hr{#e=!0;#t;#n;constructor(){super(),this.#n=n=>{if(typeof window<"u"&&window.addEventListener){const a=()=>n(!0),u=()=>n(!1);return window.addEventListener("online",a,!1),window.addEventListener("offline",u,!1),()=>{window.removeEventListener("online",a),window.removeEventListener("offline",u)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(n){this.#n=n,this.#t?.(),this.#t=n(this.setOnline.bind(this))}setOnline(n){this.#e!==n&&(this.#e=n,this.listeners.forEach(u=>{u(n)}))}isOnline(){return this.#e}},Ao=new R3;function U3(n){return Math.min(1e3*2**n,3e4)}function Ob(n){return(n??"online")==="online"?Ao.isOnline():!0}var Sh=class extends Error{constructor(n){super("CancelledError"),this.revert=n?.revert,this.silent=n?.silent}};function Nb(n){let a=!1,u=0,s;const c=bh(),d=()=>c.status!=="pending",f=Y=>{if(!d()){const W=new Sh(Y);T(W),n.onCancel?.(W)}},p=()=>{a=!0},g=()=>{a=!1},v=()=>tm.isFocused()&&(n.networkMode==="always"||Ao.isOnline())&&n.canRun(),x=()=>Ob(n.networkMode)&&n.canRun(),S=Y=>{d()||(s?.(),c.resolve(Y))},T=Y=>{d()||(s?.(),c.reject(Y))},w=()=>new Promise(Y=>{s=W=>{(d()||v())&&Y(W)},n.onPause?.()}).then(()=>{s=void 0,d()||n.onContinue?.()}),O=()=>{if(d())return;let Y;const W=u===0?n.initialPromise:void 0;try{Y=W??n.fn()}catch(F){Y=Promise.reject(F)}Promise.resolve(Y).then(S).catch(F=>{if(d())return;const B=n.retry??(Zr.isServer()?0:3),I=n.retryDelay??U3,q=typeof I=="function"?I(u,F):I,ae=B===!0||typeof B=="number"&&uv()?void 0:w()).then(()=>{a?T(F):O()})})};return{promise:c,status:()=>c.status,cancel:f,continue:()=>(s?.(),c),cancelRetry:p,continueRetry:g,canStart:x,start:()=>(x()?O():w().then(O),c)}}var jb=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ph(this.gcTime)&&(this.#e=ru.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(n){this.gcTime=Math.max(this.gcTime||0,n??(Zr.isServer()?1/0:300*1e3))}clearGcTimeout(){this.#e!==void 0&&(ru.clearTimeout(this.#e),this.#e=void 0)}};function k3(n){return{onFetch:(a,u)=>{const s=a.options,c=a.fetchOptions?.meta?.fetchMore?.direction,d=a.state.data?.pages||[],f=a.state.data?.pageParams||[];let p={pages:[],pageParams:[]},g=0;const v=async()=>{let x=!1;const S=O=>{j3(O,()=>a.signal,()=>x=!0)},T=Mb(a.options,a.fetchOptions),w=async(O,Y,W)=>{if(x)return Promise.reject(a.signal.reason);if(Y==null&&O.pages.length)return Promise.resolve(O);const B=(()=>{const ne={client:a.client,queryKey:a.queryKey,pageParam:Y,direction:W?"backward":"forward",meta:a.options.meta};return S(ne),ne})(),I=await T(B),{maxPages:q}=a.options,ae=W?N3:O3;return{pages:ae(O.pages,I,q),pageParams:ae(O.pageParams,Y,q)}};if(c&&d.length){const O=c==="backward",Y=O?Z3:Bv,W={pages:d,pageParams:f},F=Y(s,W);p=await w(W,F,O)}else{const O=n??d.length;do{const Y=g===0?f[0]??s.initialPageParam:Bv(s,p);if(g>0&&Y==null)break;p=await w(p,Y),g++}while(ga.options.persister?.(v,{client:a.client,queryKey:a.queryKey,meta:a.options.meta,signal:a.signal},u):a.fetchFn=v}}}function Bv(n,{pages:a,pageParams:u}){const s=a.length-1;return a.length>0?n.getNextPageParam(a[s],a,u[s],u):void 0}function Z3(n,{pages:a,pageParams:u}){return a.length>0?n.getPreviousPageParam?.(a[0],a,u[0],u):void 0}var L3=class extends jb{#e;#t;#n;#l;#a;#i;#s;#u;constructor(n){super(),this.#u=!1,this.#s=n.defaultOptions,this.setOptions(n.options),this.observers=[],this.#a=n.client,this.#l=this.#a.getQueryCache(),this.queryKey=n.queryKey,this.queryHash=n.queryHash,this.#t=Gv(this.options),this.state=n.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#i?.promise}setOptions(n){if(this.options={...this.#s,...n},n?._type&&(this.#e=n._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const a=Gv(this.options);a.data!==void 0&&(this.setState(qv(a.data,a.dataUpdatedAt)),this.#t=a)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#l.remove(this)}setData(n,a){const u=yh(this.state.data,n,this.options);return this.#r({data:u,type:"success",dataUpdatedAt:a?.updatedAt,manual:a?.manual}),u}setState(n){this.#r({type:"setState",state:n})}cancel(n){const a=this.#i?.promise;return this.#i?.cancel(n),a?a.then(Wn).catch(Wn):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(n=>fl(n.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===lm||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(n=>wi(n.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(n=>n.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(n=0){return this.state.data===void 0?!0:n==="static"?!1:this.state.isInvalidated?!0:!Tb(this.state.dataUpdatedAt,n)}onFocus(){this.observers.find(a=>a.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(a=>a.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(n){this.observers.includes(n)||(this.observers.push(n),this.clearGcTimeout(),this.#l.notify({type:"observerAdded",query:this,observer:n}))}removeObserver(n){this.observers.includes(n)&&(this.observers=this.observers.filter(a=>a!==n),this.observers.length||(this.#i&&(this.#u||this.#c()?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#l.notify({type:"observerRemoved",query:this,observer:n}))}getObserversCount(){return this.observers.length}#c(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"}invalidate(){this.state.isInvalidated||this.#r({type:"invalidate"})}async fetch(n,a){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&a?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(n&&this.setOptions(n),!this.options.queryFn){const g=this.observers.find(v=>v.options.queryFn);g&&this.setOptions(g.options)}const u=new AbortController,s=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(this.#u=!0,u.signal)})},c=()=>{const g=Mb(this.options,a),x=(()=>{const S={client:this.#a,queryKey:this.queryKey,meta:this.meta};return s(S),S})();return this.#u=!1,this.options.persister?this.options.persister(g,x,this):g(x)},f=(()=>{const g={fetchOptions:a,options:this.options,queryKey:this.queryKey,client:this.#a,state:this.state,fetchFn:c};return s(g),g})();(this.#e==="infinite"?k3(this.options.pages):this.options.behavior)?.onFetch(f,this),this.#n=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==f.fetchOptions?.meta)&&this.#r({type:"fetch",meta:f.fetchOptions?.meta}),this.#i=Nb({initialPromise:a?.initialPromise,fn:f.fetchFn,onCancel:g=>{g instanceof Sh&&g.revert&&this.setState({...this.#n,fetchStatus:"idle"}),u.abort()},onFail:(g,v)=>{this.#r({type:"failed",failureCount:g,error:v})},onPause:()=>{this.#r({type:"pause"})},onContinue:()=>{this.#r({type:"continue"})},retry:f.options.retry,retryDelay:f.options.retryDelay,networkMode:f.options.networkMode,canRun:()=>!0});try{const g=await this.#i.start();if(g===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(g),this.#l.config.onSuccess?.(g,this),this.#l.config.onSettled?.(g,this.state.error,this),g}catch(g){if(g instanceof Sh){if(g.silent)return this.#i.promise;if(g.rever)DELIM" +R"DELIM(t){if(this.state.data===void 0)throw g;return this.state.data}}throw this.#r({type:"error",error:g}),this.#l.config.onError?.(g,this),this.#l.config.onSettled?.(this.state.data,g,this),g}finally{this.scheduleGc()}}#r(n){const a=u=>{switch(n.type){case"failed":return{...u,fetchFailureCount:n.failureCount,fetchFailureReason:n.error};case"pause":return{...u,fetchStatus:"paused"};case"continue":return{...u,fetchStatus:"fetching"};case"fetch":return{...u,...Db(u.data,this.options),fetchMeta:n.meta??null};case"success":const s={...u,...qv(n.data,n.dataUpdatedAt),dataUpdateCount:u.dataUpdateCount+1,...!n.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#n=n.manual?s:void 0,s;case"error":const c=n.error;return{...u,error:c,errorUpdateCount:u.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:u.fetchFailureCount+1,fetchFailureReason:c,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...u,isInvalidated:!0};case"setState":return{...u,...n.state}}};this.state=a(this.state),Sn.batch(()=>{this.observers.forEach(u=>{u.onQueryUpdate()}),this.#l.notify({query:this,type:"updated",action:n})})}};function Db(n,a){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ob(a.networkMode)?"fetching":"paused",...n===void 0&&{error:null,status:"pending"}}}function qv(n,a){return{data:n,dataUpdatedAt:a??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Gv(n){const a=typeof n.initialData=="function"?n.initialData():n.initialData,u=a!==void 0,s=u?typeof n.initialDataUpdatedAt=="function"?n.initialDataUpdatedAt():n.initialDataUpdatedAt:0;return{data:a,dataUpdateCount:0,dataUpdatedAt:u?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:u?"success":"pending",fetchStatus:"idle"}}var H3=class extends Hr{constructor(n,a){super(),this.options=a,this.#e=n,this.#u=null,this.#s=bh(),this.bindMethods(),this.setOptions(a)}#e;#t=void 0;#n=void 0;#l=void 0;#a;#i;#s;#u;#c;#r;#d;#h;#f;#m;#g=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),Qv(this.#t,this.options)?this.#o():this.updateResult(),this.#x())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return _h(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return _h(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#p(),this.#t.removeObserver(this)}setOptions(n){const a=this.options,u=this.#t;if(this.options=this.#e.defaultQueryOptions(n),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof fl(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#y(),this.#t.setOptions(this.options),a._defaulted&&!gh(this.options,a)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const s=this.hasListeners();s&&Yv(this.#t,u,this.options,a)&&this.#o(),this.updateResult(),s&&(this.#t!==u||fl(this.options.enabled,this.#t)!==fl(a.enabled,this.#t)||wi(this.options.staleTime,this.#t)!==wi(a.staleTime,this.#t))&&this.#b();const c=this.#S();s&&(this.#t!==u||fl(this.options.enabled,this.#t)!==fl(a.enabled,this.#t)||c!==this.#m)&&this.#_(c)}getOptimisticResult(n){const a=this.#e.getQueryCache().build(this.#e,n),u=this.createResult(a,n);return q3(this,u)&&(this.#l=u,this.#i=this.options,this.#a=this.#t.state),u}getCurrentResult(){return this.#l}trackResult(n,a){return new Proxy(n,{get:(u,s)=>(this.trackProp(s),a?.(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#s.status==="pending"&&this.#s.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(u,s))})}trackProp(n){this.#g.add(n)}getCurrentQuery(){return this.#t}refetch({...n}={}){return this.fetch({...n})}fetchOptimistic(n){const a=this.#e.defaultQueryOptions(n),u=this.#e.getQueryCache().build(this.#e,a);return u.fetch().then(()=>this.createResult(u,a))}fetch(n){return this.#o({...n,cancelRefetch:n.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#l))}#o(n){this.#y();let a=this.#t.fetch(this.options,n);return n?.throwOnError||(a=a.catch(Wn)),a}#b(){this.#v();const n=wi(this.options.staleTime,this.#t);if(Zr.isServer()||this.#l.isStale||!ph(n))return;const u=Tb(this.#l.dataUpdatedAt,n)+1;this.#h=ru.setTimeout(()=>{this.#l.isStale||this.updateResult()},u)}#S(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#_(n){this.#p(),this.#m=n,!(Zr.isServer()||fl(this.options.enabled,this.#t)===!1||!ph(this.#m)||this.#m===0)&&(this.#f=ru.setInterval(()=>{(this.options.refetchIntervalInBackground||tm.isFocused())&&this.#o()},this.#m))}#x(){this.#b(),this.#_(this.#S())}#v(){this.#h!==void 0&&(ru.clearTimeout(this.#h),this.#h=void 0)}#p(){this.#f!==void 0&&(ru.clearInterval(this.#f),this.#f=void 0)}createResult(n,a){const u=this.#t,s=this.options,c=this.#l,d=this.#a,f=this.#i,g=n!==u?n.state:this.#n,{state:v}=n;let x={...v},S=!1,T;if(a._optimisticResults){const se=this.hasListeners(),Ae=!se&&Qv(n,a),ze=se&&Yv(n,u,a,s);(Ae||ze)&&(x={...x,...Db(v.data,n.options)}),a._optimisticResults==="isRestoring"&&(x.fetchStatus="idle")}let{error:w,errorUpdatedAt:O,status:Y}=x;T=x.data;let W=!1;if(a.placeholderData!==void 0&&T===void 0&&Y==="pending"){let se;c?.isPlaceholderData&&a.placeholderData===f?.placeholderData?(se=c.data,W=!0):se=typeof a.placeholderData=="function"?a.placeholderData(this.#d?.state.data,this.#d):a.placeholderData,se!==void 0&&(Y="success",T=yh(c?.data,se,a),S=!0)}if(a.select&&T!==void 0&&!W)if(c&&T===d?.data&&a.select===this.#c)T=this.#r;else try{this.#c=a.select,T=a.select(T),T=yh(c?.data,T,a),this.#r=T,this.#u=null}catch(se){this.#u=se}this.#u&&(w=this.#u,T=this.#r,O=Date.now(),Y="error");const F=x.fetchStatus==="fetching",B=Y==="pending",I=Y==="error",q=B&&F,ae=T!==void 0,le={status:Y,fetchStatus:x.fetchStatus,isPending:B,isSuccess:Y==="success",isError:I,isInitialLoading:q,isLoading:q,data:T,dataUpdatedAt:x.dataUpdatedAt,error:w,errorUpdatedAt:O,failureCount:x.fetchFailureCount,failureReason:x.fetchFailureReason,errorUpdateCount:x.errorUpdateCount,isFetched:n.isFetched(),isFetchedAfterMount:x.dataUpdateCount>g.dataUpdateCount||x.errorUpdateCount>g.errorUpdateCount,isFetching:F,isRefetching:F&&!B,isLoadingError:I&&!ae,isPaused:x.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:I&&ae,isStale:am(n,a),refetch:this.refetch,promise:this.#s,isEnabled:fl(a.enabled,n)!==!1};if(this.options.experimental_prefetchInRender){const se=le.data!==void 0,Ae=le.status==="error"&&!se,ze=ce=>{Ae?ce.reject(le.error):se&&ce.resolve(le.data)},ee=()=>{const ce=this.#s=le.promise=bh();ze(ce)},ye=this.#s;switch(ye.status){case"pending":n.queryHash===u.queryHash&&ze(ye);break;case"fulfilled":(Ae||le.data!==ye.value)&&ee();break;case"rejected":(!Ae||le.error!==ye.reason)&&ee();break}}return le}updateResult(){const n=this.#l,a=this.createResult(this.#t,this.options);if(this.#a=this.#t.state,this.#i=this.options,this.#a.data!==void 0&&(this.#d=this.#t),gh(a,n))return;this.#l=a;const u=()=>{if(!n)return!0;const{notifyOnChangeProps:s}=this.options,c=typeof s=="function"?s():s;if(c==="all"||!c&&!this.#g.size)return!0;const d=new Set(c??this.#g);return this.options.throwOnError&&d.add("error"),Object.keys(this.#l).some(f=>{const p=f;return this.#l[p]!==n[p]&&d.has(p)})};this.#z({listeners:u()})}#y(){const n=this.#e.getQueryCache().build(this.#e,this.options);if(n===this.#t)return;const a=this.#t;this.#t=n,this.#n=n.state,this.hasListeners()&&(a?.removeObserver(this),n.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#x()}#z(n){Sn.batch(()=>{n.listeners&&this.listeners.forEach(a=>{a(t)DELIM" +R"DELIM(his.#l)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function B3(n,a){return fl(a.enabled,n)!==!1&&n.state.data===void 0&&!(n.state.status==="error"&&fl(a.retryOnMount,n)===!1)}function Qv(n,a){return B3(n,a)||n.state.data!==void 0&&_h(n,a,a.refetchOnMount)}function _h(n,a,u){if(fl(a.enabled,n)!==!1&&wi(a.staleTime,n)!=="static"){const s=typeof u=="function"?u(n):u;return s==="always"||s!==!1&&am(n,a)}return!1}function Yv(n,a,u,s){return(n!==a||fl(s.enabled,n)===!1)&&(!u.suspense||n.state.status!=="error")&&am(n,u)}function am(n,a){return fl(a.enabled,n)!==!1&&n.isStaleByTime(wi(a.staleTime,n))}function q3(n,a){return!gh(n.getCurrentResult(),a)}var G3=class extends jb{#e;#t;#n;#l;constructor(n){super(),this.#e=n.client,this.mutationId=n.mutationId,this.#n=n.mutationCache,this.#t=[],this.state=n.state||Q3(),this.setOptions(n.options),this.scheduleGc()}setOptions(n){this.options=n,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(n){this.#t.includes(n)||(this.#t.push(n),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:n}))}removeObserver(n){this.#t=this.#t.filter(a=>a!==n),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:n})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#l?.continue()??this.execute(this.state.variables)}async execute(n){const a=()=>{this.#a({type:"continue"})},u={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#l=Nb({fn:()=>this.options.mutationFn?this.options.mutationFn(n,u):Promise.reject(new Error("No mutationFn found")),onFail:(d,f)=>{this.#a({type:"failed",failureCount:d,error:f})},onPause:()=>{this.#a({type:"pause"})},onContinue:a,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});const s=this.state.status==="pending",c=!this.#l.canStart();try{if(s)a();else{this.#a({type:"pending",variables:n,isPaused:c}),this.#n.config.onMutate&&await this.#n.config.onMutate(n,this,u);const f=await this.options.onMutate?.(n,u);f!==this.state.context&&this.#a({type:"pending",context:f,variables:n,isPaused:c})}const d=await this.#l.start();return await this.#n.config.onSuccess?.(d,n,this.state.context,this,u),await this.options.onSuccess?.(d,n,this.state.context,u),await this.#n.config.onSettled?.(d,null,this.state.variables,this.state.context,this,u),await this.options.onSettled?.(d,null,n,this.state.context,u),this.#a({type:"success",data:d}),d}catch(d){try{await this.#n.config.onError?.(d,n,this.state.context,this,u)}catch(f){Promise.reject(f)}try{await this.options.onError?.(d,n,this.state.context,u)}catch(f){Promise.reject(f)}try{await this.#n.config.onSettled?.(void 0,d,this.state.variables,this.state.context,this,u)}catch(f){Promise.reject(f)}try{await this.options.onSettled?.(void 0,d,n,this.state.context,u)}catch(f){Promise.reject(f)}throw this.#a({type:"error",error:d}),d}finally{this.#n.runNext(this)}}#a(n){const a=u=>{switch(n.type){case"failed":return{...u,failureCount:n.failureCount,failureReason:n.error};case"pause":return{...u,isPaused:!0};case"continue":return{...u,isPaused:!1};case"pending":return{...u,context:n.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:n.isPaused,status:"pending",variables:n.variables,submittedAt:Date.now()};case"success":return{...u,data:n.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...u,data:void 0,error:n.error,failureCount:u.failureCount+1,failureReason:n.error,isPaused:!1,status:"error"}}};this.state=a(this.state),Sn.batch(()=>{this.#t.forEach(u=>{u.onMutationUpdate(n)}),this.#n.notify({mutation:this,type:"updated",action:n})})}};function Q3(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Y3=class extends Hr{constructor(n={}){super(),this.config=n,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(n,a,u){const s=new G3({client:n,mutationCache:this,mutationId:++this.#n,options:n.defaultMutationOptions(a),state:u});return this.add(s),s}add(n){this.#e.add(n);const a=po(n);if(typeof a=="string"){const u=this.#t.get(a);u?u.push(n):this.#t.set(a,[n])}this.notify({type:"added",mutation:n})}remove(n){if(this.#e.delete(n)){const a=po(n);if(typeof a=="string"){const u=this.#t.get(a);if(u)if(u.length>1){const s=u.indexOf(n);s!==-1&&u.splice(s,1)}else u[0]===n&&this.#t.delete(a)}}this.notify({type:"removed",mutation:n})}canRun(n){const a=po(n);if(typeof a=="string"){const s=this.#t.get(a)?.find(c=>c.state.status==="pending");return!s||s===n}else return!0}runNext(n){const a=po(n);return typeof a=="string"?this.#t.get(a)?.find(s=>s!==n&&s.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Sn.batch(()=>{this.#e.forEach(n=>{this.notify({type:"removed",mutation:n})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(n){const a={exact:!0,...n};return this.getAll().find(u=>Zv(a,u))}findAll(n={}){return this.getAll().filter(a=>Zv(n,a))}notify(n){Sn.batch(()=>{this.listeners.forEach(a=>{a(n)})})}resumePausedMutations(){const n=this.getAll().filter(a=>a.state.isPaused);return Sn.batch(()=>Promise.all(n.map(a=>a.continue().catch(Wn))))}};function po(n){return n.options.scope?.id}var $3=class extends Hr{constructor(n={}){super(),this.config=n,this.#e=new Map}#e;build(n,a,u){const s=a.queryKey,c=a.queryHash??nm(s,a);let d=this.get(c);return d||(d=new L3({client:n,queryKey:s,queryHash:c,options:n.defaultQueryOptions(a),state:u,defaultOptions:n.getQueryDefaults(s)}),this.add(d)),d}add(n){this.#e.has(n.queryHash)||(this.#e.set(n.queryHash,n),this.notify({type:"added",query:n}))}remove(n){const a=this.#e.get(n.queryHash);a&&(n.destroy(),a===n&&this.#e.delete(n.queryHash),this.notify({type:"removed",query:n}))}clear(){Sn.batch(()=>{this.getAll().forEach(n=>{this.remove(n)})})}get(n){return this.#e.get(n)}getAll(){return[...this.#e.values()]}find(n){const a={exact:!0,...n};return this.getAll().find(u=>kv(a,u))}findAll(n={}){const a=this.getAll();return Object.keys(n).length>0?a.filter(u=>kv(n,u)):a}notify(n){Sn.batch(()=>{this.listeners.forEach(a=>{a(n)})})}onFocus(){Sn.batch(()=>{this.getAll().forEach(n=>{n.onFocus()})})}onOnline(){Sn.batch(()=>{this.getAll().forEach(n=>{n.onOnline()})})}},V3=class{#e;#t;#n;#l;#a;#i;#s;#u;constructor(n={}){this.#e=n.queryCache||new $3,this.#t=n.mutationCache||new Y3,this.#n=n.defaultOptions||{},this.#l=new Map,this.#a=new Map,this.#i=0}mount(){this.#i++,this.#i===1&&(this.#s=tm.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#u=Ao.subscribe(async n=>{n&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#i--,this.#i===0&&(this.#s?.(),this.#s=void 0,this.#u?.(),this.#u=void 0)}isFetching(n){return this.#e.findAll({...n,fetchStatus:"fetching"}).length}isMutating(n){return this.#t.findAll({...n,status:"pending"}).length}getQueryData(n){const a=this.defaultQueryOptions({queryKey:n});return this.#e.get(a.queryHash)?.state.data}ensureQueryData(n){const a=this.defaultQueryOptions(n),u=this.#e.build(this,a),s=u.state.data;return s===void 0?this.fetchQuery(n):(n.revalidateIfStale&&u.isStaleByTime(wi(a.staleTime,u))&&this.prefetchQuery(a),Promise.resolve(s))}getQueriesData(n){return this.#e.findAll(n).map(({queryKey:a,state:u})=>{const s=u.data;return[a,s]})}setQueryData(n,a,u){const s=this.defaultQueryOptions({queryKey:n}),d=this.#e.get(s.queryHash)?.state.data,f=w3(a,d);if(f!==void 0)return this.#e.build(this,s).setData(f,{...u,manual:!0})}setQueriesData(n,a,u){return Sn.batch(()=>this.#e.findAll(n).map(({queryKey:s})=>[s,this.setQueryData(s,a,u)]))}getQueryState(n){const a=this.defaultQueryOptions({queryKey:n});return this.#e.get(a.queryHash)?.state}removeQueries(n){const a=this.#e;Sn.bat)DELIM" +R"DELIM(ch(()=>{a.findAll(n).forEach(u=>{a.remove(u)})})}resetQueries(n,a){const u=this.#e;return Sn.batch(()=>(u.findAll(n).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...n},a)))}cancelQueries(n,a={}){const u={revert:!0,...a},s=Sn.batch(()=>this.#e.findAll(n).map(c=>c.cancel(u)));return Promise.all(s).then(Wn).catch(Wn)}invalidateQueries(n,a={}){return Sn.batch(()=>(this.#e.findAll(n).forEach(u=>{u.invalidate()}),n?.refetchType==="none"?Promise.resolve():this.refetchQueries({...n,type:n?.refetchType??n?.type??"active"},a)))}refetchQueries(n,a={}){const u={...a,cancelRefetch:a.cancelRefetch??!0},s=Sn.batch(()=>this.#e.findAll(n).filter(c=>!c.isDisabled()&&!c.isStatic()).map(c=>{let d=c.fetch(void 0,u);return u.throwOnError||(d=d.catch(Wn)),c.state.fetchStatus==="paused"?Promise.resolve():d}));return Promise.all(s).then(Wn)}fetchQuery(n){const a=this.defaultQueryOptions(n);a.retry===void 0&&(a.retry=!1);const u=this.#e.build(this,a);return u.isStaleByTime(wi(a.staleTime,u))?u.fetch(a):Promise.resolve(u.state.data)}prefetchQuery(n){return this.fetchQuery(n).then(Wn).catch(Wn)}fetchInfiniteQuery(n){return n._type="infinite",this.fetchQuery(n)}prefetchInfiniteQuery(n){return this.fetchInfiniteQuery(n).then(Wn).catch(Wn)}ensureInfiniteQueryData(n){return n._type="infinite",this.ensureQueryData(n)}resumePausedMutations(){return Ao.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(n){this.#n=n}setQueryDefaults(n,a){this.#l.set(kr(n),{queryKey:n,defaultOptions:a})}getQueryDefaults(n){const a=[...this.#l.values()],u={};return a.forEach(s=>{vs(n,s.queryKey)&&Object.assign(u,s.defaultOptions)}),u}setMutationDefaults(n,a){this.#a.set(kr(n),{mutationKey:n,defaultOptions:a})}getMutationDefaults(n){const a=[...this.#a.values()],u={};return a.forEach(s=>{vs(n,s.mutationKey)&&Object.assign(u,s.defaultOptions)}),u}defaultQueryOptions(n){if(n._defaulted)return n;const a={...this.#n.queries,...this.getQueryDefaults(n.queryKey),...n,_defaulted:!0};return a.queryHash||(a.queryHash=nm(a.queryKey,a)),a.refetchOnReconnect===void 0&&(a.refetchOnReconnect=a.networkMode!=="always"),a.throwOnError===void 0&&(a.throwOnError=!!a.suspense),!a.networkMode&&a.persister&&(a.networkMode="offlineFirst"),a.queryFn===lm&&(a.enabled=!1),a}defaultMutationOptions(n){return n?._defaulted?n:{...this.#n.mutations,...n?.mutationKey&&this.getMutationDefaults(n.mutationKey),...n,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Cb=_e.createContext(void 0),K3=n=>{const a=_e.useContext(Cb);if(!a)throw new Error("No QueryClient set, use QueryClientProvider to set one");return a},X3=({client:n,children:a})=>(_e.useEffect(()=>(n.mount(),()=>{n.unmount()}),[n]),z.jsx(Cb.Provider,{value:n,children:a})),Rb=_e.createContext(!1),J3=()=>_e.useContext(Rb);Rb.Provider;function F3(){let n=!1;return{clearReset:()=>{n=!1},reset:()=>{n=!0},isReset:()=>n}}var W3=_e.createContext(F3()),I3=()=>_e.useContext(W3),P3=(n,a,u)=>{const s=u?.state.error&&typeof n.throwOnError=="function"?Ab(n.throwOnError,[u.state.error,u]):n.throwOnError;(n.suspense||n.experimental_prefetchInRender||s)&&(a.isReset()||(n.retryOnMount=!1))},eM=n=>{_e.useEffect(()=>{n.clearReset()},[n])},tM=({result:n,errorResetBoundary:a,throwOnError:u,query:s,suspense:c})=>n.isError&&!a.isReset()&&!n.isFetching&&s&&(c&&n.data===void 0||Ab(u,[n.error,s])),nM=n=>{if(n.suspense){const u=c=>c==="static"?c:Math.max(c??1e3,1e3),s=n.staleTime;n.staleTime=typeof s=="function"?(...c)=>u(s(...c)):u(s),typeof n.gcTime=="number"&&(n.gcTime=Math.max(n.gcTime,1e3))}},lM=(n,a)=>n.isLoading&&n.isFetching&&!a,aM=(n,a)=>n?.suspense&&a.isPending,$v=(n,a,u)=>a.fetchOptimistic(n).catch(()=>{u.clearReset()});function iM(n,a,u){const s=J3(),c=I3(),d=K3(),f=d.defaultQueryOptions(n);d.getDefaultOptions().queries?._experimental_beforeQuery?.(f);const p=d.getQueryCache().get(f.queryHash),g=n.subscribed!==!1;f._optimisticResults=s?"isRestoring":g?"optimistic":void 0,nM(f),P3(f,c,p),eM(c);const v=!d.getQueryCache().get(f.queryHash),[x]=_e.useState(()=>new a(d,f)),S=x.getOptimisticResult(f),T=!s&&g;if(_e.useSyncExternalStore(_e.useCallback(w=>{const O=T?x.subscribe(Sn.batchCalls(w)):Wn;return x.updateResult(),O},[x,T]),()=>x.getCurrentResult(),()=>x.getCurrentResult()),_e.useEffect(()=>{x.setOptions(f)},[f,x]),aM(f,S))throw $v(f,x,c);if(tM({result:S,errorResetBoundary:c,throwOnError:f.throwOnError,query:p,suspense:f.suspense}))throw S.error;return d.getDefaultOptions().queries?._experimental_afterQuery?.(f,S),f.experimental_prefetchInRender&&!Zr.isServer()&&lM(S,s)&&(v?$v(f,x,c):p?.promise)?.catch(Wn).finally(()=>{x.updateResult()}),f.notifyOnChangeProps?S:x.trackResult(S)}function uM(n,a){return iM(n,H3)}const Vv={phase:"idle",attempt:0,reconnects:0,connectedAt:null,lastMessageAt:null,error:null};class Ub{#e;#t=Vv;#n=null;#l=new Set;#a=null;#i=null;#s=null;#u;#c=!1;constructor(a){this.#e={...a,connectTimeoutMs:a.connectTimeoutMs??5e3,retryMinimumMs:a.retryMinimumMs??1e3,retryMaximumMs:a.retryMaximumMs??3e4,heartbeatMs:a.heartbeatMs??24e4,jitterRatio:a.jitterRatio??.2,now:a.now??Date.now,random:a.random??Math.random,webSocketFactory:a.webSocketFactory??(u=>new WebSocket(u))},this.#u=this.#e.retryMinimumMs}getStatus=()=>this.#t;subscribeStatus=a=>(this.#l.add(a),()=>{this.#l.delete(a)});start(){this.#c||(this.#c=!0,this.#u=this.#e.retryMinimumMs,this.#r())}stop(){this.#c=!1,this.#g();const a=this.#n;if(this.#n=null,a)try{a.readyState===1&&this.#e.onBeforeStop?.(a),a.close()}catch{}this.#o(Vv)}send(a){if(this.#n?.readyState!==1)return!1;try{return this.#n.send(a),!0}catch{return!1}}#r(){if(!this.#c||this.#n)return;const a=this.#t.reconnects>0;this.#o({...this.#t,phase:a?"reconnecting":"connecting",attempt:this.#t.attempt+1,error:null});let u;try{u=this.#e.webSocketFactory(this.#e.url),this.#n=u}catch(s){this.#o({...this.#t,error:rM(s)}),this.#d();return}this.#a=setTimeout(()=>{if(this.#n===u){this.#o({...this.#t,error:"Connection timed out"});try{u.close()}catch{this.#n=null,this.#d()}}},this.#e.connectTimeoutMs),u.addEventListener("open",()=>{this.#n!==u||!this.#c||(this.#f(),this.#u=this.#e.retryMinimumMs,this.#o({...this.#t,phase:"connected",connectedAt:this.#e.now(),error:null}),this.#e.onOpen?.(u),this.#h(u))}),u.addEventListener("message",s=>{if(this.#n!==u||!this.#c)return;const c=sM(s.data);if(c===null)return;const d=this.#e.now();(this.#t.lastMessageAt===null||d-this.#t.lastMessageAt>=1e3)&&this.#o({...this.#t,lastMessageAt:d}),this.#e.onMessage(c)}),u.addEventListener("error",()=>{if(!(this.#n!==u||!this.#c)){this.#o({...this.#t,error:"WebSocket connection failed"});try{u.close()}catch{this.#n=null,this.#d()}}}),u.addEventListener("close",()=>{this.#n===u&&(this.#n=null,this.#f(),this.#m(),this.#c&&this.#d())})}#d(){if(!this.#c||this.#i)return;const a=1+(this.#e.random()*2-1)*this.#e.jitterRatio,u=Math.max(0,Math.round(this.#u*a));this.#u=Math.min(this.#u*2,this.#e.retryMaximumMs),this.#o({...this.#t,phase:"reconnecting",reconnects:this.#t.reconnects+1,connectedAt:null}),this.#i=setTimeout(()=>{this.#i=null,this.#r()},u)}#h(a){this.#m(),!(!this.#e.onHeartbeat||this.#e.heartbeatMs<=0)&&(this.#s=setInterval(()=>{this.#n===a&&a.readyState===1&&this.#e.onHeartbeat?.(a)},this.#e.heartbeatMs))}#f(){this.#a&&(clearTimeout(this.#a),this.#a=null)}#m(){this.#s&&(clearInterval(this.#s),this.#s=null)}#g(){this.#f(),this.#m(),this.#i&&(clearTimeout(this.#i),this.#i=null)}#o(a){this.#t=a;for(const u of this.#l)u()}}function sM(n){return typeof n=="string"?n:n instanceof ArrayBuffer?new TextDecoder().decode(n):null}function rM(n){return n instanceof Error?n.message:"Unable to create WebSocket"}class cM{#e;#t;#n=new Set;#l=new Set;#a;constructor(a,u={}){this.#e=u.logFilter??uE,this.#t=u.eventFilter??sE,this.#a=new Ub({url:Wv(a),webSocketFactory:u.webSocketFactory,retryMinimumMs:u.retryMinimumMs,retryMaximumMs:u.retryMaximumMs,jitterRatio:u.jitterRatio,)DELIM" +R"DELIM(onOpen:s=>{this.#i(s)},onHeartbeat:s=>{this.#i(s)},onBeforeStop:s=>{s.send("/v1/log/subscribe?filter=0"),s.send("/v1/event/subscribe?filter=0")},onMessage:s=>{const c=fE(s);if(!c){for(const d of this.#l)d(s);return}for(const d of this.#n)d(c)}})}getStatus=()=>this.#a.getStatus();subscribeStatus=a=>this.#a.subscribeStatus(a);start(){this.#a.start()}stop(){this.#a.stop()}subscribeFrames(a){return this.#n.add(a),()=>{this.#n.delete(a)}}subscribeInvalidFrames(a){return this.#l.add(a),()=>{this.#l.delete(a)}}setFilters(a,u){this.#e=a,this.#t=u,this.#a.send(`/v1/log/subscribe?filter=${String(a)}`),this.#a.send(`/v1/event/subscribe?filter=${String(u)}`)}#i(a){a.send(`/v1/log/subscribe?filter=${String(this.#e)}`),a.send(`/v1/event/subscribe?filter=${String(this.#t)}`)}}const kb=pu({address:ls(),filter:ls(),turbo:ls(),witness:ls(),retarget:ls(),difficult:ls(),pruned:Ti().int().nonnegative()}),Zb=Ti().int().nonnegative();function oM(n){try{const a=JSON.parse(n),u=kb.safeParse(a);if(u.success)return{type:"configuration",payload:u.data};const s=Zb.safeParse(a);return s.success?{type:"top",payload:s.data}:null}catch{return null}}function Kv(n,a){return new URL(a,`${n.replace(/\/+$/u,"")}/`).toString()}async function Xv(n,a){const u=await fetch(n,{headers:{Accept:"application/json"},signal:a});if(!u.ok)throw new Error(`Native API request failed with status ${String(u.status)}`);return await u.json()}async function fM(n,a){const[u,s]=await Promise.all([Xv(Kv(n,"/v1/configuration?format=json"),a),Xv(Kv(n,"/v1/top?format=json"),a)]),c=kb.parse(u),d=Zb.parse(s);return{configuration:c,top:d,receivedAt:Date.now()}}const dM=15e3,hM={configuration:null,top:null,receivedAt:null,invalidFrames:0};class mM{#e=hM;#t=new Set;#n;#l;constructor(a,u={}){this.#l=u.now??Date.now,this.#n=new Ub({url:Wv(a),webSocketFactory:u.webSocketFactory,retryMinimumMs:u.retryMinimumMs,retryMaximumMs:u.retryMaximumMs,jitterRatio:u.jitterRatio,heartbeatMs:u.topPollIntervalMs??dM,now:this.#l,onOpen:s=>{s.send("/v1/configuration?format=json"),s.send("/v1/top/subscribe?format=json")},onHeartbeat:s=>{s.send("/v1/top?format=json")},onBeforeStop:s=>{s.send("/v1/top/subscribe?format=json&stop=true")},onMessage:s=>{const c=oM(s);if(!c){this.#i({...this.#e,invalidFrames:this.#e.invalidFrames+1});return}this.#a(c)}})}getStatus=()=>this.#n.getStatus();subscribeStatus=a=>this.#n.subscribeStatus(a);getState=()=>this.#e;subscribeState=a=>(this.#t.add(a),()=>{this.#t.delete(a)});start(){this.#n.start()}stop(){this.#n.stop()}#a(a){const u=this.#l();this.#i(a.type==="top"?{...this.#e,top:a.payload,receivedAt:u}:{...this.#e,configuration:a.payload,receivedAt:u})}#i(a){this.#e=a;for(const u of this.#t)u()}}function pM(n,a){const u=_e.useMemo(()=>new cM(n),[n]),s=_e.useSyncExternalStore(u.subscribeStatus,u.getStatus,u.getStatus);return _e.useEffect(()=>{const c=u.subscribeFrames(f=>{a.ingest(f)}),d=u.subscribeInvalidFrames(()=>{a.recordInvalidFrame()});return u.start(),()=>{c(),d(),u.stop()}},[u,a]),s}function gM(n,a){const u=_e.useMemo(()=>new mM(n),[n]),s=_e.useMemo(()=>gS(n),[n]),c=_e.useSyncExternalStore(u.subscribeStatus,u.getStatus,u.getStatus),d=_e.useSyncExternalStore(u.subscribeState,u.getState,u.getState);_e.useEffect(()=>(u.start(),()=>{u.stop()}),[u]);const f=uM({queryKey:["native-snapshot",n],queryFn:({signal:S})=>fM(n,S),enabled:s&&c.phase!=="connected",refetchInterval:15e3,retry:!1}),p=d.top??f.data?.top??null,g=d.configuration??f.data?.configuration??null,v=d.receivedAt??f.data?.receivedAt??null,x=c.phase==="connected"&&(d.top!==null||d.configuration!==null)?"websocket":f.isSuccess?"rest":"none";return _e.useEffect(()=>{p!==null&&a.recordNativeTop(p,v??Date.now())},[a,v,p]),{status:c,live:d,top:p,configuration:g,receivedAt:v,transport:x,restError:f.error instanceof Error?f.error.message:null}}const vM=[{id:"overview",label:"Overview"},{id:"logs",label:"Logs"},{id:"events",label:"Events"}];function yM(){const n=_e.useMemo(()=>new ZE,[]),[a,u]=_e.useState(vS),[s,c]=_e.useState("overview"),[d,f]=_e.useState(!1),p=_e.useSyncExternalStore(n.subscribe,n.getSnapshot,n.getSnapshot),g=pM(a.adminUrl,n),v=gM(a.nativeUrl,n);_e.useEffect(()=>(n.start(),()=>{n.stop()}),[n]);function x(T){yS(T),n.reset(),u(T),f(!1)}function S(){bS();const T=Iv();n.reset(),u(T),f(!1)}return z.jsxs("div",{className:"bg-background text-textPrimary min-h-screen",children:[z.jsx("header",{className:"border-accent/25 bg-surface/95 sticky top-0 z-40 border-b backdrop-blur",children:z.jsx("div",{className:"mx-auto max-w-[96rem] px-4 sm:px-6",children:z.jsxs("div",{className:"flex min-h-16 flex-wrap items-center gap-x-6 gap-y-2 py-3",children:[z.jsxs("button",{type:"button",onClick:()=>{c("overview")},className:"mr-auto text-left",children:[z.jsx("p",{className:"text-accentSecondary text-[10px] font-medium tracking-[0.2em] uppercase",children:"Libbitcoin Server"}),z.jsx("h1",{className:"text-accent text-lg font-semibold tracking-tight",children:"Admin Dashboard"})]}),z.jsx("nav",{className:"order-3 flex w-full items-center gap-1 sm:order-none sm:w-auto",children:vM.map(T=>z.jsxs("button",{type:"button",onClick:()=>{c(T.id)},className:`rounded-lg px-3 py-2 text-sm transition ${s===T.id?"bg-accent/15 text-accent":"text-textMuted hover:text-textPrimary hover:bg-white/5"}`,children:[T.label,T.id==="logs"&&p.totalLogs>0&&z.jsx("span",{className:"bg-background/60 ml-2 rounded px-1.5 py-0.5 text-[10px] tabular-nums",children:p.totalLogs>999?"999+":String(p.totalLogs)}),T.id==="events"&&p.totalEvents>0&&z.jsx("span",{className:"bg-background/60 ml-2 rounded px-1.5 py-0.5 text-[10px] tabular-nums",children:p.totalEvents>999?"999+":String(p.totalEvents)})]},T.id))}),z.jsxs("div",{className:"flex items-center gap-3",children:[z.jsxs("div",{className:"hidden items-center gap-2 lg:flex","aria-label":"Connection summary",children:[z.jsx(Jv,{connected:g.phase==="connected",label:"Admin"}),z.jsx(Jv,{connected:v.transport!=="none",label:"Native"})]}),z.jsx("button",{type:"button",onClick:()=>{f(!0)},className:"border-accent/30 text-textMuted hover:border-accent hover:text-accent rounded-lg border px-3 py-2 text-xs font-medium tracking-wide uppercase",children:"Endpoints"})]})]})})}),z.jsxs("main",{className:"mx-auto max-w-[96rem] min-w-0 px-4 py-8 sm:px-6",children:[s==="overview"&&z.jsx(b3,{adminStatus:g,endpoints:a,metrics:p,native:v}),s==="logs"&&z.jsx(SE,{logs:p.recentLogs,onClear:()=>{n.clearLogs()}}),s==="events"&&z.jsx(bE,{events:p.recentEvents,onClear:()=>{n.clearEvents()}})]}),d&&z.jsx(SS,{configuration:a,onClose:()=>{f(!1)},onReset:S,onSave:x},`${a.adminUrl}|${a.nativeUrl}`)]})}function Jv({connected:n,label:a}){return z.jsxs("span",{className:"text-textMuted inline-flex items-center gap-1.5 text-xs",children:[z.jsx("span",{className:`h-2 w-2 rounded-full ${n?"bg-emerald-400":"bg-amber-400"}`,"aria-hidden":"true"}),a]})}function bM({children:n}){const[a]=_e.useState(()=>new V3({defaultOptions:{queries:{staleTime:1e4,refetchOnWindowFocus:!1,retry:1}}}));return z.jsxs(X3,{client:a,children:[n,null]})}const Lb=document.querySelector("#root");if(!Lb)throw new Error("Root element not found");mS.createRoot(Lb).render(z.jsx(uS.StrictMode,{children:z.jsx(bM,{children:z.jsx(yM,{})})})); )DELIM" )