PageSourceSearch

https://isitup.ai/assets/index-fXPEgJ7_.js

js isitup.ai collected 2026-10-05 13:30:10 UTC 1,993,638 bytes, 779 lines download raw bytes

vendor: 6,687 bytes, lines 1-9
1var eP=e=>{throw TypeError(e)};var sb=(e,t,r)=>t.has(e)||eP("Cannot "+r);var ae=(e,t,r)=>(sb(e,t,"read from private field"),r?r.call(e):t.get(e)),ot=(e,t,r)=>t.has(e)?eP("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Ge=(e,t,r,s)=>(sb(e,t,"write to private field"),s?s.call(e,r):t.set(e,r),r),bt=(e,t,r)=>(sb(e,t,"access private method"),r);var Mg=(e,t,r,s)=>({set _(a){Ge(e,t,a,r)},get _(){return ae(e,t,s)}});function rW(e,t){for(var r=0;r<t.length;r++){const s=t[r];if(typeof s!="string"&&!Array.isArray(s)){for(const a in s)if(a!=="default"&&!(a in e)){const i=Object.getOwnPropertyDescriptor(s,a);i&&Object.defineProperty(e,a,i.get?i:{enumerable:!0,get:()=>s[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const i of a)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&s(o)}).observe(document,{childList:!0,subtree:!0});function r(a){const i={};return a.integrity&&(i.integrity=a.integrity),a.referrerPolicy&&(i.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?i.credentials="include":a.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function s(a){if(a.ep)return;a.ep=!0;const i=r(a);fetch(a.href,i)}})();var rs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function nW(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function s(){return this instanceof s?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}),r}var ND={exports:{}},n0={},SD={exports:{}},At={};/**
2 * @license React
3 * react.production.min.js
4 *
5 * Copyright (c) Facebook, Inc. and its affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */var Yp=Symbol.for("react.element"),sW=Symbol.for("react.portal"),aW=Symbol.for("react.fragment"),iW=Symbol.for("react.strict_mode"),oW=Symbol.for("react.profiler"),lW=Symbol.for("react.provider"),cW=Symbol.for("react.context"),dW=Symbol.for("react.forward_ref"),uW=Symbol.for("react.suspense"),hW=Symbol.for("react.memo"),fW=Symbol.for("react.lazy"),tP=Symbol.iterator;function mW(e){return e===null||typeof e!="object"?null:(e=tP&&e[tP]||e["@@iterator"],typeof e=="function"?e:null)}var CD={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},kD=Object.assign,PD={};function $h(e,t,r){this.props=e,this.context=t,this.refs=PD,this.updater=r||CD}$h.prototype.isReactComponent={};$h.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};$h.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function TD(){}TD.prototype=$h.prototype;function gS(e,t,r){this.props=e,this.context=t,this.refs=PD,this.updater=r||CD}var xS=gS.prototype=new TD;xS.constructor=gS;kD(xS,$h.prototype);xS.isPureReactComponent=!0;var rP=Array.isArray,AD=Object.prototype.hasOwnProperty,vS={current:null},ED={key:!0,ref:!0,__self:!0,__source:!0};function OD(e,t,r){var s,a={},i=null,o=null;if(t!=null)for(s in t.ref!==void 0&&(o=t.ref),t.key!==void 0&&(i=""+t.key),t)AD.call(t,s)&&!ED.hasOwnProperty(s)&&(a[s]=t[s]);var l=arguments.length-2;if(l===1)a.children=r;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];a.children=c}if(e&&e.defaultProps)for(s in l=e.defaultProps,l)a[s]===void 0&&(a[s]=l[s]);return{$$typeof:Yp,type:e,key:i,ref:o,props:a,_owner:vS.current}}function pW(e,t){return{$$typeof:Yp,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function yS(e){return typeof e=="object"&&e!==null&&e.$$typeof===Yp}function gW(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(r){return t[r]})}var nP=/\/+/g;function ab(e,t){return typeof e=="object"&&e!==null&&e.key!=null?gW(""+e.key):t.toString(36)}function Rx(e,t,r,s,a){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var o=!1;if(e===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(e.$$typeof){case Yp:case sW:o=!0}}if(o)return o=e,a=a(o),e=s===""?"."+ab(o,0):s,rP(a)?(r="",e!=null&&(r=e.replace(nP,"$&/")+"/"),Rx(a,t,r,"",function(d){return d})):a!=null&&(yS(a)&&(a=pW(a,r+(!a.key||o&&o.key===a.key?"":(""+a.key).replace(nP,"$&/")+"/")+e)),t.push(a)),1;if(o=0,s=s===""?".":s+":",rP(e))for(var l=0;l<e.length;l++){i=e[l];var c=s+ab(i,l);o+=Rx(i,t,r,c,a)}else if(c=mW(e),typeof c=="function")for(e=c.call(e),l=0;!(i=e.next()).done;)i=i.value,c=s+ab(i,l++),o+=Rx(i,t,r,c,a);else if(i==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return o}function Dg(e,t,r){if(e==null)return e;var s=[],a=0;return Rx(e,s,"","",function(i){return t.call(r,i,a++)}),s}function xW(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(r){(e._status===0||e._status===-1)&&(e._status=1,e._result=r)},function(r){(e._status===0||e._status===-1)&&(e._status=2,e._result=r)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var Ns={current:null},$x={transition:null},vW={ReactCurrentDispatcher:Ns,ReactCurrentBatchConfig:$x,ReactCurrentOwner:vS};function MD(){throw Error("act(...) is not supported in production builds of React.")}At.Children={map:Dg,forEach:function(e,t,r){Dg(e,function(){t.apply(this,arguments)},r)},count:function(e){var t=0;return Dg(e,function(){t++}),t},toArray:function(e){return Dg(e,function(t){return t})||[]},only:function(e){if(!yS(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};At.Component=$h;At.Fragment=aW;At.Profiler=oW;At.PureComponent=gS;At.StrictMode=iW;At.Suspense=uW;
vendor: 9,015 bytes, lines 9-33
9At.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vW;At.act=MD;At.cloneElement=function(e,t,r){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var s=kD({},e.props),a=e.key,i=e.ref,o=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,o=vS.current),t.key!==void 0&&(a=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)AD.call(t,c)&&!ED.hasOwnProperty(c)&&(s[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)s.children=r;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];s.children=l}return{$$typeof:Yp,type:e.type,key:a,ref:i,props:s,_owner:o}};At.createContext=function(e){return e={$$typeof:cW,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:lW,_context:e},e.Consumer=e};At.createElement=OD;At.createFactory=function(e){var t=OD.bind(null,e);return t.type=e,t};At.createRef=function(){return{current:null}};At.forwardRef=function(e){return{$$typeof:dW,render:e}};At.isValidElement=yS;At.lazy=function(e){return{$$typeof:fW,_payload:{_status:-1,_result:e},_init:xW}};At.memo=function(e,t){return{$$typeof:hW,type:e,compare:t===void 0?null:t}};At.startTransition=function(e){var t=$x.transition;$x.transition={};try{e()}finally{$x.transition=t}};At.unstable_act=MD;At.useCallback=function(e,t){return Ns.current.useCallback(e,t)};At.useContext=function(e){return Ns.current.useContext(e)};At.useDebugValue=function(){};At.useDeferredValue=function(e){return Ns.current.useDeferredValue(e)};At.useEffect=function(e,t){return Ns.current.useEffect(e,t)};At.useId=function(){return Ns.current.useId()};At.useImperativeHandle=function(e,t,r){return Ns.current.useImperativeHandle(e,t,r)};At.useInsertionEffect=function(e,t){return Ns.current.useInsertionEffect(e,t)};At.useLayoutEffect=function(e,t){return Ns.current.useLayoutEffect(e,t)};At.useMemo=function(e,t){return Ns.current.useMemo(e,t)};At.useReducer=function(e,t,r){return Ns.current.useReducer(e,t,r)};At.useRef=function(e){return Ns.current.useRef(e)};At.useState=function(e){return Ns.current.useState(e)};At.useSyncExternalStore=function(e,t,r){return Ns.current.useSyncExternalStore(e,t,r)};At.useTransition=function(){return Ns.current.useTransition()};At.version="18.3.1";SD.exports=At;var x=SD.exports;const G=fr(x),jS=rW({__proto__:null,default:G},[x]);/**
10 * @license React
11 * react-jsx-runtime.production.min.js
12 *
13 * Copyright (c) Facebook, Inc. and its affiliates.
14 *
15 * This source code is licensed under the MIT license found in the
16 * LICENSE file in the root directory of this source tree.
17 */var yW=x,jW=Symbol.for("react.element"),bW=Symbol.for("react.fragment"),wW=Object.prototype.hasOwnProperty,_W=yW.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,NW={key:!0,ref:!0,__self:!0,__source:!0};function DD(e,t,r){var s,a={},i=null,o=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(o=t.ref);for(s in t)wW.call(t,s)&&!NW.hasOwnProperty(s)&&(a[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)a[s]===void 0&&(a[s]=t[s]);return{$$typeof:jW,type:e,key:i,ref:o,props:a,_owner:_W.current}}n0.Fragment=bW;n0.jsx=DD;n0.jsxs=DD;ND.exports=n0;var n=ND.exports,RD={exports:{}},ca={},$D={exports:{}},ID={};/**
18 * @license React
19 * scheduler.production.min.js
20 *
21 * Copyright (c) Facebook, Inc. and its affiliates.
22 *
23 * This source code is licensed under the MIT license found in the
24 * LICENSE file in the root directory of this source tree.
25 */(function(e){function t(T,k){var W=T.length;T.push(k);e:for(;0<W;){var q=W-1>>>1,Q=T[q];if(0<a(Q,k))T[q]=k,T[W]=Q,W=q;else break e}}function r(T){return T.length===0?null:T[0]}function s(T){if(T.length===0)return null;var k=T[0],W=T.pop();if(W!==k){T[0]=W;e:for(var q=0,Q=T.length,ue=Q>>>1;q<ue;){var X=2*(q+1)-1,le=T[X],pe=X+1,ce=T[pe];if(0>a(le,W))pe<Q&&0>a(ce,le)?(T[q]=ce,T[pe]=W,q=pe):(T[q]=le,T[X]=W,q=X);else if(pe<Q&&0>a(ce,W))T[q]=ce,T[pe]=W,q=pe;else break e}}return k}function a(T,k){var W=T.sortIndex-k.sortIndex;return W!==0?W:T.id-k.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var c=[],d=[],u=1,h=null,f=3,m=!1,g=!1,p=!1,y=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function b(T){for(var k=r(d);k!==null;){if(k.callback===null)s(d);else if(k.startTime<=T)s(d),k.sortIndex=k.expirationTime,t(c,k);else break;k=r(d)}}function _(T){if(p=!1,b(T),!g)if(r(c)!==null)g=!0,$(w);else{var k=r(d);k!==null&&R(_,k.startTime-T)}}function w(T,k){g=!1,p&&(p=!1,v(C),C=-1),m=!0;var W=f;try{for(b(k),h=r(c);h!==null&&(!(h.expirationTime>k)||T&&!D());){var q=h.callback;if(typeof q=="function"){h.callback=null,f=h.priorityLevel;var Q=q(h.expirationTime<=k);k=e.unstable_now(),typeof Q=="function"?h.callback=Q:h===r(c)&&s(c),b(k)}else s(c);h=r(c)}if(h!==null)var ue=!0;else{var X=r(d);X!==null&&R(_,X.startTime-k),ue=!1}return ue}finally{h=null,f=W,m=!1}}var N=!1,S=null,C=-1,P=5,M=-1;function D(){return!(e.unstable_now()-M<P)}function A(){if(S!==null){var T=e.unstable_now();M=T;var k=!0;try{k=S(!0,T)}finally{k?U():(N=!1,S=null)}}else N=!1}var U;if(typeof j=="function")U=function(){j(A)};else if(typeof MessageChannel<"u"){var F=new MessageChannel,L=F.port2;F.port1.onmessage=A,U=function(){L.postMessage(null)}}else U=function(){y(A,0)};function $(T){S=T,N||(N=!0,U())}function R(T,k){C=y(function(){T(e.unstable_now())},k)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(T){T.callback=null},e.unstable_continueExecution=function(){g||m||(g=!0,$(w))},e.unstable_forceFrameRate=function(T){0>T||125<T?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<T?Math.floor(1e3/T):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_getFirstCallbackNode=function(){return r(c)},e.unstable_next=function(T){switch(f){case 1:case 2:case 3:var k=3;break;default:k=f}var W=f;f=k;try{return T()}finally{f=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(T,k){switch(T){case 1:case 2:case 3:case 4:case 5:break;default:T=3}var W=f;f=T;try{return k()}finally{f=W}},e.unstable_scheduleCallback=function(T,k,W){var q=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?q+W:q):W=q,T){case 1:var Q=-1;break;case 2:Q=250;break;case 5:Q=1073741823;break;case 4:Q=1e4;break;default:Q=5e3}return Q=W+Q,T={id:u++,callback:k,priorityLevel:T,startTime:W,expirationTime:Q,sortIndex:-1},W>q?(T.sortIndex=W,t(d,T),r(c)===null&&T===r(d)&&(p?(v(C),C=-1):p=!0,R(_,W-q))):(T.sortIndex=Q,t(c,T),g||m||(g=!0,$(w))),T},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(T){var k=f;return function(){var W=f;f=k;try{return T.apply(this,arguments)}finally{f=W}}}})(ID);$D.exports=ID;var SW=$D.exports;/**
26 * @license React
27 * react-dom.production.min.js
28 *
29 * Copyright (c) Facebook, Inc. and its affiliates.
30 *
31 * This source code is licensed under the MIT license found in the
32 * LICENSE file in the root directory of this source tree.
33 */var CW=x,na=SW;function Oe(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var LD=new Set,Pm={};function Pd(e,t){Yu(e,t),Yu(e+"Capture",t)}function Yu(e,t){for(Pm[e]=t,e=0;e<t.length;e++)LD.add(t[e])}var Oo=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ww=Object.prototype.hasOwnProperty,kW=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,sP={},aP={};function PW(e){return Ww.call(aP,e)?!0:Ww.call(sP,e)?!1:kW.test(e)?aP[e]=!0:(sP[e]=!0,!1)}function TW(e,t,r,s){if(r!==null&&r.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return s?!1:r!==null?!r.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function AW(e,t,r,s){if(t===null||typeof t>"u"||TW(e,t,r,s))return!0;
vendor: 5,200 bytes, lines 33-34
33if(s)return!1;if(r!==null)switch(r.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ss(e,t,r,s,a,i,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=s,this.attributeNamespace=a,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=o}var In={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){In[e]=new Ss(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];In[t]=new Ss(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){In[e]=new Ss(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){In[e]=new Ss(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){In[e]=new Ss(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){In[e]=new Ss(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){In[e]=new Ss(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){In[e]=new Ss(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){In[e]=new Ss(e,5,!1,e.toLowerCase(),null,!1,!1)});var bS=/[\-:]([a-z])/g;function wS(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(bS,wS);In[t]=new Ss(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(bS,wS);In[t]=new Ss(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(bS,wS);In[t]=new Ss(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){In[e]=new Ss(e,1,!1,e.toLowerCase(),null,!1,!1)});In.xlinkHref=new Ss("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){In[e]=new Ss(e,1,!1,e.toLowerCase(),null,!0,!0)});function _S(e,t,r,s){var a=In.hasOwnProperty(t)?In[t]:null;(a!==null?a.type!==0:s||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(AW(t,r,a,s)&&(r=null),s||a===null?PW(t)&&(r===null?e.removeAttribute(t):e.setAttribute(t,""+r)):a.mustUseProperty?e[a.propertyName]=r===null?a.type===3?!1:"":r:(t=a.attributeName,s=a.attributeNamespace,r===null?e.removeAttribute(t):(a=a.type,r=a===3||a===4&&r===!0?"":""+r,s?e.setAttributeNS(s,t,r):e.setAttribute(t,r))))}var Go=CW.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Rg=Symbol.for("react.element"),iu=Symbol.for("react.portal"),ou=Symbol.for("react.fragment"),NS=Symbol.for("react.strict_mode"),Hw=Symbol.for("react.profiler"),FD=Symbol.for("react.provider"),UD=Symbol.for("react.context"),SS=Symbol.for("react.forward_ref"),Vw=Symbol.for("react.suspense"),Kw=Symbol.for("react.suspense_list"),CS=Symbol.for("react.memo"),ml=Symbol.for("react.lazy"),zD=Symbol.for("react.offscreen"),iP=Symbol.iterator;function yf(e){return e===null||typeof e!="object"?null:(e=iP&&e[iP]||e["@@iterator"],typeof e=="function"?e:null)}var Fr=Object.assign,ib;function Gf(e){if(ib===void 0)try{throw Error()}catch(r){var t=r.stack.trim().match(/\n( *(at )?)/);ib=t&&t[1]||""}return`
34`+ib+e}var ob=!1;function lb(e,t){if(!e||ob)return"";ob=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var s=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){s=d}e.call(t.prototype)}else{try{throw Error()}catch(d){s=d}e()}}
vendor: 5,289 bytes, lines 34-37
34catch(d){if(d&&s&&typeof d.stack=="string"){for(var a=d.stack.split(`
35`),i=s.stack.split(`
36`),o=a.length-1,l=i.length-1;1<=o&&0<=l&&a[o]!==i[l];)l--;for(;1<=o&&0<=l;o--,l--)if(a[o]!==i[l]){if(o!==1||l!==1)do if(o--,l--,0>l||a[o]!==i[l]){var c=`
37`+a[o].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=o&&0<=l);break}}}finally{ob=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Gf(e):""}function EW(e){switch(e.tag){case 5:return Gf(e.type);case 16:return Gf("Lazy");case 13:return Gf("Suspense");case 19:return Gf("SuspenseList");case 0:case 2:case 15:return e=lb(e.type,!1),e;case 11:return e=lb(e.type.render,!1),e;case 1:return e=lb(e.type,!0),e;default:return""}}function Gw(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ou:return"Fragment";case iu:return"Portal";case Hw:return"Profiler";case NS:return"StrictMode";case Vw:return"Suspense";case Kw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case UD:return(e.displayName||"Context")+".Consumer";case FD:return(e._context.displayName||"Context")+".Provider";case SS:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case CS:return t=e.displayName||null,t!==null?t:Gw(e.type)||"Memo";case ml:t=e._payload,e=e._init;try{return Gw(e(t))}catch{}}return null}function OW(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Gw(t);case 8:return t===NS?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function Xl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function BD(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function MW(e){var t=BD(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),s=""+e[t];if(!e.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var a=r.get,i=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return a.call(this)},set:function(o){s=""+o,i.call(this,o)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return s},setValue:function(o){s=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function $g(e){e._valueTracker||(e._valueTracker=MW(e))}function qD(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),s="";return e&&(s=BD(e)?e.checked?"true":"false":e.value),e=s,e!==r?(t.setValue(e),!0):!1}function tv(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Yw(e,t){var r=t.checked;return Fr({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function oP(e,t){var r=t.defaultValue==null?"":t.defaultValue,s=t.checked!=null?t.checked:t.defaultChecked;r=Xl(t.value!=null?t.value:r),e._wrapperState={initialChecked:s,initialValue:r,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function WD(e,t){t=t.checked,t!=null&&_S(e,"checked",t,!1)}function Qw(e,t){WD(e,t);var r=Xl(t.value),s=t.type;if(r!=null)s==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if(s==="submit"||s==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Xw(e,t.type,r):t.hasOwnProperty("defaultValue")&&Xw(e,t.type,Xl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function lP(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var s=t.type;if(!(s!=="submit"&&s!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}r=e.name,r!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,r!==""&&(e.name=r)}function Xw(e,t,r){(t!=="number"||tv(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var Yf=Array.isArray;function bu(e,t,r,s){if(e=e.options,t){t={};for(var a=0;a<r.length;a++)t["$"+r[a]]=!0;for(r=0;r<e.length;r++)a=t.hasOwnProperty("$"+e[r].value),e[r].selected!==a&&(e[r].selected=a),a&&s&&(e[r].defaultSelected=!0)}else{for(r=""+Xl(r),t=null,a=0;a<e.length;a++){if(e[a].value===r){e[a].selected=!0,s&&(e[a].defaultSelected=!0);return}t!==null||e[a].disabled||(t=e[a])}t!==null&&(t.selected=!0)}}function Zw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Oe(91)
vendor: 8,817 bytes, line 37
37);return Fr({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function cP(e,t){var r=t.value;if(r==null){if(r=t.children,t=t.defaultValue,r!=null){if(t!=null)throw Error(Oe(92));if(Yf(r)){if(1<r.length)throw Error(Oe(93));r=r[0]}t=r}t==null&&(t=""),r=t}e._wrapperState={initialValue:Xl(r)}}function HD(e,t){var r=Xl(t.value),s=Xl(t.defaultValue);r!=null&&(r=""+r,r!==e.value&&(e.value=r),t.defaultValue==null&&e.defaultValue!==r&&(e.defaultValue=r)),s!=null&&(e.defaultValue=""+s)}function dP(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function VD(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Jw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?VD(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ig,KD=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,r,s,a){MSApp.execUnsafeLocalFunction(function(){return e(t,r,s,a)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Ig=Ig||document.createElement("div"),Ig.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Ig.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Tm(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=t;return}}e.textContent=t}var lm={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},DW=["Webkit","ms","Moz","O"];Object.keys(lm).forEach(function(e){DW.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),lm[t]=lm[e]})});function GD(e,t,r){return t==null||typeof t=="boolean"||t===""?"":r||typeof t!="number"||t===0||lm.hasOwnProperty(e)&&lm[e]?(""+t).trim():t+"px"}function YD(e,t){e=e.style;for(var r in t)if(t.hasOwnProperty(r)){var s=r.indexOf("--")===0,a=GD(r,t[r],s);r==="float"&&(r="cssFloat"),s?e.setProperty(r,a):e[r]=a}}var RW=Fr({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function e_(e,t){if(t){if(RW[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Oe(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Oe(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Oe(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Oe(62))}}function t_(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var r_=null;function kS(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var n_=null,wu=null,_u=null;function uP(e){if(e=Zp(e)){if(typeof n_!="function")throw Error(Oe(280));var t=e.stateNode;t&&(t=l0(t),n_(e.stateNode,e.type,t))}}function QD(e){wu?_u?_u.push(e):_u=[e]:wu=e}function XD(){if(wu){var e=wu,t=_u;if(_u=wu=null,uP(e),t)for(e=0;e<t.length;e++)uP(t[e])}}function ZD(e,t){return e(t)}function JD(){}var cb=!1;function eR(e,t,r){if(cb)return e(t,r);cb=!0;try{return ZD(e,t,r)}finally{cb=!1,(wu!==null||_u!==null)&&(JD(),XD())}}function Am(e,t){var r=e.stateNode;if(r===null)return null;var s=l0(r);if(s===null)return null;r=s[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(Oe(231,t,typeof r));return r}var s_=!1;if(Oo)try{var jf={};Object.defineProperty(jf,"passive",{get:function(){s_=!0}}),window.addEventListener("test",jf,jf),window.removeEventListener("test",jf,jf)}catch{s_=!1}function $W(e,t,r,s,a,i,o,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(r,d)}catch(u){this.onError(u)}}var cm=!1,rv=null,nv=!1,a_=null,IW={onError:function(e){cm=!0,rv=e}};function LW(e,t,r,s,a,i,o,l,c){cm=!1,rv=null,$W.apply(IW,arguments)}function FW(e,t,r,s,a,i,o,l,c){if(LW.apply(this,arguments),cm){if(cm){var d=rv;cm=!1,rv=null}else throw Error(Oe(198));nv||(nv=!0,a_=d)}}function Td(e){var t=e,r=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(r=t.return),e=t.return;while(e)}return t.tag===3?r:null}function tR(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function hP(e){if(Td(e)!==e)throw Error(Oe(188))}function UW(e){var t=e.alternate;if(!t){if(t=Td(e),t===null)throw Error(Oe(188));return t!==e?null:e}for(var r=e,s=t;;){var a=r.return;if(a===null)break;var i=a.alternate;if(i===null){if(s=a.return,s!==null){r=s;continue}break}if(a.child===i.child){for(i=a.child;i;){if(i===r)return hP(a),e;if(i===s)return hP(a),t;i=i.sibling}throw Error(Oe(188))}if(r.return!==s.return)r=a,s=i;else{for(var o=!1,l=a.child;l;){if(l===r){o=!0,r=a,s=i;break}if(l===s){o=!0,s=a,r=i;break}l=l.sibling}if(!o){for(l=i.child;l;){if(l===r){o=!0,r=i,s=a;break}if(l===s){o=!0,s=i,r=a;break}l=l.sibling}if(!o)throw Error(Oe(189))}}if(r.alternate!==s)throw Error(Oe(190))}if(r.tag!==3)throw Error(Oe(188));return r.stateNode.current===r?e:t}function rR(e){return e=UW(e),e!==null?nR(e):null}function nR(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=nR(e);if(t!==null)return t;e=e.sibling}return null}var sR=na.unstable_scheduleCallback,fP=na.unstable_cancelCallback,zW=na.unstable_shouldYield,BW=na.unstable_requestPaint,Zr=na.unstable_now,qW=na.unstable_getCurrentPriorityLevel,PS=na.unstable_ImmediatePriority,aR=na.unstable_UserBlockingPriority,sv=na.unstable_NormalPriority,WW=na.unstable_LowPriority,iR=na.unstable_IdlePriority,s0=null,Ei=null;function HW(e){if(Ei&&typeof Ei.onCommitFiberRoot=="function")try{Ei.onCommitFiberRoot(s0,e,void 0,(e.current.flags&128)===128)}catch{}}var ni=Math.clz32?Math.clz32:GW,VW=Math.log,KW=Math.LN2;function GW(e){return e>>>=0,e===0?32:31-(VW(e)/KW|0)|0}var Lg=64,Fg=4194304;function Qf(e){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: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function av(e,t){var r=e.pendingLanes;if(r===0)return 0;var s=0,a=e.suspendedLanes,i=e.pingedLanes,o=r&268435455;if(o!==0){var l=o&~a;l!==0?s=Qf(l):(i&=o,i!==0&&(s=Qf(i)))}else o=r&~a,o!==0?s=Qf(o):i!==0&&(s=Qf(i));if(s===0)return 0;if(t!==0&&t!==s&&!(t&a)&&(a=s&-s,i=t&-t,a>=i||a===16&&(i&4194240)!==0))return t;if(s&4&&(s|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=s;0<t;)r=31-ni(t),a=1<<r,s|=e[r],t&=~a;return s}function YW(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64: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:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function QW(e,t){for(var r=e.suspendedLanes,s=e.pingedLanes,a=e.expirationTimes,i=e.pendingLanes;0<i;){var o=31-ni(i),l=1<<o,c=a[o];c===-1?(!(l&r)||l&s)&&(a[o]=YW(l,t)):c<=t&&(e.expiredLanes|=l),i&=~l}}function i_(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function oR(){var e=Lg;return Lg<<=1,!(Lg&4194240)&&(Lg=64),e}function db(e){for(var t=[],r=0;31>r;r++)t.push(e);return t}
vendor: 4,087 bytes, line 37
37function Qp(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ni(t),e[t]=r}function XW(e,t){var r=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var s=e.eventTimes;for(e=e.expirationTimes;0<r;){var a=31-ni(r),i=1<<a;t[a]=0,s[a]=-1,e[a]=-1,r&=~i}}function TS(e,t){var r=e.entangledLanes|=t;for(e=e.entanglements;r;){var s=31-ni(r),a=1<<s;a&t|e[s]&t&&(e[s]|=t),r&=~a}}var or=0;function lR(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var cR,AS,dR,uR,hR,o_=!1,Ug=[],Il=null,Ll=null,Fl=null,Em=new Map,Om=new Map,vl=[],ZW="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function mP(e,t){switch(e){case"focusin":case"focusout":Il=null;break;case"dragenter":case"dragleave":Ll=null;break;case"mouseover":case"mouseout":Fl=null;break;case"pointerover":case"pointerout":Em.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Om.delete(t.pointerId)}}function bf(e,t,r,s,a,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:r,eventSystemFlags:s,nativeEvent:i,targetContainers:[a]},t!==null&&(t=Zp(t),t!==null&&AS(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,a!==null&&t.indexOf(a)===-1&&t.push(a),e)}function JW(e,t,r,s,a){switch(t){case"focusin":return Il=bf(Il,e,t,r,s,a),!0;case"dragenter":return Ll=bf(Ll,e,t,r,s,a),!0;case"mouseover":return Fl=bf(Fl,e,t,r,s,a),!0;case"pointerover":var i=a.pointerId;return Em.set(i,bf(Em.get(i)||null,e,t,r,s,a)),!0;case"gotpointercapture":return i=a.pointerId,Om.set(i,bf(Om.get(i)||null,e,t,r,s,a)),!0}return!1}function fR(e){var t=Fc(e.target);if(t!==null){var r=Td(t);if(r!==null){if(t=r.tag,t===13){if(t=tR(r),t!==null){e.blockedOn=t,hR(e.priority,function(){dR(r)});return}}else if(t===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ix(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var r=l_(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(r===null){r=e.nativeEvent;var s=new r.constructor(r.type,r);r_=s,r.target.dispatchEvent(s),r_=null}else return t=Zp(r),t!==null&&AS(t),e.blockedOn=r,!1;t.shift()}return!0}function pP(e,t,r){Ix(e)&&r.delete(t)}function eH(){o_=!1,Il!==null&&Ix(Il)&&(Il=null),Ll!==null&&Ix(Ll)&&(Ll=null),Fl!==null&&Ix(Fl)&&(Fl=null),Em.forEach(pP),Om.forEach(pP)}function wf(e,t){e.blockedOn===t&&(e.blockedOn=null,o_||(o_=!0,na.unstable_scheduleCallback(na.unstable_NormalPriority,eH)))}function Mm(e){function t(a){return wf(a,e)}if(0<Ug.length){wf(Ug[0],e);for(var r=1;r<Ug.length;r++){var s=Ug[r];s.blockedOn===e&&(s.blockedOn=null)}}for(Il!==null&&wf(Il,e),Ll!==null&&wf(Ll,e),Fl!==null&&wf(Fl,e),Em.forEach(t),Om.forEach(t),r=0;r<vl.length;r++)s=vl[r],s.blockedOn===e&&(s.blockedOn=null);for(;0<vl.length&&(r=vl[0],r.blockedOn===null);)fR(r),r.blockedOn===null&&vl.shift()}var Nu=Go.ReactCurrentBatchConfig,iv=!0;function tH(e,t,r,s){var a=or,i=Nu.transition;Nu.transition=null;try{or=1,ES(e,t,r,s)}finally{or=a,Nu.transition=i}}function rH(e,t,r,s){var a=or,i=Nu.transition;Nu.transition=null;try{or=4,ES(e,t,r,s)}finally{or=a,Nu.transition=i}}function ES(e,t,r,s){if(iv){var a=l_(e,t,r,s);if(a===null)jb(e,t,s,ov,r),mP(e,s);else if(JW(a,e,t,r,s))s.stopPropagation();else if(mP(e,s),t&4&&-1<ZW.indexOf(e)){for(;a!==null;){var i=Zp(a);if(i!==null&&cR(i),i=l_(e,t,r,s),i===null&&jb(e,t,s,ov,r),i===a)break;a=i}a!==null&&s.stopPropagation()}else jb(e,t,s,null,r)}}var ov=null;function l_(e,t,r,s){if(ov=null,e=kS(s),e=Fc(e),e!==null)if(t=Td(e),t===null)e=null;else if(r=t.tag,r===13){if(e=tR(t),e!==null)return e;e=null}else if(r===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return ov=e,null}
vendor: 10,401 bytes, line 37
37function mR(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(qW()){case PS:return 1;case aR:return 4;case sv:case WW:return 16;case iR:return 536870912;default:return 16}default:return 16}}var Ol=null,OS=null,Lx=null;function pR(){if(Lx)return Lx;var e,t=OS,r=t.length,s,a="value"in Ol?Ol.value:Ol.textContent,i=a.length;for(e=0;e<r&&t[e]===a[e];e++);var o=r-e;for(s=1;s<=o&&t[r-s]===a[i-s];s++);return Lx=a.slice(e,1<s?1-s:void 0)}function Fx(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function zg(){return!0}function gP(){return!1}function da(e){function t(r,s,a,i,o){this._reactName=r,this._targetInst=a,this.type=s,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(r=e[l],this[l]=r?r(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?zg:gP,this.isPropagationStopped=gP,this}return Fr(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=zg)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=zg)},persist:function(){},isPersistent:zg}),t}var Ih={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},MS=da(Ih),Xp=Fr({},Ih,{view:0,detail:0}),nH=da(Xp),ub,hb,_f,a0=Fr({},Xp,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:DS,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!==_f&&(_f&&e.type==="mousemove"?(ub=e.screenX-_f.screenX,hb=e.screenY-_f.screenY):hb=ub=0,_f=e),ub)},movementY:function(e){return"movementY"in e?e.movementY:hb}}),xP=da(a0),sH=Fr({},a0,{dataTransfer:0}),aH=da(sH),iH=Fr({},Xp,{relatedTarget:0}),fb=da(iH),oH=Fr({},Ih,{animationName:0,elapsedTime:0,pseudoElement:0}),lH=da(oH),cH=Fr({},Ih,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),dH=da(cH),uH=Fr({},Ih,{data:0}),vP=da(uH),hH={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},fH={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"},mH={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function pH(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=mH[e])?!!t[e]:!1}function DS(){return pH}var gH=Fr({},Xp,{key:function(e){if(e.key){var t=hH[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Fx(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?fH[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:DS,charCode:function(e){return e.type==="keypress"?Fx(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Fx(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),xH=da(gH),vH=Fr({},a0,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),yP=da(vH),yH=Fr({},Xp,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:DS}),jH=da(yH),bH=Fr({},Ih,{propertyName:0,elapsedTime:0,pseudoElement:0}),wH=da(bH),_H=Fr({},a0,{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}),NH=da(_H),SH=[9,13,27,32],RS=Oo&&"CompositionEvent"in window,dm=null;Oo&&"documentMode"in document&&(dm=document.documentMode);var CH=Oo&&"TextEvent"in window&&!dm,gR=Oo&&(!RS||dm&&8<dm&&11>=dm),jP=" ",bP=!1;function xR(e,t){switch(e){case"keyup":return SH.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function vR(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var lu=!1;function kH(e,t){switch(e){case"compositionend":return vR(t);case"keypress":return t.which!==32?null:(bP=!0,jP);case"textInput":return e=t.data,e===jP&&bP?null:e;default:return null}}function PH(e,t){if(lu)return e==="compositionend"||!RS&&xR(e,t)?(e=pR(),Lx=OS=Ol=null,lu=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return gR&&t.locale!=="ko"?null:t.data;default:return null}}var TH={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function wP(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!TH[e.type]:t==="textarea"}function yR(e,t,r,s){QD(s),t=lv(t,"onChange"),0<t.length&&(r=new MS("onChange","change",null,r,s),e.push({event:r,listeners:t}))}var um=null,Dm=null;function AH(e){AR(e,0)}function i0(e){var t=uu(e);if(qD(t))return e}function EH(e,t){if(e==="change")return t}var jR=!1;if(Oo){var mb;if(Oo){var pb="oninput"in document;if(!pb){var _P=document.createElement("div");_P.setAttribute("oninput","return;"),pb=typeof _P.oninput=="function"}mb=pb}else mb=!1;jR=mb&&(!document.documentMode||9<document.documentMode)}function NP(){um&&(um.detachEvent("onpropertychange",bR),Dm=um=null)}function bR(e){if(e.propertyName==="value"&&i0(Dm)){var t=[];yR(t,Dm,e,kS(e)),eR(AH,t)}}function OH(e,t,r){e==="focusin"?(NP(),um=t,Dm=r,um.attachEvent("onpropertychange",bR)):e==="focusout"&&NP()}function MH(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return i0(Dm)}function DH(e,t){if(e==="click")return i0(t)}function RH(e,t){if(e==="input"||e==="change")return i0(t)}function $H(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ai=typeof Object.is=="function"?Object.is:$H;function Rm(e,t){if(ai(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var r=Object.keys(e),s=Object.keys(t);if(r.length!==s.length)return!1;for(s=0;s<r.length;s++){var a=r[s];if(!Ww.call(t,a)||!ai(e[a],t[a]))return!1}return!0}function SP(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function CP(e,t){var r=SP(e);e=0;for(var s;r;){if(r.nodeType===3){if(s=e+r.textContent.length,e<=t&&s>=t)return{node:r,offset:t-e};e=s}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=SP(r)}}function wR(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wR(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function _R(){for(var e=window,t=tv();t instanceof e.HTMLIFrameElement;){try{var r=typeof t.contentWindow.location.href=="string"}catch{r=!1}if(r)e=t.contentWindow;else break;t=tv(e.document)}return t}function $S(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")}function IH(e){var t=_R(),r=e.focusedElem,s=e.selectionRange;if(t!==r&&r&&r.ownerDocument&&wR(r.ownerDocument.documentElement,r)){if(s!==null&&$S(r)){if(t=s.start,e=s.end,e===void 0&&(e=t),"selectionStart"in r)r.selectionStart=t,r.selectionEnd=Math.min(e,r.value.length);else if(e=(t=r.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var a=r.textContent.length,i=Math.min(s.start,a);s=s.end===void 0?i:Math.min(s.end,a),!e.extend&&i>s&&(a=s,s=i,i=a),a=CP(r,i);var o=CP(r,s);a&&o&&(e.rangeCount!==1||e.anchorNode!==a.node||e.anchorOffset!==a.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(a.node,a.offset),e.removeAllRanges(),i>s?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=r;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<t.length;r++)e=t[r],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var LH=Oo&&"documentMode"in document&&11>=document.documentMode,cu=null,c_=null,hm=null,d_=!1;function kP(e,t,r){var s=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;d_||cu==null||cu!==tv(s)||(s=cu,"selectionStart"in s&&$S(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focu
vendor: 4,383 bytes, line 37
37sNode:s.focusNode,focusOffset:s.focusOffset}),hm&&Rm(hm,s)||(hm=s,s=lv(c_,"onSelect"),0<s.length&&(t=new MS("onSelect","select",null,t,r),e.push({event:t,listeners:s}),t.target=cu)))}function Bg(e,t){var r={};return r[e.toLowerCase()]=t.toLowerCase(),r["Webkit"+e]="webkit"+t,r["Moz"+e]="moz"+t,r}var du={animationend:Bg("Animation","AnimationEnd"),animationiteration:Bg("Animation","AnimationIteration"),animationstart:Bg("Animation","AnimationStart"),transitionend:Bg("Transition","TransitionEnd")},gb={},NR={};Oo&&(NR=document.createElement("div").style,"AnimationEvent"in window||(delete du.animationend.animation,delete du.animationiteration.animation,delete du.animationstart.animation),"TransitionEvent"in window||delete du.transitionend.transition);function o0(e){if(gb[e])return gb[e];if(!du[e])return e;var t=du[e],r;for(r in t)if(t.hasOwnProperty(r)&&r in NR)return gb[e]=t[r];return e}var SR=o0("animationend"),CR=o0("animationiteration"),kR=o0("animationstart"),PR=o0("transitionend"),TR=new Map,PP="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function sc(e,t){TR.set(e,t),Pd(t,[e])}for(var xb=0;xb<PP.length;xb++){var vb=PP[xb],FH=vb.toLowerCase(),UH=vb[0].toUpperCase()+vb.slice(1);sc(FH,"on"+UH)}sc(SR,"onAnimationEnd");sc(CR,"onAnimationIteration");sc(kR,"onAnimationStart");sc("dblclick","onDoubleClick");sc("focusin","onFocus");sc("focusout","onBlur");sc(PR,"onTransitionEnd");Yu("onMouseEnter",["mouseout","mouseover"]);Yu("onMouseLeave",["mouseout","mouseover"]);Yu("onPointerEnter",["pointerout","pointerover"]);Yu("onPointerLeave",["pointerout","pointerover"]);Pd("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Pd("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Pd("onBeforeInput",["compositionend","keypress","textInput","paste"]);Pd("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Pd("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Pd("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Xf="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),zH=new Set("cancel close invalid load scroll toggle".split(" ").concat(Xf));function TP(e,t,r){var s=e.type||"unknown-event";e.currentTarget=r,FW(s,t,void 0,e),e.currentTarget=null}function AR(e,t){t=(t&4)!==0;for(var r=0;r<e.length;r++){var s=e[r],a=s.event;s=s.listeners;e:{var i=void 0;if(t)for(var o=s.length-1;0<=o;o--){var l=s[o],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==i&&a.isPropagationStopped())break e;TP(a,l,d),i=c}else for(o=0;o<s.length;o++){if(l=s[o],c=l.instance,d=l.currentTarget,l=l.listener,c!==i&&a.isPropagationStopped())break e;TP(a,l,d),i=c}}}if(nv)throw e=a_,nv=!1,a_=null,e}function br(e,t){var r=t[p_];r===void 0&&(r=t[p_]=new Set);var s=e+"__bubble";r.has(s)||(ER(t,e,2,!1),r.add(s))}function yb(e,t,r){var s=0;t&&(s|=4),ER(r,e,s,t)}var qg="_reactListening"+Math.random().toString(36).slice(2);function $m(e){if(!e[qg]){e[qg]=!0,LD.forEach(function(r){r!=="selectionchange"&&(zH.has(r)||yb(r,!1,e),yb(r,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[qg]||(t[qg]=!0,yb("selectionchange",!1,t))}}function ER(e,t,r,s){switch(mR(t)){case 1:var a=tH;break;case 4:a=rH;break;default:a=ES}r=a.bind(null,t,r,e),a=void 0,!s_||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(a=!0),s?a!==void 0?e.addEventListener(t,r,{capture:!0,passive:a}):e.addEventListener(t,r,!0):a!==void 0?e.addEventListener(t,r,{passive:a}):e.addEventListener(t,r,!1)}function jb(e,t,r,s,a){var i=s;
vendor: 5,522 bytes, lines 37-38
37if(!(t&1)&&!(t&2)&&s!==null)e:for(;;){if(s===null)return;var o=s.tag;if(o===3||o===4){var l=s.stateNode.containerInfo;if(l===a||l.nodeType===8&&l.parentNode===a)break;if(o===4)for(o=s.return;o!==null;){var c=o.tag;if((c===3||c===4)&&(c=o.stateNode.containerInfo,c===a||c.nodeType===8&&c.parentNode===a))return;o=o.return}for(;l!==null;){if(o=Fc(l),o===null)return;if(c=o.tag,c===5||c===6){s=i=o;continue e}l=l.parentNode}}s=s.return}eR(function(){var d=i,u=kS(r),h=[];e:{var f=TR.get(e);if(f!==void 0){var m=MS,g=e;switch(e){case"keypress":if(Fx(r)===0)break e;case"keydown":case"keyup":m=xH;break;case"focusin":g="focus",m=fb;break;case"focusout":g="blur",m=fb;break;case"beforeblur":case"afterblur":m=fb;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=xP;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=aH;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=jH;break;case SR:case CR:case kR:m=lH;break;case PR:m=wH;break;case"scroll":m=nH;break;case"wheel":m=NH;break;case"copy":case"cut":case"paste":m=dH;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=yP}var p=(t&4)!==0,y=!p&&e==="scroll",v=p?f!==null?f+"Capture":null:f;p=[];for(var j=d,b;j!==null;){b=j;var _=b.stateNode;if(b.tag===5&&_!==null&&(b=_,v!==null&&(_=Am(j,v),_!=null&&p.push(Im(j,_,b)))),y)break;j=j.return}0<p.length&&(f=new m(f,g,null,r,u),h.push({event:f,listeners:p}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",f&&r!==r_&&(g=r.relatedTarget||r.fromElement)&&(Fc(g)||g[Mo]))break e;if((m||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,m?(g=r.relatedTarget||r.toElement,m=d,g=g?Fc(g):null,g!==null&&(y=Td(g),g!==y||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=d),m!==g)){if(p=xP,_="onMouseLeave",v="onMouseEnter",j="mouse",(e==="pointerout"||e==="pointerover")&&(p=yP,_="onPointerLeave",v="onPointerEnter",j="pointer"),y=m==null?f:uu(m),b=g==null?f:uu(g),f=new p(_,j+"leave",m,r,u),f.target=y,f.relatedTarget=b,_=null,Fc(u)===d&&(p=new p(v,j+"enter",g,r,u),p.target=b,p.relatedTarget=y,_=p),y=_,m&&g)t:{for(p=m,v=g,j=0,b=p;b;b=Bd(b))j++;for(b=0,_=v;_;_=Bd(_))b++;for(;0<j-b;)p=Bd(p),j--;for(;0<b-j;)v=Bd(v),b--;for(;j--;){if(p===v||v!==null&&p===v.alternate)break t;p=Bd(p),v=Bd(v)}p=null}else p=null;m!==null&&AP(h,f,m,p,!1),g!==null&&y!==null&&AP(h,y,g,p,!0)}}e:{if(f=d?uu(d):window,m=f.nodeName&&f.nodeName.toLowerCase(),m==="select"||m==="input"&&f.type==="file")var w=EH;else if(wP(f))if(jR)w=RH;else{w=MH;var N=OH}else(m=f.nodeName)&&m.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(w=DH);if(w&&(w=w(e,d))){yR(h,w,r,u);break e}N&&N(e,f,d),e==="focusout"&&(N=f._wrapperState)&&N.controlled&&f.type==="number"&&Xw(f,"number",f.value)}switch(N=d?uu(d):window,e){case"focusin":(wP(N)||N.contentEditable==="true")&&(cu=N,c_=d,hm=null);break;case"focusout":hm=c_=cu=null;break;case"mousedown":d_=!0;break;case"contextmenu":case"mouseup":case"dragend":d_=!1,kP(h,r,u);break;case"selectionchange":if(LH)break;case"keydown":case"keyup":kP(h,r,u)}var S;if(RS)e:{switch(e){case"compositionstart":var C="onCompositionStart";break e;case"compositionend":C="onCompositionEnd";break e;case"compositionupdate":C="onCompositionUpdate";break e}C=void 0}else lu?xR(e,r)&&(C="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(C="onCompositionStart");C&&(gR&&r.locale!=="ko"&&(lu||C!=="onCompositionStart"?C==="onCompositionEnd"&&lu&&(S=pR()):(Ol=u,OS="value"in Ol?Ol.value:Ol.textContent,lu=!0)),N=lv(d,C),0<N.length&&(C=new vP(C,e,null,r,u),h.push({event:C,listeners:N}),S?C.data=S:(S=vR(r),S!==null&&(C.data=S)))),(S=CH?kH(e,r):PH(e,r))&&(d=lv(d,"onBeforeInput"),0<d.length&&(u=new vP("onBeforeInput","beforeinput",null,r,u),h.push({event:u,listeners:d}),u.data=S))}AR(h,t)})}function Im(e,t,r){return{instance:e,listener:t,currentTarget:r}}function lv(e,t){for(var r=t+"Capture",s=[];e!==null;){var a=e,i=a.stateNode;a.tag===5&&i!==null&&(a=i,i=Am(e,r),i!=null&&s.unshift(Im(e,i,a)),i=Am(e,t),i!=null&&s.push(Im(e,i,a))),e=e.return}return s}function Bd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function AP(e,t,r,s,a){for(var i=t._reactName,o=[];r!==null&&r!==s;){var l=r,c=l.alternate,d=l.stateNode;if(c!==null&&c===s)break;l.tag===5&&d!==null&&(l=d,a?(c=Am(r,i),c!=null&&o.unshift(Im(r,c,l))):a||(c=Am(r,i),c!=null&&o.push(Im(r,c,l)))),r=r.return}o.length!==0&&e.push({event:t,listeners:o})}var BH=/\r\n?/g,qH=/\u0000|\uFFFD/g;function EP(e){return(typeof e=="string"?e:""+e).replace(BH,`
38`).replace(qH,"")}function Wg(e,t,r){if(t=EP(t),EP(e)!==t&&r)throw Error(Oe(425))}function cv(){}var u_=null,h_=null;function f_(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var m_=typeof setTimeout=="function"?setTimeout:void 0,WH=typeof clearTimeout=="function"?clearTimeout:void 0,OP=typeof Promise=="function"?Promise:void 0,HH=typeof queueMicrotask=="function"?queueMicrotask:typeof OP<"u"?function(e){return OP.resolve(null).then(e).catch(VH)}:m_;function VH(e){setTimeout(function(){throw e})}function bb(e,t){var r=t,s=0;
vendor: 4,835 bytes, line 38
38do{var a=r.nextSibling;if(e.removeChild(r),a&&a.nodeType===8)if(r=a.data,r==="/$"){if(s===0){e.removeChild(a),Mm(t);return}s--}else r!=="$"&&r!=="$?"&&r!=="$!"||s++;r=a}while(r);Mm(t)}function Ul(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function MP(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"){if(t===0)return e;t--}else r==="/$"&&t++}e=e.previousSibling}return null}var Lh=Math.random().toString(36).slice(2),Si="__reactFiber$"+Lh,Lm="__reactProps$"+Lh,Mo="__reactContainer$"+Lh,p_="__reactEvents$"+Lh,KH="__reactListeners$"+Lh,GH="__reactHandles$"+Lh;function Fc(e){var t=e[Si];if(t)return t;for(var r=e.parentNode;r;){if(t=r[Mo]||r[Si]){if(r=t.alternate,t.child!==null||r!==null&&r.child!==null)for(e=MP(e);e!==null;){if(r=e[Si])return r;e=MP(e)}return t}e=r,r=e.parentNode}return null}function Zp(e){return e=e[Si]||e[Mo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function uu(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Oe(33))}function l0(e){return e[Lm]||null}var g_=[],hu=-1;function ac(e){return{current:e}}function Cr(e){0>hu||(e.current=g_[hu],g_[hu]=null,hu--)}function yr(e,t){hu++,g_[hu]=e.current,e.current=t}var Zl={},as=ac(Zl),Ls=ac(!1),od=Zl;function Qu(e,t){var r=e.type.contextTypes;if(!r)return Zl;var s=e.stateNode;if(s&&s.__reactInternalMemoizedUnmaskedChildContext===t)return s.__reactInternalMemoizedMaskedChildContext;var a={},i;for(i in r)a[i]=t[i];return s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=a),a}function Fs(e){return e=e.childContextTypes,e!=null}function dv(){Cr(Ls),Cr(as)}function DP(e,t,r){if(as.current!==Zl)throw Error(Oe(168));yr(as,t),yr(Ls,r)}function OR(e,t,r){var s=e.stateNode;if(t=t.childContextTypes,typeof s.getChildContext!="function")return r;s=s.getChildContext();for(var a in s)if(!(a in t))throw Error(Oe(108,OW(e)||"Unknown",a));return Fr({},r,s)}function uv(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Zl,od=as.current,yr(as,e),yr(Ls,Ls.current),!0}function RP(e,t,r){var s=e.stateNode;if(!s)throw Error(Oe(169));r?(e=OR(e,t,od),s.__reactInternalMemoizedMergedChildContext=e,Cr(Ls),Cr(as),yr(as,e)):Cr(Ls),yr(Ls,r)}var co=null,c0=!1,wb=!1;function MR(e){co===null?co=[e]:co.push(e)}function YH(e){c0=!0,MR(e)}function ic(){if(!wb&&co!==null){wb=!0;var e=0,t=or;try{var r=co;for(or=1;e<r.length;e++){var s=r[e];do s=s(!0);while(s!==null)}co=null,c0=!1}catch(a){throw co!==null&&(co=co.slice(e+1)),sR(PS,ic),a}finally{or=t,wb=!1}}return null}var fu=[],mu=0,hv=null,fv=0,va=[],ya=0,ld=null,po=1,go="";function Ac(e,t){fu[mu++]=fv,fu[mu++]=hv,hv=e,fv=t}function DR(e,t,r){va[ya++]=po,va[ya++]=go,va[ya++]=ld,ld=e;var s=po;e=go;var a=32-ni(s)-1;s&=~(1<<a),r+=1;var i=32-ni(t)+a;if(30<i){var o=a-a%5;i=(s&(1<<o)-1).toString(32),s>>=o,a-=o,po=1<<32-ni(t)+a|r<<a|s,go=i+e}else po=1<<i|r<<a|s,go=e}function IS(e){e.return!==null&&(Ac(e,1),DR(e,1,0))}function LS(e){for(;e===hv;)hv=fu[--mu],fu[mu]=null,fv=fu[--mu],fu[mu]=null;for(;e===ld;)ld=va[--ya],va[ya]=null,go=va[--ya],va[ya]=null,po=va[--ya],va[ya]=null}var ea=null,Js=null,Tr=!1,Xa=null;function RR(e,t){var r=ba(5,null,null,0);r.elementType="DELETED",r.stateNode=t,r.return=e,t=e.deletions,t===null?(e.deletions=[r],e.flags|=16):t.push(r)}function $P(e,t){switch(e.tag){case 5:var r=e.type;return t=t.nodeType!==1||r.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,ea=e,Js=Ul(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,ea=e,Js=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(r=ld!==null?{id:po,overflow:go}:null,e.memoizedState={dehydrated:t,treeContext:r,retryLane:1073741824},r=ba(18,null,null,0),r.stateNode=t,r.return=e,e.child=r,ea=e,Js=null,!0):!1;default:return!1}}function x_(e){return(e.mode&1)!==0&&(e.flags&128)===0}function v_(e){if(Tr){var t=Js;if(t){var r=t;if(!$P(e,t)){if(x_(e))throw Error(Oe(418));t=Ul(r.nextSibling);var s=ea;t&&$P(e,t)?RR(s,r):(e.flags=e.flags&-4097|2,Tr=!1,ea=e)}}else{if(x_(e))throw Error(Oe(418));e.flags=e.flags&-4097|2,Tr=!1,ea=e}}}function IP(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;ea=e}function Hg(e){if(e!==ea)return!1;if(!Tr)return IP(e),Tr=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!f_(e.type,e.memoizedProps)),t&&(t=Js)){if(x_(e))throw $R(),Error(Oe(418));for(;t;)RR(e,t),t=Ul(t.nextSibling)}if(IP(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Oe(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"){if(t===0){Js=Ul(e.nextSibling);break e}t--}
vendor: 25,525 bytes, lines 38-40
38else r!=="$"&&r!=="$!"&&r!=="$?"||t++}e=e.nextSibling}Js=null}}else Js=ea?Ul(e.stateNode.nextSibling):null;return!0}function $R(){for(var e=Js;e;)e=Ul(e.nextSibling)}function Xu(){Js=ea=null,Tr=!1}function FS(e){Xa===null?Xa=[e]:Xa.push(e)}var QH=Go.ReactCurrentBatchConfig;function Nf(e,t,r){if(e=r.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(Oe(309));var s=r.stateNode}if(!s)throw Error(Oe(147,e));var a=s,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(o){var l=a.refs;o===null?delete l[i]:l[i]=o},t._stringRef=i,t)}if(typeof e!="string")throw Error(Oe(284));if(!r._owner)throw Error(Oe(290,e))}return e}function Vg(e,t){throw e=Object.prototype.toString.call(t),Error(Oe(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function LP(e){var t=e._init;return t(e._payload)}function IR(e){function t(v,j){if(e){var b=v.deletions;b===null?(v.deletions=[j],v.flags|=16):b.push(j)}}function r(v,j){if(!e)return null;for(;j!==null;)t(v,j),j=j.sibling;return null}function s(v,j){for(v=new Map;j!==null;)j.key!==null?v.set(j.key,j):v.set(j.index,j),j=j.sibling;return v}function a(v,j){return v=Wl(v,j),v.index=0,v.sibling=null,v}function i(v,j,b){return v.index=b,e?(b=v.alternate,b!==null?(b=b.index,b<j?(v.flags|=2,j):b):(v.flags|=2,j)):(v.flags|=1048576,j)}function o(v){return e&&v.alternate===null&&(v.flags|=2),v}function l(v,j,b,_){return j===null||j.tag!==6?(j=Tb(b,v.mode,_),j.return=v,j):(j=a(j,b),j.return=v,j)}function c(v,j,b,_){var w=b.type;return w===ou?u(v,j,b.props.children,_,b.key):j!==null&&(j.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===ml&&LP(w)===j.type)?(_=a(j,b.props),_.ref=Nf(v,j,b),_.return=v,_):(_=Vx(b.type,b.key,b.props,null,v.mode,_),_.ref=Nf(v,j,b),_.return=v,_)}function d(v,j,b,_){return j===null||j.tag!==4||j.stateNode.containerInfo!==b.containerInfo||j.stateNode.implementation!==b.implementation?(j=Ab(b,v.mode,_),j.return=v,j):(j=a(j,b.children||[]),j.return=v,j)}function u(v,j,b,_,w){return j===null||j.tag!==7?(j=nd(b,v.mode,_,w),j.return=v,j):(j=a(j,b),j.return=v,j)}function h(v,j,b){if(typeof j=="string"&&j!==""||typeof j=="number")return j=Tb(""+j,v.mode,b),j.return=v,j;if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Rg:return b=Vx(j.type,j.key,j.props,null,v.mode,b),b.ref=Nf(v,null,j),b.return=v,b;case iu:return j=Ab(j,v.mode,b),j.return=v,j;case ml:var _=j._init;return h(v,_(j._payload),b)}if(Yf(j)||yf(j))return j=nd(j,v.mode,b,null),j.return=v,j;Vg(v,j)}return null}function f(v,j,b,_){var w=j!==null?j.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return w!==null?null:l(v,j,""+b,_);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Rg:return b.key===w?c(v,j,b,_):null;case iu:return b.key===w?d(v,j,b,_):null;case ml:return w=b._init,f(v,j,w(b._payload),_)}if(Yf(b)||yf(b))return w!==null?null:u(v,j,b,_,null);Vg(v,b)}return null}function m(v,j,b,_,w){if(typeof _=="string"&&_!==""||typeof _=="number")return v=v.get(b)||null,l(j,v,""+_,w);if(typeof _=="object"&&_!==null){switch(_.$$typeof){case Rg:return v=v.get(_.key===null?b:_.key)||null,c(j,v,_,w);case iu:return v=v.get(_.key===null?b:_.key)||null,d(j,v,_,w);case ml:var N=_._init;return m(v,j,b,N(_._payload),w)}if(Yf(_)||yf(_))return v=v.get(b)||null,u(j,v,_,w,null);Vg(j,_)}return null}function g(v,j,b,_){for(var w=null,N=null,S=j,C=j=0,P=null;S!==null&&C<b.length;C++){S.index>C?(P=S,S=null):P=S.sibling;var M=f(v,S,b[C],_);if(M===null){S===null&&(S=P);break}e&&S&&M.alternate===null&&t(v,S),j=i(M,j,C),N===null?w=M:N.sibling=M,N=M,S=P}if(C===b.length)return r(v,S),Tr&&Ac(v,C),w;if(S===null){for(;C<b.length;C++)S=h(v,b[C],_),S!==null&&(j=i(S,j,C),N===null?w=S:N.sibling=S,N=S);return Tr&&Ac(v,C),w}for(S=s(v,S);C<b.length;C++)P=m(S,v,C,b[C],_),P!==null&&(e&&P.alternate!==null&&S.delete(P.key===null?C:P.key),j=i(P,j,C),N===null?w=P:N.sibling=P,N=P);return e&&S.forEach(function(D){return t(v,D)}),Tr&&Ac(v,C),w}function p(v,j,b,_){var w=yf(b);if(typeof w!="function")throw Error(Oe(150));if(b=w.call(b),b==null)throw Error(Oe(151));for(var N=w=null,S=j,C=j=0,P=null,M=b.next();S!==null&&!M.done;C++,M=b.next()){S.index>C?(P=S,S=null):P=S.sibling;var D=f(v,S,M.value,_);if(D===null){S===null&&(S=P);break}e&&S&&D.alternate===null&&t(v,S),j=i(D,j,C),N===null?w=D:N.sibling=D,N=D,S=P}if(M.done)return r(v,S),Tr&&Ac(v,C),w;if(S===null){for(;!M.done;C++,M=b.next())M=h(v,M.value,_),M!==null&&(j=i(M,j,C),N===null?w=M:N.sibling=M,N=M);return Tr&&Ac(v,C),w}for(S=s(v,S);!M.done;C++,M=b.next())M=m(S,v,C,M.value,_),M!==null&&(e&&M.alternate!==null&&S.delete(M.key===null?C:M.key),j=i(M,j,C),N===null?w=M:N.sibling=M,N=M);return e&&S.forEach(function(A){return t(v,A)}),Tr&&Ac(v,C),w}function y(v,j,b,_){if(typeof b=="object"&&b!==null&&b.type===ou&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case Rg:e:{for(var w=b.key,N=j;N!==null;){if(N.key===w){if(w=b.type,w===ou){if(N.tag===7){r(v,N.sibling),j=a(N,b.props.children),j.return=v,v=j;break e}}else if(N.elementType===w||typeof w=="object"&&w!==null&&w.$$typeof===ml&&LP(w)===N.type){r(v,N.sibling),j=a(N,b.props),j.ref=Nf(v,N,b),j.return=v,v=j;break e}r(v,N);break}else t(v,N);N=N.sibling}b.type===ou?(j=nd(b.props.children,v.mode,_,b.key),j.return=v,v=j):(_=Vx(b.type,b.key,b.props,null,v.mode,_),_.ref=Nf(v,j,b),_.return=v,v=_)}return o(v);case iu:e:{for(N=b.key;j!==null;){if(j.key===N)if(j.tag===4&&j.stateNode.containerInfo===b.containerInfo&&j.stateNode.implementation===b.implementation){r(v,j.sibling),j=a(j,b.children||[]),j.return=v,v=j;break e}else{r(v,j);break}else t(v,j);j=j.sibling}j=Ab(b,v.mode,_),j.return=v,v=j}return o(v);case ml:return N=b._init,y(v,j,N(b._payload),_)}if(Yf(b))return g(v,j,b,_);if(yf(b))return p(v,j,b,_);Vg(v,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,j!==null&&j.tag===6?(r(v,j.sibling),j=a(j,b),j.return=v,v=j):(r(v,j),j=Tb(b,v.mode,_),j.return=v,v=j),o(v)):r(v,j)}return y}var Zu=IR(!0),LR=IR(!1),mv=ac(null),pv=null,pu=null,US=null;function zS(){US=pu=pv=null}function BS(e){var t=mv.current;Cr(mv),e._currentValue=t}function y_(e,t,r){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===r)break;e=e.return}}function Su(e,t){pv=e,US=pu=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&($s=!0),e.firstContext=null)}function Ta(e){var t=e._currentValue;if(US!==e)if(e={context:e,memoizedValue:t,next:null},pu===null){if(pv===null)throw Error(Oe(308));pu=e,pv.dependencies={lanes:0,firstContext:e}}else pu=pu.next=e;return t}var Uc=null;function qS(e){Uc===null?Uc=[e]:Uc.push(e)}function FR(e,t,r,s){var a=t.interleaved;return a===null?(r.next=r,qS(t)):(r.next=a.next,a.next=r),t.interleaved=r,Do(e,s)}function Do(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var pl=!1;function WS(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function UR(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function No(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function zl(e,t,r){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,Bt&2){var a=s.pending;return a===null?t.next=t:(t.next=a.next,a.next=t),s.pending=t,Do(e,r)}return a=s.interleaved,a===null?(t.next=t,qS(s)):(t.next=a.next,a.next=t),s.interleaved=t,Do(e,r)}function Ux(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var s=t.lanes;s&=e.pendingLanes,r|=s,t.lanes=r,TS(e,r)}}function FP(e,t){var r=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,r===s)){var a=null,i=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};i===null?a=i=o:i=i.next=o,r=r.next}while(r!==null);i===null?a=i=t:i=i.next=t}else a=i=t;r={baseState:s.baseState,firstBaseUpdate:a,lastBaseUpdate:i,shared:s.shared,effects:s.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function gv(e,t,r,s){var a=e.updateQueue;pl=!1;var i=a.firstBaseUpdate,o=a.lastBaseUpdate,l=a.shared.pending;if(l!==null){a.shared.pending=null;var c=l,d=c.next;c.next=null,o===null?i=d:o.next=d,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==o&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(i!==null){var h=a.baseState;o=0,u=d=c=null,l=i;do{var f=l.lane,m=l.eventTime;if((s&f)===f){u!==null&&(u=u.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,p=l;switch(f=t,m=r,p.tag){case 1:if(g=p.payload,typeof g=="function"){h=g.call(m,h,f);break e}h=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=p.payload,f=typeof g=="function"?g.call(m,h,f):g,f==null)break e;h=Fr({},h,f);break e;case 2:pl=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,f=a.effects,f===null?a.effects=[l]:f.push(l))}else m={eventTime:m,lane:f,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=m,c=h):u=u.next=m,o|=f;if(l=l.next,l===null){if(l=a.shared.pending,l===null)break;f=l,l=f.next,f.next=null,a.lastBaseUpdate=f,a.shared.pending=null}}while(!0);if(u===null&&(c=h),a.baseState=c,a.firstBaseUpdate=d,a.lastBaseUpdate=u,t=a.shared.interleaved,t!==null){a=t;do o|=a.lane,a=a.next;while(a!==t)}else i===null&&(a.shared.lanes=0);dd|=o,e.lanes=o,e.memoizedState=h}}function UP(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var s=e[t],a=s.callback;if(a!==null){if(s.callback=null,s=r,typeof a!="function")throw Error(Oe(191,a));a.call(s)}}}var Jp={},Oi=ac(Jp),Fm=ac(Jp),Um=ac(Jp);function zc(e){if(e===Jp)throw Error(Oe(174));return e}function HS(e,t){switch(yr(Um,t),yr(Fm,e),yr(Oi,Jp),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Jw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Jw(t,e)}Cr(Oi),yr(Oi,t)}function Ju(){Cr(Oi),Cr(Fm),Cr(Um)}function zR(e){zc(Um.current);var t=zc(Oi.current),r=Jw(t,e.type);t!==r&&(yr(Fm,e),yr(Oi,r))}function VS(e){Fm.current===e&&(Cr(Oi),Cr(Fm))}var Dr=ac(0);function xv(e){for(var t=e;t!==null;){if(t.tag===13){var r=t.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var _b=[];function KS(){for(var e=0;e<_b.length;e++)_b[e]._workInProgressVersionPrimary=null;_b.length=0}var zx=Go.ReactCurrentDispatcher,Nb=Go.ReactCurrentBatchConfig,cd=0,Ir=null,pn=null,Nn=null,vv=!1,fm=!1,zm=0,XH=0;function Gn(){throw Error(Oe(321))}function GS(e,t){if(t===null)return!1;for(var r=0;r<t.length&&r<e.length;r++)if(!ai(e[r],t[r]))return!1;return!0}function YS(e,t,r,s,a,i){if(cd=i,Ir=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,zx.current=e===null||e.memoizedState===null?tV:rV,e=r(s,a),fm){i=0;do{if(fm=!1,zm=0,25<=i)throw Error(Oe(301));i+=1,Nn=pn=null,t.updateQueue=null,zx.current=nV,e=r(s,a)}while(fm)}if(zx.current=yv,t=pn!==null&&pn.next!==null,cd=0,Nn=pn=Ir=null,vv=!1,t)throw Error(Oe(300));return e}function QS(){var e=zm!==0;return zm=0,e}function ji(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Nn===null?Ir.memoizedState=Nn=e:Nn=Nn.next=e,Nn}function Aa(){if(pn===null){var e=Ir.alternate;e=e!==null?e.memoizedState:null}else e=pn.next;var t=Nn===null?Ir.memoizedState:Nn.next;if(t!==null)Nn=t,pn=e;else{if(e===null)throw Error(Oe(310));pn=e,e={memoizedState:pn.memoizedState,baseState:pn.baseState,baseQueue:pn.baseQueue,queue:pn.queue,next:null},Nn===null?Ir.memoizedState=Nn=e:Nn=Nn.next=e}return Nn}function Bm(e,t){return typeof t=="function"?t(e):t}function Sb(e){var t=Aa(),r=t.queue;if(r===null)throw Error(Oe(311));r.lastRenderedReducer=e;var s=pn,a=s.baseQueue,i=r.pending;if(i!==null){if(a!==null){var o=a.next;a.next=i.next,i.next=o}s.baseQueue=a=i,r.pending=null}if(a!==null){i=a.next,s=s.baseState;var l=o=null,c=null,d=i;do{var u=d.lane;if((cd&u)===u)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),s=d.hasEagerState?d.eagerState:e(s,d.action);else{var h={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=h,o=s):c=c.next=h,Ir.lanes|=u,dd|=u}d=d.next}while(d!==null&&d!==i);c===null?o=s:c.next=l,ai(s,t.memoizedState)||($s=!0),t.memoizedState=s,t.baseState=o,t.baseQueue=c,r.lastRenderedState=s}if(e=r.interleaved,e!==null){a=e;do i=a.lane,Ir.lanes|=i,dd|=i,a=a.next;while(a!==e)}else a===null&&(r.lanes=0);return[t.memoizedState,r.dispatch]}function Cb(e){var t=Aa(),r=t.queue;if(r===null)throw Error(Oe(311));r.lastRenderedReducer=e;var s=r.dispatch,a=r.pending,i=t.memoizedState;if(a!==null){r.pending=null;var o=a=a.next;do i=e(i,o.action),o=o.next;while(o!==a);ai(i,t.memoizedState)||($s=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),r.lastRenderedState=i}return[i,s]}function BR(){}function qR(e,t){var r=Ir,s=Aa(),a=t(),i=!ai(s.memoizedState,a);if(i&&(s.memoizedState=a,$s=!0),s=s.queue,XS(VR.bind(null,r,s,e),[e]),s.getSnapshot!==t||i||Nn!==null&&Nn.memoizedState.tag&1){if(r.flags|=2048,qm(9,HR.bind(null,r,s,a,t),void 0,null),Sn===null)throw Error(Oe(349));cd&30||WR(r,t,a)}return a}function WR(e,t,r){e.flags|=16384,e={getSnapshot:t,value:r},t=Ir.updateQueue,t===null?(t={lastEffect:null,stores:null},Ir.updateQueue=t,t.stores=[e]):(r=t.stores,r===null?t.stores=[e]:r.push(e))}function HR(e,t,r,s){t.value=r,t.getSnapshot=s,KR(t)&&GR(e)}function VR(e,t,r){return r(function(){KR(t)&&GR(e)})}function KR(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!ai(e,r)}catch{return!0}}function GR(e){var t=Do(e,1);t!==null&&si(t,e,1,-1)}function zP(e){var t=ji();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Bm,lastRenderedState:e},t.queue=e,e=e.dispatch=eV.bind(null,Ir,e),[t.memoizedState,e]}function qm(e,t,r,s){return e={tag:e,create:t,destroy:r,deps:s,next:null},t=Ir.updateQueue,t===null?(t={lastEffect:null,stores:null},Ir.updateQueue=t,t.lastEffect=e.next=e):(r=t.lastEffect,r===null?t.lastEffect=e.next=e:(s=r.next,r.next=e,e.next=s,t.lastEffect=e)),e}function YR(){return Aa().memoizedState}function Bx(e,t,r,s){var a=ji();Ir.flags|=e,a.memoizedState=qm(1|t,r,void 0,s===void 0?null:s)}function d0(e,t,r,s){var a=Aa();s=s===void 0?null:s;var i=void 0;if(pn!==null){var o=pn.memoizedState;if(i=o.destroy,s!==null&&GS(s,o.deps)){a.memoizedState=qm(t,r,i,s);return}}Ir.flags|=e,a.memoizedState=qm(1|t,r,i,s)}function BP(e,t){return Bx(8390656,8,e,t)}function XS(e,t){return d0(2048,8,e,t)}function QR(e,t){return d0(4,2,e,t)}function XR(e,t){return d0(4,4,e,t)}function ZR(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function JR(e,t,r){return r=r!=null?r.concat([e]):null,d0(4,4,ZR.bind(null,t,e),r)}function ZS(){}function e$(e,t){var r=Aa();t=t===void 0?null:t;var s=r.memoizedState;return s!==null&&t!==null&&GS(t,s[1])?s[0]:(r.memoizedState=[e,t],e)}function t$(e,t){var r=Aa();t=t===void 0?null:t;var s=r.memoizedState;return s!==null&&t!==null&&GS(t,s[1])?s[0]:(e=e(),r.memoizedState=[e,t],e)}function r$(e,t,r){return cd&21?(ai(r,t)||(r=oR(),Ir.lanes|=r,dd|=r,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,$s=!0),e.memoizedState=r)}function ZH(e,t){var r=or;or=r!==0&&4>r?r:4,e(!0);var s=Nb.transition;Nb.transition={};try{e(!1),t()}finally{or=r,Nb.transition=s}}function n$(){return Aa().memoizedState}function JH(e,t,r){var s=ql(e);if(r={lane:s,action:r,hasEagerState:!1,eagerState:null,next:null},s$(e))a$(t,r);else if(r=FR(e,t,r,s),r!==null){var a=bs();si(r,e,s,a),i$(r,t,s)}}function eV(e,t,r){var s=ql(e),a={lane:s,action:r,hasEagerState:!1,eagerState:null,next:null};if(s$(e))a$(t,a);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var o=t.lastRenderedState,l=i(o,r);if(a.hasEagerState=!0,a.eagerState=l,ai(l,o)){var c=t.interleaved;c===null?(a.next=a,qS(t)):(a.next=c.next,c.next=a),t.interleaved=a;return}}catch{}finally{}r=FR(e,t,a,s),r!==null&&(a=bs(),si(r,e,s,a),i$(r,t,s))}}function s$(e){var t=e.alternate;return e===Ir||t!==null&&t===Ir}function a$(e,t){fm=vv=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function i$(e,t,r){if(r&4194240){var s=t.lanes;s&=e.pendingLanes,r|=s,t.lanes=r,TS(e,r)}}var yv={readContext:Ta,useCallback:Gn,useContext:Gn,useEffect:Gn,useImperativeHandle:Gn,useInsertionEffect:Gn,useLayoutEffect:Gn,useMemo:Gn,useReducer:Gn,useRef:Gn,useState:Gn,useDebugValue:Gn,useDeferredValue:Gn,useTransition:Gn,useMutableSource:Gn,useSyncExternalStore:Gn,useId:Gn,unstable_isNewReconciler:!1},tV={readContext:Ta,useCallback:function(e,t){return ji().memoizedState=[e,t===void 0?null:t],e},useContext:Ta,useEffect:BP,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,Bx(4194308,4,ZR.bind(null,t,e),r)},useLayoutEffect:function(e,t){return Bx(4194308,4,e,t)},useInsertionEffect:function(e,t){return Bx(4,2,e,t)},useMemo:function(e,t){var r=ji();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var s=ji();return t=r!==void 0?r(t):t,s.memoizedState=s.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},s.queue=e,e=e.dispatch=JH.bind(null,Ir,e),[s.memoizedState,e]},useRef:function(e){var t=ji();return e={current:e},t.memoizedState=e},useState:zP,useDebugValue:ZS,useDeferredValue:function(e){return ji().memoizedState=e},useTransition:function(){var e=zP(!1),t=e[0];return e=ZH.bind(null,e[1]),ji().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var s=Ir,a=ji();if(Tr){if(r===void 0)throw Error(Oe(407));r=r()}else{if(r=t(),Sn===null)throw Error(Oe(349));cd&30||WR(s,t,r)}a.memoizedState=r;var i={value:r,getSnapshot:t};return a.queue=i,BP(VR.bind(null,s,i,e),[e]),s.flags|=2048,qm(9,HR.bind(null,s,i,r,t),void 0,null),r},useId:function(){var e=ji(),t=Sn.identifierPrefix;if(Tr){var r=go,s=po;r=(s&~(1<<32-ni(s)-1)).toString(32)+r,t=":"+t+"R"+r,r=zm++,0<r&&(t+="H"+r.toString(32)),t+=":"}else r=XH++,t=":"+t+"r"+r.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},rV={readContext:Ta,useCallback:e$,useContext:Ta,useEffect:XS,useImperativeHandle:JR,useInsertionEffect:QR,useLayoutEffect:XR,useMemo:t$,useReducer:Sb,useRef:YR,useState:function(){return Sb(Bm)},useDebugValue:ZS,useDeferredValue:function(e){var t=Aa();return r$(t,pn.memoizedState,e)},useTransition:function(){var e=Sb(Bm)[0],t=Aa().memoizedState;return[e,t]},useMutableSource:BR,useSyncExternalStore:qR,useId:n$,unstable_isNewReconciler:!1},nV={readContext:Ta,useCallback:e$,useContext:Ta,useEffect:XS,useImperativeHandle:JR,useInsertionEffect:QR,useLayoutEffect:XR,useMemo:t$,useReducer:Cb,useRef:YR,useState:function(){return Cb(Bm)},useDebugValue:ZS,useDeferredValue:function(e){var t=Aa();return pn===null?t.memoizedState=e:r$(t,pn.memoizedState,e)},useTransition:function(){var e=Cb(Bm)[0],t=Aa().memoizedState;return[e,t]},useMutableSource:BR,useSyncExternalStore:qR,useId:n$,unstable_isNewReconciler:!1};function Wa(e,t){if(e&&e.defaultProps){t=Fr({},t),e=e.defaultProps;for(var r in e)t[r]===void 0&&(t[r]=e[r]);return t}return t}function j_(e,t,r,s){t=e.memoizedState,r=r(s,t),r=r==null?t:Fr({},t,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var u0={isMounted:function(e){return(e=e._reactInternals)?Td(e)===e:!1},enqueueSetState:function(e,t,r){e=e._reactInternals;var s=bs(),a=ql(e),i=No(s,a);i.payload=t,r!=null&&(i.callback=r),t=zl(e,i,a),t!==null&&(si(t,e,a,s),Ux(t,e,a))},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var s=bs(),a=ql(e),i=No(s,a);i.tag=1,i.payload=t,r!=null&&(i.callback=r),t=zl(e,i,a),t!==null&&(si(t,e,a,s),Ux(t,e,a))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=bs(),s=ql(e),a=No(r,s);a.tag=2,t!=null&&(a.callback=t),t=zl(e,a,s),t!==null&&(si(t,e,s,r),Ux(t,e,s))}};function qP(e,t,r,s,a,i,o){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,i,o):t.prototype&&t.prototype.isPureReactComponent?!Rm(r,s)||!Rm(a,i):!0}function o$(e,t,r){var s=!1,a=Zl,i=t.contextType;return typeof i=="object"&&i!==null?i=Ta(i):(a=Fs(t)?od:as.current,s=t.contextTypes,i=(s=s!=null)?Qu(e,a):Zl),t=new t(r,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=u0,e.stateNode=t,t._reactInternals=e,s&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=a,e.__reactInternalMemoizedMaskedChildContext=i),t}function WP(e,t,r,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(r,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(r,s),t.state!==e&&u0.enqueueReplaceState(t,t.state,null)}function b_(e,t,r,s){var a=e.stateNode;a.props=r,a.state=e.memoizedState,a.refs={},WS(e);var i=t.contextType;typeof i=="object"&&i!==null?a.context=Ta(i):(i=Fs(t)?od:as.current,a.context=Qu(e,i)),a.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(j_(e,t,i,r),a.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof a.getSnapshotBeforeUpdate=="function"||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(t=a.state,typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount(),t!==a.state&&u0.enqueueReplaceState(a,a.state,null),gv(e,r,a,s),a.state=e.memoizedState),typeof a.componentDidMount=="function"&&(e.flags|=4194308)}function eh(e,t){try{var r="",s=t;do r+=EW(s),s=s.return;while(s);var a=r}catch(i){a=`
39Error generating stack: `+i.message+`
40`+i.stack}return{value:e,source:t,stack:a,digest:null}}function kb(e,t,r){return{value:e,source:null,stack:r??null,digest:t??null}}function w_(e,t){try{console.error(t.value)}catch(r){setTimeout(function(){throw r})}}var sV=typeof WeakMap=="function"?WeakMap:Map;function l$(e,t,r){r=No(-1,r),r.tag=3,r.payload={element:null};var s=t.value;return r.callback=function(){bv||(bv=!0,O_=s),w_(e,t)},r}function c$(e,t,r){r=No(-1,r),r.tag=3;var s=e.type.getDerivedStateFromError;if(typeof s=="function"){var a=t.value;r.payload=function(){return s(a)},r.callback=function(){w_(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(r.callback=function(){w_(e,t),typeof s!="function"&&(Bl===null?Bl=new Set([this]):Bl.add(this));var o=t.stack;this.componentDidCatch(t.value,{componentStack:o!==null?o:""})}),r}function HP(e,t,r){var s=e.pingCache;if(s===null){s=e.pingCache=new sV;var a=new Set;s.set(t,a)}else a=s.get(t),a===void 0&&(a=new Set,s.set(t,a));a.has(r)||(a.add(r),e=vV.bind(null,e,t,r),t.then(e,e))}function VP(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function KP(e,t,r,s,a){return e.mode&1?(e.flags|=65536,e.lanes=a,e):(e===t?e.flags|=65536:(e.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(t=No(-1,1),t.tag=2,zl(r,t,1))),r.lanes|=1),e)}var aV=Go.ReactCurrentOwner,$s=!1;function gs(e,t,r,s){t.child=e===null?LR(t,null,r,s):Zu(t,e.child,r,s)}function GP(e,t,r,s,a){r=r.render;var i=t.ref;return Su(t,a),s=YS(e,t,r,s,i,a),r=QS(),e!==null&&!$s?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Ro(e,t,a)):(Tr&&r&&IS(t),t.flags|=1,gs(e,t,s,a),t.child)}function YP(e,t,r,s,a){if(e===null){var i=r.type;return typeof i=="function"&&!iC(i)&&i.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(t.tag=15,t.type=i,d$(e,t,i,s,a)):(e=Vx(r.type,null,s,t,t.mode,a),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&a)){var o=i.memoizedProps;if(r=r.compare,r=r!==null?r:Rm,r(o,s)&&e.ref===t.ref)return Ro(e,t,a)}return t.flags|=1,e=Wl(i,s),e.ref=t.ref,e.return=t,t.child=e}function d$(e,t,r,s,a){if(e!==null){var i=e.memoizedProps;if(Rm(i,s)&&e.ref===t.ref)if($s=!1,t.pendingProps=s=i,(e.lanes&a)!==0)e.flags&131072&&($s=!0);else return t.lanes=e.lanes,Ro(e,t,a)}return __(e,t,r,s,a)}function u$(e,t,r){var s=t.pendingProps,a=s.children,i=e!==null?e.memoizedState:null;if(s.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},yr(xu,Gs),Gs|=r;else{if(!(r&1073741824))return e=i!==null?i.baseLanes|r:r,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,yr(xu,Gs),Gs|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},s=i!==null?i.baseLanes:r,yr(xu,Gs),Gs|=s}else i!==null?(s=i.baseLanes|r,t.memoizedState=null):s=r,yr(xu,Gs),Gs|=s;return gs(e,t,a,r),t.child}function h$(e,t){var r=t.ref;(e===null&&r!==null||e!==null&&e.ref!==r)&&(t.flags|=512,t.flags|=2097152)}
vendor: 4,711 bytes, line 40
40function __(e,t,r,s,a){var i=Fs(r)?od:as.current;return i=Qu(t,i),Su(t,a),r=YS(e,t,r,s,i,a),s=QS(),e!==null&&!$s?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~a,Ro(e,t,a)):(Tr&&s&&IS(t),t.flags|=1,gs(e,t,r,a),t.child)}function QP(e,t,r,s,a){if(Fs(r)){var i=!0;uv(t)}else i=!1;if(Su(t,a),t.stateNode===null)qx(e,t),o$(t,r,s),b_(t,r,s,a),s=!0;else if(e===null){var o=t.stateNode,l=t.memoizedProps;o.props=l;var c=o.context,d=r.contextType;typeof d=="object"&&d!==null?d=Ta(d):(d=Fs(r)?od:as.current,d=Qu(t,d));var u=r.getDerivedStateFromProps,h=typeof u=="function"||typeof o.getSnapshotBeforeUpdate=="function";h||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==s||c!==d)&&WP(t,o,s,d),pl=!1;var f=t.memoizedState;o.state=f,gv(t,s,o,a),c=t.memoizedState,l!==s||f!==c||Ls.current||pl?(typeof u=="function"&&(j_(t,r,u,s),c=t.memoizedState),(l=pl||qP(t,r,l,s,f,c,d))?(h||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=s,t.memoizedState=c),o.props=s,o.state=c,o.context=d,s=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{o=t.stateNode,UR(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Wa(t.type,l),o.props=d,h=t.pendingProps,f=o.context,c=r.contextType,typeof c=="object"&&c!==null?c=Ta(c):(c=Fs(r)?od:as.current,c=Qu(t,c));var m=r.getDerivedStateFromProps;(u=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==h||f!==c)&&WP(t,o,s,c),pl=!1,f=t.memoizedState,o.state=f,gv(t,s,o,a);var g=t.memoizedState;l!==h||f!==g||Ls.current||pl?(typeof m=="function"&&(j_(t,r,m,s),g=t.memoizedState),(d=pl||qP(t,r,d,s,f,g,c)||!1)?(u||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(s,g,c),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(s,g,c)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=g),o.props=s,o.state=g,o.context=c,s=d):(typeof o.componentDidUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),s=!1)}return N_(e,t,r,s,i,a)}function N_(e,t,r,s,a,i){h$(e,t);var o=(t.flags&128)!==0;if(!s&&!o)return a&&RP(t,r,!1),Ro(e,t,i);s=t.stateNode,aV.current=t;var l=o&&typeof r.getDerivedStateFromError!="function"?null:s.render();return t.flags|=1,e!==null&&o?(t.child=Zu(t,e.child,null,i),t.child=Zu(t,null,l,i)):gs(e,t,l,i),t.memoizedState=s.state,a&&RP(t,r,!0),t.child}function f$(e){var t=e.stateNode;t.pendingContext?DP(e,t.pendingContext,t.pendingContext!==t.context):t.context&&DP(e,t.context,!1),HS(e,t.containerInfo)}function XP(e,t,r,s,a){return Xu(),FS(a),t.flags|=256,gs(e,t,r,s),t.child}var S_={dehydrated:null,treeContext:null,retryLane:0};function C_(e){return{baseLanes:e,cachePool:null,transitions:null}}function m$(e,t,r){var s=t.pendingProps,a=Dr.current,i=!1,o=(t.flags&128)!==0,l;if((l=o)||(l=e!==null&&e.memoizedState===null?!1:(a&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(a|=1),yr(Dr,a&1),e===null)return v_(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(o=s.children,e=s.fallback,i?(s=t.mode,i=t.child,o={mode:"hidden",children:o},!(s&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=m0(o,s,0,null),e=nd(e,s,r,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=C_(r),t.memoizedState=S_,e):JS(t,o));if(a=e.memoizedState,a!==null&&(l=a.dehydrated,l!==null))return iV(e,t,o,s,l,a,r);if(i){i=s.fallback,o=t.mode,a=e.child,l=a.sibling;var c={mode:"hidden",children:s.children};return!(o&1)&&t.child!==a?(s=t.child,s.childLanes=0,s.pendingProps=c,t.deletions=null):(s=Wl(a,c),s.subtreeFlags=a.subtreeFlags&14680064),l!==null?i=Wl(l,i):(i=nd(i,o,r,null),i.flags|=2),i.return=t,s.return=t,s.sibling=i,t.child=s,s=i,i=t.child,o=e.child.memoizedState,o=o===null?C_(r):{base
vendor: 7,501 bytes, line 40
40Lanes:o.baseLanes|r,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=e.childLanes&~r,t.memoizedState=S_,s}return i=e.child,e=i.sibling,s=Wl(i,{mode:"visible",children:s.children}),!(t.mode&1)&&(s.lanes=r),s.return=t,s.sibling=null,e!==null&&(r=t.deletions,r===null?(t.deletions=[e],t.flags|=16):r.push(e)),t.child=s,t.memoizedState=null,s}function JS(e,t){return t=m0({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function Kg(e,t,r,s){return s!==null&&FS(s),Zu(t,e.child,null,r),e=JS(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function iV(e,t,r,s,a,i,o){if(r)return t.flags&256?(t.flags&=-257,s=kb(Error(Oe(422))),Kg(e,t,o,s)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=s.fallback,a=t.mode,s=m0({mode:"visible",children:s.children},a,0,null),i=nd(i,a,o,null),i.flags|=2,s.return=t,i.return=t,s.sibling=i,t.child=s,t.mode&1&&Zu(t,e.child,null,o),t.child.memoizedState=C_(o),t.memoizedState=S_,i);if(!(t.mode&1))return Kg(e,t,o,null);if(a.data==="$!"){if(s=a.nextSibling&&a.nextSibling.dataset,s)var l=s.dgst;return s=l,i=Error(Oe(419)),s=kb(i,s,void 0),Kg(e,t,o,s)}if(l=(o&e.childLanes)!==0,$s||l){if(s=Sn,s!==null){switch(o&-o){case 4:a=2;break;case 16:a=8;break;case 64: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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:a=32;break;case 536870912:a=268435456;break;default:a=0}a=a&(s.suspendedLanes|o)?0:a,a!==0&&a!==i.retryLane&&(i.retryLane=a,Do(e,a),si(s,e,a,-1))}return aC(),s=kb(Error(Oe(421))),Kg(e,t,o,s)}return a.data==="$?"?(t.flags|=128,t.child=e.child,t=yV.bind(null,e),a._reactRetry=t,null):(e=i.treeContext,Js=Ul(a.nextSibling),ea=t,Tr=!0,Xa=null,e!==null&&(va[ya++]=po,va[ya++]=go,va[ya++]=ld,po=e.id,go=e.overflow,ld=t),t=JS(t,s.children),t.flags|=4096,t)}function ZP(e,t,r){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),y_(e.return,t,r)}function Pb(e,t,r,s,a){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:r,tailMode:a}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=s,i.tail=r,i.tailMode=a)}function p$(e,t,r){var s=t.pendingProps,a=s.revealOrder,i=s.tail;if(gs(e,t,s.children,r),s=Dr.current,s&2)s=s&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&ZP(e,r,t);else if(e.tag===19)ZP(e,r,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}s&=1}if(yr(Dr,s),!(t.mode&1))t.memoizedState=null;else switch(a){case"forwards":for(r=t.child,a=null;r!==null;)e=r.alternate,e!==null&&xv(e)===null&&(a=r),r=r.sibling;r=a,r===null?(a=t.child,t.child=null):(a=r.sibling,r.sibling=null),Pb(t,!1,a,r,i);break;case"backwards":for(r=null,a=t.child,t.child=null;a!==null;){if(e=a.alternate,e!==null&&xv(e)===null){t.child=a;break}e=a.sibling,a.sibling=r,r=a,a=e}Pb(t,!0,r,null,i);break;case"together":Pb(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function qx(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Ro(e,t,r){if(e!==null&&(t.dependencies=e.dependencies),dd|=t.lanes,!(r&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Oe(153));if(t.child!==null){for(e=t.child,r=Wl(e,e.pendingProps),t.child=r,r.return=t;e.sibling!==null;)e=e.sibling,r=r.sibling=Wl(e,e.pendingProps),r.return=t;r.sibling=null}return t.child}function oV(e,t,r){switch(t.tag){case 3:f$(t),Xu();break;case 5:zR(t);break;case 1:Fs(t.type)&&uv(t);break;case 4:HS(t,t.stateNode.containerInfo);break;case 10:var s=t.type._context,a=t.memoizedProps.value;yr(mv,s._currentValue),s._currentValue=a;break;case 13:if(s=t.memoizedState,s!==null)return s.dehydrated!==null?(yr(Dr,Dr.current&1),t.flags|=128,null):r&t.child.childLanes?m$(e,t,r):(yr(Dr,Dr.current&1),e=Ro(e,t,r),e!==null?e.sibling:null);yr(Dr,Dr.current&1);break;case 19:if(s=(r&t.childLanes)!==0,e.flags&128){if(s)return p$(e,t,r);t.flags|=128}if(a=t.memoizedState,a!==null&&(a.rendering=null,a.tail=null,a.lastEffect=null),yr(Dr,Dr.current),s)break;return null;case 22:case 23:return t.lanes=0,u$(e,t,r)}return Ro(e,t,r)}var g$,k_,x$,v$;g$=function(e,t){for(var r=t.child;r!==null;){if(r.tag===5||r.tag===6)e.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===t)break;for(;r.sibling===null;){if(r.return===null||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};k_=function(){};x$=function(e,t,r,s){var a=e.memoizedProps;if(a!==s){e=t.stateNode,zc(Oi.current);var i=null;switch(r){case"input":a=Yw(e,a),s=Yw(e,s),i=[];break;case"select":a=Fr({},a,{value:void 0}),s=Fr({},s,{value:void 0}),i=[];break;case"textarea":a=Zw(e,a),s=Zw(e,s),i=[];break;default:typeof a.onClick!="function"&&typeof s.onClick=="function"&&(e.onclick=cv)}e_(r,s);var o;r=null;for(d in a)if(!s.hasOwnProperty(d)&&a.hasOwnProperty(d)&&a[d]!=null)if(d==="style"){var l=a[d];for(o in l)l.hasOwnProperty(o)&&(r||(r={}),r[o]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(Pm.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in s){var c=s[d];if(l=a!=null?a[d]:void 0,s.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(o in l)!l.hasOwnProperty(o)||c&&c.hasOwnProperty(o)||(r||(r={}),r[o]="");for(o in c)c.hasOwnProperty(o)&&l[o]!==c[o]&&(r||(r={}),r[o]=c[o])}else r||(i||(i=[]),i.push(d,r)),r=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(i=i||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(i=i||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(Pm.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&br("scroll",e),i||l===c||(i=[])):(i=i||[]).push(d,c))}r&&(i=i||[]).push("style",r);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};v$=function(e,t,r,s){r!==s&&(t.flags|=4)};function Sf(e,t){if(!Tr)switch(e.tailMode){case"hidden":t=e.tail;for(var r=null;t!==null;)t.alternate!==null&&(r=t),t=t.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function Yn(e){var t=e.alternate!==null&&e.alternate.child===e.child,r=0,s=0;if(t)for(var a=e.child;a!==null;)r|=a.lanes|a.childLanes,s|=a.subtreeFlags&14680064,s|=a.flags&14680064,a.return=e,a=a.sibling;else for(a=e.child;a!==null;)r|=a.lanes|a.childLanes,s|=a.subtreeFlags,s|=a.flags,a.return=e,a=a.sibling;return e.subtreeFlags|=s,e.childLanes=r,t}function lV(e,t,r){var s=t.pendingProps;switch(LS(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yn(t),null;case 1:return Fs(t.type)&&dv(),Yn(t),null;case 3:return s=t.stateNode,Ju(),Cr(Ls),Cr(as),KS(),s.pendingContext&&(s.context=s.pendingContext,s.pendingContext=null),(e===null||e.child===null)&&(Hg(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Xa!==null&&(R_(Xa),Xa=null))),k_(e,t),Yn(t),null;case 5:VS(t);var a=zc(Um.current);if(r=t.type,e!==null&&t.stateNode!=null)x$(e,t,r,s,a),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);
vendor: 33,443 bytes, line 40
40else{if(!s){if(t.stateNode===null)throw Error(Oe(166));return Yn(t),null}if(e=zc(Oi.current),Hg(t)){s=t.stateNode,r=t.type;var i=t.memoizedProps;switch(s[Si]=t,s[Lm]=i,e=(t.mode&1)!==0,r){case"dialog":br("cancel",s),br("close",s);break;case"iframe":case"object":case"embed":br("load",s);break;case"video":case"audio":for(a=0;a<Xf.length;a++)br(Xf[a],s);break;case"source":br("error",s);break;case"img":case"image":case"link":br("error",s),br("load",s);break;case"details":br("toggle",s);break;case"input":oP(s,i),br("invalid",s);break;case"select":s._wrapperState={wasMultiple:!!i.multiple},br("invalid",s);break;case"textarea":cP(s,i),br("invalid",s)}e_(r,i),a=null;for(var o in i)if(i.hasOwnProperty(o)){var l=i[o];o==="children"?typeof l=="string"?s.textContent!==l&&(i.suppressHydrationWarning!==!0&&Wg(s.textContent,l,e),a=["children",l]):typeof l=="number"&&s.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&Wg(s.textContent,l,e),a=["children",""+l]):Pm.hasOwnProperty(o)&&l!=null&&o==="onScroll"&&br("scroll",s)}switch(r){case"input":$g(s),lP(s,i,!0);break;case"textarea":$g(s),dP(s);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(s.onclick=cv)}s=a,t.updateQueue=s,s!==null&&(t.flags|=4)}else{o=a.nodeType===9?a:a.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=VD(r)),e==="http://www.w3.org/1999/xhtml"?r==="script"?(e=o.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof s.is=="string"?e=o.createElement(r,{is:s.is}):(e=o.createElement(r),r==="select"&&(o=e,s.multiple?o.multiple=!0:s.size&&(o.size=s.size))):e=o.createElementNS(e,r),e[Si]=t,e[Lm]=s,g$(e,t,!1,!1),t.stateNode=e;e:{switch(o=t_(r,s),r){case"dialog":br("cancel",e),br("close",e),a=s;break;case"iframe":case"object":case"embed":br("load",e),a=s;break;case"video":case"audio":for(a=0;a<Xf.length;a++)br(Xf[a],e);a=s;break;case"source":br("error",e),a=s;break;case"img":case"image":case"link":br("error",e),br("load",e),a=s;break;case"details":br("toggle",e),a=s;break;case"input":oP(e,s),a=Yw(e,s),br("invalid",e);break;case"option":a=s;break;case"select":e._wrapperState={wasMultiple:!!s.multiple},a=Fr({},s,{value:void 0}),br("invalid",e);break;case"textarea":cP(e,s),a=Zw(e,s),br("invalid",e);break;default:a=s}e_(r,a),l=a;for(i in l)if(l.hasOwnProperty(i)){var c=l[i];i==="style"?YD(e,c):i==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&KD(e,c)):i==="children"?typeof c=="string"?(r!=="textarea"||c!=="")&&Tm(e,c):typeof c=="number"&&Tm(e,""+c):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Pm.hasOwnProperty(i)?c!=null&&i==="onScroll"&&br("scroll",e):c!=null&&_S(e,i,c,o))}switch(r){case"input":$g(e),lP(e,s,!1);break;case"textarea":$g(e),dP(e);break;case"option":s.value!=null&&e.setAttribute("value",""+Xl(s.value));break;case"select":e.multiple=!!s.multiple,i=s.value,i!=null?bu(e,!!s.multiple,i,!1):s.defaultValue!=null&&bu(e,!!s.multiple,s.defaultValue,!0);break;default:typeof a.onClick=="function"&&(e.onclick=cv)}switch(r){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}}s&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Yn(t),null;case 6:if(e&&t.stateNode!=null)v$(e,t,e.memoizedProps,s);else{if(typeof s!="string"&&t.stateNode===null)throw Error(Oe(166));if(r=zc(Um.current),zc(Oi.current),Hg(t)){if(s=t.stateNode,r=t.memoizedProps,s[Si]=t,(i=s.nodeValue!==r)&&(e=ea,e!==null))switch(e.tag){case 3:Wg(s.nodeValue,r,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Wg(s.nodeValue,r,(e.mode&1)!==0)}i&&(t.flags|=4)}else s=(r.nodeType===9?r:r.ownerDocument).createTextNode(s),s[Si]=t,t.stateNode=s}return Yn(t),null;case 13:if(Cr(Dr),s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Tr&&Js!==null&&t.mode&1&&!(t.flags&128))$R(),Xu(),t.flags|=98560,i=!1;else if(i=Hg(t),s!==null&&s.dehydrated!==null){if(e===null){if(!i)throw Error(Oe(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(Oe(317));i[Si]=t}else Xu(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Yn(t),i=!1}else Xa!==null&&(R_(Xa),Xa=null),i=!0;if(!i)return t.flags&65536?t:null}return t.flags&128?(t.lanes=r,t):(s=s!==null,s!==(e!==null&&e.memoizedState!==null)&&s&&(t.child.flags|=8192,t.mode&1&&(e===null||Dr.current&1?xn===0&&(xn=3):aC())),t.updateQueue!==null&&(t.flags|=4),Yn(t),null);case 4:return Ju(),k_(e,t),e===null&&$m(t.stateNode.containerInfo),Yn(t),null;case 10:return BS(t.type._context),Yn(t),null;case 17:return Fs(t.type)&&dv(),Yn(t),null;case 19:if(Cr(Dr),i=t.memoizedState,i===null)return Yn(t),null;if(s=(t.flags&128)!==0,o=i.rendering,o===null)if(s)Sf(i,!1);else{if(xn!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=xv(e),o!==null){for(t.flags|=128,Sf(i,!1),s=o.updateQueue,s!==null&&(t.updateQueue=s,t.flags|=4),t.subtreeFlags=0,s=r,r=t.child;r!==null;)i=r,e=s,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,e=o.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return yr(Dr,Dr.current&1|2),t.child}e=e.sibling}i.tail!==null&&Zr()>th&&(t.flags|=128,s=!0,Sf(i,!1),t.lanes=4194304)}else{if(!s)if(e=xv(o),e!==null){if(t.flags|=128,s=!0,r=e.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),Sf(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!Tr)return Yn(t),null}else 2*Zr()-i.renderingStartTime>th&&r!==1073741824&&(t.flags|=128,s=!0,Sf(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(r=i.last,r!==null?r.sibling=o:t.child=o,i.last=o)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Zr(),t.sibling=null,r=Dr.current,yr(Dr,s?r&1|2:r&1),t):(Yn(t),null);case 22:case 23:return sC(),s=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==s&&(t.flags|=8192),s&&t.mode&1?Gs&1073741824&&(Yn(t),t.subtreeFlags&6&&(t.flags|=8192)):Yn(t),null;case 24:return null;case 25:return null}throw Error(Oe(156,t.tag))}function cV(e,t){switch(LS(t),t.tag){case 1:return Fs(t.type)&&dv(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ju(),Cr(Ls),Cr(as),KS(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return VS(t),null;case 13:if(Cr(Dr),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Oe(340));Xu()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Cr(Dr),null;case 4:return Ju(),null;case 10:return BS(t.type._context),null;case 22:case 23:return sC(),null;case 24:return null;default:return null}}var Gg=!1,Jn=!1,dV=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function gu(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(s){Kr(e,t,s)}else r.current=null}function P_(e,t,r){try{r()}catch(s){Kr(e,t,s)}}var JP=!1;function uV(e,t){if(u_=iv,e=_R(),$S(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var s=r.getSelection&&r.getSelection();if(s&&s.rangeCount!==0){r=s.anchorNode;var a=s.anchorOffset,i=s.focusNode;s=s.focusOffset;try{r.nodeType,i.nodeType}catch{r=null;break e}var o=0,l=-1,c=-1,d=0,u=0,h=e,f=null;t:for(;;){for(var m;h!==r||a!==0&&h.nodeType!==3||(l=o+a),h!==i||s!==0&&h.nodeType!==3||(c=o+s),h.nodeType===3&&(o+=h.nodeValue.length),(m=h.firstChild)!==null;)f=h,h=m;for(;;){if(h===e)break t;if(f===r&&++d===a&&(l=o),f===i&&++u===s&&(c=o),(m=h.nextSibling)!==null)break;h=f,f=h.parentNode}h=m}r=l===-1||c===-1?null:{start:l,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(h_={focusedElem:e,selectionRange:r},iv=!1,Qe=t;Qe!==null;)if(t=Qe,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Qe=e;else for(;Qe!==null;){t=Qe;try{var g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var p=g.memoizedProps,y=g.memoizedState,v=t.stateNode,j=v.getSnapshotBeforeUpdate(t.elementType===t.type?p:Wa(t.type,p),y);v.__reactInternalSnapshotBeforeUpdate=j}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Oe(163))}}catch(_){Kr(t,t.return,_)}if(e=t.sibling,e!==null){e.return=t.return,Qe=e;break}Qe=t.return}return g=JP,JP=!1,g}function mm(e,t,r){var s=t.updateQueue;if(s=s!==null?s.lastEffect:null,s!==null){var a=s=s.next;do{if((a.tag&e)===e){var i=a.destroy;a.destroy=void 0,i!==void 0&&P_(t,r,i)}a=a.next}while(a!==s)}}function h0(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var s=r.create;r.destroy=s()}r=r.next}while(r!==t)}}function T_(e){var t=e.ref;if(t!==null){var r=e.stateNode;switch(e.tag){case 5:e=r;break;default:e=r}typeof t=="function"?t(e):t.current=e}}function y$(e){var t=e.alternate;t!==null&&(e.alternate=null,y$(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Si],delete t[Lm],delete t[p_],delete t[KH],delete t[GH])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function j$(e){return e.tag===5||e.tag===3||e.tag===4}function eT(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||j$(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.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 A_(e,t,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?r.nodeType===8?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(r.nodeType===8?(t=r.parentNode,t.insertBefore(e,r)):(t=r,t.appendChild(e)),r=r._reactRootContainer,r!=null||t.onclick!==null||(t.onclick=cv));else if(s!==4&&(e=e.child,e!==null))for(A_(e,t,r),e=e.sibling;e!==null;)A_(e,t,r),e=e.sibling}function E_(e,t,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?r.insertBefore(e,t):r.appendChild(e);else if(s!==4&&(e=e.child,e!==null))for(E_(e,t,r),e=e.sibling;e!==null;)E_(e,t,r),e=e.sibling}var Dn=null,Ka=!1;function sl(e,t,r){for(r=r.child;r!==null;)b$(e,t,r),r=r.sibling}function b$(e,t,r){if(Ei&&typeof Ei.onCommitFiberUnmount=="function")try{Ei.onCommitFiberUnmount(s0,r)}catch{}switch(r.tag){case 5:Jn||gu(r,t);case 6:var s=Dn,a=Ka;Dn=null,sl(e,t,r),Dn=s,Ka=a,Dn!==null&&(Ka?(e=Dn,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):Dn.removeChild(r.stateNode));break;case 18:Dn!==null&&(Ka?(e=Dn,r=r.stateNode,e.nodeType===8?bb(e.parentNode,r):e.nodeType===1&&bb(e,r),Mm(e)):bb(Dn,r.stateNode));break;case 4:s=Dn,a=Ka,Dn=r.stateNode.containerInfo,Ka=!0,sl(e,t,r),Dn=s,Ka=a;break;case 0:case 11:case 14:case 15:if(!Jn&&(s=r.updateQueue,s!==null&&(s=s.lastEffect,s!==null))){a=s=s.next;do{var i=a,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&P_(r,t,o),a=a.next}while(a!==s)}sl(e,t,r);break;case 1:if(!Jn&&(gu(r,t),s=r.stateNode,typeof s.componentWillUnmount=="function"))try{s.props=r.memoizedProps,s.state=r.memoizedState,s.componentWillUnmount()}catch(l){Kr(r,t,l)}sl(e,t,r);break;case 21:sl(e,t,r);break;case 22:r.mode&1?(Jn=(s=Jn)||r.memoizedState!==null,sl(e,t,r),Jn=s):sl(e,t,r);break;default:sl(e,t,r)}}function tT(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new dV),t.forEach(function(s){var a=jV.bind(null,e,s);r.has(s)||(r.add(s),s.then(a,a))})}}function Fa(e,t){var r=t.deletions;if(r!==null)for(var s=0;s<r.length;s++){var a=r[s];try{var i=e,o=t,l=o;e:for(;l!==null;){switch(l.tag){case 5:Dn=l.stateNode,Ka=!1;break e;case 3:Dn=l.stateNode.containerInfo,Ka=!0;break e;case 4:Dn=l.stateNode.containerInfo,Ka=!0;break e}l=l.return}if(Dn===null)throw Error(Oe(160));b$(i,o,a),Dn=null,Ka=!1;var c=a.alternate;c!==null&&(c.return=null),a.return=null}catch(d){Kr(a,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)w$(t,e),t=t.sibling}function w$(e,t){var r=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Fa(t,e),pi(e),s&4){try{mm(3,e,e.return),h0(3,e)}catch(p){Kr(e,e.return,p)}try{mm(5,e,e.return)}catch(p){Kr(e,e.return,p)}}break;case 1:Fa(t,e),pi(e),s&512&&r!==null&&gu(r,r.return);break;case 5:if(Fa(t,e),pi(e),s&512&&r!==null&&gu(r,r.return),e.flags&32){var a=e.stateNode;try{Tm(a,"")}catch(p){Kr(e,e.return,p)}}if(s&4&&(a=e.stateNode,a!=null)){var i=e.memoizedProps,o=r!==null?r.memoizedProps:i,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&WD(a,i),t_(l,o);var d=t_(l,i);for(o=0;o<c.length;o+=2){var u=c[o],h=c[o+1];u==="style"?YD(a,h):u==="dangerouslySetInnerHTML"?KD(a,h):u==="children"?Tm(a,h):_S(a,u,h,d)}switch(l){case"input":Qw(a,i);break;case"textarea":HD(a,i);break;case"select":var f=a._wrapperState.wasMultiple;a._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?bu(a,!!i.multiple,m,!1):f!==!!i.multiple&&(i.defaultValue!=null?bu(a,!!i.multiple,i.defaultValue,!0):bu(a,!!i.multiple,i.multiple?[]:"",!1))}a[Lm]=i}catch(p){Kr(e,e.return,p)}}break;case 6:if(Fa(t,e),pi(e),s&4){if(e.stateNode===null)throw Error(Oe(162));a=e.stateNode,i=e.memoizedProps;try{a.nodeValue=i}catch(p){Kr(e,e.return,p)}}break;case 3:if(Fa(t,e),pi(e),s&4&&r!==null&&r.memoizedState.isDehydrated)try{Mm(t.containerInfo)}catch(p){Kr(e,e.return,p)}break;case 4:Fa(t,e),pi(e);break;case 13:Fa(t,e),pi(e),a=e.child,a.flags&8192&&(i=a.memoizedState!==null,a.stateNode.isHidden=i,!i||a.alternate!==null&&a.alternate.memoizedState!==null||(rC=Zr())),s&4&&tT(e);break;case 22:if(u=r!==null&&r.memoizedState!==null,e.mode&1?(Jn=(d=Jn)||u,Fa(t,e),Jn=d):Fa(t,e),pi(e),s&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(Qe=e,u=e.child;u!==null;){for(h=Qe=u;Qe!==null;){switch(f=Qe,m=f.child,f.tag){case 0:case 11:case 14:case 15:mm(4,f,f.return);break;case 1:gu(f,f.return);var g=f.stateNode;if(typeof g.componentWillUnmount=="function"){s=f,r=f.return;try{t=s,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(p){Kr(s,r,p)}}break;case 5:gu(f,f.return);break;case 22:if(f.memoizedState!==null){nT(h);continue}}m!==null?(m.return=f,Qe=m):nT(h)}u=u.sibling}e:for(u=null,h=e;;){if(h.tag===5){if(u===null){u=h;try{a=h.stateNode,d?(i=a.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=h.stateNode,c=h.memoizedProps.style,o=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=GD("display",o))}catch(p){Kr(e,e.return,p)}}}else if(h.tag===6){if(u===null)try{h.stateNode.nodeValue=d?"":h.memoizedProps}catch(p){Kr(e,e.return,p)}}else if((h.tag!==22&&h.tag!==23||h.memoizedState===null||h===e)&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;h.sibling===null;){if(h.return===null||h.return===e)break e;u===h&&(u=null),h=h.return}u===h&&(u=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:Fa(t,e),pi(e),s&4&&tT(e);break;case 21:break;default:Fa(t,e),pi(e)}}function pi(e){var t=e.flags;if(t&2){try{e:{for(var r=e.return;r!==null;){if(j$(r)){var s=r;break e}r=r.return}throw Error(Oe(160))}switch(s.tag){case 5:var a=s.stateNode;s.flags&32&&(Tm(a,""),s.flags&=-33);var i=eT(e);E_(e,i,a);break;case 3:case 4:var o=s.stateNode.containerInfo,l=eT(e);A_(e,l,o);break;default:throw Error(Oe(161))}}catch(c){Kr(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function hV(e,t,r){Qe=e,_$(e)}function _$(e,t,r){for(var s=(e.mode&1)!==0;Qe!==null;){var a=Qe,i=a.child;if(a.tag===22&&s){var o=a.memoizedState!==null||Gg;if(!o){var l=a.alternate,c=l!==null&&l.memoizedState!==null||Jn;l=Gg;var d=Jn;if(Gg=o,(Jn=c)&&!d)for(Qe=a;Qe!==null;)o=Qe,c=o.child,o.tag===22&&o.memoizedState!==null?sT(a):c!==null?(c.return=o,Qe=c):sT(a);for(;i!==null;)Qe=i,_$(i),i=i.sibling;Qe=a,Gg=l,Jn=d}rT(e)}else a.subtreeFlags&8772&&i!==null?(i.return=a,Qe=i):rT(e)}}function rT(e){for(;Qe!==null;){var t=Qe;if(t.flags&8772){var r=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Jn||h0(5,t);break;case 1:var s=t.stateNode;if(t.flags&4&&!Jn)if(r===null)s.componentDidMount();else{var a=t.elementType===t.type?r.memoizedProps:Wa(t.type,r.memoizedProps);s.componentDidUpdate(a,r.memoizedState,s.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&UP(t,i,s);break;case 3:var o=t.updateQueue;if(o!==null){if(r=null,t.child!==null)switch(t.child.tag){case 5:r=t.child.stateNode;break;case 1:r=t.child.stateNode}UP(t,o,r)}break;case 5:var l=t.stateNode;if(r===null&&t.flags&4){r=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var u=d.memoizedState;if(u!==null){var h=u.dehydrated;h!==null&&Mm(h)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Oe(163))}Jn||t.flags&512&&T_(t)}catch(f){Kr(t,t.return,f)}}if(t===e){Qe=null;break}if(r=t.sibling,r!==null){r.return=t.return,Qe=r;break}Qe=t.return}}function nT(e){for(;Qe!==null;){var t=Qe;if(t===e){Qe=null;break}var r=t.sibling;if(r!==null){r.return=t.return,Qe=r;break}Qe=t.return}}function sT(e){for(;Qe!==null;){var t=Qe;try{switch(t.tag){case 0:case 11:case 15:var r=t.return;try{h0(4,t)}catch(c){Kr(t,r,c)}break;case 1:var s=t.stateNode;if(typeof s.componentDidMount=="function"){var a=t.return;try{s.componentDidMount()}catch(c){Kr(t,a,c)}}var i=t.return;try{T_(t)}catch(c){Kr(t,i,c)}break;case 5:var o=t.return;try{T_(t)}catch(c){Kr(t,o,c)}}}catch(c){Kr(t,t.return,c)}if(t===e){Qe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,Qe=l;break}Qe=t.return}}var fV=Math.ceil,jv=Go.ReactCurrentDispatcher,eC=Go.ReactCurrentOwner,Sa=Go.ReactCurrentBatchConfig,Bt=0,Sn=null,on=null,$n=0,Gs=0,xu=ac(0),xn=0,Wm=null,dd=0,f0=0,tC=0,pm=null,Ms=null,rC=0,th=1/0,oo=null,bv=!1,O_=null,Bl=null,Yg=!1,Ml=null,wv=0,gm=0,M_=null,Wx=-1,Hx=0;function bs(){return Bt&6?Zr():Wx!==-1?Wx:Wx=Zr()}function ql(e){return e.mode&1?Bt&2&&$n!==0?$n&-$n:QH.transition!==null?(Hx===0&&(Hx=oR()),Hx):(e=or,e!==0||(e=window.event,e=e===void 0?16:mR(e.type)),e):1}function si(e,t,r,s){if(50<gm)throw gm=0,M_=null,Error(Oe(185));Qp(e,r,s),(!(Bt&2)||e!==Sn)&&(e===Sn&&(!(Bt&2)&&(f0|=r),xn===4&&yl(e,$n)),Us(e,s),r===1&&Bt===0&&!(t.mode&1)&&(th=Zr()+500,c0&&ic()))}function Us(e,t){var r=e.callbackNode;QW(e,t);var s=av(e,e===Sn?$n:0);if(s===0)r!==null&&fP(r),e.callbackNode=null,e.callbackPriority=0;else if(t=s&-s,e.callbackPriority!==t){if(r!=null&&fP(r),t===1)e.tag===0?YH(aT.bind(null,e)):MR(aT.bind(null,e)),HH(function(){!(Bt&6)&&ic()}),r=null;else{switch(lR(s)){case 1:r=PS;break;case 4:r=aR;break;case 16:r=sv;break;case 536870912:r=iR;break;default:r=sv}r=E$(r,N$.bind(null,e))}e.callbackPriority=t,e.callbackNode=r}}function N$(e,t){if(Wx=-1,Hx=0,Bt&6)throw Error(Oe(327));var r=e.callbackNode;if(Cu()&&e.callbackNode!==r)return null;var s=av(e,e===Sn?$n:0);if(s===0)return null;if(s&30||s&e.expiredLanes||t)t=_v(e,s);else{t=s;var a=Bt;Bt|=2;var i=C$();(Sn!==e||$n!==t)&&(oo=null,th=Zr()+500,rd(e,t));do try{gV();break}catch(l){S$(e,l)}while(!0);zS(),jv.current=i,Bt=a,on!==null?t=0:(Sn=null,$n=0,t=xn)}if(t!==0){if(t===2&&(a=i_(e),a!==0&&(s=a,t=D_(e,a))),t===1)throw r=Wm,rd(e,0),yl(e,s),Us(e,Zr()),r;if(t===6)yl(e,s);else{if(a=e.current.alternate,!(s&30)&&!mV(a)&&(t=_v(e,s),t===2&&(i=i_(e),i!==0&&(s=i,t=D_(e,i))),t===1))throw r=Wm,rd(e,0),yl(e,s),Us(e,Zr()),r;switch(e.finishedWork=a,e.finishedLanes=s,t){case 0:case 1:throw Error(Oe(345));case 2:Ec(e,Ms,oo);break;case 3:if(yl(e,s),(s&130023424)===s&&(t=rC+500-Zr(),10<t)){if(av(e,0)!==0)break;if(a=e.suspendedLanes,(a&s)!==s){bs(),e.pingedLanes|=e.suspendedLanes&a;break}e.timeoutHandle=m_(Ec.bind(null,e,Ms,oo),t);break}Ec(e,Ms,oo);break;case 4:if(yl(e,s),(s&4194240)===s)break;for(t=e.eventTimes,a=-1;0<s;){var o=31-ni(s);i=1<<o,o=t[o],o>a&&(a=o),s&=~i}if(s=a,s=Zr()-s,s=(120>s?120:480>s?480:1080>s?1080:1920>s?1920:3e3>s?3e3:4320>s?4320:1960*fV(s/1960))-s,10<s){e.timeoutHandle=m_(Ec.bind(null,e,Ms,oo),s);break}Ec(e,Ms,oo);break;case 5:Ec(e,Ms,oo);break;default:throw Error(Oe(329))}}}return Us(e,Zr()),e.callbackNode===r?N$.bind(null,e):null}function D_(e,t){var r=pm;return e.current.memoizedState.isDehydrated&&(rd(e,t).flags|=256),e=_v(e,t),e!==2&&(t=Ms,Ms=r,t!==null&&R_(t)),e}function R_(e){Ms===null?Ms=e:Ms.push.apply(Ms,e)}function mV(e){for(var t=e;;){if(t.flags&16384){var r=t.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var s=0;s<r.length;s++){var a=r[s],i=a.getSnapshot;a=a.value;try{if(!ai(i(),a))return!1}catch{return!1}}}if(r=t.child,t.subtreeFlags&16384&&r!==null)r.return=t,t=r;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function yl(e,t){for(t&=~tC,t&=~f0,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var r=31-ni(t),s=1<<r;e[r]=-1,t&=~s}}function aT(e){if(Bt&6)throw Error(Oe(327));Cu();var t=av(e,0);if(!(t&1))return Us(e,Zr()),null;var r=_v(e,t);if(e.tag!==0&&r===2){var s=i_(e);s!==0&&(t=s,r=D_(e,s))}if(r===1)throw r=Wm,rd(e,0),yl(e,t),Us(e,Zr()),r;if(r===6)throw Error(Oe(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ec(e,Ms,oo),Us(e,Zr()),null}function nC(e,t){var r=Bt;Bt|=1;try{return e(t)}finally{Bt=r,Bt===0&&(th=Zr()+500,c0&&ic())}}function ud(e){Ml!==null&&Ml.tag===0&&!(Bt&6)&&Cu();var t=Bt;Bt|=1;var r=Sa.transition,s=or;try{if(Sa.transition=null,or=1,e)return e()}finally{or=s,Sa.transition=r,Bt=t,!(Bt&6)&&ic()}}function sC(){Gs=xu.current,Cr(xu)}function rd(e,t){e.finishedWork=null,e.finishedLanes=0;var r=e.timeoutHandle;if(r!==-1&&(e.timeoutHandle=-1,WH(r)),on!==null)for(r=on.return;r!==null;){var s=r;switch(LS(s),s.tag){case 1:s=s.type.childContextTypes,s!=null&&dv();break;case 3:Ju(),Cr(Ls),Cr(as),KS();break;case 5:VS(s);break;case 4:Ju();break;case 13:Cr(Dr);break;case 19:Cr(Dr);break;case 10:BS(s.type._context);break;case 22:case 23:sC()}r=r.return}if(Sn=e,on=e=Wl(e.current,null),$n=Gs=t,xn=0,Wm=null,tC=f0=dd=0,Ms=pm=null,Uc!==null){for(t=0;t<Uc.length;t++)if(r=Uc[t],s=r.interleaved,s!==null){r.interleaved=null;var a=s.next,i=r.pending;if(i!==null){var o=i.next;i.next=a,s.next=o}r.pending=s}Uc=null}return e}function S$(e,t){do{var r=on;try{if(zS(),zx.current=yv,vv){for(var s=Ir.memoizedState;s!==null;){var a=s.queue;a!==null&&(a.pending=null),s=s.next}vv=!1}if(cd=0,Nn=pn=Ir=null,fm=!1,zm=0,eC.current=null,r===null||r.return===null){xn=1,Wm=t,on=null;break}e:{var i=e,o=r.return,l=r,c=t;if(t=$n,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=l,h=u.tag;if(!(u.mode&1)&&(h===0||h===11||h===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var m=VP(o);if(m!==null){m.flags&=-257,KP(m,o,l,i,t),m.mode&1&&HP(i,d,t),t=m,c=d;var g=t.updateQueue;if(g===null){var p=new Set;p.add(c),t.updateQueue=p}else g.add(c);break e}else{if(!(t&1)){HP(i,d,t),aC();break e}c=Error(Oe(426))}}else if(Tr&&l.mode&1){var y=VP(o);if(y!==null){!(y.flags&65536)&&(y.flags|=256),KP(y,o,l,i,t),FS(eh(c,l));break e}}i=c=eh(c,l),xn!==4&&(xn=2),pm===null?pm=[i]:pm.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var v=l$(i,c,t);FP(i,v);break e;case 1:l=c;var j=i.type,b=i.stateNode;if(!(i.flags&128)&&(typeof j.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(Bl===null||!Bl.has(b)))){i.flags|=65536,t&=-t,i.lanes|=t;var _=c$(i,l,t);FP(i,_);break e}}i=i.return}while(i!==null)}P$(r)}catch(w){t=w,on===r&&r!==null&&(on=r=r.return);continue}break}while(!0)}function C$(){var e=jv.current;return jv.current=yv,e===null?yv:e}function aC(){(xn===0||xn===3||xn===2)&&(xn=4),Sn===null||!(dd&268435455)&&!(f0&268435455)||yl(Sn,$n)}function _v(e,t){var r=Bt;Bt|=2;var s=C$();(Sn!==e||$n!==t)&&(oo=null,rd(e,t));do try{pV();break}catch(a){S$(e,a)}while(!0);if(zS(),Bt=r,jv.current=s,on!==null)throw Error(Oe(261));return Sn=null,$n=0,xn}function pV(){for(;on!==null;)k$(on)}function gV(){for(;on!==null&&!zW();)k$(on)}function k$(e){var t=A$(e.alternate,e,Gs);e.memoizedProps=e.pendingProps,t===null?P$(e):on=t,eC.current=null}function P$(e){var t=e;do{var r=t.alternate;if(e=t.return,t.flags&32768){if(r=cV(r,t),r!==null){r.flags&=32767,on=r;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{xn=6,on=null;return}}else if(r=lV(r,t,Gs),r!==null){on=r;return}if(t=t.sibling,t!==null){on=t;return}on=t=e}while(t!==null);xn===0&&(xn=5)}function Ec(e,t,r){var s=or,a=Sa.transition;try{Sa.transition=null,or=1,xV(e,t,r,s)}finally{Sa.transition=a,or=s}return null}function xV(e,t,r,s){do Cu();while(Ml!==null);if(Bt&6)throw Error(Oe(327));r=e.finishedWork;var a=e.finishedLanes;if(r===null)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(Oe(177));e.callbackNode=null,e.callbackPriority=0;var i=r.lanes|r.childLanes;if(XW(e,i),e===Sn&&(on=Sn=null,$n=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||Yg||(Yg=!0,E$(sv,function(){return Cu(),null})),i=(r.flags&15990)!==0,r.subtreeFlags&15990||i){i=Sa.transition,Sa.transition=null;var o=or;or=1;var l=Bt;Bt|=4,eC.current=null,uV(e,r),w$(r,e),IH(h_),iv=!!u_,h_=u_=null,e.current=r,hV(r),BW(),Bt=l,or=o,Sa.transition=i}else e.current=r;if(Yg&&(Yg=!1,Ml=e,wv=a),i=e.pendingLanes,i===0&&(Bl=null),HW(r.stateNode),Us(e,Zr()),t!==null)for(s=e.onRecoverableError,r=0;r<t.length;r++)a=t[r],s(a.value,{componentStack:a.stack,digest:a.digest});if(bv)throw bv=!1,e=O_,O_=null,e;return wv&1&&e.tag!==0&&Cu(),i=e.pendingLanes,i&1?e===M_?gm++:(gm=0,M_=e):gm=0,ic(),null}function Cu(){if(Ml!==null){var e=lR(wv),t=Sa.transition,r=or;try{if(Sa.transition=null,or=16>e?16:e,Ml===null)var s=!1;else{if(e=Ml,Ml=null,wv=0,Bt&6)throw Error(Oe(331));var a=Bt;for(Bt|=4,Qe=e.current;Qe!==null;){var i=Qe,o=i.child;if(Qe.flags&16){var l=i.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(Qe=d;Qe!==null;){var u=Qe;switch(u.tag){case 0:case 11:case 15:mm(8,u,i)}var h=u.child;if(h!==null)h.return=u,Qe=h;else for(;Qe!==null;){u=Qe;var f=u.sibling,m=u.return;if(y$(u),u===d){Qe=null;break}if(f!==null){f.return=m,Qe=f;break}Qe=m}}}var g=i.alternate;if(g!==null){var p=g.child;if(p!==null){g.child=null;do{var y=p.sibling;p.sibling=null,p=y}while(p!==null)}}Qe=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,Qe=o;else e:for(;Qe!==null;){if(i=Qe,i.flags&2048)switch(i.tag){case 0:case 11:case 15:mm(9,i,i.return)}var v=i.sibling;if(v!==null){v.return=i.return,Qe=v;break e}Qe=i.return}}var j=e.current;for(Qe=j;Qe!==null;){o=Qe;var b=o.child;if(o.subtreeFlags&2064&&b!==null)b.return=o,Qe=b;else e:for(o=j;Qe!==null;){if(l=Qe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:h0(9,l)}}catch(w){Kr(l,l.return,w)}if(l===o){Qe=null;break e}var _=l.sibling;if(_!==null){_.return=l.return,Qe=_;break e}Qe=l.return}}if(Bt=a,ic(),Ei&&typeof Ei.onPostCommitFiberRoot=="function")try{Ei.onPostCommitFiberRoot(s0,e)}catch{}s=!0}return s}finally{or=r,Sa.transition=t}}return!1}function iT(e,t,r){t=eh(r,t),t=l$(e,t,1),e=zl(e,t,1),t=bs(),e!==null&&(Qp(e,1,t),Us(e,t))}function Kr(e,t,r){if(e.tag===3)iT(e,e,r);else for(;t!==null;){if(t.tag===3){iT(t,e,r);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Bl===null||!Bl.has(s))){e=eh(r,e),e=c$(t,e,1),t=zl(t,e,1),e=bs(),t!==null&&(Qp(t,1,e),Us(t,e));break}}t=t.return}}function vV(e,t,r){var s=e.pingCache;s!==null&&s.delete(t),t=bs(),e.pingedLanes|=e.suspendedLanes&r,Sn===e&&($n&r)===r&&(xn===4||xn===3&&($n&130023424)===$n&&500>Zr()-rC?rd(e,0):tC|=r),Us(e,t)}function T$(e,t){t===0&&(e.mode&1?(t=Fg,Fg<<=1,!(Fg&130023424)&&(Fg=4194304)):t=1);var r=bs();e=Do(e,t),e!==null&&(Qp(e,t,r),Us(e,r))}function yV(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),T$(e,r)}function jV(e,t){var r=0;switch(e.tag){case 13:var s=e.stateNode,a=e.memoizedState;a!==null&&(r=a.retryLane);break;case 19:s=e.stateNode;break;default:throw Error(Oe(314))}s!==null&&s.delete(t),T$(e,r)}var A$;A$=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ls.current)$s=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return $s=!1,oV(e,t,r);$s=!!(e.flags&131072)}else $s=!1,Tr&&t.flags&1048576&&DR(t,fv,t.index);switch(t.lanes=0,t.tag){case 2:var s=t.type;qx(e,t),e=t.pendingProps;var a=Qu(t,as.current);Su(t,r),a=YS(null,t,s,e,a,r);var i=QS();return t.flags|=1,typeof a=="object"&&a!==null&&typeof a.render=="function"&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Fs(s)?(i=!0,uv(t)):i=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,WS(t),a.updater=u0,t.stateNode=a,a._reactInternals=t,b_(t,s,e,r),t=N_(null,t,s,!0,i,r)):(t.tag=0,Tr&&i&&IS(t),gs(null,t,a,r),t=t.child),t;case 16:s=t.elementType;e:{switch(qx(e,t),e=t.pendingProps,a=s._init,s=a(s._payload),t.type=s,a=t.tag=wV(s),e=Wa(s,e),a){case 0:t=__(null,t,s,e,r);break e;case 1:t=QP(null,t,s,e,r);break e;case 11:t=GP(null,t,s,e,r);break e;case 14:t=YP(null,t,s,Wa(s.type,e),r);break e}throw Error(Oe(306,s,""))}return t;case 0:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:Wa(s,a),__(e,t,s,a,r);case 1:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:Wa(s,a),QP(e,t,s,a,r);case 3:e:{if(f$(t),e===null)throw Error(Oe(387));s=t.pendingProps,i=t.memoizedState,a=i.element,UR(e,t),gv(t,s,null,r);var o=t.memoizedState;if(s=o.element,i.isDehydrated)if(i={element:s,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){a=eh(Error(Oe(423)),t),t=XP(e,t,s,r,a);break e}else if(s!==a){a=eh(Error(Oe(424)),t),t=XP(e,t,s,r,a);break e}else for(Js=Ul(t.stateNode.containerInfo.firstChild),ea=t,Tr=!0,Xa=null,r=LR(t,null,s,r),t.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(Xu(),s===a){t=Ro(e,t,r);break e}gs(e,t,s,r)}t=t.child}return t;case 5:return zR(t),e===null&&v_(t),s=t.type,a=t.pendingProps,i=e!==null?e.memoizedProps:null,o=a.children,f_(s,a)?o=null:i!==null&&f_(s,i)&&(t.flags|=32),h$(e,t),gs(e,t,o,r),t.child;case 6:return e===null&&v_(t),null;case 13:return m$(e,t,r);case 4:return HS(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=Zu(t,null,s,r):gs(e,t,s,r),t.child;case 11:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:Wa(s,a),GP(e,t,s,a,r);case 7:return gs(e,t,t.pendingProps,r),t.child;case 8:return gs(e,t,t.pendingProps.children,r),t.child;case 12:return gs(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(s=t.type._context,a=t.pendingProps,i=t.memoizedProps,o=a.value,yr(mv,s._currentValue),s._currentValue=o,i!==null)if(ai(i.value,o)){if(i.children===a.children&&!Ls.current){t=Ro(e,t,r);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){o=i.child;for(var c=l.firstContext;c!==null;){if(c.context===s){if(i.tag===1){c=No(-1,r&-r),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}i.lanes|=r,c=i.alternate,c!==null&&(c.lanes|=r),y_(i.return,r,t),l.lanes|=r;break}c=c.next}}else if(i.tag===10)o=i.type===t.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(Oe(341));o.lanes|=r,l=o.alternate,l!==null&&(l.lanes|=r),y_(o,r,t),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===t){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}gs(e,t,a.children,r),t=t.child}return t;case 9:return a=t.type,s=t.pendingProps.children,Su(t,r),a=Ta(a),s=s(a),t.flags|=1,gs(e,t,s,r),t.child;case 14:return s=t.type,a=Wa(s,t.pendingProps),a=Wa(s.type,a),YP(e,t,s,a,r);case 15:return d$(e,t,t.type,t.pendingProps,r);case 17:return s=t.type,a=t.pendingProps,a=t.elementType===s?a:Wa(s,a),qx(e,t),t.tag=1,Fs(s)?(e=!0,uv(t)):e=!1,Su(t,r),o$(t,s,a),b_(t,s,a,r),N_(null,t,s,!0,e,r);case 19:return p$(e,t,r);case 22:return u$(e,t,r)}throw Error(Oe(156,t.tag))};function E$(e,t){return sR(e,t)}function bV(e,t,r,s){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ba(e,t,r,s){return new bV(e,t,r,s)}function iC(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wV(e){if(typeof e=="function")return iC(e)?1:0;if(e!=null){if(e=e.$$typeof,e===SS)return 11;if(e===CS)return 14}return 2}function Wl(e,t){var r=e.alternate;return r===null?(r=ba(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.depen
vendor: 4,358 bytes, line 40
40dencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Vx(e,t,r,s,a,i){var o=2;if(s=e,typeof e=="function")iC(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case ou:return nd(r.children,a,i,t);case NS:o=8,a|=8;break;case Hw:return e=ba(12,r,t,a|2),e.elementType=Hw,e.lanes=i,e;case Vw:return e=ba(13,r,t,a),e.elementType=Vw,e.lanes=i,e;case Kw:return e=ba(19,r,t,a),e.elementType=Kw,e.lanes=i,e;case zD:return m0(r,a,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case FD:o=10;break e;case UD:o=9;break e;case SS:o=11;break e;case CS:o=14;break e;case ml:o=16,s=null;break e}throw Error(Oe(130,e==null?e:typeof e,""))}return t=ba(o,r,t,a),t.elementType=e,t.type=s,t.lanes=i,t}function nd(e,t,r,s){return e=ba(7,e,s,t),e.lanes=r,e}function m0(e,t,r,s){return e=ba(22,e,s,t),e.elementType=zD,e.lanes=r,e.stateNode={isHidden:!1},e}function Tb(e,t,r){return e=ba(6,e,null,t),e.lanes=r,e}function Ab(e,t,r){return t=ba(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function _V(e,t,r,s,a){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=db(0),this.expirationTimes=db(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=db(0),this.identifierPrefix=s,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function oC(e,t,r,s,a,i,o,l,c){return e=new _V(e,t,r,l,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ba(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:s,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},WS(i),e}function NV(e,t,r){var s=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:iu,key:s==null?null:""+s,children:e,containerInfo:t,implementation:r}}function O$(e){if(!e)return Zl;e=e._reactInternals;e:{if(Td(e)!==e||e.tag!==1)throw Error(Oe(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Fs(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Oe(171))}if(e.tag===1){var r=e.type;if(Fs(r))return OR(e,r,t)}return t}function M$(e,t,r,s,a,i,o,l,c){return e=oC(r,s,!0,e,a,i,o,l,c),e.context=O$(null),r=e.current,s=bs(),a=ql(r),i=No(s,a),i.callback=t??null,zl(r,i,a),e.current.lanes=a,Qp(e,a,s),Us(e,s),e}function p0(e,t,r,s){var a=t.current,i=bs(),o=ql(a);return r=O$(r),t.context===null?t.context=r:t.pendingContext=r,t=No(i,o),t.payload={element:e},s=s===void 0?null:s,s!==null&&(t.callback=s),e=zl(a,t,o),e!==null&&(si(e,a,o,i),Ux(e,a,o)),o}function Nv(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function oT(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<t?r:t}}function lC(e,t){oT(e,t),(e=e.alternate)&&oT(e,t)}function SV(){return null}var D$=typeof reportError=="function"?reportError:function(e){console.error(e)};function cC(e){this._internalRoot=e}g0.prototype.render=cC.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Oe(409));p0(e,t,null,null)};g0.prototype.unmount=cC.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ud(function(){p0(null,e,null,null)}),t[Mo]=null}};function g0(e){this._internalRoot=e}g0.prototype.unstable_scheduleHydration=function(e){if(e){var t=uR();e={blockedOn:null,target:e,priority:t};for(var r=0;r<vl.length&&t!==0&&t<vl[r].priority;r++);vl.splice(r,0,e),r===0&&fR(e)}};function dC(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function x0(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function lT(){}function CV(e,t,r,s,a){if(a){if(typeof s=="function"){var i=s;s=function(){var d=Nv(o);i.call(d)}}var o=M$(t,s,e,0,null,!1,!1,"",lT);return e._reactRootContainer=o,e[Mo]=o.current,$m(e.nodeType===8?e.parentNode:e),ud(),o}for(;
vendor: 5,160 bytes, line 40
40a=e.lastChild;)e.removeChild(a);if(typeof s=="function"){var l=s;s=function(){var d=Nv(c);l.call(d)}}var c=oC(e,0,!1,null,null,!1,!1,"",lT);return e._reactRootContainer=c,e[Mo]=c.current,$m(e.nodeType===8?e.parentNode:e),ud(function(){p0(t,c,r,s)}),c}function v0(e,t,r,s,a){var i=r._reactRootContainer;if(i){var o=i;if(typeof a=="function"){var l=a;a=function(){var c=Nv(o);l.call(c)}}p0(t,o,e,a)}else o=CV(r,t,e,a,s);return Nv(o)}cR=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var r=Qf(t.pendingLanes);r!==0&&(TS(t,r|1),Us(t,Zr()),!(Bt&6)&&(th=Zr()+500,ic()))}break;case 13:ud(function(){var s=Do(e,1);if(s!==null){var a=bs();si(s,e,1,a)}}),lC(e,1)}};AS=function(e){if(e.tag===13){var t=Do(e,134217728);if(t!==null){var r=bs();si(t,e,134217728,r)}lC(e,134217728)}};dR=function(e){if(e.tag===13){var t=ql(e),r=Do(e,t);if(r!==null){var s=bs();si(r,e,t,s)}lC(e,t)}};uR=function(){return or};hR=function(e,t){var r=or;try{return or=e,t()}finally{or=r}};n_=function(e,t,r){switch(t){case"input":if(Qw(e,r),t=r.name,r.type==="radio"&&t!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var s=r[t];if(s!==e&&s.form===e.form){var a=l0(s);if(!a)throw Error(Oe(90));qD(s),Qw(s,a)}}}break;case"textarea":HD(e,r);break;case"select":t=r.value,t!=null&&bu(e,!!r.multiple,t,!1)}};ZD=nC;JD=ud;var kV={usingClientEntryPoint:!1,Events:[Zp,uu,l0,QD,XD,nC]},Cf={findFiberByHostInstance:Fc,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},PV={bundleType:Cf.bundleType,version:Cf.version,rendererPackageName:Cf.rendererPackageName,rendererConfig:Cf.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Go.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=rR(e),e===null?null:e.stateNode},findFiberByHostInstance:Cf.findFiberByHostInstance||SV,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Qg=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Qg.isDisabled&&Qg.supportsFiber)try{s0=Qg.inject(PV),Ei=Qg}catch{}}ca.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kV;ca.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!dC(t))throw Error(Oe(200));return NV(e,t,null,r)};ca.createRoot=function(e,t){if(!dC(e))throw Error(Oe(299));var r=!1,s="",a=D$;return t!=null&&(t.unstable_strictMode===!0&&(r=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onRecoverableError!==void 0&&(a=t.onRecoverableError)),t=oC(e,1,!1,null,null,r,!1,s,a),e[Mo]=t.current,$m(e.nodeType===8?e.parentNode:e),new cC(t)};ca.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(Oe(188)):(e=Object.keys(e).join(","),Error(Oe(268,e)));return e=rR(t),e=e===null?null:e.stateNode,e};ca.flushSync=function(e){return ud(e)};ca.hydrate=function(e,t,r){if(!x0(t))throw Error(Oe(200));return v0(null,e,t,!0,r)};ca.hydrateRoot=function(e,t,r){if(!dC(e))throw Error(Oe(405));var s=r!=null&&r.hydratedSources||null,a=!1,i="",o=D$;if(r!=null&&(r.unstable_strictMode===!0&&(a=!0),r.identifierPrefix!==void 0&&(i=r.identifierPrefix),r.onRecoverableError!==void 0&&(o=r.onRecoverableError)),t=M$(t,null,e,1,r??null,a,!1,i,o),e[Mo]=t.current,$m(e),s)for(e=0;e<s.length;e++)r=s[e],a=r._getVersion,a=a(r._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[r,a]:t.mutableSourceEagerHydrationData.push(r,a);return new g0(t)};ca.render=function(e,t,r){if(!x0(t))throw Error(Oe(200));return v0(null,e,t,!1,r)};ca.unmountComponentAtNode=function(e){if(!x0(e))throw Error(Oe(40));return e._reactRootContainer?(ud(function(){v0(null,null,e,!1,function(){e._reactRootContainer=null,e[Mo]=null})}),!0):!1};ca.unstable_batchedUpdates=nC;ca.unstable_renderSubtreeIntoContainer=function(e,t,r,s){if(!x0(r))throw Error(Oe(200));if(e==null||e._reactInternals===void 0)throw Error(Oe(38));return v0(e,t,r,!1,s)};ca.version="18.3.1-next-f1338f8080-20240426";function R$(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(R$)}catch(e){console.error(e)}}R$(),RD.exports=ca;var Ad=RD.exports;const $$=fr(Ad);var I$,cT=Ad;I$=cT.createRoot,cT.hydrateRoot;const TV=1,AV=1e6;let Eb=0;function EV(){return Eb=(Eb+1)%Number.MAX_SAFE_INTEGER,Eb.toString()}const Ob=new Map,dT=e=>{if(Ob.has(e))return;const t=setTimeout(()=>{Ob.delete(e),xm({type:"REMOVE_TOAST",toastId:e})},AV);Ob.set(e,t)},OV=(e,t)=>{switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,TV)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(r=>r.id===t.toast.id?{...r,...t.toast}:r)};case"DISMISS_TOAST":{const{toastId:r}=t;
vendor: 13,982 bytes, line 40
40return r?dT(r):e.toasts.forEach(s=>{dT(s.id)}),{...e,toasts:e.toasts.map(s=>s.id===r||r===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(r=>r.id!==t.toastId)}}},Kx=[];let Gx={toasts:[]};function xm(e){Gx=OV(Gx,e),Kx.forEach(t=>{t(Gx)})}function L$({...e}){const t=EV(),r=a=>xm({type:"UPDATE_TOAST",toast:{...a,id:t}}),s=()=>xm({type:"DISMISS_TOAST",toastId:t});return xm({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:a=>{a||s()}}}),{id:t,dismiss:s,update:r}}function qr(){const[e,t]=x.useState(Gx);return x.useEffect(()=>(Kx.push(t),()=>{const r=Kx.indexOf(t);r>-1&&Kx.splice(r,1)}),[e]),{...e,toast:L$,dismiss:r=>xm({type:"DISMISS_TOAST",toastId:r})}}function Te(e,t,{checkForDefaultPrevented:r=!0}={}){return function(a){if(e==null||e(a),r===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}function uT(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function y0(...e){return t=>{let r=!1;const s=e.map(a=>{const i=uT(a,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let a=0;a<s.length;a++){const i=s[a];typeof i=="function"?i():uT(e[a],null)}}}}function nt(...e){return x.useCallback(y0(...e),e)}function MV(e,t){const r=x.createContext(t),s=i=>{const{children:o,...l}=i,c=x.useMemo(()=>l,Object.values(l));return n.jsx(r.Provider,{value:c,children:o})};s.displayName=e+"Provider";function a(i){const o=x.useContext(r);if(o)return o;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[s,a]}function Qr(e,t=[]){let r=[];function s(i,o){const l=x.createContext(o),c=r.length;r=[...r,o];const d=h=>{var v;const{scope:f,children:m,...g}=h,p=((v=f==null?void 0:f[e])==null?void 0:v[c])||l,y=x.useMemo(()=>g,Object.values(g));return n.jsx(p.Provider,{value:y,children:m})};d.displayName=i+"Provider";function u(h,f){var p;const m=((p=f==null?void 0:f[e])==null?void 0:p[c])||l,g=x.useContext(m);if(g)return g;if(o!==void 0)return o;throw new Error(`\`${h}\` must be used within \`${i}\``)}return[d,u]}const a=()=>{const i=r.map(o=>x.createContext(o));return function(l){const c=(l==null?void 0:l[e])||i;return x.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return a.scopeName=e,[s,DV(a,...t)]}function DV(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const s=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=s.reduce((l,{useScope:c,scopeName:d})=>{const h=c(i)[`__scope${d}`];return{...l,...h}},{});return x.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return r.scopeName=t.scopeName,r}function Jl(e){const t=RV(e),r=x.forwardRef((s,a)=>{const{children:i,...o}=s,l=x.Children.toArray(i),c=l.find($V);if(c){const d=c.props.children,u=l.map(h=>h===c?x.Children.count(d)>1?x.Children.only(null):x.isValidElement(d)?d.props.children:null:h);return n.jsx(t,{...o,ref:a,children:x.isValidElement(d)?x.cloneElement(d,void 0,u):null})}return n.jsx(t,{...o,ref:a,children:i})});return r.displayName=`${e}.Slot`,r}var oc=Jl("Slot");function RV(e){const t=x.forwardRef((r,s)=>{const{children:a,...i}=r;if(x.isValidElement(a)){const o=LV(a),l=IV(i,a.props);return a.type!==x.Fragment&&(l.ref=s?y0(s,o):o),x.cloneElement(a,l)}return x.Children.count(a)>1?x.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var F$=Symbol("radix.slottable");function U$(e){const t=({children:r})=>n.jsx(n.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=F$,t}function $V(e){return x.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===F$}function IV(e,t){const r={...t};for(const s in t){const a=e[s],i=t[s];/^on[A-Z]/.test(s)?a&&i?r[s]=(...l)=>{const c=i(...l);return a(...l),c}:a&&(r[s]=a):s==="style"?r[s]={...a,...i}:s==="className"&&(r[s]=[a,i].filter(Boolean).join(" "))}return{...e,...r}}function LV(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function eg(e){const t=e+"CollectionProvider",[r,s]=Qr(t),[a,i]=r(t,{collectionRef:{current:null},itemMap:new Map}),o=p=>{const{scope:y,children:v}=p,j=G.useRef(null),b=G.useRef(new Map).current;return n.jsx(a,{scope:y,itemMap:b,collectionRef:j,children:v})};o.displayName=t;const l=e+"CollectionSlot",c=Jl(l),d=G.forwardRef((p,y)=>{const{scope:v,children:j}=p,b=i(l,v),_=nt(y,b.collectionRef);return n.jsx(c,{ref:_,children:j})});d.displayName=l;const u=e+"CollectionItemSlot",h="data-radix-collection-item",f=Jl(u),m=G.forwardRef((p,y)=>{const{scope:v,children:j,...b}=p,_=G.useRef(null),w=nt(y,_),N=i(u,v);return G.useEffect(()=>(N.itemMap.set(_,{ref:_,...b}),()=>void N.itemMap.delete(_))),n.jsx(f,{[h]:"",ref:w,children:j})});m.displayName=u;function g(p){const y=i(e+"CollectionConsumer",p);return G.useCallback(()=>{const j=y.collectionRef.current;if(!j)return[];const b=Array.from(j.querySelectorAll(`[${h}]`));return Array.from(y.itemMap.values()).sort((N,S)=>b.indexOf(N.ref.current)-b.indexOf(S.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:d,ItemSlot:m},g,s]}var FV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],We=FV.reduce((e,t)=>{const r=Jl(`Primitive.${t}`),s=x.forwardRef((a,i)=>{const{asChild:o,...l}=a,c=o?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(c,{...l,ref:i})});return s.displayName=`Primitive.${t}`,{...e,[t]:s}},{});function j0(e,t){e&&Ad.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=x.useRef(e);return x.useEffect(()=>{t.current=e}),x.useMemo(()=>(...r)=>{var s;return(s=t.current)==null?void 0:s.call(t,...r)},[])}function z$(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e);x.useEffect(()=>{const s=a=>{a.key==="Escape"&&r(a)};return t.addEventListener("keydown",s,{capture:!0}),()=>t.removeEventListener("keydown",s,{capture:!0})},[r,t])}var UV="DismissableLayer",$_="dismissableLayer.update",zV="dismissableLayer.pointerDownOutside",BV="dismissableLayer.focusOutside",hT,B$=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Fh=x.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=x.useContext(B$),[u,h]=x.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=x.useState({}),g=nt(t,S=>h(S)),p=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=p.indexOf(y),j=u?p.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,_=j>=v,w=WV(S=>{const C=S.target,P=[...d.branches].some(M=>M.contains(C));!_||P||(a==null||a(S),o==null||o(S),S.defaultPrevented||l==null||l())},f),N=HV(S=>{const C=S.target;[...d.branches].some(M=>M.contains(C))||(i==null||i(S),o==null||o(S),S.defaultPrevented||l==null||l())},f);return z$(S=>{j===d.layers.size-1&&(s==null||s(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},f),x.useEffect(()=>{if(u)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(hT=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),fT(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=hT)}},[u,f,r,d]),x.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),fT())},[u,d]),x.useEffect(()=>{const S=()=>m({});return document.addEventListener($_,S),()=>document.removeEventListener($_,S)},[]),n.jsx(We.div,{...c,ref:g,style:{pointerEvents:b?_?"auto":"none":void 0,...e.style},onFocusCapture:Te(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Te(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Te(e.onPointerDownCapture,w.onPointerDownCapture)})});Fh.displayName=UV;var qV="DismissableLayerBranch",q$=x.forwardRef((e,t)=>{const r=x.useContext(B$),s=x.useRef(null),a=nt(t,s);return x.useEffect(()=>{const i=s.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),n.jsx(We.div,{...e,ref:a})});q$.displayName=qV;function WV(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e),s=x.useRef(!1),a=x.useRef(()=>{});return x.useEffect(()=>{const i=l=>{if(l.target&&!s.current){let c=function(){W$(zV,r,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=c,t.addEventListener("click",a.current,{once:!0})):c()}else t.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}function HV(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e),s=x.useRef(!1);return x.useEffect(()=>{const a=i=>{i.target&&!s.current&&W$(BV,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function fT(){const e=new CustomEvent($_);document.dispatchEvent(e)}function W$(e,t,r,{discrete:s}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),s?j0(a,i):a.dispatchEvent(i)}var VV=Fh,KV=q$,Ur=globalThis!=null&&globalThis.document?x.useLayoutEffect:()=>{},GV="Portal",Uh=x.forwardRef((e,t)=>{var l;const{container:r,...s}=e,[a,i]=x.useState(!1);Ur(()=>i(!0),[]);const o=r||a&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return o?$$.createPortal(n.jsx(We.div,{...s,ref:t}),o):null});Uh.displayName=GV;function YV(e,t){return x.useReducer((r,s)=>t[r][s]??r,e)}var jn=e=>{const{present:t,children:r}=e,s=QV(t),a=typeof r=="function"?r({present:s.isPresent}):x.Children.only(r),i=nt(s.ref,XV(a));return typeof r=="function"||s.isPresent?x.cloneElement(a,{ref:i}):null};jn.displayName="Presence";function QV(e){const[t,r]=x.useState(),s=x.useRef(null),a=x.useRef(e),i=x.useRef("none"),o=e?"mounted":"unmounted",[l,c]=YV(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const d=Xg(s.current);i.current=l==="mounted"?d:"none"},[l]),Ur(()=>{const d=s.current,u=a.current;if(u!==e){const f=i.current,m=Xg(d);e?c("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&f!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Ur(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,h=m=>{const p=Xg(s.current).includes(m.animationName);if(m.target===t&&p&&(c("ANIMATION_END"),!a.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},f=m=>{m.target===t&&(i.current=Xg(s.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:x.useCallback(d=>{s.current=d?getComputedStyle(d):null,r(d)},[])}}function Xg(e){return(e==null?void 0:e.animationName)||"none"}function XV(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var ZV=jS[" useInsertionEffect ".trim().toString()]||Ur;function Bs({prop:e,defaultProp:t,onChange:r=()=>{},caller:s}){const[a,i,o]=JV({defaultProp:t,onChange:r}),l=e!==void 0,c=l?e:a;{const u=x.useRef(e!==void 0);x.useEffect(()=>{const h=u.current;h!==l&&console.warn(`${s} is changing from ${h?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=l},[l,s])}const d=x.useCallback(u=>{var h;if(l){const f=e7(u)?u(e):u;f!==e&&((h=o.current)==null||h.call(o,f))}else i(u)},[l,e,i,o]);return[c,d]}function JV({defaultProp:e,onChange:t}){const[r,s]=x.useState(e),a=x.useRef(r),i=x.useRef(t);return ZV(()=>{i.current=t},[t]),x.useEffect(()=>{var o;a.current!==r&&((o=i.current)==null||o.call(i,r),a.current=r)},[r,a]),[r,s,i]}function e7(e){return typeof e=="function"}var H$=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),t7="VisuallyHidden",b0=x.forwardRef((e,t)=>n.jsx(We.span,{...e,ref:t,style:{...H$,...e.style}}));b0.displayName=t7;var r7=b0,uC="ToastProvider",[hC,n7,s7]=eg("Toast"),[V$,HDe]=Qr("Toast",[s7]),[a7,w0]=V$(uC),K$=e=>{const{__scopeToast:t,label:r="Notification",duration:s=5e3,swipeDirection:a="right",swipeThreshold:i=50,children:o}=e,[l,c]=x.useState(null),[d,u]=x.useState(0),h=x.useRef(!1),f=x.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${uC}\`. Expected non-empty \`string\`.`),n.jsx(hC.Provider,{scope:t,children:n.jsx(a7,{scope:t,label:r,duration:s,swipeDirection:a,swipeThreshold:i,toastCount:d,viewport:l,onViewportChange:c,onToastAdd:x.useCallback(()=>u(m=>m+1),[]),onToastRemove:x.useCallback(()=>u(m=>m-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:f,children:o})})};K$.displayName=uC;var G$="ToastViewport",i7=["F8"],I_="toast.viewportPause",L_="toast.viewportResume",Y$=x.forwardRef((e,t)=>
40{const{__scopeToast:r,hotkey:s=i7,label:a="Notifications ({hotkey})",...i}=e,o=w0(G$,r),l=n7(r),c=x.useRef(null),d=x.useRef(null),u=x.useRef(null),h=x.useRef(null),f=nt(t,h,o.onViewportChange),m=s.join("+").replace(/Key/g,"").replace(/Digit/g,""),g=o.toastCount>0;x.useEffect(()=>{const y=v=>{var b;s.length!==0&&s.every(_=>v[_]||v.code===_)&&((b=h.current)==null||b.focus())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[s]),x.useEffect(()=>{const y=c.current,v=h.current;if(g&&y&&v){const j=()=>{if(!o.isClosePausedRef.current){const N=new CustomEvent(I_);v.dispatchEvent(N),o.isClosePausedRef.current=!0}},b=()=>{if(o.isClosePausedRef.current){const N=new CustomEvent(L_);v.dispatchEvent(N),o.isClosePausedRef.current=!1}},_=N=>{!y.contains(N.relatedTarget)&&b()},w=()=>{y.contains(document.activeElement)||b()};return y.addEventListener("focusin",j),y.addEventListener("focusout",_),y.addEventListener("pointermove",j),y.addEventListener("pointerleave",w),window.addEventListener("blur",j),window.addEventListener("focus",b),()=>{y.removeEventListener("focusin",j),y.removeEventListener("focusout",_),y.removeEventListener("pointermove",j),y.removeEventListener("pointerleave",w),window.removeEventListener("blur",j),window.removeEventListener("focus",b)}}},[g,o.isClosePausedRef]);const p=x.useCallback(({tabbingDirection:y})=>{const j=l().map(b=>{const _=b.ref.current,w=[_,...y7(_)];return y==="forwards"?w:w.reverse()});return(y==="forwards"?j.reverse():j).flat()},[l]);return x.useEffect(()=>{const y=h.current;if(y){const v=j=>{var w,N,S;const b=j.altKey||j.ctrlKey||j.metaKey;if(j.key==="Tab"&&!b){const C=document.activeElement,P=j.shiftKey;if(j.target===y&&P){(w=d.current)==null||w.focus();return}const A=p({tabbingDirection:P?"backwards":"forwards"}),U=A.findIndex(F=>F===C);Mb(A.slice(U+1))?j.preventDefault():P?(N=d.current)==null||N.focus():(S=u.current)==null||S.focus()}};return y.addEventListener("keydown",v),()=>y.removeEventListener("keydown",v)}},[l,p]),n.jsxs(KV,{ref:c,role:"region","aria-label":a.replace("{hotkey}",m),tabIndex:-1,style:{pointerEvents:g?void 0:"none"},children:[g&&n.jsx(F_,{ref:d,onFocusFromOutsideViewport:()=>{const y=p({tabbingDirection:"forwards"});Mb(y)}}),n.jsx(hC.Slot,{scope:r,children:n.jsx(We.ol,{tabIndex:-1,...i,ref:f})}),g&&n.jsx(F_,{ref:u,onFocusFromOutsideViewport:()=>{const y=p({tabbingDirection:"backwards"});Mb(y)}})]})});Y$.displayName=G$;var Q$="ToastFocusProxy",F_=x.forwardRef((e,t)=>{const{__scopeToast:r,onFocusFromOutsideViewport:s,...a}=e,i=w0(Q$,r);return n.jsx(b0,{"aria-hidden":!0,tabIndex:0,...a,ref:t,style:{position:"fixed"},onFocus:o=>{var d;const l=o.relatedTarget;!((d=i.viewport)!=null&&d.contains(l))&&s()}})});F_.displayName=Q$;var tg="Toast",o7="toast.swipeStart",l7="toast.swipeMove",c7="toast.swipeCancel",d7="toast.swipeEnd",X$=x.forwardRef((e,t)=>{const{forceMount:r,open:s,defaultOpen:a,onOpenChange:i,...o}=e,[l,c]=Bs({prop:s,defaultProp:a??!0,onChange:i,caller:tg});return n.jsx(jn,{present:r||l,children:n.jsx(f7,{open:l,...o,ref:t,onClose:()=>c(!1),onPause:Sr(e.onPause),onResume:Sr(e.onResume),onSwipeStart:Te(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Te(e.onSwipeMove,d=>{const{x:u,y:h}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${h}px`)}),onSwipeCancel:Te(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Te(e.onSwipeEnd,d=>{const{x:u,y:h}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${h}px`),c(!1)})})})});X$.displayName=tg;var[u7,h7]=V$(tg,{onClose(){}}),f7=x.forwardRef((e,t)=>
40{const{__scopeToast:r,type:s="foreground",duration:a,open:i,onClose:o,onEscapeKeyDown:l,onPause:c,onResume:d,onSwipeStart:u,onSwipeMove:h,onSwipeCancel:f,onSwipeEnd:m,...g}=e,p=w0(tg,r),[y,v]=x.useState(null),j=nt(t,F=>v(F)),b=x.useRef(null),_=x.useRef(null),w=a||p.duration,N=x.useRef(0),S=x.useRef(w),C=x.useRef(0),{onToastAdd:P,onToastRemove:M}=p,D=Sr(()=>{var L;(y==null?void 0:y.contains(document.activeElement))&&((L=p.viewport)==null||L.focus()),o()}),A=x.useCallback(F=>{!F||F===1/0||(window.clearTimeout(C.current),N.current=new Date().getTime(),C.current=window.setTimeout(D,F))},[D]);x.useEffect(()=>{const F=p.viewport;if(F){const L=()=>{A(S.current),d==null||d()},$=()=>{const R=new Date().getTime()-N.current;S.current=S.current-R,window.clearTimeout(C.current),c==null||c()};return F.addEventListener(I_,$),F.addEventListener(L_,L),()=>{F.removeEventListener(I_,$),F.removeEventListener(L_,L)}}},[p.viewport,w,c,d,A]),x.useEffect(()=>{i&&!p.isClosePausedRef.current&&A(w)},[i,w,p.isClosePausedRef,A]),x.useEffect(()=>(P(),()=>M()),[P,M]);const U=x.useMemo(()=>y?sI(y):null,[y]);return p.viewport?n.jsxs(n.Fragment,{children:[U&&n.jsx(m7,{__scopeToast:r,role:"status","aria-live":s==="foreground"?"assertive":"polite","aria-atomic":!0,children:U}),n.jsx(u7,{scope:r,onClose:D,children:Ad.createPortal(n.jsx(hC.ItemSlot,{scope:r,children:n.jsx(VV,{asChild:!0,onEscapeKeyDown:Te(l,()=>{p.isFocusedToastEscapeKeyDownRef.current||D(),p.isFocusedToastEscapeKeyDownRef.current=!1}),children:n.jsx(We.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":i?"open":"closed","data-swipe-direction":p.swipeDirection,...g,ref:j,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Te(e.onKeyDown,F=>{F.key==="Escape"&&(l==null||l(F.nativeEvent),F.nativeEvent.defaultPrevented||(p.isFocusedToastEscapeKeyDownRef.current=!0,D()))}),onPointerDown:Te(e.onPointerDown,F=>{F.button===0&&(b.current={x:F.clientX,y:F.clientY})}),onPointerMove:Te(e.onPointerMove,F=>{if(!b.current)return;const L=F.clientX-b.current.x,$=F.clientY-b.current.y,R=!!_.current,T=["left","right"].includes(p.swipeDirection),k=["left","up"].includes(p.swipeDirection)?Math.min:Math.max,W=T?k(0,L):0,q=T?0:k(0,$),Q=F.pointerType==="touch"?10:2,ue={x:W,y:q},X={originalEvent:F,delta:ue};R?(_.current=ue,Zg(l7,h,X,{discrete:!1})):mT(ue,p.swipeDirection,Q)?(_.current=ue,Zg(o7,u,X,{discrete:!1}),F.target.setPointerCapture(F.pointerId)):(Math.abs(L)>Q||Math.abs($)>Q)&&(b.current=null)}),onPointerUp:Te(e.onPointerUp,F=>{const L=_.current,$=F.target;if($.hasPointerCapture(F.pointerId)&&$.releasePointerCapture(F.pointerId),_.current=null,b.current=null,L){const R=F.currentTarget,T={originalEvent:F,delta:L};mT(L,p.swipeDirection,p.swipeThreshold)?Zg(d7,m,T,{discrete:!0}):Zg(c7,f,T,{discrete:!0}),R.addEventListener("click",k=>k.preventDefault(),{once:!0})}})})})}),p.viewport)})]}):null}),m7=e=>{const{__scopeToast:t,children:r,...s}=e,a=w0(tg,t),[i,o]=x.useState(!1),[l,c]=x.useState(!1);return x7(()=>o(!0)),x.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),l?null:n.jsx(Uh,{asChild:!0,children:n.jsx(b0,{...s,children:i&&n.jsxs(n.Fragment,{children:[a.label," ",r]})})})},p7="ToastTitle",Z$=x.forwardRef((e,t)=>{const{__scopeToast:r,...s}=e;return n.jsx(We.div,{...s,ref:t})});Z$.displayName=p7;var g7="ToastDescription",J$=x.forwardRef((e,t)=>{const{__scopeToast:r,...s}=e;return n.jsx(We.div,{...s,ref:t})});J$.displayName=g7;var eI="ToastAction",tI=x.forwardRef((e,t)=>{const{altText:r,...s}=e;return r.trim()?n.jsx(nI,{altText:r,asChild:!0,children:n.jsx(fC,{...s,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${eI}\`. Expected non-empty \`string\`.`),null)});tI.displayName=eI;var rI="ToastClose",fC=x.forwardRef((e,t)=>{const{__scopeToast:r,...s}=e,a=h7(rI,r);return n.jsx(nI,{asChild:!0,children:n.jsx(We.button,{type:"button",...s,ref:t,onClick:Te(e.onClick,a.onClose)})})});fC.displayName=rI;var nI=x.forwardRef((e,t)=>{const{__scopeToast:r,altText:s,...a}=e;return n.jsx(We.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":s||void 0,...a,ref:t})});function sI(e){const t=[];
vendor: 3,823 bytes, lines 40-60
40return Array.from(e.childNodes).forEach(s=>{if(s.nodeType===s.TEXT_NODE&&s.textContent&&t.push(s.textContent),v7(s)){const a=s.ariaHidden||s.hidden||s.style.display==="none",i=s.dataset.radixToastAnnounceExclude==="";if(!a)if(i){const o=s.dataset.radixToastAnnounceAlt;o&&t.push(o)}else t.push(...sI(s))}}),t}function Zg(e,t,r,{discrete:s}){const a=r.originalEvent.currentTarget,i=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),s?j0(a,i):a.dispatchEvent(i)}var mT=(e,t,r=0)=>{const s=Math.abs(e.x),a=Math.abs(e.y),i=s>a;return t==="left"||t==="right"?i&&s>r:!i&&a>r};function x7(e=()=>{}){const t=Sr(e);Ur(()=>{let r=0,s=0;return r=window.requestAnimationFrame(()=>s=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(s)}},[t])}function v7(e){return e.nodeType===e.ELEMENT_NODE}function y7(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Mb(e){const t=document.activeElement;return e.some(r=>r===t?!0:(r.focus(),document.activeElement!==t))}var j7=K$,aI=Y$,iI=X$,oI=Z$,lI=J$,cI=tI,dI=fC;function uI(e){var t,r,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=uI(e[t]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function It(){for(var e,t,r=0,s="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=uI(e))&&(s&&(s+=" "),s+=t);return s}const pT=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,gT=It,Ed=(e,t)=>r=>{var s;if((t==null?void 0:t.variants)==null)return gT(e,r==null?void 0:r.class,r==null?void 0:r.className);const{variants:a,defaultVariants:i}=t,o=Object.keys(a).map(d=>{const u=r==null?void 0:r[d],h=i==null?void 0:i[d];if(u===null)return null;const f=pT(u)||pT(h);return a[d][f]}),l=r&&Object.entries(r).reduce((d,u)=>{let[h,f]=u;return f===void 0||(d[h]=f),d},{}),c=t==null||(s=t.compoundVariants)===null||s===void 0?void 0:s.reduce((d,u)=>{let{class:h,className:f,...m}=u;return Object.entries(m).every(g=>{let[p,y]=g;return Array.isArray(y)?y.includes({...i,...l}[p]):{...i,...l}[p]===y})?[...d,h,f]:d},[]);return gT(e,o,c,r==null?void 0:r.class,r==null?void 0:r.className)};/**
41 * @license lucide-react v0.462.0 - ISC
42 *
43 * This source code is licensed under the ISC license.
44 * See the LICENSE file in the root directory of this source tree.
45 */const b7=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),hI=(...e)=>e.filter((t,r,s)=>!!t&&t.trim()!==""&&s.indexOf(t)===r).join(" ").trim();/**
46 * @license lucide-react v0.462.0 - ISC
47 *
48 * This source code is licensed under the ISC license.
49 * See the LICENSE file in the root directory of this source tree.
50 */var w7={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
51 * @license lucide-react v0.462.0 - ISC
52 *
53 * This source code is licensed under the ISC license.
54 * See the LICENSE file in the root directory of this source tree.
55 */const _7=x.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:a="",children:i,iconNode:o,...l},c)=>x.createElement("svg",{ref:c,...w7,width:t,height:t,stroke:e,strokeWidth:s?Number(r)*24/Number(t):r,className:hI("lucide",a),...l},[...o.map(([d,u])=>x.createElement(d,u)),...Array.isArray(i)?i:[i]]));/**
56 * @license lucide-react v0.462.0 - ISC
57 *
58 * This source code is licensed under the ISC license.
59 * See the LICENSE file in the root directory of this source tree.
60 */const Ae=(e,t)=>
60{const r=x.forwardRef(({className:s,...a},i)=>x.createElement(_7,{ref:i,iconNode:t,className:hI(`lucide-${b7(e)}`,s),...a}));return r.displayName=`${e}`,r};/**
61 * @license lucide-react v0.462.0 - ISC
62 *
63 * This source code is licensed under the ISC license.
64 * See the LICENSE file in the root directory of this source tree.
65 */const Wr=Ae("Activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);/**
66 * @license lucide-react v0.462.0 - ISC
67 *
68 * This source code is licensed under the ISC license.
69 * See the LICENSE file in the root directory of this source tree.
70 */const Ma=Ae("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
71 * @license lucide-react v0.462.0 - ISC
72 *
73 * This source code is licensed under the ISC license.
74 * See the LICENSE file in the root directory of this source tree.
75 */const ns=Ae("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
76 * @license lucide-react v0.462.0 - ISC
77 *
78 * This source code is licensed under the ISC license.
79 * See the LICENSE file in the root directory of this source tree.
80 */const N7=Ae("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
81 * @license lucide-react v0.462.0 - ISC
82 *
83 * This source code is licensed under the ISC license.
84 * See the LICENSE file in the root directory of this source tree.
85 */const ii=Ae("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
86 * @license lucide-react v0.462.0 - ISC
87 *
88 * This source code is licensed under the ISC license.
89 * See the LICENSE file in the root directory of this source tree.
90 */const S7=Ae("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/**
91 * @license lucide-react v0.462.0 - ISC
92 *
93 * This source code is licensed under the ISC license.
94 * See the LICENSE file in the root directory of this source tree.
95 */const Ea=Ae("Building2",[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]]);/**
96 * @license lucide-react v0.462.0 - ISC
97 *
98 * This source code is licensed under the ISC license.
99 * See the LICENSE file in the root directory of this source tree.
100 */const fI=Ae("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
101 * @license lucide-react v0.462.0 - ISC
102 *
103 * This source code is licensed under the ISC license.
104 * See the LICENSE file in the root directory of this source tree.
105 */const C7=Ae("ChartColumn",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/**
106 * @license lucide-react v0.462.0 - ISC
107 *
108 * This source code is licensed under the ISC license.
109 * See the LICENSE file in the root directory of this source tree.
110 */const oi=Ae("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
111 * @license lucide-react v0.462.0 - ISC
112 *
113 * This source code is licensed under the ISC license.
114 * See the LICENSE file in the root directory of this source tree.
115 */const dr=Ae("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
116 * @license lucide-react v0.462.0 - ISC
117 *
118 * This source code is licensed under the ISC license.
119 * See the LICENSE file in the root directory of this source tree.
120 */const zh=Ae("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
121 * @license lucide-react v0.462.0 - ISC
122 *
123 * This source code is licensed under the ISC license.
124 * See the LICENSE file in the root directory of this source tree.
125 */const Yo=Ae("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
126 * @license lucide-react v0.462.0 - ISC
127 *
128 * This source code is licensed under the ISC license.
129 * See the LICENSE file in the root directory of this source tree.
130 */const Ar=Ae("ChevronUp",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
131 * @license lucide-react v0.462.0 - ISC
132 *
133 * This source code is licensed under the ISC license.
134 * See the LICENSE file in the root directory of this source tree.
135 */const kn=Ae("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
136 * @license lucide-react v0.462.0 - ISC
137 *
138 * This source code is licensed under the ISC license.
139 * See the LICENSE file in the root directory of this source tree.
140 */const Tt=Ae("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
141 * @license lucide-react v0.462.0 - ISC
142 *
143 * This source code is licensed under the ISC license.
144 * See the LICENSE file in the root directory of this source tree.
145 */const zs=Ae("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
146 * @license lucide-react v0.462.0 - ISC
147 *
148 * This source code is licensed under the ISC license.
149 * See the LICENSE file in the root directory of this source tree.
150 */const Hm=Ae("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
151 * @license lucide-react v0.462.0 - ISC
152 *
153 * This source code is licensed under the ISC license.
154 * See the LICENSE file in the root directory of this source tree.
155 */const mI=Ae("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
156 * @license lucide-react v0.462.0 - ISC
157 *
158 * This source code is licensed under the ISC license.
159 * See the LICENSE file in the root directory of this source tree.
160 */const k7=Ae("CircleStop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);/**
161 * @license lucide-react v0.462.0 - ISC
162 *
163 * This source code is licensed under the ISC license.
164 * See the LICENSE file in the root directory of this source tree.
165 */const sa=Ae("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
166 * @license lucide-react v0.462.0 - ISC
167 *
168 * This source code is licensed under the ISC license.
169 * See the LICENSE file in the root directory of this source tree.
170 */const ku=Ae("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
171 * @license lucide-react v0.462.0 - ISC
172 *
173 * This source code is licensed under the ISC license.
174 * See the LICENSE file in the root directory of this source tree.
175 */const Xt=Ae("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/**
176 * @license lucide-react v0.462.0 - ISC
177 *
178 * This source code is licensed under the ISC license.
179 * See the LICENSE file in the root directory of this source tree.
180 */const P7=Ae("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
181 * @license lucide-react v0.462.0 - ISC
182 *
183 * This source code is licensed under the ISC license.
184 * See the LICENSE file in the root directory of this source tree.
185 */const pI=Ae("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);/**
186 * @license lucide-react v0.462.0 - ISC
187 *
188 * This source code is licensed under the ISC license.
189 * See the LICENSE file in the root directory of this source tree.
190 */const mC=Ae("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
191 * @license lucide-react v0.462.0 - ISC
192 *
193 * This source code is licensed under the ISC license.
194 * See the LICENSE file in the root directory of this source tree.
195 */const T7=Ae("Coffee",[["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M14 2v2",key:"6buw04"}],["path",{d:"M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1",key:"pwadti"}],["path",{d:"M6 2v2",key:"colzsn"}]]);/**
196 * @license lucide-react v0.462.0 - ISC
197 *
198 * This source code is licensed under the ISC license.
199 * See the LICENSE file in the root directory of this source tree.
200 */const rg=Ae("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
201 * @license lucide-react v0.462.0 - ISC
202 *
203 * This source code is licensed under the ISC license.
204 * See the LICENSE file in the root directory of this source tree.
205 */const A7=Ae("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
206 * @license lucide-react v0.462.0 - ISC
207 *
208 * This source code is licensed under the ISC license.
209 * See the LICENSE file in the root directory of this source tree.
210 */const ng=Ae("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
211 * @license lucide-react v0.462.0 - ISC
212 *
213 * This source code is licensed under the ISC license.
214 * See the LICENSE file in the root directory of this source tree.
215 */const wa=Ae("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
216 * @license lucide-react v0.462.0 - ISC
217 *
218 * This source code is licensed under the ISC license.
219 * See the LICENSE file in the root directory of this source tree.
220 */const E7=Ae("Earth",[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
221 * @license lucide-react v0.462.0 - ISC
222 *
223 * This source code is licensed under the ISC license.
224 * See the LICENSE file in the root directory of this source tree.
225 */const gI=Ae("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
226 * @license lucide-react v0.462.0 - ISC
227 *
228 * This source code is licensed under the ISC license.
229 * See the LICENSE file in the root directory of this source tree.
230 */const xI=Ae("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
231 * @license lucide-react v0.462.0 - ISC
232 *
233 * This source code is licensed under the ISC license.
234 * See the LICENSE file in the root directory of this source tree.
235 */const _0=Ae("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/**
236 * @license lucide-react v0.462.0 - ISC
237 *
238 * This source code is licensed under the ISC license.
239 * See the LICENSE file in the root directory of this source tree.
240 */const U_=Ae("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
241 * @license lucide-react v0.462.0 - ISC
242 *
243 * This source code is licensed under the ISC license.
244 * See the LICENSE file in the root directory of this source tree.
245 */const $o=Ae("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
246 * @license lucide-react v0.462.0 - ISC
247 *
248 * This source code is licensed under the ISC license.
249 * See the LICENSE file in the root directory of this source tree.
250 */const hd=Ae("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",ke
250y:"1mlx9k"}]]);/**
251 * @license lucide-react v0.462.0 - ISC
252 *
253 * This source code is licensed under the ISC license.
254 * See the LICENSE file in the root directory of this source tree.
255 */const Dl=Ae("FileText",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);/**
256 * @license lucide-react v0.462.0 - ISC
257 *
258 * This source code is licensed under the ISC license.
259 * See the LICENSE file in the root directory of this source tree.
260 */const Ui=Ae("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
261 * @license lucide-react v0.462.0 - ISC
262 *
263 * This source code is licensed under the ISC license.
264 * See the LICENSE file in the root directory of this source tree.
265 */const Vm=Ae("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
266 * @license lucide-react v0.462.0 - ISC
267 *
268 * This source code is licensed under the ISC license.
269 * See the LICENSE file in the root directory of this source tree.
270 */const pC=Ae("Folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
271 * @license lucide-react v0.462.0 - ISC
272 *
273 * This source code is licensed under the ISC license.
274 * See the LICENSE file in the root directory of this source tree.
275 */const vI=Ae("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
276 * @license lucide-react v0.462.0 - ISC
277 *
278 * This source code is licensed under the ISC license.
279 * See the LICENSE file in the root directory of this source tree.
280 */const Pn=Ae("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
281 * @license lucide-react v0.462.0 - ISC
282 *
283 * This source code is licensed under the ISC license.
284 * See the LICENSE file in the root directory of this source tree.
285 */const Pu=Ae("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);/**
286 * @license lucide-react v0.462.0 - ISC
287 *
288 * This source code is licensed under the ISC license.
289 * See the LICENSE file in the root directory of this source tree.
290 */const O7=Ae("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/**
291 * @license lucide-react v0.462.0 - ISC
292 *
293 * This source code is licensed under the ISC license.
294 * See the LICENSE file in the root directory of this source tree.
295 */const yI=Ae("Hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);/**
296 * @license lucide-react v0.462.0 - ISC
297 *
298 * This source code is licensed under the ISC license.
299 * See the LICENSE file in the root directory of this source tree.
300 */const Km=Ae("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
301 * @license lucide-react v0.462.0 - ISC
302 *
303 * This source code is licensed under the ISC license.
304 * See the LICENSE file in the root directory of this source tree.
305 */const M7=Ae("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
306 * @license lucide-react v0.462.0 - ISC
307 *
308 * This source code is licensed under the ISC license.
309 * See the LICENSE file in the root directory of this source tree.
310 */const D7=Ae("Lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);/**
311 * @license lucide-react v0.462.0 - ISC
312 *
313 * This source code is licensed under the ISC license.
314 * See the LICENSE file in the root directory of this source tree.
315 */const mr=Ae("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
316 * @license lucide-react v0.462.0 - ISC
317 *
318 * This source code is licensed under the ISC license.
319 * See the LICENSE file in the root directory of this source tree.
320 */const Io=Ae("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
321 * @license lucide-react v0.462.0 - ISC
322 *
323 * This source code is licensed under the ISC license.
324 * See the LICENSE file in the root directory of this source tree.
325 */const Gm=Ae("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/**
326 * @license lucide-react v0.462.0 - ISC
327 *
328 * This source code is licensed under the ISC license.
329 * See the LICENSE file in the root directory of this source tree.
330 */const R7=Ae("MailX",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h9",key:"1j9vog"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m17 17 4 4",key:"1b3523"}],["path",{d:"m21 17-4 4",key:"uinynz"}]]);/**
331 * @license lucide-react v0.462.0 - ISC
332 *
333 * This source code is licensed under the ISC license.
334 * See the LICENSE file in the root directory of this source tree.
335 */const aa=Ae("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
336 * @license lucide-react v0.462.0 - ISC
337 *
338 * This source code is licensed under the ISC license.
339 * See the LICENSE file in the root directory of this source tree.
340 */const $7=Ae("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
341 * @license lucide-react v0.462.0 - ISC
342 *
343 * This source code is licensed under the ISC license.
344 * See the LICENSE file in the root directory of this source tree.
345 */const I7=Ae("MessageCircle",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]]);/**
346 * @license lucide-react v0.462.0 - ISC
347 *
348 * This source code is licensed under the ISC license.
349 * See the LICENSE file in the root directory of this source tree.
350 */const L7=Ae("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
351 * @license lucide-react v0.462.0 - ISC
352 *
353 * This source code is licensed under the ISC license.
354 * See the LICENSE file in the root directory of this source tree.
355 */const gC=Ae("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
356 * @license lucide-react v0.462.0 - ISC
357 *
358 * This source code is licensed under the ISC license.
359 * See the LICENSE file in the root directory of this source tree.
360 */const N0=Ae("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
361 * @license lucide-react v0.462.0 - ISC
362 *
363 * This source code is licensed under the ISC license.
364 * See the LICENSE file in the root directory of this source tree.
365 */const F7=Ae("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
366 * @license lucide-react v0.462.0 - ISC
367 *
368 * This source code is licensed under the ISC license.
369 * See the LICENSE file in the root directory of this source tree.
370 */const ia=Ae("Pause",[["rect",{x:"14",y:"4",width:"4",height:"16",rx:"1",key:"zuxfzm"}],["rect",{x:"6",y:"4",width:"4",height:"16",rx:"1",key:"1okwgv"}]]);/**
371 * @license lucide-react v0.462.0 - ISC
372 *
373 * This source code is licensed under the ISC license.
374 * See the LICENSE file in the root directory of this source tree.
375 */const U7=Ae("PenLine",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]);/**
376 * @license lucide-react v0.462.0 - ISC
377 *
378 * This source code is licensed under the ISC license.
379 * See the LICENSE file in the root directory of this source tree.
380 */const z7=Ae("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/**
381 * @license lucide-react v0.462.0 - ISC
382 *
383 * This source code is licensed under the ISC license.
384 * See the LICENSE file in the root directory of this source tree.
385 */const B7=Ae("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
386 * @license lucide-react v0.462.0 - ISC
387 *
388 * This source code is licensed under the ISC license.
389 * See the LICENSE file in the root directory of this source tree.
390 */const q7=Ae("Phone",[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]]);/**
391 * @license lucide-react v0.462.0 - ISC
392 *
393 * This source code is licensed under the ISC license.
394 * See the LICENSE file in the root directory of this source tree.
395 */const qs=Ae("Play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);/**
396 * @license lucide-react v0.462.0 - ISC
397 *
398 * This source code is licensed under the ISC license.
399 * See the LICENSE file in the root directory of this source tree.
400 */const Ws=Ae("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
401 * @license lucide-react v0.462.0 - ISC
402 *
403 * This source code is licensed under the ISC license.
404 * See the LICENSE file in the root directory of this source tree.
405 */const Cn=Ae("Radar",[["path",{d:"M19.07 4.93A10 10 0 0 0 6.99 3.34",key:"z3du51"}
405],["path",{d:"M4 6h.01",key:"oypzma"}],["path",{d:"M2.29 9.62A10 10 0 1 0 21.31 8.35",key:"qzzz0"}],["path",{d:"M16.24 7.76A6 6 0 1 0 8.23 16.67",key:"1yjesh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M17.99 11.66A6 6 0 0 1 15.77 16.67",key:"1u2y91"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"m13.41 10.59 5.66-5.66",key:"mhq4k0"}]]);/**
406 * @license lucide-react v0.462.0 - ISC
407 *
408 * This source code is licensed under the ISC license.
409 * See the LICENSE file in the root directory of this source tree.
410 */const sr=Ae("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
411 * @license lucide-react v0.462.0 - ISC
412 *
413 * This source code is licensed under the ISC license.
414 * See the LICENSE file in the root directory of this source tree.
415 */const Ym=Ae("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
416 * @license lucide-react v0.462.0 - ISC
417 *
418 * This source code is licensed under the ISC license.
419 * See the LICENSE file in the root directory of this source tree.
420 */const Lo=Ae("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);/**
421 * @license lucide-react v0.462.0 - ISC
422 *
423 * This source code is licensed under the ISC license.
424 * See the LICENSE file in the root directory of this source tree.
425 */const W7=Ae("ScrollText",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);/**
426 * @license lucide-react v0.462.0 - ISC
427 *
428 * This source code is licensed under the ISC license.
429 * See the LICENSE file in the root directory of this source tree.
430 */const qt=Ae("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/**
431 * @license lucide-react v0.462.0 - ISC
432 *
433 * This source code is licensed under the ISC license.
434 * See the LICENSE file in the root directory of this source tree.
435 */const Ii=Ae("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);/**
436 * @license lucide-react v0.462.0 - ISC
437 *
438 * This source code is licensed under the ISC license.
439 * See the LICENSE file in the root directory of this source tree.
440 */const ht=Ae("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
441 * @license lucide-react v0.462.0 - ISC
442 *
443 * This source code is licensed under the ISC license.
444 * See the LICENSE file in the root directory of this source tree.
445 */const Qo=Ae("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
446 * @license lucide-react v0.462.0 - ISC
447 *
448 * This source code is licensed under the ISC license.
449 * See the LICENSE file in the root directory of this source tree.
450 */const yt=Ae("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",ke
450y:"oel41y"}]]);/**
451 * @license lucide-react v0.462.0 - ISC
452 *
453 * This source code is licensed under the ISC license.
454 * See the LICENSE file in the root directory of this source tree.
455 */const H7=Ae("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
456 * @license lucide-react v0.462.0 - ISC
457 *
458 * This source code is licensed under the ISC license.
459 * See the LICENSE file in the root directory of this source tree.
460 */const zi=Ae("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
461 * @license lucide-react v0.462.0 - ISC
462 *
463 * This source code is licensed under the ISC license.
464 * See the LICENSE file in the root directory of this source tree.
465 */const Sv=Ae("Star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);/**
466 * @license lucide-react v0.462.0 - ISC
467 *
468 * This source code is licensed under the ISC license.
469 * See the LICENSE file in the root directory of this source tree.
470 */const ws=Ae("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
471 * @license lucide-react v0.462.0 - ISC
472 *
473 * This source code is licensed under the ISC license.
474 * See the LICENSE file in the root directory of this source tree.
475 */const xC=Ae("Timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);/**
476 * @license lucide-react v0.462.0 - ISC
477 *
478 * This source code is licensed under the ISC license.
479 * See the LICENSE file in the root directory of this source tree.
480 */const V7=Ae("ToggleLeft",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]]);/**
481 * @license lucide-react v0.462.0 - ISC
482 *
483 * This source code is licensed under the ISC license.
484 * See the LICENSE file in the root directory of this source tree.
485 */const K7=Ae("ToggleRight",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"16",cy:"12",r:"2",key:"4ma0v8"}]]);/**
486 * @license lucide-react v0.462.0 - ISC
487 *
488 * This source code is licensed under the ISC license.
489 * See the LICENSE file in the root directory of this source tree.
490 */const Vt=Ae("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
491 * @license lucide-react v0.462.0 - ISC
492 *
493 * This source code is licensed under the ISC license.
494 * See the LICENSE file in the root directory of this source tree.
495 */const Bi=Ae("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]]);/**
496 * @license lucide-react v0.462.0 - ISC
497 *
498 * This source code is licensed under the ISC license.
499 * See the LICENSE file in the root directory of this source tree.
500 */const tn=Ae("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
501 * @license lucide-react v0.462.0 - ISC
502 *
503 * This source code is licensed under the ISC license.
504 * See the LICENSE file in the root directory of this source tree.
505 */const Db=Ae("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]);/**
506 * @license lucide-react v0.462.0 - ISC
507 *
508 * This source code is licensed under the ISC license.
509 * See the LICENSE file in the root directory of this source tree.
510 */const G7=Ae("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}
510],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);/**
511 * @license lucide-react v0.462.0 - ISC
512 *
513 * This source code is licensed under the ISC license.
514 * See the LICENSE file in the root directory of this source tree.
515 */const Y7=Ae("UserCog",[["circle",{cx:"18",cy:"15",r:"3",key:"gjjjvw"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M10 15H6a4 4 0 0 0-4 4v2",key:"1nfge6"}],["path",{d:"m21.7 16.4-.9-.3",key:"12j9ji"}],["path",{d:"m15.2 13.9-.9-.3",key:"1fdjdi"}],["path",{d:"m16.6 18.7.3-.9",key:"heedtr"}],["path",{d:"m19.1 12.2.3-.9",key:"1af3ki"}],["path",{d:"m19.6 18.7-.4-1",key:"1x9vze"}],["path",{d:"m16.8 12.3-.4-1",key:"vqeiwj"}],["path",{d:"m14.3 16.6 1-.4",key:"1qlj63"}],["path",{d:"m20.7 13.8 1-.4",key:"1v5t8k"}]]);/**
516 * @license lucide-react v0.462.0 - ISC
517 *
518 * This source code is licensed under the ISC license.
519 * See the LICENSE file in the root directory of this source tree.
520 */const jI=Ae("UserMinus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
521 * @license lucide-react v0.462.0 - ISC
522 *
523 * This source code is licensed under the ISC license.
524 * See the LICENSE file in the root directory of this source tree.
525 */const xo=Ae("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
526 * @license lucide-react v0.462.0 - ISC
527 *
528 * This source code is licensed under the ISC license.
529 * See the LICENSE file in the root directory of this source tree.
530 */const Rb=Ae("UserX",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]);/**
531 * @license lucide-react v0.462.0 - ISC
532 *
533 * This source code is licensed under the ISC license.
534 * See the LICENSE file in the root directory of this source tree.
535 */const Cv=Ae("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
536 * @license lucide-react v0.462.0 - ISC
537 *
538 * This source code is licensed under the ISC license.
539 * See the LICENSE file in the root directory of this source tree.
540 */const Rr=Ae("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
541 * @license lucide-react v0.462.0 - ISC
542 *
543 * This source code is licensed under the ISC license.
544 * See the LICENSE file in the root directory of this source tree.
545 */const bI=Ae("WifiOff",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
546 * @license lucide-react v0.462.0 - ISC
547 *
548 * This source code is licensed under the ISC license.
549 * See the LICENSE file in the root directory of this source tree.
550 */const wI=Ae("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
551 * @license lucide-react v0.462.0 - ISC
552 *
553 * This source code is licensed under the ISC license.
554 * See the LICENSE file in the root directory of this source tree.
555 */const vn=Ae("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/**
556 * @license lucide-react v0.462.0 - ISC
557 *
558 * This source code is licensed under the ISC license.
559 * See the LICENSE file in the root directory of this source tree.
560 */const S0=Ae("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),vC="-",Q7=e=>{const t=Z7(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:s}=e;return{getClassGroupId:o=>{const l=o.split(vC);
vendor: 12,076 bytes, line 560
560return l[0]===""&&l.length!==1&&l.shift(),_I(l,t)||X7(o)},getConflictingClassGroupIds:(o,l)=>{const c=r[o]||[];return l&&s[o]?[...c,...s[o]]:c}}},_I=(e,t)=>{var o;if(e.length===0)return t.classGroupId;const r=e[0],s=t.nextPart.get(r),a=s?_I(e.slice(1),s):void 0;if(a)return a;if(t.validators.length===0)return;const i=e.join(vC);return(o=t.validators.find(({validator:l})=>l(i)))==null?void 0:o.classGroupId},xT=/^\[(.+)\]$/,X7=e=>{if(xT.test(e)){const t=xT.exec(e)[1],r=t==null?void 0:t.substring(0,t.indexOf(":"));if(r)return"arbitrary.."+r}},Z7=e=>{const{theme:t,prefix:r}=e,s={nextPart:new Map,validators:[]};return eK(Object.entries(e.classGroups),r).forEach(([i,o])=>{z_(o,s,i,t)}),s},z_=(e,t,r,s)=>{e.forEach(a=>{if(typeof a=="string"){const i=a===""?t:vT(t,a);i.classGroupId=r;return}if(typeof a=="function"){if(J7(a)){z_(a(s),t,r,s);return}t.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([i,o])=>{z_(o,vT(t,i),r,s)})})},vT=(e,t)=>{let r=e;return t.split(vC).forEach(s=>{r.nextPart.has(s)||r.nextPart.set(s,{nextPart:new Map,validators:[]}),r=r.nextPart.get(s)}),r},J7=e=>e.isThemeGetter,eK=(e,t)=>t?e.map(([r,s])=>{const a=s.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([o,l])=>[t+o,l])):i);return[r,a]}):e,tK=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=new Map,s=new Map;const a=(i,o)=>{r.set(i,o),t++,t>e&&(t=0,s=r,r=new Map)};return{get(i){let o=r.get(i);if(o!==void 0)return o;if((o=s.get(i))!==void 0)return a(i,o),o},set(i,o){r.has(i)?r.set(i,o):a(i,o)}}},NI="!",rK=e=>{const{separator:t,experimentalParseClassName:r}=e,s=t.length===1,a=t[0],i=t.length,o=l=>{const c=[];let d=0,u=0,h;for(let y=0;y<l.length;y++){let v=l[y];if(d===0){if(v===a&&(s||l.slice(y,y+i)===t)){c.push(l.slice(u,y)),u=y+i;continue}if(v==="/"){h=y;continue}}v==="["?d++:v==="]"&&d--}const f=c.length===0?l:l.substring(u),m=f.startsWith(NI),g=m?f.substring(1):f,p=h&&h>u?h-u:void 0;return{modifiers:c,hasImportantModifier:m,baseClassName:g,maybePostfixModifierPosition:p}};return r?l=>r({className:l,parseClassName:o}):o},nK=e=>{if(e.length<=1)return e;const t=[];let r=[];return e.forEach(s=>{s[0]==="["?(t.push(...r.sort(),s),r=[]):r.push(s)}),t.push(...r.sort()),t},sK=e=>({cache:tK(e.cacheSize),parseClassName:rK(e),...Q7(e)}),aK=/\s+/,iK=(e,t)=>{const{parseClassName:r,getClassGroupId:s,getConflictingClassGroupIds:a}=t,i=[],o=e.trim().split(aK);let l="";for(let c=o.length-1;c>=0;c-=1){const d=o[c],{modifiers:u,hasImportantModifier:h,baseClassName:f,maybePostfixModifierPosition:m}=r(d);let g=!!m,p=s(g?f.substring(0,m):f);if(!p){if(!g){l=d+(l.length>0?" "+l:l);continue}if(p=s(f),!p){l=d+(l.length>0?" "+l:l);continue}g=!1}const y=nK(u).join(":"),v=h?y+NI:y,j=v+p;if(i.includes(j))continue;i.push(j);const b=a(p,g);for(let _=0;_<b.length;++_){const w=b[_];i.push(v+w)}l=d+(l.length>0?" "+l:l)}return l};function oK(){let e=0,t,r,s="";for(;e<arguments.length;)(t=arguments[e++])&&(r=SI(t))&&(s&&(s+=" "),s+=r);return s}const SI=e=>{if(typeof e=="string")return e;let t,r="";for(let s=0;s<e.length;s++)e[s]&&(t=SI(e[s]))&&(r&&(r+=" "),r+=t);return r};function lK(e,...t){let r,s,a,i=o;function o(c){const d=t.reduce((u,h)=>h(u),e());return r=sK(d),s=r.cache.get,a=r.cache.set,i=l,l(c)}function l(c){const d=s(c);if(d)return d;const u=iK(c,r);return a(c,u),u}return function(){return i(oK.apply(null,arguments))}}const jr=e=>{const t=r=>r[e]||[];return t.isThemeGetter=!0,t},CI=/^\[(?:([a-z-]+):)?(.+)\]$/i,cK=/^\d+\/\d+$/,dK=new Set(["px","full","screen"]),uK=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,hK=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,fK=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,mK=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pK=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,to=e=>Tu(e)||dK.has(e)||cK.test(e),al=e=>Bh(e,"length",_K),Tu=e=>!!e&&!Number.isNaN(Number(e)),$b=e=>Bh(e,"number",Tu),kf=e=>!!e&&Number.isInteger(Number(e)),gK=e=>e.endsWith("%")&&Tu(e.slice(0,-1)),jt=e=>CI.test(e),il=e=>uK.test(e),xK=new Set(["length","size","percentage"]),vK=e=>Bh(e,xK,kI),yK=e=>Bh(e,"position",kI),jK=new Set(["image","url"]),bK=e=>Bh(e,jK,SK),wK=e=>Bh(e,"",NK),Pf=()=>!0,Bh=(e,t,r)=>{const s=CI.exec(e);return s?s[1]?typeof t=="string"?s[1]===t:t.has(s[1]):r(s[2]):!1},_K=e=>hK.test(e)&&!fK.test(e),kI=()=>!1,NK=e=>mK.test(e),SK=e=>pK.test(e),CK=()=>{const e=jr("colors"),t=jr("spacing"),r=jr("blur"),s=jr("brightness"),a=jr("borderColor"),i=jr("borderRadius"),o=jr("borderSpacing"),l=jr("borderWidth"),c=jr("contrast"),d=jr("grayscale"),u=jr("hueRotate"),h=jr("invert"),f=jr("gap"),m=jr("gradientColorStops"),g=jr("gradientColorStopPositions"),p=jr("inset"),y=jr("margin"),v=jr("opacity"),j=jr("padding"),b=jr("saturate"),_=jr("scale"),w=jr("sepia"),N=jr("skew"),S=jr("space"),C=jr("translate"),P=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",jt,t],A=()=>[jt,t],U=()=>["",to,al],F=()=>["auto",Tu,jt],L=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],$=()=>["solid","dashed","dotted","double","none"],R=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],T=()=>["start","end","center","between","around","evenly","stretch"],k=()=>["","0",jt],W=()=>["auto","avoid","all","avoid-page","page","left","right","column"],q=()=>[Tu,jt];return{cacheSize:500,separator:":",theme:{colors:[Pf],spacing:[to,al],blur:["none","",il,jt],brightness:q(),borderColor:[e],borderRadius:["none","","full",il,jt],borderSpacing:A(),borderWidth:U(),contrast:q(),grayscale:k(),hueRotate:q(),invert:k(),gap:A(),gradientColorStops:[e],gradientColorStopPositions:[gK,al],inset:D(),margin:D(),opacity:q(),padding:A(),saturate:q(),scale:q(),sepia:k(),skew:q(),space:A(),translate:A()},classGroups:{aspect:[{aspect:["auto","square","video",jt]}],container:["container"],columns:[{columns:[il]}],"break-after":[{"break-after":W()}],"break-before":[{"break-before":W()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...L(),jt]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:P()}],"overscroll-x":[{"overscroll-x":P()}],"overscroll-y":[{"overscroll-y":P()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[p]}],"inset-x":[{"inset-x":[p]}],"inset-y":[{"inset-y":[p]}],start:[{start:[p]}],end:[{end:[p]}],top:[{top:[p]}],right:[{right:[p]}],bottom:[{bottom:[p]}],left:[{left:[p]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",kf,jt]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",jt]}],grow:[{grow:k()}],shrink:[{shrink:k()}],order:[{order:["first","last","none",kf,jt]}],"grid-cols":[{"grid-cols":[Pf]}],"col-start-end":[{col:["auto",{span:["full",kf,jt]},jt]}],"col-start":[{"col-start":F()}],"col-end":[{"col-end":F()}],"grid-rows":[{"grid-rows":[Pf]}],"row-start-end":[{row:["auto",{span:[kf,jt]},jt]}],"row-start":[{"row-start":F()}],"row-end":[{"row-end":F()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",jt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",jt]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...T()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...T(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...T(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[j]}],px:[{px:[j]}],py:[{py:[j]}],ps:[{ps:[j]}],pe:[{pe:[j]}],pt:[{pt:[j]}],pr:[{pr:[j]}],pb:[{pb:[j]}],pl:[{pl:[j]}],m:[{m:[y]}],mx:[{mx:[y]}],my:[{my:[y]}],ms:[{ms:[y]}],me:[{me:[y]}],mt:[{mt:[y]}],mr:[{mr:[y]}],mb:[{mb:[y]}],ml:[{ml:[y]}],"space-x":[{"space-x":[S]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[S]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",jt,t]}],"min-w":[{"min-w":[jt,t,"min","max","fit"]}],"max-w":[{"max-w":[jt,t,"none","full","min","max","fit","prose",{screen:[il]},il]}],h:[{h:[jt,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[jt,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[jt,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[jt,t,"auto","min","max","fit"]}],"font-size":[{text:["base",il,al]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",$b]}],"font-family":[{font:[Pf]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",jt]}],"line-clamp":[{"line-clamp":["none",Tu,$b]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",to,jt]}],"list-image":[{"list-image":["none",jt]}],"list-style-type":[{list:["none","disc","decimal",jt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[v]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[v]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...$(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",to,al]}],"underline-offset":[{"underline-offset":["auto",to,jt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:A()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",jt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",jt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[v]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...L(),yK]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",vK]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},bK]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}
vendor: 5,180 bytes, line 560
560],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[v]}],"border-style":[{border:[...$(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[v]}],"divide-style":[{divide:$()}],"border-color":[{border:[a]}],"border-color-x":[{"border-x":[a]}],"border-color-y":[{"border-y":[a]}],"border-color-s":[{"border-s":[a]}],"border-color-e":[{"border-e":[a]}],"border-color-t":[{"border-t":[a]}],"border-color-r":[{"border-r":[a]}],"border-color-b":[{"border-b":[a]}],"border-color-l":[{"border-l":[a]}],"divide-color":[{divide:[a]}],"outline-style":[{outline:["",...$()]}],"outline-offset":[{"outline-offset":[to,jt]}],"outline-w":[{outline:[to,al]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:U()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[v]}],"ring-offset-w":[{"ring-offset":[to,al]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",il,wK]}],"shadow-color":[{shadow:[Pf]}],opacity:[{opacity:[v]}],"mix-blend":[{"mix-blend":[...R(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":R()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[s]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",il,jt]}],grayscale:[{grayscale:[d]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[h]}],saturate:[{saturate:[b]}],sepia:[{sepia:[w]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[s]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[d]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[h]}],"backdrop-opacity":[{"backdrop-opacity":[v]}],"backdrop-saturate":[{"backdrop-saturate":[b]}],"backdrop-sepia":[{"backdrop-sepia":[w]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",jt]}],duration:[{duration:q()}],ease:[{ease:["linear","in","out","in-out",jt]}],delay:[{delay:q()}],animate:[{animate:["none","spin","ping","pulse","bounce",jt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[_]}],"scale-x":[{"scale-x":[_]}],"scale-y":[{"scale-y":[_]}],rotate:[{rotate:[kf,jt]}],"translate-x":[{"translate-x":[C]}],"translate-y":[{"translate-y":[C]}],"skew-x":[{"skew-x":[N]}],"skew-y":[{"skew-y":[N]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",jt]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",jt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":A()}],"scroll-mx":[{"scroll-mx":A()}],"scroll-my":[{"scroll-my":A()}],"scroll-ms":[{"scroll-ms":A()}],"scroll-me":[{"scroll-me":A()}],"scroll-mt":[{"scroll-mt":A()}],"scroll-mr":[{"scroll-mr":A()}],"scroll-mb":[{"scroll-mb":A()}],"scroll-ml":[{"scroll-ml":A()}],"scroll-p":[{"scroll-p":A()}],"scroll-px":[{"scroll-px":A()}],"scroll-py":[{"scroll-py":A()}],"scroll-ps":[{"scroll-ps":A()}],"scroll-pe":[{"scroll-pe":A()}],"scroll-pt":[{"scroll-pt":A()}],"scroll-pr":[{"scroll-pr":A()}],"scroll-pb":[{"scroll-pb":A()}],"scroll-pl":[{"scroll-pl":A()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}
vendor: 4,647 bytes, line 560
560],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",jt]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[to,al,$b]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},kK=lK(CK);function we(...e){return kK(It(e))}const PK=j7,PI=x.forwardRef(({className:e,...t},r)=>n.jsx(aI,{ref:r,className:we("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));PI.displayName=aI.displayName;const TK=Ed("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),TI=x.forwardRef(({className:e,variant:t,...r},s)=>n.jsx(iI,{ref:s,className:we(TK({variant:t}),e),...r}));TI.displayName=iI.displayName;const AK=x.forwardRef(({className:e,...t},r)=>n.jsx(cI,{ref:r,className:we("inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors group-[.destructive]:border-muted/40 hover:bg-secondary group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 group-[.destructive]:focus:ring-destructive disabled:pointer-events-none disabled:opacity-50",e),...t}));AK.displayName=cI.displayName;const AI=x.forwardRef(({className:e,...t},r)=>n.jsx(dI,{ref:r,className:we("absolute right-2 top-2 rounded-md p-1 text-foreground
560/50 opacity-0 transition-opacity group-hover:opacity-100 group-[.destructive]:text-red-300 hover:text-foreground group-[.destructive]:hover:text-red-50 focus:opacity-100 focus:outline-none focus:ring-2 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:n.jsx(vn,{className:"h-4 w-4"})}));AI.displayName=dI.displayName;const EI=x.forwardRef(({className:e,...t},r)=>n.jsx(oI,{ref:r,className:we("text-sm font-semibold",e),...t}));EI.displayName=oI.displayName;const OI=x.forwardRef(({className:e,...t},r)=>n.jsx(lI,{ref:r,className:we("text-sm opacity-90",e),...t}));OI.displayName=lI.displayName;function EK(){const{toasts:e}=qr();return n.jsxs(PK,{children:[e.map(function({id:t,title:r,description:s,action:a,...i}){return n.jsxs(TI,{...i,children:[n.jsxs("div",{className:"grid gap-1",children:[r&&n.jsx(EI,{children:r}),s&&n.jsx(OI,{children:s})]}),a,n.jsx(AI,{})]},t)}),n.jsx(PI,{})]})}var yT=["light","dark"],OK="(prefers-color-scheme: dark)",MK=x.createContext(void 0),DK={setTheme:e=>{},themes:[]},RK=()=>{var e;return(e=x.useContext(MK))!=null?e:DK};x.memo(({forcedTheme:e,storageKey:t,attribute:r,enableSystem:s,enableColorScheme:a,defaultTheme:i,value:o,attrs:l,nonce:c})=>{let d=i==="system",u=r==="class"?`var d=document.documentElement,c=d.classList;${`c.remove(${l.map(g=>`'${g}'`).join(",")})`};`:`var d=document.documentElement,n='${r}',s='setAttribute';`,h=a?yT.includes(i)&&i?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${i}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",f=(g,p=!1,y=!0)=>{let v=o?o[g]:g,j=p?g+"|| ''":`'${v}'`,b="";return a&&y&&!p&&yT.includes(g)&&(b+=`d.style.colorScheme = '${g}';`),r==="class"?p||v?b+=`c.add(${j})`:b+="null":v&&(b+=`d[s](n,${j})`),b},m=e?`!function(){${u}${f(e)}}()`:s?`!function(){try{${u}var e=localStorage.getItem('${t}');if('system'===e||(!e&&${d})){var t='${OK}',m=window.matchMedia(t);if(m.media!==t||m.matches){${f("dark")}}else{${f("light")}}}else if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}${d?"":"else{"+f(i,!1,!1)+"}"}${h}}catch(e){}}()`:`!function(){try{${u}var e=localStorage.getItem('${t}');if(e){${o?`var x=${JSON.stringify(o)};`:""}${f(o?"x[e]":"e",!0)}}else{${f(i,!1,!1)};}${h}}catch(t){}}();`;return x.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:m}})});var $K=e=>{switch(e){case"success":return FK;case"info":return zK;case"warning":return UK;case"error":return BK;default:return null}},IK=Array(12).fill(0),LK=({visible:e,className:t})=>G.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},G.createElement("div",{className:"sonner-spinner"},IK.map((r,s)=>G.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${s}`})))),FK=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},G.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),UK=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},G.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),zK=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},G.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),BK=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},G.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),qK=G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},G.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),G.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),WK=()=>{let[e,t]=G.useState(document.hidden);return G.useEffect(()=>{let r=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",r),()=>window.removeEventListener("visibilitychange",r)},[]),e},B_=1,HK=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>
vendor: 1,050 bytes, line 560
560{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:r,...s}=e,a=typeof(e==null?void 0:e.id)=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:B_++,i=this.toasts.find(l=>l.id===a),o=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...e,id:a,title:r}),{...l,...e,id:a,dismissible:o,title:r}):l):this.addToast({title:r,...s,dismissible:o,id:a}),a},this.dismiss=e=>(this.dismissedToasts.add(e),e||this.toasts.forEach(t=>{this.subscribers.forEach(r=>r({id:t.id,dismiss:!0}))}),this.subscribers.forEach(t=>t({id:e,dismiss:!0})),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>
560this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let r;t.loading!==void 0&&(r=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let s=e instanceof Promise?e:e(),a=r!==void 0,i,o=s.then(async c=>{if(i=["resolve",c],G.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(KK(c)&&!c.ok){a=!1;let d=typeof t.error=="function"?await t.error(`HTTP error! status: ${c.status}`):t.error,u=typeof t.description=="function"?await t.description(`HTTP error! status: ${c.status}`):t.description;this.create({id:r,type:"error",message:d,description:u})}else if(t.success!==void 0){a=!1;let d=typeof t.success=="function"?await t.success(c):t.success,u=typeof t.description=="function"?await t.description(c):t.description;this.create({id:r,type:"success",message:d,description:u})}}).catch(async c=>{if(i=["reject",c],t.error!==void 0){a=!1;let d=typeof t.error=="function"?await t.error(c):t.error,u=typeof t.description=="function"?await t.description(c):t.description;this.create({id:r,type:"error",message:d,description:u})}}).finally(()=>{var c;a&&(this.dismiss(r),r=void 0),(c=t.finally)==null||c.call(t)}),l=()=>new Promise((c,d)=>o.then(()=>i[0]==="reject"?d(i[1]):c(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(e,t)=>{let r=(t==null?void 0:t.id)||B_++;return this.create({jsx:e(r),id:r,...t}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Os=new HK,VK=(e,t)=>{let r=(t==null?void 0:t.id)||B_++;return Os.addToast({title:e,...t,id:r}),r},KK=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",GK=VK,YK=()=>Os.toasts,QK=()=>Os.getActiveToasts(),ye=Object.assign(GK,{success:Os.success,info:Os.info,warning:Os.warning,error:Os.error,custom:Os.custom,message:Os.message,promise:Os.promise,dismiss:Os.dismiss,loading:Os.loading},{getHistory:YK,getToasts:QK});function XK(e,{insertAt:t}={}){if(typeof document>"u")return;let r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=e:s.appendChild(document.createTextNode(e))}XK(`:where(html[dir="ltr"]),:where([data-sonner-toaster][dir="ltr"]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir="rtl"]),:where([data-sonner-toaster][dir="rtl"]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999;transition:transform .4s ease}:where([data-sonner-toaster][data-lifted="true"]){transform:translateY(-10px)}@media (hover: none) and (pointer: coarse){:where([data-sonner-toaster][data-lifted="true"]){transform:none}}:where([data-sonner-toaster][data-x-position="right"]){right:var(--offset-right)}:where([data-sonner-toaster][data-x-position="left"]){left:var(--offset-left)}:where([data-sonner-toaster][data-x-position="center"]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position="top"]){top:var(--offset-top)}:where([data-sonner-toaster][data-y-position="bottom"]){bottom:var(--offset-bottom)}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled="true"]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position="top"]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position="bottom"]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise="true"]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:rgba(0,0,0,.08)}:where([data-sonner-toast][data-theme="dark"]) :where([data-cancel]){background:rgba(255,255,255,.3)}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;
560left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast] [data-close-button]{background:var(--gray1)}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled="true"]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping="true"]):before{content:"";position:absolute;left:-50%;right:-50%;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position="top"][data-swiping="true"]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position="bottom"][data-swiping="true"]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping="false"][data-removed="true"]):before{content:"";position:absolute;inset:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted="true"]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded="false"][data-front="false"]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded="false"][data-front="false"][data-styled="true"])>*{opacity:0}
560:where([data-sonner-toast][data-visible="false"]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted="true"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed="true"][data-front="true"][data-swipe-out="false"]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="true"]){--y: translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed="true"][data-front="false"][data-swipe-out="false"][data-expanded="false"]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed="true"][data-front="false"]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y, 0px)) translate(var(--swipe-amount-x, 0px));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{0%{transform:var(--y) translate(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translate(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{0%{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-bg-hover: hsl(0, 0%, 12%);--normal-border: hsl(0, 0%, 20%);--normal-border-hover: hsl(0, 0%, 25%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);
560--error-text: hsl(358, 100%, 81%)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success],[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info],[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning],[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error],[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}
561`);function Jg(e){return e.label!==void 0}var ZK=3,JK="32px",eG="16px",jT=4e3,tG=356,rG=14,nG=20,sG=200;function Ua(...e){return e.filter(Boolean).join(" ")}function aG(e){let[t,r]=e.split("-"),s=[];return t&&s.push(t),r&&s.push(r),s}var iG=e=>{var t,r,s,a,i,o,l,c,d,u,h;let{invert:f,toast:m,unstyled:g,interacting:p,setHeights:y,visibleToasts:v,heights:j,index:b,toasts:_,expanded:w,removeToast:N,defaultRichColors:S,closeButton:C,style:P,cancelButtonStyle:M,actionButtonStyle:D,className:A="",descriptionClassName:U="",duration:F,position:L,gap:$,loadingIcon:R,expandByDefault:T,classNames:k,icons:W,closeButtonAriaLabel:q="Close toast",pauseWhenPageIsHidden:
561Q}=e,[ue,X]=G.useState(null),[le,pe]=G.useState(null),[ce,se]=G.useState(!1),[oe,V]=G.useState(!1),[fe,ne]=G.useState(!1),[Ce,Pe]=G.useState(!1),[he,ke]=G.useState(!1),[Me,Je]=G.useState(0),[Ke,E]=G.useState(0),O=G.useRef(m.duration||F||jT),I=G.useRef(null),Y=G.useRef(null),te=b===0,K=b+1<=v,Z=m.type,je=m.dismissible!==!1,_e=m.className||"",Ee=m.descriptionClassName||"",Ze=G.useMemo(()=>j.findIndex(dt=>dt.toastId===m.id)||0,[j,m.id]),st=G.useMemo(()=>{var dt;return(dt=m.closeButton)!=null?dt:C},[m.closeButton,C]),xt=G.useMemo(()=>m.duration||F||jT,[m.duration,F]),Dt=G.useRef(0),xe=G.useRef(0),qe=G.useRef(0),St=G.useRef(null),[Pr,wn]=L.split("-"),An=G.useMemo(()=>j.reduce((dt,zt,Ft)=>Ft>=Ze?dt:dt+zt.height,0),[j,Ze]),En=WK(),ls=m.invert||f,cs=Z==="loading";xe.current=G.useMemo(()=>Ze*$+An,[Ze,An]),G.useEffect(()=>{O.current=xt},[xt]),G.useEffect(()=>{se(!0)},[]),G.useEffect(()=>{let dt=Y.current;if(dt){let zt=dt.getBoundingClientRect().height;return E(zt),y(Ft=>[{toastId:m.id,height:zt,position:m.position},...Ft]),()=>y(Ft=>Ft.filter(ds=>ds.toastId!==m.id))}},[y,m.id]),G.useLayoutEffect(()=>{if(!ce)return;let dt=Y.current,zt=dt.style.height;dt.style.height="auto";let Ft=dt.getBoundingClientRect().height;dt.style.height=zt,E(Ft),y(ds=>ds.find(Ct=>Ct.toastId===m.id)?ds.map(Ct=>Ct.toastId===m.id?{...Ct,height:Ft}:Ct):[{toastId:m.id,height:Ft,position:m.position},...ds])},[ce,m.title,m.description,y,m.id]);let ze=G.useCallback(()=>{V(!0),Je(xe.current),y(dt=>dt.filter(zt=>zt.toastId!==m.id)),setTimeout(()=>{N(m)},sG)},[m,N,y,xe]);G.useEffect(()=>{if(m.promise&&Z==="loading"||m.duration===1/0||m.type==="loading")return;let dt;return w||p||Q&&En?(()=>{if(qe.current<Dt.current){let zt=new Date().getTime()-Dt.current;O.current=O.current-zt}qe.current=new Date().getTime()})():O.current!==1/0&&(Dt.current=new Date().getTime(),dt=setTimeout(()=>{var zt;(zt=m.onAutoClose)==null||zt.call(m,m),ze()},O.current)),()=>clearTimeout(dt)},[w,p,m,Z,Q,En,ze]),G.useEffect(()=>{m.delete&&ze()},[ze,m.delete]);function xf(){var dt,zt,Ft;return W!=null&&W.loading?G.createElement("div",{className:Ua(k==null?void 0:k.loader,(dt=m==null?void 0:m.classNames)==null?void 0:dt.loader,"sonner-loader"),"data-visible":Z==="loading"},W.loading):R?G.createElement("div",{className:Ua(k==null?void 0:k.loader,(zt=m==null?void 0:m.classNames)==null?void 0:zt.loader,"sonner-loader"),"data-visible":Z==="loading"},R):G.createElement(LK,{className:Ua(k==null?void 0:k.loader,(Ft=m==null?void 0:m.classNames)==null?void 0:Ft.loader),visible:Z==="loading"})}return G.createElement("li",{tabIndex:0,ref:Y,className:Ua(A,_e,k==null?void 0:k.toast,(t=m==null?void 0:m.classNames)==null?void 0:t.toast,k==null?void 0:k.default,k==null?void 0:k[Z],(r=m==null?void 0:m.classNames)==null?void 0:r[Z]),"data-sonner-toast":"","data-rich-colors":(s=m.richColors)!=null?s:S,"data-styled":!(m.jsx||m.unstyled||g),"data-mounted":ce,"data-promise":!!m.promise,"data-swiped":he,"data-removed":oe,"data-visible":K,"data-y-position":Pr,"data-x-position":wn,"data-index":b,"data-front":te,"data-swiping":fe,"data-dismissible":je,"data-type":Z,"data-invert":ls,"data-swipe-out":Ce,"data-swipe-direction":le,"data-expanded":!!(w||T&&ce),style:{"--index":b,"--toasts-before":b,"--z-index":_.length-b,"--offset":`${oe?Me:xe.current}px`,"--initial-height":T?"auto":`${Ke}px`,...P,...m.style},onDragEnd:()=>{ne(!1),X(null),St.current=null},onPointerDown:dt=>{cs||!je||(I.current=new Date,Je(xe.current),dt.target.setPointerCapture(dt.pointerId),dt.target.tagName!=="BUTTON"&&(ne(!0),St.current={x:dt.clientX,y:dt.clientY}))},onPointerUp:()=>{var dt,zt,Ft,ds;if(Ce||!je)return;St.current=null;let Ct=Number(((dt=Y.current)==null?void 0:dt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),fi=Number(((zt=Y.current)==null?void 0:zt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),nl=new Date().getTime()-((Ft=I.current)==null?void 0:Ft.getTime()),ua=ue==="x"?Ct:fi,ha=Math.abs(ua)/nl;if(Math.abs(ua)>=nG||ha>.11){Je(xe.current),(ds=m.onDismiss)==null||ds.call(m,m),pe(ue==="x"?Ct>0?"right":"left":fi>0?"down":"up"),ze(),Pe(!0),ke(!1);return}ne(!1),X(null)},onPointerMove:dt=>{var zt,Ft,ds,Ct;if(!St.current||!je||((zt=window.getSelection())==null?void 0:zt.toString().length)>0)return;let fi=dt.clientY-St.current.y,nl=dt.clientX-St.current.x,ua=(Ft=e.swipeDirections)!=null?Ft:aG(L);!ue&&(Math.abs(nl)>1||Math.abs(fi)>1)&&X(Math.abs(nl)>Math.abs(fi)?"x":"y");let ha={x:0,y:0};ue==="y"?(ua.includes("top")||ua.includes("bottom"))&&(ua.includes("top")&&fi<0||ua.includes("bottom")&&fi>0)&&(ha.y=fi):ue==="x"&&(ua.includes("left")||ua.includes("right"))&&(ua.includes("left")&&nl<0||ua.includes("right")&&nl>0)&&(ha.x=nl),(Math.abs(ha.x)>0||Math.abs(ha.y)>0)&&ke(!0),(ds=Y.current)==null||ds.style.setProperty("--swipe-amount-x",`${ha.x}px`),(Ct=Y.current)==null||Ct.style.setProperty("--swipe-amount-y",`${ha.y}px`)}},st&&!m.jsx?G.createElement("button",{"aria-label":q,"data-disabled":cs,"data-close-button":!0,onClick:cs||!je?()=>{}:()=>{var dt;ze(),(dt=m.onDismiss)==null||dt.call(m,m)},className:Ua(k==null?void 0:k.closeButton,(a=m==null?void 0:m.classNames)==null?void 0:a.closeButton)},(i=W==null?void 0:W.close)!=null?i:qK):null,m.jsx||x.isValidElement(m.title)?m.jsx?m.jsx:typeof m.title=="function"?m.title():m.title:G.createElement(G.Fragment,null,Z||m.icon||m.promise?G.createElement("div",{"data-icon":"",className:Ua(k==null?void 0:k.icon,(o=m==null?void 0:m.classNames)==null?void 0:o.icon)},m.promise||m.type==="loading"&&!m.icon?m.icon||xf():null,m.type!=="loading"?m.
vendor: 6,706 bytes, line 561
561icon||(W==null?void 0:W[Z])||$K(Z):null):null,G.createElement("div",{"data-content":"",className:Ua(k==null?void 0:k.content,(l=m==null?void 0:m.classNames)==null?void 0:l.content)},G.createElement("div",{"data-title":"",className:Ua(k==null?void 0:k.title,(c=m==null?void 0:m.classNames)==null?void 0:c.title)},typeof m.title=="function"?m.title():m.title),m.description?G.createElement("div",{"data-description":"",className:Ua(U,Ee,k==null?void 0:k.description,(d=m==null?void 0:m.classNames)==null?void 0:d.description)},typeof m.description=="function"?m.description():m.description):null),x.isValidElement(m.cancel)?m.cancel:m.cancel&&Jg(m.cancel)?G.createElement("button",{"data-button":!0,"data-cancel":!0,style:m.cancelButtonStyle||M,onClick:dt=>{var zt,Ft;Jg(m.cancel)&&je&&((Ft=(zt=m.cancel).onClick)==null||Ft.call(zt,dt),ze())},className:Ua(k==null?void 0:k.cancelButton,(u=m==null?void 0:m.classNames)==null?void 0:u.cancelButton)},m.cancel.label):null,x.isValidElement(m.action)?m.action:m.action&&Jg(m.action)?G.createElement("button",{"data-button":!0,"data-action":!0,style:m.actionButtonStyle||D,onClick:dt=>{var zt,Ft;Jg(m.action)&&((Ft=(zt=m.action).onClick)==null||Ft.call(zt,dt),!dt.defaultPrevented&&ze())},className:Ua(k==null?void 0:k.actionButton,(h=m==null?void 0:m.classNames)==null?void 0:h.actionButton)},m.action.label):null))};function bT(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function oG(e,t){let r={};return[e,t].forEach((s,a)=>{let i=a===1,o=i?"--mobile-offset":"--offset",l=i?eG:JK;function c(d){["top","right","bottom","left"].forEach(u=>{r[`${o}-${u}`]=typeof d=="number"?`${d}px`:d})}typeof s=="number"||typeof s=="string"?c(s):typeof s=="object"?["top","right","bottom","left"].forEach(d=>{s[d]===void 0?r[`${o}-${d}`]=l:r[`${o}-${d}`]=typeof s[d]=="number"?`${s[d]}px`:s[d]}):c(l)}),r}var lG=x.forwardRef(function(e,t){let{invert:r,position:s="bottom-right",hotkey:a=["altKey","KeyT"],expand:i,closeButton:o,className:l,offset:c,mobileOffset:d,theme:u="light",richColors:h,duration:f,style:m,visibleToasts:g=ZK,toastOptions:p,dir:y=bT(),gap:v=rG,loadingIcon:j,icons:b,containerAriaLabel:_="Notifications",pauseWhenPageIsHidden:w}=e,[N,S]=G.useState([]),C=G.useMemo(()=>Array.from(new Set([s].concat(N.filter(Q=>Q.position).map(Q=>Q.position)))),[N,s]),[P,M]=G.useState([]),[D,A]=G.useState(!1),[U,F]=G.useState(!1),[L,$]=G.useState(u!=="system"?u:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),R=G.useRef(null),T=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),k=G.useRef(null),W=G.useRef(!1),q=G.useCallback(Q=>{S(ue=>{var X;return(X=ue.find(le=>le.id===Q.id))!=null&&X.delete||Os.dismiss(Q.id),ue.filter(({id:le})=>le!==Q.id)})},[]);return G.useEffect(()=>Os.subscribe(Q=>{if(Q.dismiss){S(ue=>ue.map(X=>X.id===Q.id?{...X,delete:!0}:X));return}setTimeout(()=>{$$.flushSync(()=>{S(ue=>{let X=ue.findIndex(le=>le.id===Q.id);return X!==-1?[...ue.slice(0,X),{...ue[X],...Q},...ue.slice(X+1)]:[Q,...ue]})})})}),[]),G.useEffect(()=>{if(u!=="system"){$(u);return}if(u==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;let Q=window.matchMedia("(prefers-color-scheme: dark)");try{Q.addEventListener("change",({matches:ue})=>{$(ue?"dark":"light")})}catch{Q.addListener(({matches:X})=>{try{$(X?"dark":"light")}catch(le){console.error(le)}})}},[u]),G.useEffect(()=>{N.length<=1&&A(!1)},[N]),G.useEffect(()=>{let Q=ue=>{var X,le;a.every(pe=>ue[pe]||ue.code===pe)&&(A(!0),(X=R.current)==null||X.focus()),ue.code==="Escape"&&(document.activeElement===R.current||(le=R.current)!=null&&le.contains(document.activeElement))&&A(!1)};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[a]),G.useEffect(()=>{if(R.current)return()=>{k.current&&(k.current.focus({preventScroll:!0}),k.current=null,W.current=!1)}},[R.current]),G.createElement("section",{ref:t,"aria-label":`${_} ${T}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},C.map((Q,ue)=>{var X;let[le,pe]=Q.split("-");return N.length?G.createElement("ol",{key:Q,dir:y==="auto"?bT():y,tabIndex:-1,ref:R,className:l,"data-sonner-toaster":!0,"data-theme":L,"data-y-position":le,"data-lifted":D&&N.length>1&&!i,"data-x-position":pe,style:{"--front-toast-height":`${((X=P[0])==null?void 0:X.height)||0}px`,"--width":`${tG}px`,"--gap":`${v}px`,...m,...oG(c,d)},onBlur:ce=>{W.current&&!ce.currentTarget.contains(ce.relatedTarget)&&(W.current=!1,k.current&&(k.current.focus({preventScroll:!0}),k.current=null))},onFocus:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||W.current||(W.current=!0,k.current=ce.relatedTarget)},onMouseEnter:()=>A(!0),onMouseMove:()=>A(!0),onMouseLeave:()=>{U||A(!1)},onDragEnd:()=>A(!1),onPointerDown:ce=>{ce.target instanceof HTMLElement&&ce.target.dataset.dismissible==="false"||F(!0)},onPointerUp:()=>F(!1)},N.filter(ce=>!ce.position&&ue===0||ce.position===Q).map((ce,se)=>{var oe,V;return G.createElement(iG,{key:ce.id,icons:b,index:se,toast:ce,defaultRichColors:h,duration:(oe=p==null?void 0:p.duration)!=null?oe:f,className:p==null?void 0:p.className,descriptionClassName:p==null?void 0:p.descriptionClassName,invert:r,visibleToasts:g,closeButton:(V=p==null?void 0:p.closeButton)!=null?V:o,interacting:U,position:Q,style:p==null?void 0:p.style,unstyled:p==null?void 0:p.unstyled,classNames:p==null?void 0:p.classNames,cancelButtonStyle:p==null?void 0:p.cancelButtonStyle,actionButtonStyle:p==null?void 0:p.actionButtonStyle,removeToast:q,toasts:N.filter(fe=>fe.position==ce.position),heights:P.filter(fe=>fe.position==ce.position),setHeights:M,expandByDefault:i,gap:v,loadingIcon:j,expanded:D,pauseWhenPageIsHidden:w,swipeDirections:e.swipeDirections})})):null}))});const cG=({...e})=>{const{theme:t="system"}=RK();return n.jsx(lG,{theme:t,className:"toaster group",closeButton:!0,toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",closeButton:"group-[.toast]:bg-background group-[.toast]:text-foreground group-[.toast]:border-border group-[.toast]:hover:bg-muted"}},...e})};function uo(e,t,{checkForDefaultPrevented:r=!0}={}
vendor: 15,119 bytes, line 561
561){return function(a){if(e==null||e(a),r===!1||!a.defaultPrevented)return t==null?void 0:t(a)}}var dG="DismissableLayer",q_="dismissableLayer.update",uG="dismissableLayer.pointerDownOutside",hG="dismissableLayer.focusOutside",wT,MI=x.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),DI=x.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:o,onDismiss:l,...c}=e,d=x.useContext(MI),[u,h]=x.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=x.useState({}),g=nt(t,S=>h(S)),p=Array.from(d.layers),[y]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),v=p.indexOf(y),j=u?p.indexOf(u):-1,b=d.layersWithOutsidePointerEventsDisabled.size>0,_=j>=v,w=pG(S=>{const C=S.target,P=[...d.branches].some(M=>M.contains(C));!_||P||(a==null||a(S),o==null||o(S),S.defaultPrevented||l==null||l())},f),N=gG(S=>{const C=S.target;[...d.branches].some(M=>M.contains(C))||(i==null||i(S),o==null||o(S),S.defaultPrevented||l==null||l())},f);return z$(S=>{j===d.layers.size-1&&(s==null||s(S),!S.defaultPrevented&&l&&(S.preventDefault(),l()))},f),x.useEffect(()=>{if(u)return r&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(wT=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(u)),d.layers.add(u),_T(),()=>{r&&d.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=wT)}},[u,f,r,d]),x.useEffect(()=>()=>{u&&(d.layers.delete(u),d.layersWithOutsidePointerEventsDisabled.delete(u),_T())},[u,d]),x.useEffect(()=>{const S=()=>m({});return document.addEventListener(q_,S),()=>document.removeEventListener(q_,S)},[]),n.jsx(We.div,{...c,ref:g,style:{pointerEvents:b?_?"auto":"none":void 0,...e.style},onFocusCapture:uo(e.onFocusCapture,N.onFocusCapture),onBlurCapture:uo(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:uo(e.onPointerDownCapture,w.onPointerDownCapture)})});DI.displayName=dG;var fG="DismissableLayerBranch",mG=x.forwardRef((e,t)=>{const r=x.useContext(MI),s=x.useRef(null),a=nt(t,s);return x.useEffect(()=>{const i=s.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),n.jsx(We.div,{...e,ref:a})});mG.displayName=fG;function pG(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e),s=x.useRef(!1),a=x.useRef(()=>{});return x.useEffect(()=>{const i=l=>{if(l.target&&!s.current){let c=function(){RI(uG,r,d,{discrete:!0})};const d={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=c,t.addEventListener("click",a.current,{once:!0})):c()}else t.removeEventListener("click",a.current);s.current=!1},o=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(o),t.removeEventListener("pointerdown",i),t.removeEventListener("click",a.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}function gG(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e),s=x.useRef(!1);return x.useEffect(()=>{const a=i=>{i.target&&!s.current&&RI(hG,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function _T(){const e=new CustomEvent(q_);document.dispatchEvent(e)}function RI(e,t,r,{discrete:s}){const a=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&a.addEventListener(e,t,{once:!0}),s?j0(a,i):a.dispatchEvent(i)}var xG=jS[" useId ".trim().toString()]||(()=>{}),vG=0;function ta(e){const[t,r]=x.useState(xG());return Ur(()=>{e||r(s=>s??String(vG++))},[e]),e||(t?`radix-${t}`:"")}const yG=["top","right","bottom","left"],ec=Math.min,Xs=Math.max,kv=Math.round,ex=Math.floor,Mi=e=>({x:e,y:e}),jG={left:"right",right:"left",bottom:"top",top:"bottom"},bG={start:"end",end:"start"};function W_(e,t,r){return Xs(e,ec(t,r))}function Fo(e,t){return typeof e=="function"?e(t):e}function Uo(e){return e.split("-")[0]}function qh(e){return e.split("-")[1]}function yC(e){return e==="x"?"y":"x"}function jC(e){return e==="y"?"height":"width"}const wG=new Set(["top","bottom"]);function ki(e){return wG.has(Uo(e))?"y":"x"}function bC(e){return yC(ki(e))}function _G(e,t,r){r===void 0&&(r=!1);const s=qh(e),a=bC(e),i=jC(a);let o=a==="x"?s===(r?"end":"start")?"right":"left":s==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(o=Pv(o)),[o,Pv(o)]}function NG(e){const t=Pv(e);return[H_(e),t,H_(t)]}function H_(e){return e.replace(/start|end/g,t=>bG[t])}const NT=["left","right"],ST=["right","left"],SG=["top","bottom"],CG=["bottom","top"];function kG(e,t,r){switch(e){case"top":case"bottom":return r?t?ST:NT:t?NT:ST;case"left":case"right":return t?SG:CG;default:return[]}}function PG(e,t,r,s){const a=qh(e);let i=kG(Uo(e),r==="start",s);return a&&(i=i.map(o=>o+"-"+a),t&&(i=i.concat(i.map(H_)))),i}function Pv(e){return e.replace(/left|right|bottom|top/g,t=>jG[t])}function TG(e){return{top:0,right:0,bottom:0,left:0,...e}}function $I(e){return typeof e!="number"?TG(e):{top:e,right:e,bottom:e,left:e}}function Tv(e){const{x:t,y:r,width:s,height:a}=e;return{width:s,height:a,top:r,left:t,right:t+s,bottom:r+a,x:t,y:r}}function CT(e,t,r){let{reference:s,floating:a}=e;const i=ki(t),o=bC(t),l=jC(o),c=Uo(t),d=i==="y",u=s.x+s.width/2-a.width/2,h=s.y+s.height/2-a.height/2,f=s[l]/2-a[l]/2;let m;switch(c){case"top":m={x:u,y:s.y-a.height};break;case"bottom":m={x:u,y:s.y+s.height};break;case"right":m={x:s.x+s.width,y:h};break;case"left":m={x:s.x-a.width,y:h};break;default:m={x:s.x,y:s.y}}switch(qh(t)){case"start":m[o]-=f*(r&&d?-1:1);break;case"end":m[o]+=f*(r&&d?-1:1);break}return m}const AG=async(e,t,r)=>{const{placement:s="bottom",strategy:a="absolute",middleware:i=[],platform:o}=r,l=i.filter(Boolean),c=await(o.isRTL==null?void 0:o.isRTL(t));let d=await o.getElementRects({reference:e,floating:t,strategy:a}),{x:u,y:h}=CT(d,s,c),f=s,m={},g=0;for(let p=0;p<l.length;p++){const{name:y,fn:v}=l[p],{x:j,y:b,data:_,reset:w}=await v({x:u,y:h,initialPlacement:s,placement:f,strategy:a,middlewareData:m,rects:d,platform:o,elements:{reference:e,floating:t}});u=j??u,h=b??h,m={...m,[y]:{...m[y],..._}},w&&g<=50&&(g++,typeof w=="object"&&(w.placement&&(f=w.placement),w.rects&&(d=w.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:a}):w.rects),{x:u,y:h}=CT(d,f,c)),p=-1)}return{x:u,y:h,placement:f,strategy:a,middlewareData:m}};async function Qm(e,t){var r;t===void 0&&(t={});const{x:s,y:a,platform:i,rects:o,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:h="floating",altBoundary:f=!1,padding:m=0}=Fo(t,e),g=$I(m),y=l[f?h==="floating"?"reference":"floating":h],v=Tv(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(y)))==null||r?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),j=h==="floating"?{x:s,y:a,width:o.floating.width,height:o.floating.height}:o.reference,b=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),_=await(i.isElement==null?void 0:i.isElement(b))?await(i.getScale==null?void 0:i.getScale(b))||{x:1,y:1}:{x:1,y:1},w=Tv(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:j,offsetParent:b,strategy:c}):j);return{top:(v.top-w.top+g.top)/_.y,bottom:(w.bottom-v.bottom+g.bottom)/_.y,left:(v.left-w.left+g.left)/_.x,right:(w.right-v.right+g.right)/_.x}}const EG=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:s,placement:a,rects:i,platform:o,elements:l,middlewareData:c}=t,{element:d,padding:u=0}=Fo(e,t)||{};if(d==null)return{};const h=$I(u),f={x:r,y:s},m=bC(a),g=jC(m),p=await o.getDimensions(d),y=m==="y",v=y?"top":"left",j=y?"bottom":"right",b=y?"clientHeight":"clientWidth",_=i.reference[g]+i.reference[m]-f[m]-i.floating[g],w=f[m]-i.reference[m],N=await(o.getOffsetParent==null?void 0:o.getOffsetParent(d));let S=N?N[b]:0;(!S||!await(o.isElement==null?void 0:o.isElement(N)))&&(S=l.floating[b]||i.floating[g]);const C=_/2-w/2,P=S/2-p[g]/2-1,M=ec(h[v],P),D=ec(h[j],P),A=M,U=S-p[g]-D,F=S/2-p[g]/2+C,L=W_(A,F,U),$=!c.arrow&&qh(a)!=null&&F!==L&&i.reference[g]/2-(F<A?M:D)-p[g]/2<0,R=$?F<A?F-A:F-U:0;return{[m]:f[m]+R,data:{[m]:L,centerOffset:F-L-R,...$&&{alignmentOffset:R}},reset:$}}}),OG=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,s;const{placement:a,middlewareData:i,rects:o,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:u=!0,crossAxis:h=!0,fallbackPlacements:f,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...y}=Fo(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const v=Uo(a),j=ki(l),b=Uo(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(d.floating)),w=f||(b||!p?[Pv(l)]:NG(l)),N=g!=="none";!f&&N&&w.push(...PG(l,p,g,_));const S=[l,...w],C=await Qm(t,y),P=[];let M=((s=i.flip)==null?void 0:s.overflows)||[];if(u&&P.push(C[v]),h){const F=_G(a,o,_);P.push(C[F[0]],C[F[1]])}if(M=[...M,{placement:a,overflows:P}],!P.every(F=>F<=0)){var D,A;const F=(((D=i.flip)==null?void 0:D.index)||0)+1,L=S[F];if(L&&(!(h==="alignment"?j!==ki(L):!1)||M.every(T=>T.overflows[0]>0&&ki(T.placement)===j)))return{data:{index:F,overflows:M},reset:{placement:L}};let $=(A=M.filter(R=>R.overflows[0]<=0).sort((R,T)=>R.overflows[1]-T.overflows[1])[0])==null?void 0:A.placement;if(!$)switch(m){case"bestFit":{var U;const R=(U=M.filter(T=>{if(N){const k=ki(T.placement);return k===j||k==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(k=>k>0).reduce((k,W)=>k+W,0)]).sort((T,k)=>T[1]-k[1])[0])==null?void 0:U[0];R&&($=R);break}case"initialPlacement":$=l;break}if(a!==$)return{reset:{placement:$}}}return{}}}};function kT(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function PT(e){return yG.some(t=>e[t]>=0)}const MG=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:s="referenceHidden",...a}=Fo(e,t);switch(s){case"referenceHidden":{const i=await Qm(t,{...a,elementContext:"reference"}),o=kT(i,r.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:PT(o)}}}case"escaped":{const i=await Qm(t,{...a,altBoundary:!0}),o=kT(i,r.floating);return{data:{escapedOffsets:o,escaped:PT(o)}}}default:return{}}}}},II=new Set(["left","top"]);async function DG(e,t){const{placement:r,platform:s,elements:a}=e,i=await(s.isRTL==null?void 0:s.isRTL(a.floating)),o=Uo(r),l=qh(r),c=ki(r)==="y",d=II.has(o)?-1:1,u=i&&c?-1:1,h=Fo(t,e);let{mainAxis:f,crossAxis:m,alignmentAxis:g}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),c?{x:m*u,y:f*d}:{x:f*d,y:m*u}}const RG=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,s;const{x:a,y:i,placement:o,middlewareData:l}=t,c=await DG(t,e);return o===((r=l.offset)==null?void 0:r.placement)&&(s=l.arrow)!=null&&s.alignmentOffset?{}:{x:a+c.x,y:i+c.y,data:{...c,placement:o}}}}},$G=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:s,placement:a}=t,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:v,y:j}=y;return{x:v,y:j}}},...c}=Fo(e,t),d={x:r,y:s},u=await Qm(t,c),h=ki(Uo(a)),f=yC(h);let m=d[f],g=d[h];if(i){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",j=m+u[y],b=m-u[v];m=W_(j,m,b)}if(o){const y=h==="y"?"top":"left",v=h==="y"?"bottom":"right",j=g+u[y],b=g-u[v];g=W_(j,g,b)}const p=l.fn({...t,[f]:m,[h]:g});return{...p,data:{x:p.x-r,y:p.y-s,enabled:{[f]:i,[h]:o}}}}}},IG=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:s,placement:a,rects:i,middlewareData:o}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=Fo(e,t),u={x:r,y:s},h=ki(a),f=yC(h);let m=u[f],g=u[h];const p=Fo(l,t),y=typeof p=="number"?{mainAxis:p,crossAxis:0}:{mainAxis:0,crossAxis:0,...p};if(c){const b=f==="y"?"height":"width",_=i.reference[f]-i.floating[b]+y.mainAxis,w=i.reference[f]+i.reference[b]-y.mainAxis;m<_?m=_:m>w&&(m=w)}if(d){var v,j;const b=f==="y"?"width":"height",_=II.has(Uo(a)),w=i.reference[h]-i.floating[b]+(_&&((v=o.offset)==null?void 0:v[h])||0)+(_?0:y.crossAxis),N=i.reference[h]+i.reference[b]+(_?0:((j=o.offset)==null?void 0:j[h])||0)-(_?y.crossAxis:0);g<w?g=w:g>N&&(g=N)}return{[f]:m,[h]:g}}}},LG=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,s;const{placement:a,rects:i,platform:o,elements:l}=t,{apply:c=()=>{},...d}=Fo(e,t),u=await Qm(t,d),h=Uo(a),f=qh(a),m=ki(a)==="y",{width:g,height:p}=i.floating;let y,v;h==="top"||h==="bottom"?(y=h,v=f===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(v=h,y=f==="end"?"top":"bottom");const j=p-u.top-u.bottom,b=g-u.left-u.right,_=ec(p-u[y],j),w=ec(g-u[v],b),N=!t.middlewareData.shift;let S=_,C=w;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(C=b),(s=t.middlewareData.shift)!=null&&s.enabled.y&&(S=j),N&&!f){const M=Xs(u.left,0),D=Xs(u.right,0),A=Xs(u.top,0),U=Xs(u.bottom,0);m?C=g-2*(M!==0||D!==0?M+D:Xs(u.left,u.right)):S=p-2*(A!==0||U!==0?A+U:Xs(u.top,u.bottom))}await c({...t,availableWidth:C,availableHeight:S});const P=await o.getDimensions(l.floating);return g!==P.width||p!==P.height?{reset:{rects:!0}}:{}}}};function C0(){return typeof window<"u"}function Wh(e){return LI(e)?(e.nodeName||"").toLowerCase():"#document"}function ra(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function qi(e){var t;return(t=(LI(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function LI(e){return C0()?e instanceof Node||e instanceof ra(e).Node:!1}function li(e){return C0()?e instanceof Element||e instanceof ra(e).Element:!1}function Li(e){return C0()?e instanceof HTMLElement||e instanceof ra(e).HTMLElement:!1}function TT(e){return!C0()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ra(e).ShadowRoot}const FG=new Set(["inline","contents"]);function sg(e){const{overflow:t,overflowX:r,overflowY:s,display:a}=ci(e);return/auto|scroll|overlay|hidden|clip/.test(t+s+r)&&!FG.has(a)}const UG=new Set(["table","td","th"]);function zG(e){return UG.has(Wh(e))}const BG=[":popover-open",":modal"];function k0(e){return BG.some(t=>{try{return e.matches(t)}catch{return!1}})}const qG=["transform","translate","scale","rotate","perspective"],WG=["transform","translate","scale","rotate","perspective","filter"],HG=["paint","layout","strict","content"];function wC(e){const t=_C(),r=li(e)?ci(e):e;return qG.some(s=>r[s]?r[s]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||WG.some(s=>(r.willChange||"").includes(s))||HG.some(s=>(r.contain||"").includes(s))}function VG(e){let t=tc(e);for(;Li(t)&&!rh(t);){if(wC(t))return t;if(k0(t))return null;t=tc(t)}return null}function _C(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}
vendor: 2,593 bytes, line 561
561const KG=new Set(["html","body","#document"]);function rh(e){return KG.has(Wh(e))}function ci(e){return ra(e).getComputedStyle(e)}function P0(e){return li(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tc(e){if(Wh(e)==="html")return e;const t=e.assignedSlot||e.parentNode||TT(e)&&e.host||qi(e);return TT(t)?t.host:t}function FI(e){const t=tc(e);return rh(t)?e.ownerDocument?e.ownerDocument.body:e.body:Li(t)&&sg(t)?t:FI(t)}function Xm(e,t,r){var s;t===void 0&&(t=[]),r===void 0&&(r=!0);const a=FI(e),i=a===((s=e.ownerDocument)==null?void 0:s.body),o=ra(a);if(i){const l=V_(o);return t.concat(o,o.visualViewport||[],sg(a)?a:[],l&&r?Xm(l):[])}return t.concat(a,Xm(a,[],r))}function V_(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function UI(e){const t=ci(e);let r=parseFloat(t.width)||0,s=parseFloat(t.height)||0;const a=Li(e),i=a?e.offsetWidth:r,o=a?e.offsetHeight:s,l=kv(r)!==i||kv(s)!==o;return l&&(r=i,s=o),{width:r,height:s,$:l}}function NC(e){return li(e)?e:e.contextElement}function Au(e){const t=NC(e);if(!Li(t))return Mi(1);const r=t.getBoundingClientRect(),{width:s,height:a,$:i}=UI(t);let o=(i?kv(r.width):r.width)/s,l=(i?kv(r.height):r.height)/a;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const GG=Mi(0);function zI(e){const t=ra(e);return!_C()||!t.visualViewport?GG:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function YG(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==ra(e)?!1:t}function fd(e,t,r,s){t===void 0&&(t=!1),r===void 0&&(r=!1);const a=e.getBoundingClientRect(),i=NC(e);let o=Mi(1);t&&(s?li(s)&&(o=Au(s)):o=Au(e));const l=YG(i,r,s)?zI(i):Mi(0);let c=(a.left+l.x)/o.x,d=(a.top+l.y)/o.y,u=a.width/o.x,h=a.height/o.y;if(i){const f=ra(i),m=s&&li(s)?ra(s):s;let g=f,p=V_(g);for(;p&&s&&m!==g;){const y=Au(p),v=p.getBoundingClientRect(),j=ci(p),b=v.left+(p.clientLeft+parseFloat(j.paddingLeft))*y.x,_=v.top+(p.clientTop+parseFloat(j.paddingTop))*y.y;c*=y.x,d*=y.y,u*=y.x,h*=y.y,c+=b,d+=_,g=ra(p),p=V_(g)}}return Tv({width:u,height:h,x:c,y:d})}function SC(e,t){const r=P0(e).scrollLeft;return t?t.left+r:fd(qi(e)).left+r}function BI(e,t,r){r===void 0&&(r=!1);const s=e.getBoundingClientRect(),a=s.left+t.scrollLeft-(r?0:SC(e,s)),i=s.top+t.scrollTop;return{x:a,y:i}}function QG(e){let{elements:t,rect:r,offsetParent:s,strategy:a}=e;const i=a==="fixed",o=qi(s),l=t?k0(t.floating):!1;if(s===o||l&&i)return r;let c={scrollLeft:0,scrollTop:0},d=Mi(1);const u=Mi(0),h=Li(s);if((h||!h&&!i)&&((Wh(s)!=="body"||sg(o))&&(c=P0(s)),Li(s))){const m=fd(s);
vendor: 5,435 bytes, line 561
561d=Au(s),u.x=m.x+s.clientLeft,u.y=m.y+s.clientTop}const f=o&&!h&&!i?BI(o,c,!0):Mi(0);return{width:r.width*d.x,height:r.height*d.y,x:r.x*d.x-c.scrollLeft*d.x+u.x+f.x,y:r.y*d.y-c.scrollTop*d.y+u.y+f.y}}function XG(e){return Array.from(e.getClientRects())}function ZG(e){const t=qi(e),r=P0(e),s=e.ownerDocument.body,a=Xs(t.scrollWidth,t.clientWidth,s.scrollWidth,s.clientWidth),i=Xs(t.scrollHeight,t.clientHeight,s.scrollHeight,s.clientHeight);let o=-r.scrollLeft+SC(e);const l=-r.scrollTop;return ci(s).direction==="rtl"&&(o+=Xs(t.clientWidth,s.clientWidth)-a),{width:a,height:i,x:o,y:l}}function JG(e,t){const r=ra(e),s=qi(e),a=r.visualViewport;let i=s.clientWidth,o=s.clientHeight,l=0,c=0;if(a){i=a.width,o=a.height;const d=_C();(!d||d&&t==="fixed")&&(l=a.offsetLeft,c=a.offsetTop)}return{width:i,height:o,x:l,y:c}}const eY=new Set(["absolute","fixed"]);function tY(e,t){const r=fd(e,!0,t==="fixed"),s=r.top+e.clientTop,a=r.left+e.clientLeft,i=Li(e)?Au(e):Mi(1),o=e.clientWidth*i.x,l=e.clientHeight*i.y,c=a*i.x,d=s*i.y;return{width:o,height:l,x:c,y:d}}function AT(e,t,r){let s;if(t==="viewport")s=JG(e,r);else if(t==="document")s=ZG(qi(e));else if(li(t))s=tY(t,r);else{const a=zI(e);s={x:t.x-a.x,y:t.y-a.y,width:t.width,height:t.height}}return Tv(s)}function qI(e,t){const r=tc(e);return r===t||!li(r)||rh(r)?!1:ci(r).position==="fixed"||qI(r,t)}function rY(e,t){const r=t.get(e);if(r)return r;let s=Xm(e,[],!1).filter(l=>li(l)&&Wh(l)!=="body"),a=null;const i=ci(e).position==="fixed";let o=i?tc(e):e;for(;li(o)&&!rh(o);){const l=ci(o),c=wC(o);!c&&l.position==="fixed"&&(a=null),(i?!c&&!a:!c&&l.position==="static"&&!!a&&eY.has(a.position)||sg(o)&&!c&&qI(e,o))?s=s.filter(u=>u!==o):a=l,o=tc(o)}return t.set(e,s),s}function nY(e){let{element:t,boundary:r,rootBoundary:s,strategy:a}=e;const o=[...r==="clippingAncestors"?k0(t)?[]:rY(t,this._c):[].concat(r),s],l=o[0],c=o.reduce((d,u)=>{const h=AT(t,u,a);return d.top=Xs(h.top,d.top),d.right=ec(h.right,d.right),d.bottom=ec(h.bottom,d.bottom),d.left=Xs(h.left,d.left),d},AT(t,l,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function sY(e){const{width:t,height:r}=UI(e);return{width:t,height:r}}function aY(e,t,r){const s=Li(t),a=qi(t),i=r==="fixed",o=fd(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const c=Mi(0);function d(){c.x=SC(a)}if(s||!s&&!i)if((Wh(t)!=="body"||sg(a))&&(l=P0(t)),s){const m=fd(t,!0,i,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else a&&d();i&&!s&&a&&d();const u=a&&!s&&!i?BI(a,l):Mi(0),h=o.left+l.scrollLeft-c.x-u.x,f=o.top+l.scrollTop-c.y-u.y;return{x:h,y:f,width:o.width,height:o.height}}function Ib(e){return ci(e).position==="static"}function ET(e,t){if(!Li(e)||ci(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return qi(e)===r&&(r=r.ownerDocument.body),r}function WI(e,t){const r=ra(e);if(k0(e))return r;if(!Li(e)){let a=tc(e);for(;a&&!rh(a);){if(li(a)&&!Ib(a))return a;a=tc(a)}return r}let s=ET(e,t);for(;s&&zG(s)&&Ib(s);)s=ET(s,t);return s&&rh(s)&&Ib(s)&&!wC(s)?r:s||VG(e)||r}const iY=async function(e){const t=this.getOffsetParent||WI,r=this.getDimensions,s=await r(e.floating);return{reference:aY(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}};function oY(e){return ci(e).direction==="rtl"}const lY={convertOffsetParentRelativeRectToViewportRelativeRect:QG,getDocumentElement:qi,getClippingRect:nY,getOffsetParent:WI,getElementRects:iY,getClientRects:XG,getDimensions:sY,getScale:Au,isElement:li,isRTL:oY};function HI(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function cY(e,t){let r=null,s;const a=qi(e);function i(){var l;clearTimeout(s),(l=r)==null||l.disconnect(),r=null}function o(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),i();const d=e.getBoundingClientRect(),{left:u,top:h,width:f,height:m}=d;if(l||t(),!f||!m)return;const g=ex(h),p=ex(a.clientWidth-(u+f)),y=ex(a.clientHeight-(h+m)),v=ex(u),b={rootMargin:-g+"px "+-p+"px "+-y+"px "+-v+"px",threshold:Xs(0,ec(1,c))||1};let _=!0;function w(N){const S=N[0].intersectionRatio;if(S!==c){if(!_)return o();S?o(!1,S):s=setTimeout(()=>{o(!1,1e-7)},1e3)}S===1&&!HI(d,e.getBoundingClientRect())&&o(),_=!1}try{r=new IntersectionObserver(w,{...b,root:a.ownerDocument})}catch{r=new IntersectionObserver(w,b)}r.observe(e)}return o(!0),i}function VI(e,t,r,s){s===void 0&&(s={});const{ancestorScroll:a=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=s,d=NC(e),u=a||i?[...d?Xm(d):[],...Xm(t)]:[];u.forEach(v=>{a&&v.addEventListener("scroll",r,{passive:!0}),i&&v.addEventListener("resize",r)});const h=d&&l?cY(d,r):null;let f=-1,m=null;o&&(m=new ResizeObserver(v=>{let[j]=v;j&&j.target===d&&m&&(m.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var b;(b=m)==null||b.observe(t)})),r()}),d&&!c&&m.observe(d),m.observe(t));let g,p=c?fd(e):null;c&&y();function y(){const v=fd(e);p&&!HI(p,v)&&r(),p=v,g=requestAnimationFrame(y)}return r(),()=>{var v;u.forEach(j=>{a&&j.removeEventListener("scroll",r),i&&j.removeEventListener("resize",r)}),h==null||h(),(v=m)==null||v.disconnect(),m=null,c&&cancelAnimationFrame(g)}}const dY=RG,uY=$G,hY=OG,fY=LG,mY=MG,OT=EG,pY=IG,gY=(e,t,r)=>{const s=new Map,a={platform:lY,...r},i={...a.platform,_c:s};return AG(e,t,{...a,platform:i})};var xY=typeof document<"u",vY=function(){},Yx=xY?x.useLayoutEffect:vY;function Av(e,t){if(e===t)return!0;
vendor: 3,174 bytes, line 561
561if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,s,a;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(s=r;s--!==0;)if(!Av(e[s],t[s]))return!1;return!0}if(a=Object.keys(e),r=a.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!{}.hasOwnProperty.call(t,a[s]))return!1;for(s=r;s--!==0;){const i=a[s];if(!(i==="_owner"&&e.$$typeof)&&!Av(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function KI(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MT(e,t){const r=KI(e);return Math.round(t*r)/r}function Lb(e){const t=x.useRef(e);return Yx(()=>{t.current=e}),t}function GI(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:s=[],platform:a,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,h]=x.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,m]=x.useState(s);Av(f,s)||m(s);const[g,p]=x.useState(null),[y,v]=x.useState(null),j=x.useCallback(T=>{T!==N.current&&(N.current=T,p(T))},[]),b=x.useCallback(T=>{T!==S.current&&(S.current=T,v(T))},[]),_=i||g,w=o||y,N=x.useRef(null),S=x.useRef(null),C=x.useRef(u),P=c!=null,M=Lb(c),D=Lb(a),A=Lb(d),U=x.useCallback(()=>{if(!N.current||!S.current)return;const T={placement:t,strategy:r,middleware:f};D.current&&(T.platform=D.current),gY(N.current,S.current,T).then(k=>{const W={...k,isPositioned:A.current!==!1};F.current&&!Av(C.current,W)&&(C.current=W,Ad.flushSync(()=>{h(W)}))})},[f,t,r,D,A]);Yx(()=>{d===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,h(T=>({...T,isPositioned:!1})))},[d]);const F=x.useRef(!1);Yx(()=>(F.current=!0,()=>{F.current=!1}),[]),Yx(()=>{if(_&&(N.current=_),w&&(S.current=w),_&&w){if(M.current)return M.current(_,w,U);U()}},[_,w,U,M,P]);const L=x.useMemo(()=>({reference:N,floating:S,setReference:j,setFloating:b}),[j,b]),$=x.useMemo(()=>({reference:_,floating:w}),[_,w]),R=x.useMemo(()=>{const T={position:r,left:0,top:0};if(!$.floating)return T;const k=MT($.floating,u.x),W=MT($.floating,u.y);return l?{...T,transform:"translate("+k+"px, "+W+"px)",...KI($.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:k,top:W}},[r,l,$.floating,u.x,u.y]);return x.useMemo(()=>({...u,update:U,refs:L,elements:$,floatingStyles:R}),[u,U,L,$,R])}const yY=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:s,padding:a}=typeof e=="function"?e(r):e;return s&&t(s)?s.current!=null?OT({element:s.current,padding:a}).fn(r):{}:s?OT({element:s,padding:a}).fn(r):{}}}},YI=(e,t)=>({...dY(e),options:[e,t]}),QI=(e,t)=>({...uY(e),options:[e,t]}),XI=(e,t)=>({...pY(e),options:[e,t]}),ZI=(e,t)=>({...hY(e),options:[e,t]}),JI=(e,t)=>({...fY(e),options:[e,t]}),eL=(e,t)=>({...mY(e),options:[e,t]}),tL=(e,t)=>({...yY(e),options:[e,t]});var jY="Arrow",rL=x.forwardRef((e,t)=>{const{children:r,width:s=10,height:a=5,...i}=e;return n.jsx(We.svg,{...i,ref:t,width:s,height:a,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:n.jsx("polygon",{points:"0,0 30,0 15,10"})})});rL.displayName=jY;var nL=rL;
vendor: 4,989 bytes, line 561
561function Hh(e){const[t,r]=x.useState(void 0);return Ur(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const s=new ResizeObserver(a=>{if(!Array.isArray(a)||!a.length)return;const i=a[0];let o,l;if("borderBoxSize"in i){const c=i.borderBoxSize,d=Array.isArray(c)?c[0]:c;o=d.inlineSize,l=d.blockSize}else o=e.offsetWidth,l=e.offsetHeight;r({width:o,height:l})});return s.observe(e,{box:"border-box"}),()=>s.unobserve(e)}else r(void 0)},[e]),t}var CC="Popper",[sL,aL]=Qr(CC),[bY,iL]=sL(CC),oL=e=>{const{__scopePopper:t,children:r}=e,[s,a]=x.useState(null);return n.jsx(bY,{scope:t,anchor:s,onAnchorChange:a,children:r})};oL.displayName=CC;var lL="PopperAnchor",cL=x.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:s,...a}=e,i=iL(lL,r),o=x.useRef(null),l=nt(t,o),c=x.useRef(null);return x.useEffect(()=>{const d=c.current;c.current=(s==null?void 0:s.current)||o.current,d!==c.current&&i.onAnchorChange(c.current)}),s?null:n.jsx(We.div,{...a,ref:l})});cL.displayName=lL;var kC="PopperContent",[wY,_Y]=sL(kC),dL=x.forwardRef((e,t)=>{var ce,se,oe,V,fe,ne;const{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:m="optimized",onPlaced:g,...p}=e,y=iL(kC,r),[v,j]=x.useState(null),b=nt(t,Ce=>j(Ce)),[_,w]=x.useState(null),N=Hh(_),S=(N==null?void 0:N.width)??0,C=(N==null?void 0:N.height)??0,P=s+(i!=="center"?"-"+i:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(d)?d:[d],A=D.length>0,U={padding:M,boundary:D.filter(SY),altBoundary:A},{refs:F,floatingStyles:L,placement:$,isPositioned:R,middlewareData:T}=GI({strategy:"fixed",placement:P,whileElementsMounted:(...Ce)=>VI(...Ce,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[YI({mainAxis:a+C,alignmentAxis:o}),c&&QI({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?XI():void 0,...U}),c&&ZI({...U}),JI({...U,apply:({elements:Ce,rects:Pe,availableWidth:he,availableHeight:ke})=>{const{width:Me,height:Je}=Pe.reference,Ke=Ce.floating.style;Ke.setProperty("--radix-popper-available-width",`${he}px`),Ke.setProperty("--radix-popper-available-height",`${ke}px`),Ke.setProperty("--radix-popper-anchor-width",`${Me}px`),Ke.setProperty("--radix-popper-anchor-height",`${Je}px`)}}),_&&tL({element:_,padding:l}),CY({arrowWidth:S,arrowHeight:C}),f&&eL({strategy:"referenceHidden",...U})]}),[k,W]=fL($),q=Sr(g);Ur(()=>{R&&(q==null||q())},[R,q]);const Q=(ce=T.arrow)==null?void 0:ce.x,ue=(se=T.arrow)==null?void 0:se.y,X=((oe=T.arrow)==null?void 0:oe.centerOffset)!==0,[le,pe]=x.useState();return Ur(()=>{v&&pe(window.getComputedStyle(v).zIndex)},[v]),n.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:R?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[(V=T.transformOrigin)==null?void 0:V.x,(fe=T.transformOrigin)==null?void 0:fe.y].join(" "),...((ne=T.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(wY,{scope:r,placedSide:k,onArrowChange:w,arrowX:Q,arrowY:ue,shouldHideArrow:X,children:n.jsx(We.div,{"data-side":k,"data-align":W,...p,ref:b,style:{...p.style,animation:R?void 0:"none"}})})})});dL.displayName=kC;var uL="PopperArrow",NY={top:"bottom",right:"left",bottom:"top",left:"right"},hL=x.forwardRef(function(t,r){const{__scopePopper:s,...a}=t,i=_Y(uL,s),o=NY[i.placedSide];return n.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:n.jsx(nL,{...a,ref:r,style:{...a.style,display:"block"}})})});hL.displayName=uL;function SY(e){return e!==null}var CY=e=>({name:"transformOrigin",options:e,fn(t){var y,v,j;const{placement:r,rects:s,middlewareData:a}=t,o=((y=a.arrow)==null?void 0:y.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,u]=fL(r),h={start:"0%",center:"50%",end:"100%"}[u],f=(((v=a.arrow)==null?void 0:v.x)??0)+l/2,m=(((j=a.arrow)==null?void 0:j.y)??0)+c/2;let g="",p="";return d==="bottom"?(g=o?h:`${f}px`,p=`${-c}px`):d==="top"?(g=o?h:`${f}px`,p=`${s.floating.height+c}px`):d==="right"?(g=`${-c}px`,p=o?h:`${m}px`):d==="left"&&(g=`${s.floating.width+c}px`,p=o?h:`${m}px`),{data:{x:g,y:p}}}});function fL(e){const[t,r="center"]=e.split("-");return[t,r]}var kY=oL,PY=cL,TY=dL,AY=hL;function EY(e,t){return x.useReducer((r,s)=>t[r][s]??r,e)}var mL=e=>{const{present:t,children:r}=e,s=OY(t),a=typeof r=="function"?r({present:s.isPresent}):x.Children.only(r),i=nt(s.ref,MY(a));return typeof r=="function"||s.isPresent?x.cloneElement(a,{ref:i}):null};mL.displayName="Presence";
vendor: 4,771 bytes, line 561
561function OY(e){const[t,r]=x.useState(),s=x.useRef(null),a=x.useRef(e),i=x.useRef("none"),o=e?"mounted":"unmounted",[l,c]=EY(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return x.useEffect(()=>{const d=tx(s.current);i.current=l==="mounted"?d:"none"},[l]),Ur(()=>{const d=s.current,u=a.current;if(u!==e){const f=i.current,m=tx(d);e?c("MOUNT"):m==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&f!==m?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,c]),Ur(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,h=m=>{const p=tx(s.current).includes(CSS.escape(m.animationName));if(m.target===t&&p&&(c("ANIMATION_END"),!a.current)){const y=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=y)})}},f=m=>{m.target===t&&(i.current=tx(s.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",h),t.addEventListener("animationend",h),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",h),t.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:x.useCallback(d=>{s.current=d?getComputedStyle(d):null,r(d)},[])}}function tx(e){return(e==null?void 0:e.animationName)||"none"}function MY(e){var s,a;let t=(s=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:s.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(a=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:a.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var[T0,VDe]=Qr("Tooltip",[aL]),A0=aL(),pL="TooltipProvider",DY=700,K_="tooltip.open",[RY,PC]=T0(pL),gL=e=>{const{__scopeTooltip:t,delayDuration:r=DY,skipDelayDuration:s=300,disableHoverableContent:a=!1,children:i}=e,o=x.useRef(!0),l=x.useRef(!1),c=x.useRef(0);return x.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),n.jsx(RY,{scope:t,isOpenDelayedRef:o,delayDuration:r,onOpen:x.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:x.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,s)},[s]),isPointerInTransitRef:l,onPointerInTransitChange:x.useCallback(d=>{l.current=d},[]),disableHoverableContent:a,children:i})};gL.displayName=pL;var Zm="Tooltip",[$Y,E0]=T0(Zm),xL=e=>{const{__scopeTooltip:t,children:r,open:s,defaultOpen:a,onOpenChange:i,disableHoverableContent:o,delayDuration:l}=e,c=PC(Zm,e.__scopeTooltip),d=A0(t),[u,h]=x.useState(null),f=ta(),m=x.useRef(0),g=o??c.disableHoverableContent,p=l??c.delayDuration,y=x.useRef(!1),[v,j]=Bs({prop:s,defaultProp:a??!1,onChange:S=>{S?(c.onOpen(),document.dispatchEvent(new CustomEvent(K_))):c.onClose(),i==null||i(S)},caller:Zm}),b=x.useMemo(()=>v?y.current?"delayed-open":"instant-open":"closed",[v]),_=x.useCallback(()=>{window.clearTimeout(m.current),m.current=0,y.current=!1,j(!0)},[j]),w=x.useCallback(()=>{window.clearTimeout(m.current),m.current=0,j(!1)},[j]),N=x.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{y.current=!0,j(!0),m.current=0},p)},[p,j]);return x.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),n.jsx(kY,{...d,children:n.jsx($Y,{scope:t,contentId:f,open:v,stateAttribute:b,trigger:u,onTriggerChange:h,onTriggerEnter:x.useCallback(()=>{c.isOpenDelayedRef.current?N():_()},[c.isOpenDelayedRef,N,_]),onTriggerLeave:x.useCallback(()=>{g?w():(window.clearTimeout(m.current),m.current=0)},[w,g]),onOpen:_,onClose:w,disableHoverableContent:g,children:r})})};xL.displayName=Zm;var G_="TooltipTrigger",vL=x.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,a=E0(G_,r),i=PC(G_,r),o=A0(r),l=x.useRef(null),c=nt(t,l,a.onTriggerChange),d=x.useRef(!1),u=x.useRef(!1),h=x.useCallback(()=>d.current=!1,[]);return x.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),n.jsx(PY,{asChild:!0,...o,children:n.jsx(We.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...s,ref:c,onPointerMove:uo(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!i.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:uo(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:uo(e.onPointerDown,()=>{a.open&&a.onClose(),d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:uo(e.onFocus,()=>{d.current||a.onOpen()}),onBlur:uo(e.onBlur,a.onClose),onClick:uo(e.onClick,a.onClose)})})});vL.displayName=G_;var IY="TooltipPortal",[KDe,LY]=T0(IY,{forceMount:void 0}),nh="TooltipContent",yL=x.forwardRef((e,t)=>
vendor: 3,013 bytes, line 561
561{const r=LY(nh,e.__scopeTooltip),{forceMount:s=r.forceMount,side:a="top",...i}=e,o=E0(nh,e.__scopeTooltip);return n.jsx(mL,{present:s||o.open,children:o.disableHoverableContent?n.jsx(jL,{side:a,...i,ref:t}):n.jsx(FY,{side:a,...i,ref:t})})}),FY=x.forwardRef((e,t)=>{const r=E0(nh,e.__scopeTooltip),s=PC(nh,e.__scopeTooltip),a=x.useRef(null),i=nt(t,a),[o,l]=x.useState(null),{trigger:c,onClose:d}=r,u=a.current,{onPointerInTransitChange:h}=s,f=x.useCallback(()=>{l(null),h(!1)},[h]),m=x.useCallback((g,p)=>{const y=g.currentTarget,v={x:g.clientX,y:g.clientY},j=WY(v,y.getBoundingClientRect()),b=HY(v,j),_=VY(p.getBoundingClientRect()),w=GY([...b,..._]);l(w),h(!0)},[h]);return x.useEffect(()=>()=>f(),[f]),x.useEffect(()=>{if(c&&u){const g=y=>m(y,u),p=y=>m(y,c);return c.addEventListener("pointerleave",g),u.addEventListener("pointerleave",p),()=>{c.removeEventListener("pointerleave",g),u.removeEventListener("pointerleave",p)}}},[c,u,m,f]),x.useEffect(()=>{if(o){const g=p=>{const y=p.target,v={x:p.clientX,y:p.clientY},j=(c==null?void 0:c.contains(y))||(u==null?void 0:u.contains(y)),b=!KY(v,o);j?f():b&&(f(),d())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[c,u,o,d,f]),n.jsx(jL,{...e,ref:i})}),[UY,zY]=T0(Zm,{isInside:!1}),BY=U$("TooltipContent"),jL=x.forwardRef((e,t)=>{const{__scopeTooltip:r,children:s,"aria-label":a,onEscapeKeyDown:i,onPointerDownOutside:o,...l}=e,c=E0(nh,r),d=A0(r),{onClose:u}=c;return x.useEffect(()=>(document.addEventListener(K_,u),()=>document.removeEventListener(K_,u)),[u]),x.useEffect(()=>{if(c.trigger){const h=f=>{const m=f.target;m!=null&&m.contains(c.trigger)&&u()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,u]),n.jsx(DI,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:h=>h.preventDefault(),onDismiss:u,children:n.jsxs(TY,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[n.jsx(BY,{children:s}),n.jsx(UY,{scope:r,isInside:!0,children:n.jsx(r7,{id:c.contentId,role:"tooltip",children:a||s})})]})})});yL.displayName=nh;var bL="TooltipArrow",qY=x.forwardRef((e,t)=>{const{__scopeTooltip:r,...s}=e,a=A0(r);return zY(bL,r).isInside?null:n.jsx(AY,{...a,...s,ref:t})});qY.displayName=bL;function WY(e,t){const r=Math.abs(t.top-e.y),s=Math.abs(t.bottom-e.y),a=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,s,a,i)){case i:return"left";case a:return"right";case r:return"top";case s:return"bottom";default:throw new Error("unreachable")}}function HY(e,t,r=5){const s=[];
561switch(t){case"top":s.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":s.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":s.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":s.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return s}function VY(e){const{top:t,right:r,bottom:s,left:a}=e;return[{x:a,y:t},{x:r,y:t},{x:r,y:s},{x:a,y:s}]}function KY(e,t){const{x:r,y:s}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],c=t[o],d=l.x,u=l.y,h=c.x,f=c.y;u>s!=f>s&&r<(h-d)*(s-u)/(f-u)+d&&(a=!a)}return a}function GY(e){const t=e.slice();return t.sort((r,s)=>r.x<s.x?-1:r.x>s.x?1:r.y<s.y?-1:r.y>s.y?1:0),YY(t)}function YY(e){if(e.length<=1)return e.slice();const t=[];for(let s=0;s<e.length;s++){const a=e[s];for(;t.length>=2;){const i=t[t.length-1],o=t[t.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))t.pop();else break}t.push(a)}t.pop();const r=[];for(let s=e.length-1;s>=0;s--){const a=e[s];for(;r.length>=2;){const i=r[r.length-1],o=r[r.length-2];if((i.x-o.x)*(a.y-o.y)>=(i.y-o.y)*(a.x-o.x))r.pop();else break}r.push(a)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var QY=gL,XY=xL,ZY=vL,wL=yL;const Eu=QY,vo=XY,yo=ZY,Pi=x.forwardRef(({className:e,sideOffset:t=4,...r},s)=>n.jsx(wL,{ref:s,sideOffset:t,className:we("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));Pi.displayName=wL.displayName;var Vh=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},md=typeof window>"u"||"Deno"in globalThis;function xs(){}function JY(e,t){return typeof e=="function"?e(t):e}function Y_(e){return typeof e=="number"&&e>=0&&e!==1/0}function _L(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Hl(e,t){return typeof e=="function"?e(t):e}function xa(e,t){return typeof e=="function"?e(t):e}function DT(e,t){const{type:r="all",exact:s,fetchStatus:a,predicate:i,queryKey:o,stale:l}=e;if(o){if(s){if(t.queryHash!==TC(o,t.options))return!1}else if(!Jm(t.queryKey,o))return!1}if(r!=="all"){const c=t.isActive();if(r==="active"&&!c||r==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||a&&a!==t.state.fetchStatus||i&&!i(t))}function RT(e,t){const{exact:r,status:s,predicate:a,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(pd(t.options.mutationKey)!==pd(i))return!1}else if(!Jm(t.options.mutationKey,i))return!1}return!(s&&t.state.status!==s||a&&!a(t))}function TC(e,t){return((t==null?void 0:t.queryKeyHashFn)||pd)(e)}function pd(e){return JSON.stringify(e,(t,r)=>Q_(r)?Object.keys(r).sort().reduce((s,a)=>(s[a]=r[a],s),{}):r)}function Jm(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Jm(e[r],t[r])):!1}function NL(e,t){if(e===t)return e;const r=$T(e)&&$T(t);if(r||Q_(e)&&Q_(t)){const s=r?e:Object.keys(e),a=s.length,i=r?t:Object.keys(t),o=i.length,l=r?[]:{},c=new Set(s);let d=0;for(let u=0;u<o;u++){const h=r?u:i[u];(!r&&c.has(h)||r)&&e[h]===void 0&&t[h]===void 0?(l[h]=void 0,d++):(l[h]=NL(e[h],t[h]),l[h]===e[h]&&e[h]!==void 0&&d++)}return a===o&&d===a?e:l}return t}function Ev(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function $T(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Q_(e){if(!IT(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!IT(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function IT(e){return Object.prototype.toString.call(e)==="[object Object]"}function eQ(e){return new Promise(t=>{setTimeout(t,e)})}function X_(e,t,r){return typeof r.structuralSharing=="function"?r.structuralSharing(e,t):r.structuralSharing!==!1?NL(e,t):t}function tQ(e,t,r=0){const s=[...e,t];return r&&s.length>r?s.slice(1):s}function rQ(e,t,r=0){const s=[t,...e];return r&&s.length>r?s.slice(0,-1):s}var AC=Symbol();function SL(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===AC?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function CL(e,t){return typeof e=="function"?e(...t):!!e}var Kc,wl,Iu,mD,nQ=(mD=class extends Vh{constructor(){super();ot(this,Kc);ot(this,wl);ot(this,Iu);Ge(this,Iu,t=>{if(!md&&window.addEventListener){const r=()=>t();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ae(this,wl)||this.setEventListener(ae(this,Iu))}onUnsubscribe(){var t;this.hasListeners()||((t=ae(this,wl))==null||t.call(this),Ge(this,wl,void 0))}setEventListener(t){var r;Ge(this,Iu,t),(r=ae(this,wl))==null||r.call(this),Ge(this,wl,t(s=>{typeof s=="boolean"?this.setFocused(s):this.onFocus()}))}setFocused(t){ae(this,Kc)!==t&&(Ge(this,Kc,t),this.onFocus())}onFocus(){const t=this.isFocused();
vendor: 4,942 bytes, line 561
561this.listeners.forEach(r=>{r(t)})}isFocused(){var t;return typeof ae(this,Kc)=="boolean"?ae(this,Kc):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Kc=new WeakMap,wl=new WeakMap,Iu=new WeakMap,mD),EC=new nQ,Lu,_l,Fu,pD,sQ=(pD=class extends Vh{constructor(){super();ot(this,Lu,!0);ot(this,_l);ot(this,Fu);Ge(this,Fu,t=>{if(!md&&window.addEventListener){const r=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",s)}}})}onSubscribe(){ae(this,_l)||this.setEventListener(ae(this,Fu))}onUnsubscribe(){var t;this.hasListeners()||((t=ae(this,_l))==null||t.call(this),Ge(this,_l,void 0))}setEventListener(t){var r;Ge(this,Fu,t),(r=ae(this,_l))==null||r.call(this),Ge(this,_l,t(this.setOnline.bind(this)))}setOnline(t){ae(this,Lu)!==t&&(Ge(this,Lu,t),this.listeners.forEach(s=>{s(t)}))}isOnline(){return ae(this,Lu)}},Lu=new WeakMap,_l=new WeakMap,Fu=new WeakMap,pD),Ov=new sQ;function Z_(){let e,t;const r=new Promise((a,i)=>{e=a,t=i});r.status="pending",r.catch(()=>{});function s(a){Object.assign(r,a),delete r.resolve,delete r.reject}return r.resolve=a=>{s({status:"fulfilled",value:a}),e(a)},r.reject=a=>{s({status:"rejected",reason:a}),t(a)},r}function aQ(e){return Math.min(1e3*2**e,3e4)}function kL(e){return(e??"online")==="online"?Ov.isOnline():!0}var PL=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Fb(e){return e instanceof PL}function TL(e){let t=!1,r=0,s=!1,a;const i=Z_(),o=p=>{var y;s||(f(new PL(p)),(y=e.abort)==null||y.call(e))},l=()=>{t=!0},c=()=>{t=!1},d=()=>EC.isFocused()&&(e.networkMode==="always"||Ov.isOnline())&&e.canRun(),u=()=>kL(e.networkMode)&&e.canRun(),h=p=>{var y;s||(s=!0,(y=e.onSuccess)==null||y.call(e,p),a==null||a(),i.resolve(p))},f=p=>{var y;s||(s=!0,(y=e.onError)==null||y.call(e,p),a==null||a(),i.reject(p))},m=()=>new Promise(p=>{var y;a=v=>{(s||d())&&p(v)},(y=e.onPause)==null||y.call(e)}).then(()=>{var p;a=void 0,s||(p=e.onContinue)==null||p.call(e)}),g=()=>{if(s)return;let p;const y=r===0?e.initialPromise:void 0;try{p=y??e.fn()}catch(v){p=Promise.reject(v)}Promise.resolve(p).then(h).catch(v=>{var N;if(s)return;const j=e.retry??(md?0:3),b=e.retryDelay??aQ,_=typeof b=="function"?b(r,v):b,w=j===!0||typeof j=="number"&&r<j||typeof j=="function"&&j(r,v);if(t||!w){f(v);return}r++,(N=e.onFail)==null||N.call(e,r,v),eQ(_).then(()=>d()?void 0:m()).then(()=>{t?f(v):g()})})};return{promise:i,cancel:o,continue:()=>(a==null||a(),i),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?g():m().then(g),i)}}var iQ=e=>setTimeout(e,0);function oQ(){let e=[],t=0,r=l=>{l()},s=l=>{l()},a=iQ;const i=l=>{t?e.push(l):a(()=>{r(l)})},o=()=>{const l=e;e=[],l.length&&a(()=>{s(()=>{l.forEach(c=>{r(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||o()}return c},batchCalls:l=>(...c)=>{i(()=>{l(...c)})},schedule:i,setNotifyFunction:l=>{r=l},setBatchNotifyFunction:l=>{s=l},setScheduler:l=>{a=l}}}var gn=oQ(),Gc,gD,AL=(gD=class{constructor(){ot(this,Gc)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Y_(this.gcTime)&&Ge(this,Gc,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(md?1/0:5*60*1e3))}clearGcTimeout(){ae(this,Gc)&&(clearTimeout(ae(this,Gc)),Ge(this,Gc,void 0))}},Gc=new WeakMap,gD),Uu,Yc,ga,Qc,Xn,Hp,Xc,Ha,ao,xD,lQ=(xD=class extends AL{constructor(t){super();ot(this,Ha);ot(this,Uu);ot(this,Yc);ot(this,ga);ot(this,Qc);ot(this,Xn);ot(this,Hp);ot(this,Xc);Ge(this,Xc,!1),Ge(this,Hp,t.defaultOptions),this.setOptions(t.options),this.observers=[],Ge(this,Qc,t.client),Ge(this,ga,ae(this,Qc).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,Ge(this,Uu,cQ(this.options)),this.state=t.state??ae(this,Uu),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=ae(this,Xn))==null?void 0:t.promise}setOptions(t){this.options={...ae(this,Hp),...t},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ae(this,ga).remove(this)}setData(t,r){const s=X_(this.state.data,t,this.options);return bt(this,Ha,ao).call(this,{data:s,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),s}setState(t,r){bt(this,Ha,ao).call(this,{type:"setState",state:t,setStateOptions:r})}cancel(t){var s,a;const r=(s=ae(this,Xn))==null?void 0:s.promise;return(a=ae(this,Xn))==null||a.cancel(t),r?r.then(xs).catch(xs):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ae(this,Uu))}isActive(){return this.observers.some(t=>xa(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===AC||this.state.dataUpdateCount+this.state.errorUpdate
561Count===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Hl(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!_L(this.state.dataUpdatedAt,t)}onFocus(){var r;const t=this.observers.find(s=>s.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(r=ae(this,Xn))==null||r.continue()}onOnline(){var r;const t=this.observers.find(s=>s.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(r=ae(this,Xn))==null||r.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),ae(this,ga).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(ae(this,Xn)&&(ae(this,Xc)?ae(this,Xn).cancel({revert:!0}):ae(this,Xn).cancelRetry()),this.scheduleGc()),ae(this,ga).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||bt(this,Ha,ao).call(this,{type:"invalidate"})}fetch(t,r){var d,u,h;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(ae(this,Xn))return ae(this,Xn).continueRetry(),ae(this,Xn).promise}if(t&&this.setOptions(t),!this.options.queryFn){const f=this.observers.find(m=>m.options.queryFn);f&&this.setOptions(f.options)}const s=new AbortController,a=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(Ge(this,Xc,!0),s.signal)})},i=()=>{const f=SL(this.options,r),g=(()=>{const p={client:ae(this,Qc),queryKey:this.queryKey,meta:this.meta};return a(p),p})();return Ge(this,Xc,!1),this.options.persister?this.options.persister(f,g,this):f(g)},l=(()=>{const f={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ae(this,Qc),state:this.state,fetchFn:i};return a(f),f})();(d=this.options.behavior)==null||d.onFetch(l,this),Ge(this,Yc,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&bt(this,Ha,ao).call(this,{type:"fetch",meta:(h=l.fetchOptions)==null?void 0:h.meta});const c=f=>{var m,g,p,y;Fb(f)&&f.silent||bt(this,Ha,ao).call(this,{type:"error",error:f}),Fb(f)||((g=(m=ae(this,ga).config).onError)==null||g.call(m,f,this),(y=(p=ae(this,ga).config).onSettled)==null||y.call(p,this.state.data,f,this)),this.scheduleGc()};return Ge(this,Xn,TL({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,abort:s.abort.bind(s),onSuccess:f=>{var m,g,p,y;if(f===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(f)}catch(v){c(v);return}(g=(m=ae(this,ga).config).onSuccess)==null||g.call(m,f,this),(y=(p=ae(this,ga).config).onSettled)==null||y.call(p,f,this.state.error,this),this.scheduleGc()},onError:c,onFail:(f,m)=>{bt(this,Ha,ao).call(this,{type:"failed",failureCount:f,error:m})},onPause:()=>{bt(this,Ha,ao).call(this,{type:"pause"})},onContinue:()=>{bt(this,Ha,ao).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0})),ae(this,Xn).start()}},Uu=new WeakMap,Yc=new WeakMap,ga=new WeakMap,Qc=new WeakMap,Xn=new WeakMap,Hp=new WeakMap,Xc=new WeakMap,Ha=new WeakSet,ao=function(t){const r=s=>{switch(t.type){case"failed":return{...s,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...EL(s.data,this.options),fetchMeta:t.meta??null};case"success":return Ge(this,Yc,void 0),{...s,data:t.data,dataUpdateCount:s.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const a=t.error;return Fb(a)&&a.revert&&ae(this,Yc)?{...ae(this,Yc),fetchStatus:"idle"}
vendor: 5,129 bytes, line 561
561:{...s,error:a,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...t.state}}};this.state=r(this.state),gn.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),ae(this,ga).notify({query:this,type:"updated",action:t})})},xD);function EL(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:kL(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function cQ(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,s=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?s??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var wi,vD,dQ=(vD=class extends Vh{constructor(t={}){super();ot(this,wi);this.config=t,Ge(this,wi,new Map)}build(t,r,s){const a=r.queryKey,i=r.queryHash??TC(a,r);let o=this.get(i);return o||(o=new lQ({client:t,queryKey:a,queryHash:i,options:t.defaultQueryOptions(r),state:s,defaultOptions:t.getQueryDefaults(a)}),this.add(o)),o}add(t){ae(this,wi).has(t.queryHash)||(ae(this,wi).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const r=ae(this,wi).get(t.queryHash);r&&(t.destroy(),r===t&&ae(this,wi).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){gn.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return ae(this,wi).get(t)}getAll(){return[...ae(this,wi).values()]}find(t){const r={exact:!0,...t};return this.getAll().find(s=>DT(r,s))}findAll(t={}){const r=this.getAll();return Object.keys(t).length>0?r.filter(s=>DT(t,s)):r}notify(t){gn.batch(()=>{this.listeners.forEach(r=>{r(t)})})}onFocus(){gn.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){gn.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},wi=new WeakMap,vD),_i,ms,Zc,Ni,cl,yD,uQ=(yD=class extends AL{constructor(t){super();ot(this,Ni);ot(this,_i);ot(this,ms);ot(this,Zc);this.mutationId=t.mutationId,Ge(this,ms,t.mutationCache),Ge(this,_i,[]),this.state=t.state||OL(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){ae(this,_i).includes(t)||(ae(this,_i).push(t),this.clearGcTimeout(),ae(this,ms).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){Ge(this,_i,ae(this,_i).filter(r=>r!==t)),this.scheduleGc(),ae(this,ms).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){ae(this,_i).length||(this.state.status==="pending"?this.scheduleGc():ae(this,ms).remove(this))}continue(){var t;return((t=ae(this,Zc))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var i,o,l,c,d,u,h,f,m,g,p,y,v,j,b,_,w,N,S,C;const r=()=>{bt(this,Ni,cl).call(this,{type:"continue"})};Ge(this,Zc,TL({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(P,M)=>{bt(this,Ni,cl).call(this,{type:"failed",failureCount:P,error:M})},onPause:()=>{bt(this,Ni,cl).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ae(this,ms).canRun(this)}));const s=this.state.status==="pending",a=!ae(this,Zc).canStart();try{if(s)r();else{bt(this,Ni,cl).call(this,{type:"pending",variables:t,isPaused:a}),await((o=(i=ae(this,ms).config).onMutate)==null?void 0:o.call(i,t,this));const M=await((c=(l=this.options).onMutate)==null?void 0:c.call(l,t));M!==this.state.context&&bt(this,Ni,cl).call(this,{type:"pending",context:M,variables:t,isPaused:a})}const P=await ae(this,Zc).start();return await((u=(d=ae(this,ms).config).onSuccess)==null?void 0:u.call(d,P,t,this.state.context,this)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,P,t,this.state.context)),await((g=(m=ae(this,ms).config).onSettled)==null?void 0:g.call(m,P,null,this.state.variables,this.state.context,this)),await((y=(p=this.options).onSettled)==null?void 0:y.call(p,P,null,t,this.state.context)),bt(this,Ni,cl).call(this,{type:"success",data:P}),P}catch(P){try{throw await((j=(v=ae(this,ms).config).onError)==null?void 0:j.call(v,P,t,this.state.context,this)),await((_=(b=this.options).onError)==null?void 0:_.call(b,P,t,this.state.context)),await((N=(w=ae(this,ms).config).onSettled)==null?void 0:N.call(w,void 0,P,this.state.variables,this.state.context,this)),await((C=(S=this.options).onSettled)==null?void 0:C.call(S,void 0,P,t,this.state.context)),P}finally{bt(this,Ni,cl).call(this,{type:"error",error:P})}}finally{ae(this,ms).runNext(this)}}},_i=new WeakMap,ms=new WeakMap,Zc=new WeakMap,Ni=new WeakSet,cl=function(t){const r=s=>{switch(t.type){case"failed":return{...s,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};
561case"pending":return{...s,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...s,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:t.error,failureCount:s.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=r(this.state),gn.batch(()=>{ae(this,_i).forEach(s=>{s.onMutationUpdate(t)}),ae(this,ms).notify({mutation:this,type:"updated",action:t})})},yD);function OL(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ho,Va,Vp,jD,hQ=(jD=class extends Vh{constructor(t={}){super();ot(this,ho);ot(this,Va);ot(this,Vp);this.config=t,Ge(this,ho,new Set),Ge(this,Va,new Map),Ge(this,Vp,0)}build(t,r,s){const a=new uQ({mutationCache:this,mutationId:++Mg(this,Vp)._,options:t.defaultMutationOptions(r),state:s});return this.add(a),a}add(t){ae(this,ho).add(t);const r=rx(t);if(typeof r=="string"){const s=ae(this,Va).get(r);s?s.push(t):ae(this,Va).set(r,[t])}this.notify({type:"added",mutation:t})}remove(t){if(ae(this,ho).delete(t)){const r=rx(t);if(typeof r=="string"){const s=ae(this,Va).get(r);if(s)if(s.length>1){const a=s.indexOf(t);a!==-1&&s.splice(a,1)}else s[0]===t&&ae(this,Va).delete(r)}}this.notify({type:"removed",mutation:t})}canRun(t){const r=rx(t);if(typeof r=="string"){const s=ae(this,Va).get(r),a=s==null?void 0:s.find(i=>i.state.status==="pending");return!a||a===t}else return!0}runNext(t){var s;const r=rx(t);if(typeof r=="string"){const a=(s=ae(this,Va).get(r))==null?void 0:s.find(i=>i!==t&&i.state.isPaused);return(a==null?void 0:a.continue())??Promise.resolve()}else return Promise.resolve()}clear(){gn.batch(()=>{ae(this,ho).forEach(t=>{this.notify({type:"removed",mutation:t})}),ae(this,ho).clear(),ae(this,Va).clear()})}getAll(){return Array.from(ae(this,ho))}find(t){const r={exact:!0,...t};return this.getAll().find(s=>RT(r,s))}findAll(t={}){return this.getAll().filter(r=>RT(t,r))}notify(t){gn.batch(()=>{this.listeners.forEach(r=>{r(t)})})}resumePausedMutations(){const t=this.getAll().filter(r=>
vendor: 9,355 bytes, line 561
561r.state.isPaused);return gn.batch(()=>Promise.all(t.map(r=>r.continue().catch(xs))))}},ho=new WeakMap,Va=new WeakMap,Vp=new WeakMap,jD);function rx(e){var t;return(t=e.options.scope)==null?void 0:t.id}function LT(e){return{onFetch:(t,r)=>{var u,h,f,m,g;const s=t.options,a=(f=(h=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,i=((m=t.state.data)==null?void 0:m.pages)||[],o=((g=t.state.data)==null?void 0:g.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let p=!1;const y=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},v=SL(t.options,t.fetchOptions),j=async(b,_,w)=>{if(p)return Promise.reject();if(_==null&&b.pages.length)return Promise.resolve(b);const S=(()=>{const D={client:t.client,queryKey:t.queryKey,pageParam:_,direction:w?"backward":"forward",meta:t.options.meta};return y(D),D})(),C=await v(S),{maxPages:P}=t.options,M=w?rQ:tQ;return{pages:M(b.pages,C,P),pageParams:M(b.pageParams,_,P)}};if(a&&i.length){const b=a==="backward",_=b?fQ:FT,w={pages:i,pageParams:o},N=_(s,w);l=await j(w,N,b)}else{const b=e??i.length;do{const _=c===0?o[0]??s.initialPageParam:FT(s,l);if(c>0&&_==null)break;l=await j(l,_),c++}while(c<b)}return l};t.options.persister?t.fetchFn=()=>{var p,y;return(y=(p=t.options).persister)==null?void 0:y.call(p,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r)}:t.fetchFn=d}}}function FT(e,{pages:t,pageParams:r}){const s=t.length-1;return t.length>0?e.getNextPageParam(t[s],t,r[s],r):void 0}function fQ(e,{pages:t,pageParams:r}){var s;return t.length>0?(s=e.getPreviousPageParam)==null?void 0:s.call(e,t[0],t,r[0],r):void 0}var Hr,Nl,Sl,zu,Bu,Cl,qu,Wu,bD,mQ=(bD=class{constructor(e={}){ot(this,Hr);ot(this,Nl);ot(this,Sl);ot(this,zu);ot(this,Bu);ot(this,Cl);ot(this,qu);ot(this,Wu);Ge(this,Hr,e.queryCache||new dQ),Ge(this,Nl,e.mutationCache||new hQ),Ge(this,Sl,e.defaultOptions||{}),Ge(this,zu,new Map),Ge(this,Bu,new Map),Ge(this,Cl,0)}mount(){Mg(this,Cl)._++,ae(this,Cl)===1&&(Ge(this,qu,EC.subscribe(async e=>{e&&(await this.resumePausedMutations(),ae(this,Hr).onFocus())})),Ge(this,Wu,Ov.subscribe(async e=>{e&&(await this.resumePausedMutations(),ae(this,Hr).onOnline())})))}unmount(){var e,t;Mg(this,Cl)._--,ae(this,Cl)===0&&((e=ae(this,qu))==null||e.call(this),Ge(this,qu,void 0),(t=ae(this,Wu))==null||t.call(this),Ge(this,Wu,void 0))}isFetching(e){return ae(this,Hr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return ae(this,Nl).findAll({...e,status:"pending"}).length}getQueryData(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=ae(this,Hr).get(t.queryHash))==null?void 0:r.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=ae(this,Hr).build(this,t),s=r.state.data;return s===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Hl(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(s))}getQueriesData(e){return ae(this,Hr).findAll(e).map(({queryKey:t,state:r})=>{const s=r.data;return[t,s]})}setQueryData(e,t,r){const s=this.defaultQueryOptions({queryKey:e}),a=ae(this,Hr).get(s.queryHash),i=a==null?void 0:a.state.data,o=JY(t,i);if(o!==void 0)return ae(this,Hr).build(this,s).setData(o,{...r,manual:!0})}setQueriesData(e,t,r){return gn.batch(()=>ae(this,Hr).findAll(e).map(({queryKey:s})=>[s,this.setQueryData(s,t,r)]))}getQueryState(e){var r;const t=this.defaultQueryOptions({queryKey:e});return(r=ae(this,Hr).get(t.queryHash))==null?void 0:r.state}removeQueries(e){const t=ae(this,Hr);gn.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=ae(this,Hr);return gn.batch(()=>(r.findAll(e).forEach(s=>{s.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},s=gn.batch(()=>ae(this,Hr).findAll(e).map(a=>a.cancel(r)));return Promise.all(s).then(xs).catch(xs)}invalidateQueries(e,t={}){return gn.batch(()=>(ae(this,Hr).findAll(e).forEach(r=>{r.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},s=gn.batch(()=>ae(this,Hr).findAll(e).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let i=a.fetch(void 0,r);return r.throwOnError||(i=i.catch(xs)),a.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(s).then(xs)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=ae(this,Hr).build(this,t);return r.isStaleByTime(Hl(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(xs).catch(xs)}fetchInfiniteQuery(e){return e.behavior=LT(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(xs).catch(xs)}ensureInfiniteQueryData(e){return e.behavior=LT(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ov.isOnline()?ae(this,Nl).resumePausedMutations():Promise.resolve()}getQueryCache(){return ae(this,Hr)}getMutationCache(){return ae(this,Nl)}getDefaultOptions(){return ae(this,Sl)}setDefaultOptions(e){Ge(this,Sl,e)}setQueryDefaults(e,t){ae(this,zu).set(pd(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...ae(this,zu).values()],r={};return t.forEach(s=>{Jm(e,s.queryKey)&&Object.assign(r,s.defaultOptions)}),r}setMutationDefaults(e,t){ae(this,Bu).set(pd(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...ae(this,Bu).values()],r={};return t.forEach(s=>{Jm(e,s.mutationKey)&&Object.assign(r,s.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...ae(this,Sl).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=TC(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===AC&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...ae(this,Sl).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){ae(this,Hr).clear(),ae(this,Nl).clear()}},Hr=new WeakMap,Nl=new WeakMap,Sl=new WeakMap,zu=new WeakMap,Bu=new WeakMap,Cl=new WeakMap,qu=new WeakMap,Wu=new WeakMap,bD),Ts,Rt,Kp,ps,Jc,Hu,kl,Pl,Gp,Vu,Ku,ed,td,Tl,Gu,nr,Zf,J_,eN,tN,rN,nN,sN,aN,ML,wD,pQ=(wD=class extends Vh{constructor(t,r){super();ot(this,nr);ot(this,Ts);ot(this,Rt);ot(this,Kp);ot(this,ps);ot(this,Jc);ot(this,Hu);ot(this,kl);ot(this,Pl);ot(this,Gp);ot(this,Vu);ot(this,Ku);ot(this,ed);ot(this,td);ot(this,Tl);ot(this,Gu,new Set);this.options=r,Ge(this,Ts,t),Ge(this,Pl,null),Ge(this,kl,Z_()),this.options.experimental_prefetchInRender||ae(this,kl).reject(new Error("experimental_prefetchInRender feature flag is not enabled")),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(ae(this,Rt).addObserver(this),UT(ae(this,Rt),this.options)?bt(this,nr,Zf).call(this):this.updateResult(),bt(this,nr,rN).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return iN(ae(this,Rt),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return iN(ae(this,Rt),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,bt(this,nr,nN).call(this),bt(this,nr,sN).call(this),ae(this,Rt).removeObserver(this)}setOptions(t){const r=this.options,s=ae(this,Rt);if(this.options=ae(this,Ts).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof xa(this.options.enabled,ae(this,Rt))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");bt(this,nr,aN).call(this),ae(this,Rt).setOptions(this.options),r._defaulted&&!Ev(this.options,r)&&ae(this,Ts).getQueryCache().notify({type:"observerOptionsUpdated",query:ae(this,Rt),observer:this});const a=this.hasListeners();a&&zT(ae(this,Rt),s,this.options,r)&&bt(this,nr,Zf).call(this),this.updateResult(),a&&(ae(this,Rt)!==s||xa(this.options.enabled,ae(this,Rt))!==xa(r.enabled,ae(this,Rt))||Hl(this.options.staleTime,ae(this,Rt))!==Hl(r.staleTime,ae(this,Rt)))&&bt(this,nr,J_).call(this);const i=bt(this,nr,eN).call(this);a&&(ae(this,Rt)!==s||xa(this.options.enabled,ae(this,Rt))!==xa(r.enabled,ae(this,Rt))||i!==ae(this,Tl))&&bt(this,nr,tN).call(this,i)}getOptimisticResult(t){const r=ae(this,Ts).getQueryCache().build(ae(this,Ts),t),s=this.createResult(r,t);return xQ(this,s)&&(Ge(this,ps,s),Ge(this,Hu,this.options),Ge(this,Jc,ae(this,Rt).state)),s}getCurrentResult(){return ae(this,ps)}trackResult(t,r){return new Proxy(t,{get:(s,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(s,a))})}trackProp(t){ae(this,Gu).add(t)}getCurrentQuery(){return ae(this,Rt)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const r=ae(this,Ts).defaultQueryOptions(t),s=ae(this,Ts).getQueryCache().build(ae(this,Ts),r);return s.fetch().then(()=>this.createResult(s,r))}fetch(t){return bt(this,nr,Zf).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),ae(this,ps)))}createResult(t,r){var P;
vendor: 2,404 bytes, line 561
561const s=ae(this,Rt),a=this.options,i=ae(this,ps),o=ae(this,Jc),l=ae(this,Hu),d=t!==s?t.state:ae(this,Kp),{state:u}=t;let h={...u},f=!1,m;if(r._optimisticResults){const M=this.hasListeners(),D=!M&&UT(t,r),A=M&&zT(t,s,r,a);(D||A)&&(h={...h,...EL(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle")}let{error:g,errorUpdatedAt:p,status:y}=h;m=h.data;let v=!1;if(r.placeholderData!==void 0&&m===void 0&&y==="pending"){let M;i!=null&&i.isPlaceholderData&&r.placeholderData===(l==null?void 0:l.placeholderData)?(M=i.data,v=!0):M=typeof r.placeholderData=="function"?r.placeholderData((P=ae(this,Ku))==null?void 0:P.state.data,ae(this,Ku)):r.placeholderData,M!==void 0&&(y="success",m=X_(i==null?void 0:i.data,M,r),f=!0)}if(r.select&&m!==void 0&&!v)if(i&&m===(o==null?void 0:o.data)&&r.select===ae(this,Gp))m=ae(this,Vu);else try{Ge(this,Gp,r.select),m=r.select(m),m=X_(i==null?void 0:i.data,m,r),Ge(this,Vu,m),Ge(this,Pl,null)}catch(M){Ge(this,Pl,M)}ae(this,Pl)&&(g=ae(this,Pl),m=ae(this,Vu),p=Date.now(),y="error");const j=h.fetchStatus==="fetching",b=y==="pending",_=y==="error",w=b&&j,N=m!==void 0,C={status:y,fetchStatus:h.fetchStatus,isPending:b,isSuccess:y==="success",isError:_,isInitialLoading:w,isLoading:w,data:m,dataUpdatedAt:h.dataUpdatedAt,error:g,errorUpdatedAt:p,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:h.dataUpdateCount>0||h.errorUpdateCount>0,isFetchedAfterMount:h.dataUpdateCount>d.dataUpdateCount||h.errorUpdateCount>d.errorUpdateCount,isFetching:j,isRefetching:j&&!b,isLoadingError:_&&!N,isPaused:h.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:_&&N,isStale:OC(t,r),refetch:this.refetch,promise:ae(this,kl),isEnabled:xa(r.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const M=U=>{C.status==="error"?U.reject(C.error):C.data!==void 0&&U.resolve(C.data)},D=()=>{const U=Ge(this,kl,C.promise=Z_());M(U)},A=ae(this,kl);switch(A.status){case"pending":t.queryHash===s.queryHash&&M(A);break;case"fulfilled":(C.status==="error"||C.data!==A.value)&&D();break;case"rejected":(C.status!=="error"||C.error!==A.reason)&&D();break}}return C}updateResult(){const t=ae(this,ps),r=this.createResult(ae(this,Rt),this.options);if(Ge(this,Jc,ae(this,Rt).state),Ge(this,Hu,this.options),ae(this,Jc).data!==void 0&&Ge(this,Ku,ae(this,Rt)),Ev(r,t))return;Ge(this,ps,r);const s=()=>
vendor: 4,759 bytes, line 561
561{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,i=typeof a=="function"?a():a;if(i==="all"||!i&&!ae(this,Gu).size)return!0;const o=new Set(i??ae(this,Gu));return this.options.throwOnError&&o.add("error"),Object.keys(ae(this,ps)).some(l=>{const c=l;return ae(this,ps)[c]!==t[c]&&o.has(c)})};bt(this,nr,ML).call(this,{listeners:s()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&bt(this,nr,rN).call(this)}},Ts=new WeakMap,Rt=new WeakMap,Kp=new WeakMap,ps=new WeakMap,Jc=new WeakMap,Hu=new WeakMap,kl=new WeakMap,Pl=new WeakMap,Gp=new WeakMap,Vu=new WeakMap,Ku=new WeakMap,ed=new WeakMap,td=new WeakMap,Tl=new WeakMap,Gu=new WeakMap,nr=new WeakSet,Zf=function(t){bt(this,nr,aN).call(this);let r=ae(this,Rt).fetch(this.options,t);return t!=null&&t.throwOnError||(r=r.catch(xs)),r},J_=function(){bt(this,nr,nN).call(this);const t=Hl(this.options.staleTime,ae(this,Rt));if(md||ae(this,ps).isStale||!Y_(t))return;const s=_L(ae(this,ps).dataUpdatedAt,t)+1;Ge(this,ed,setTimeout(()=>{ae(this,ps).isStale||this.updateResult()},s))},eN=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ae(this,Rt)):this.options.refetchInterval)??!1},tN=function(t){bt(this,nr,sN).call(this),Ge(this,Tl,t),!(md||xa(this.options.enabled,ae(this,Rt))===!1||!Y_(ae(this,Tl))||ae(this,Tl)===0)&&Ge(this,td,setInterval(()=>{(this.options.refetchIntervalInBackground||EC.isFocused())&&bt(this,nr,Zf).call(this)},ae(this,Tl)))},rN=function(){bt(this,nr,J_).call(this),bt(this,nr,tN).call(this,bt(this,nr,eN).call(this))},nN=function(){ae(this,ed)&&(clearTimeout(ae(this,ed)),Ge(this,ed,void 0))},sN=function(){ae(this,td)&&(clearInterval(ae(this,td)),Ge(this,td,void 0))},aN=function(){const t=ae(this,Ts).getQueryCache().build(ae(this,Ts),this.options);if(t===ae(this,Rt))return;const r=ae(this,Rt);Ge(this,Rt,t),Ge(this,Kp,t.state),this.hasListeners()&&(r==null||r.removeObserver(this),t.addObserver(this))},ML=function(t){gn.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(ae(this,ps))}),ae(this,Ts).getQueryCache().notify({query:ae(this,Rt),type:"observerResultsUpdated"})})},wD);function gQ(e,t){return xa(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function UT(e,t){return gQ(e,t)||e.state.data!==void 0&&iN(e,t,t.refetchOnMount)}function iN(e,t,r){if(xa(t.enabled,e)!==!1&&Hl(t.staleTime,e)!=="static"){const s=typeof r=="function"?r(e):r;return s==="always"||s!==!1&&OC(e,t)}return!1}function zT(e,t,r,s){return(e!==t||xa(s.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&OC(e,r)}function OC(e,t){return xa(t.enabled,e)!==!1&&e.isStaleByTime(Hl(t.staleTime,e))}function xQ(e,t){return!Ev(e.getCurrentResult(),t)}var Al,El,As,fo,Eo,Qx,oN,_D,vQ=(_D=class extends Vh{constructor(r,s){super();ot(this,Eo);ot(this,Al);ot(this,El);ot(this,As);ot(this,fo);Ge(this,Al,r),this.setOptions(s),this.bindMethods(),bt(this,Eo,Qx).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(r){var a;const s=this.options;this.options=ae(this,Al).defaultMutationOptions(r),Ev(this.options,s)||ae(this,Al).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ae(this,As),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&pd(s.mutationKey)!==pd(this.options.mutationKey)?this.reset():((a=ae(this,As))==null?void 0:a.state.status)==="pending"&&ae(this,As).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ae(this,As))==null||r.removeObserver(this)}onMutationUpdate(r){bt(this,Eo,Qx).call(this),bt(this,Eo,oN).call(this,r)}getCurrentResult(){return ae(this,El)}reset(){var r;(r=ae(this,As))==null||r.removeObserver(this),Ge(this,As,void 0),bt(this,Eo,Qx).call(this),bt(this,Eo,oN).call(this)}mutate(r,s){var a;return Ge(this,fo,s),(a=ae(this,As))==null||a.removeObserver(this),Ge(this,As,ae(this,Al).getMutationCache().build(ae(this,Al),this.options)),ae(this,As).addObserver(this),ae(this,As).execute(r)}},Al=new WeakMap,El=new WeakMap,As=new WeakMap,fo=new WeakMap,Eo=new WeakSet,Qx=function(){var s;const r=((s=ae(this,As))==null?void 0:s.state)??OL();Ge(this,El,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},oN=function(r){gn.batch(()=>{var s,a,i,o,l,c,d,u;if(ae(this,fo)&&this.hasListeners()){const h=ae(this,El).variables,f=ae(this,El).context;(r==null?void 0:r.type)==="success"?((a=(s=ae(this,fo)).onSuccess)==null||a.call(s,r.data,h,f),(o=(i=ae(this,fo)).onSettled)==null||o.call(i,r.data,null,h,f)):(r==null?void 0:r.type)==="error"&&((c=(l=ae(this,fo)).onError)==null||c.call(l,r.error,h,f),(u=(d=ae(this,fo)).onSettled)==null||u.call(d,void 0,r.error,h,f))}
561this.listeners.forEach(h=>{h(ae(this,El))})})},_D),DL=x.createContext(void 0),Et=e=>{const t=x.useContext(DL);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},yQ=({client:e,children:t})=>(x.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),n.jsx(DL.Provider,{value:e,children:t})),RL=x.createContext(!1),jQ=()=>x.useContext(RL);RL.Provider;function bQ(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var wQ=x.createContext(bQ()),_Q=()=>x.useContext(wQ),NQ=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},SQ=e=>{x.useEffect(()=>{e.clearReset()},[e])},CQ=({result:e,errorResetBoundary:t,throwOnError:r,query:s,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&s&&(a&&e.data===void 0||CL(r,[e.error,s])),kQ=e=>{if(e.suspense){const t=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>t(r(...s)):t(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},PQ=(e,t)=>e.isLoading&&e.isFetching&&!t,TQ=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,BT=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function AQ(e,t,r){var h,f,m,g,p;const s=jQ(),a=_Q(),i=Et(),o=i.defaultQueryOptions(e);(f=(h=i.getDefaultOptions().queries)==null?void 0:h._experimental_beforeQuery)==null||f.call(h,o),o._optimisticResults=s?"isRestoring":"optimistic",kQ(o),NQ(o,a),SQ(a);const l=!i.getQueryCache().get(o.queryHash),[c]=x.useState(()=>new t(i,o)),d=c.getOptimisticResult(o),u=!s&&e.subscribed!==!1;if(x.useSyncExternalStore(x.useCallback(y=>{const v=u?c.subscribe(gn.batchCalls(y)):xs;return c.updateResult(),v},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),x.useEffect(()=>{c.setOptions(o)},[o,c]),TQ(o,d))throw BT(o,c,a);if(CQ({result:d,errorResetBoundary:a,throwOnError:o.throwOnError,query:i.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw d.error;if((g=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_afterQuery)==null||g.call(m,o,d),o.experimental_prefetchInRender&&!md&&PQ(d,s)){const y=l?BT(o,c,a):(p=i.getQueryCache().get(o.queryHash))==null?void 0:p.promise;y==null||y.catch(xs).finally(()=>{c.updateResult()})}return o.notifyOnChangeProps?d:c.trackResult(d)}function Ve(e,t){return AQ(e,pQ)}function mt(e,t){const r=Et(),[s]=x.useState(()=>new vQ(r,e));x.useEffect(()=>{s.setOptions(e)},[s,e]);
vendor: 5,675 bytes, lines 561-570
561const a=x.useSyncExternalStore(x.useCallback(o=>s.subscribe(gn.batchCalls(o)),[s]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),i=x.useCallback((o,l)=>{s.mutate(o,l).catch(xs)},[s]);if(a.error&&CL(s.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:i,mutateAsync:a.mutate}}/**
562 * @remix-run/router v1.23.0
563 *
564 * Copyright (c) Remix Software Inc.
565 *
566 * This source code is licensed under the MIT license found in the
567 * LICENSE.md file in the root directory of this source tree.
568 *
569 * @license MIT
570 */function ep(){return ep=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},ep.apply(this,arguments)}var Rl;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(Rl||(Rl={}));const qT="popstate";function EQ(e){e===void 0&&(e={});function t(s,a){let{pathname:i,search:o,hash:l}=s.location;return lN("",{pathname:i,search:o,hash:l},a.state&&a.state.usr||null,a.state&&a.state.key||"default")}function r(s,a){return typeof a=="string"?a:Mv(a)}return MQ(t,r,null,e)}function Lr(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function $L(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function OQ(){return Math.random().toString(36).substr(2,8)}function WT(e,t){return{usr:e.state,key:e.key,idx:t}}function lN(e,t,r,s){return r===void 0&&(r=null),ep({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?Kh(t):t,{state:r,key:t&&t.key||s||OQ()})}function Mv(e){let{pathname:t="/",search:r="",hash:s=""}=e;return r&&r!=="?"&&(t+=r.charAt(0)==="?"?r:"?"+r),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function Kh(e){let t={};if(e){let r=e.indexOf("#");r>=0&&(t.hash=e.substr(r),e=e.substr(0,r));let s=e.indexOf("?");s>=0&&(t.search=e.substr(s),e=e.substr(0,s)),e&&(t.pathname=e)}return t}function MQ(e,t,r,s){s===void 0&&(s={});let{window:a=document.defaultView,v5Compat:i=!1}=s,o=a.history,l=Rl.Pop,c=null,d=u();d==null&&(d=0,o.replaceState(ep({},o.state,{idx:d}),""));function u(){return(o.state||{idx:null}).idx}function h(){l=Rl.Pop;let y=u(),v=y==null?null:y-d;d=y,c&&c({action:l,location:p.location,delta:v})}function f(y,v){l=Rl.Push;let j=lN(p.location,y,v);d=u()+1;let b=WT(j,d),_=p.createHref(j);try{o.pushState(b,"",_)}catch(w){if(w instanceof DOMException&&w.name==="DataCloneError")throw w;a.location.assign(_)}i&&c&&c({action:l,location:p.location,delta:1})}function m(y,v){l=Rl.Replace;let j=lN(p.location,y,v);d=u();let b=WT(j,d),_=p.createHref(j);o.replaceState(b,"",_),i&&c&&c({action:l,location:p.location,delta:0})}function g(y){let v=a.location.origin!=="null"?a.location.origin:a.location.href,j=typeof y=="string"?y:Mv(y);return j=j.replace(/ $/,"%20"),Lr(v,"No window.location.(origin|href) available to create URL for href: "+j),new URL(j,v)}let p={get action(){return l},get location(){return e(a,o)},listen(y){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(qT,h),c=y,()=>{a.removeEventListener(qT,h),c=null}},createHref(y){return t(a,y)},createURL:g,encodeLocation(y){let v=g(y);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:f,replace:m,go(y){return o.go(y)}};return p}var HT;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(HT||(HT={}));function DQ(e,t,r){return r===void 0&&(r="/"),RQ(e,t,r,!1)}function RQ(e,t,r,s){let a=typeof t=="string"?Kh(t):t,i=sh(a.pathname||"/",r);if(i==null)return null;let o=IL(e);$Q(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let d=KQ(i);l=HQ(o[c],d,s)}return l}function IL(e,t,r,s){t===void 0&&(t=[]),r===void 0&&(r=[]),s===void 0&&(s="");let a=(i,o,l)=>{let c={relativePath:l===void 0?i.path||"":l,caseSensitive:i.caseSensitive===!0,childrenIndex:o,route:i};c.relativePath.startsWith("/")&&(Lr(c.relativePath.startsWith(s),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+s+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(s.length));let d=Vl([s,c.relativePath]),u=r.concat(c);i.children&&i.children.length>0&&(Lr(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),IL(i.children,t,u,d)),!(i.path==null&&!i.index)&&t.push({path:d,score:qQ(d,i.index),routesMeta:u})};return e.forEach((i,o)=>{var l;if(i.path===""||!((l=i.path)!=null&&l.includes("?")))a(i,o);else for(let c of LL(i.path))a(i,o,c)}),t}function LL(e){let t=e.split("/");if(t.length===0)return[];let[r,...s]=t,a=r.endsWith("?"),i=r.replace(/\?$/,"");if(s.length===0)return a?[i,""]:[i];let o=LL(s.join("/")),l=[];return l.push(...o.map(c=>c===""?i:[i,c].join("/"))),a&&l.push(...o),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function $Q(e){e.sort((t,r)=>t.score!==r.score?r.score-t.score:WQ(t.routesMeta.map(s=>s.childrenIndex),r.routesMeta.map(s=>s.childrenIndex)))}const IQ=/^:[\w-]+$/,LQ=3,FQ=2,UQ=1,zQ=10,BQ=-2,VT=e=>e==="*";function qQ(e,t){let r=e.split("/"),s=r.length;return r.some(VT)&&(s+=BQ),t&&(s+=FQ),r.filter(a=>!VT(a)).reduce((a,i)=>a+(IQ.test(i)?LQ:i===""?UQ:zQ),s)}function WQ(e,t){return e.length===t.length&&e.slice(0,-1).every((s,a)=>s===t[a])?e[e.length-1]-t[t.length-1]:0}function HQ(e,t,r){let{routesMeta:s}=e,a={},i="/",o=[];for(let l=0;l<s.length;++l){let c=s[l],d=l===s.length-1,u=i==="/"?t:t.slice(i.length)||"/",h=Dv({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),f=c.route;if(!h&&d&&r&&!s[s.length-1].route.index&&(h=Dv({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!h)return null;
vendor: 13,096 bytes, lines 570-588
570Object.assign(a,h.params),o.push({params:a,pathname:Vl([i,h.pathname]),pathnameBase:XQ(Vl([i,h.pathnameBase])),route:f}),h.pathnameBase!=="/"&&(i=Vl([i,h.pathnameBase]))}return o}function Dv(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[r,s]=VQ(e.path,e.caseSensitive,e.end),a=t.match(r);if(!a)return null;let i=a[0],o=i.replace(/(.)\/+$/,"$1"),l=a.slice(1);return{params:s.reduce((d,u,h)=>{let{paramName:f,isOptional:m}=u;if(f==="*"){let p=l[h]||"";o=i.slice(0,i.length-p.length).replace(/(.)\/+$/,"$1")}const g=l[h];return m&&!g?d[f]=void 0:d[f]=(g||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:o,pattern:e}}function VQ(e,t,r){t===void 0&&(t=!1),r===void 0&&(r=!0),$L(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let s=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,l,c)=>(s.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(s.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),s]}function KQ(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $L(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function sh(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,s=e.charAt(r);return s&&s!=="/"?null:e.slice(r)||"/"}function GQ(e,t){t===void 0&&(t="/");let{pathname:r,search:s="",hash:a=""}=typeof e=="string"?Kh(e):e;return{pathname:r?r.startsWith("/")?r:YQ(r,t):t,search:ZQ(s),hash:JQ(a)}}function YQ(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(a=>{a===".."?r.length>1&&r.pop():a!=="."&&r.push(a)}),r.length>1?r.join("/"):"/"}function Ub(e,t,r,s){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(s)+"].  Please separate it out to the ")+("`to."+r+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function QQ(e){return e.filter((t,r)=>r===0||t.route.path&&t.route.path.length>0)}function MC(e,t){let r=QQ(e);return t?r.map((s,a)=>a===r.length-1?s.pathname:s.pathnameBase):r.map(s=>s.pathnameBase)}function DC(e,t,r,s){s===void 0&&(s=!1);let a;typeof e=="string"?a=Kh(e):(a=ep({},e),Lr(!a.pathname||!a.pathname.includes("?"),Ub("?","pathname","search",a)),Lr(!a.pathname||!a.pathname.includes("#"),Ub("#","pathname","hash",a)),Lr(!a.search||!a.search.includes("#"),Ub("#","search","hash",a)));let i=e===""||a.pathname==="",o=i?"/":a.pathname,l;if(o==null)l=r;else{let h=t.length-1;if(!s&&o.startsWith("..")){let f=o.split("/");for(;f[0]==="..";)f.shift(),h-=1;a.pathname=f.join("/")}l=h>=0?t[h]:"/"}let c=GQ(a,l),d=o&&o!=="/"&&o.endsWith("/"),u=(i||o===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const Vl=e=>e.join("/").replace(/\/\/+/g,"/"),XQ=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),ZQ=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,JQ=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function eX(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const FL=["post","put","patch","delete"];new Set(FL);const tX=["get",...FL];new Set(tX);/**
571 * React Router v6.30.1
572 *
573 * Copyright (c) Remix Software Inc.
574 *
575 * This source code is licensed under the MIT license found in the
576 * LICENSE.md file in the root directory of this source tree.
577 *
578 * @license MIT
579 */function tp(){return tp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},tp.apply(this,arguments)}const O0=x.createContext(null),UL=x.createContext(null),Xo=x.createContext(null),M0=x.createContext(null),Wi=x.createContext({outlet:null,matches:[],isDataRoute:!1}),zL=x.createContext(null);function rX(e,t){let{relative:r}=t===void 0?{}:t;Gh()||Lr(!1);let{basename:s,navigator:a}=x.useContext(Xo),{hash:i,pathname:o,search:l}=D0(e,{relative:r}),c=o;return s!=="/"&&(c=o==="/"?s:Vl([s,o])),a.createHref({pathname:c,search:l,hash:i})}function Gh(){return x.useContext(M0)!=null}function Zo(){return Gh()||Lr(!1),x.useContext(M0).location}function BL(e){x.useContext(Xo).static||x.useLayoutEffect(e)}function di(){let{isDataRoute:e}=x.useContext(Wi);return e?xX():nX()}function nX(){Gh()||Lr(!1);let e=x.useContext(O0),{basename:t,future:r,navigator:s}=x.useContext(Xo),{matches:a}=x.useContext(Wi),{pathname:i}=Zo(),o=JSON.stringify(MC(a,r.v7_relativeSplatPath)),l=x.useRef(!1);return BL(()=>{l.current=!0}),x.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){s.go(d);return}let h=DC(d,JSON.parse(o),i,u.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:Vl([t,h.pathname])),(u.replace?s.replace:s.push)(h,u.state,u)},[t,s,o,i,e])}const sX=x.createContext(null);function aX(e){let t=x.useContext(Wi).outlet;return t&&x.createElement(sX.Provider,{value:e},t)}function qL(){let{matches:e}=x.useContext(Wi),t=e[e.length-1];return t?t.params:{}}function D0(e,t){let{relative:r}=t===void 0?{}:t,{future:s}=x.useContext(Xo),{matches:a}=x.useContext(Wi),{pathname:i}=Zo(),o=JSON.stringify(MC(a,s.v7_relativeSplatPath));return x.useMemo(()=>DC(e,JSON.parse(o),i,r==="path"),[e,o,i,r])}function iX(e,t){return oX(e,t)}function oX(e,t,r,s){Gh()||Lr(!1);let{navigator:a}=x.useContext(Xo),{matches:i}=x.useContext(Wi),o=i[i.length-1],l=o?o.params:{};o&&o.pathname;let c=o?o.pathnameBase:"/";o&&o.route;let d=Zo(),u;if(t){var h;let y=typeof t=="string"?Kh(t):t;c==="/"||(h=y.pathname)!=null&&h.startsWith(c)||Lr(!1),u=y}else u=d;let f=u.pathname||"/",m=f;if(c!=="/"){let y=c.replace(/^\//,"").split("/");m="/"+f.replace(/^\//,"").split("/").slice(y.length).join("/")}let g=DQ(e,{pathname:m}),p=hX(g&&g.map(y=>Object.assign({},y,{params:Object.assign({},l,y.params),pathname:Vl([c,a.encodeLocation?a.encodeLocation(y.pathname).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?c:Vl([c,a.encodeLocation?a.encodeLocation(y.pathnameBase).pathname:y.pathnameBase])})),i,r,s);return t&&p?x.createElement(M0.Provider,{value:{location:tp({pathname:"/",search:"",hash:"",state:null,key:"default"},u),navigationType:Rl.Pop}},p):p}function lX(){let e=gX(),t=eX(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),r=e instanceof Error?e.stack:null,a={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return x.createElement(x.Fragment,null,x.createElement("h2",null,"Unexpected Application Error!"),x.createElement("h3",{style:{fontStyle:"italic"}},t),r?x.createElement("pre",{style:a},r):null,null)}const cX=x.createElement(lX,null);class dX extends x.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,r){return r.location!==t.location||r.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:r.error,location:r.location,revalidation:t.revalidation||r.revalidation}}componentDidCatch(t,r){console.error("React Router caught the following error during render",t,r)}render(){return this.state.error!==void 0?x.createElement(Wi.Provider,{value:this.props.routeContext},x.createElement(zL.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function uX(e){let{routeContext:t,match:r,children:s}=e,a=x.useContext(O0);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),x.createElement(Wi.Provider,{value:t},s)}function hX(e,t,r,s){var a;if(t===void 0&&(t=[]),r===void 0&&(r=null),s===void 0&&(s=null),e==null){var i;if(!r)return null;if(r.errors)e=r.matches;else if((i=s)!=null&&i.v7_partialHydration&&t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,l=(a=r)==null?void 0:a.errors;if(l!=null){let u=o.findIndex(h=>h.route.id&&(l==null?void 0:l[h.route.id])!==void 0);u>=0||Lr(!1),o=o.slice(0,Math.min(o.length,u+1))}let c=!1,d=-1;if(r&&s&&s.v7_partialHydration)for(let u=0;u<o.length;u++){let h=o[u];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(d=u),h.route.id){let{loaderData:f,errors:m}=r,g=h.route.loader&&f[h.route.id]===void 0&&(!m||m[h.route.id]===void 0);if(h.route.lazy||g){c=!0,d>=0?o=o.slice(0,d+1):o=[o[0]];break}}}return o.reduceRight((u,h,f)=>{let m,g=!1,p=null,y=null;r&&(m=l&&h.route.id?l[h.route.id]:void 0,p=h.route.errorElement||cX,c&&(d<0&&f===0?(g=!0,y=null):d===f&&(g=!0,y=h.route.hydrateFallbackElement||null)));let v=t.concat(o.slice(0,f+1)),j=()=>{let b;return m?b=p:g?b=y:h.route.Component?b=x.createElement(h.route.Component,null):h.route.element?b=h.route.element:b=u,x.createElement(uX,{match:h,routeContext:{outlet:u,matches:v,isDataRoute:r!=null},children:b})};return r&&(h.route.ErrorBoundary||h.route.errorElement||f===0)?x.createElement(dX,{location:r.location,revalidation:r.revalidation,component:p,error:m,children:j(),routeContext:{outlet:null,matches:v,isDataRoute:!0}}):j()},null)}var WL=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(WL||{}),Rv=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Rv||{});function fX(e){let t=x.useContext(O0);return t||Lr(!1),t}function mX(e){let t=x.useContext(UL);return t||Lr(!1),t}function pX(e){let t=x.useContext(Wi);return t||Lr(!1),t}function HL(e){let t=pX(),r=t.matches[t.matches.length-1];return r.route.id||Lr(!1),r.route.id}function gX(){var e;let t=x.useContext(zL),r=mX(Rv.UseRouteError),s=HL(Rv.UseRouteError);return t!==void 0?t:(e=r.errors)==null?void 0:e[s]}function xX(){let{router:e}=fX(WL.UseNavigateStable),t=HL(Rv.UseNavigateStable),r=x.useRef(!1);return BL(()=>{r.current=!0}),x.useCallback(function(a,i){i===void 0&&(i={}),r.current&&(typeof a=="number"?e.navigate(a):e.navigate(a,tp({fromRouteId:t},i)))},[e,t])}function vX(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function lc(e){let{to:t,replace:r,state:s,relative:a}=e;Gh()||Lr(!1);let{future:i,static:o}=x.useContext(Xo),{matches:l}=x.useContext(Wi),{pathname:c}=Zo(),d=di(),u=DC(t,MC(l,i.v7_relativeSplatPath),c,a==="path"),h=JSON.stringify(u);return x.useEffect(()=>d(JSON.parse(h),{replace:r,state:s,relative:a}),[d,h,a,r,s]),null}function yX(e){return aX(e.context)}function Ut(e){Lr(!1)}function jX(e){let{basename:t="/",children:r=null,location:s,navigationType:a=Rl.Pop,navigator:i,static:o=!1,future:l}=e;Gh()&&Lr(!1);let c=t.replace(/^\/*/,"/"),d=x.useMemo(()=>({basename:c,navigator:i,static:o,future:tp({v7_relativeSplatPath:!1},l)}),[c,l,i,o]);typeof s=="string"&&(s=Kh(s));let{pathname:u="/",search:h="",hash:f="",state:m=null,key:g="default"}=s,p=x.useMemo(()=>{let y=sh(u,c);return y==null?null:{location:{pathname:y,search:h,hash:f,state:m,key:g},navigationType:a}},[c,u,h,f,m,g,a]);return p==null?null:x.createElement(Xo.Provider,{value:d},x.createElement(M0.Provider,{children:r,value:p}))}function bX(e){let{children:t,location:r}=e;return iX(cN(t),r)}new Promise(()=>{});function cN(e,t){t===void 0&&(t=[]);let r=[];return x.Children.forEach(e,(s,a)=>{if(!x.isValidElement(s))return;let i=[...t,a];if(s.type===x.Fragment){r.push.apply(r,cN(s.props.children,i));return}s.type!==Ut&&Lr(!1),!s.props.index||!s.props.children||Lr(!1);let o={id:s.props.id||i.join("-"),caseSensitive:s.props.caseSensitive,element:s.props.element,Component:s.props.Component,index:s.props.index,path:s.props.path,loader:s.props.loader,action:s.props.action,errorElement:s.props.errorElement,ErrorBoundary:s.props.ErrorBoundary,hasErrorBoundary:s.props.ErrorBoundary!=null||s.props.errorElement!=null,shouldRevalidate:s.props.shouldRevalidate,handle:s.props.handle,lazy:s.props.lazy};s.props.children&&(o.children=cN(s.props.children,i)),r.push(o)}),r}/**
580 * React Router DOM v6.30.1
581 *
582 * Copyright (c) Remix Software Inc.
583 *
584 * This source code is licensed under the MIT license found in the
585 * LICENSE.md file in the root directory of this source tree.
586 *
587 * @license MIT
588 */function $v(){return $v=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];
588for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},$v.apply(this,arguments)}function VL(e,t){if(e==null)return{};var r={},s=Object.keys(e),a,i;for(i=0;i<s.length;i++)a=s[i],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function wX(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function _X(e,t){return e.button===0&&(!t||t==="_self")&&!wX(e)}function dN(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,r)=>{let s=e[r];return t.concat(Array.isArray(s)?s.map(a=>[r,a]):[[r,s]])},[]))}function NX(e,t){let r=dN(e);return t&&t.forEach((s,a)=>{r.has(a)||t.getAll(a).forEach(i=>{r.append(a,i)})}),r}const SX=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],CX=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],kX="6";try{window.__reactRouterVersion=kX}catch{}const PX=x.createContext({isTransitioning:!1}),TX="startTransition",KT=jS[TX];function AX(e){let{basename:t,children:r,future:s,window:a}=e,i=x.useRef();i.current==null&&(i.current=EQ({window:a,v5Compat:!0}));let o=i.current,[l,c]=x.useState({action:o.action,location:o.location}),{v7_startTransition:d}=s||{},u=x.useCallback(h=>{d&&KT?KT(()=>c(h)):c(h)},[c,d]);return x.useLayoutEffect(()=>o.listen(u),[o,u]),x.useEffect(()=>
588vX(s),[s]),x.createElement(jX,{basename:t,children:r,location:l.location,navigationType:l.action,navigator:o,future:s})}const EX=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",OX=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,_a=x.forwardRef(function(t,r){let{onClick:s,relative:a,reloadDocument:i,replace:o,state:l,target:c,to:d,preventScrollReset:u,viewTransition:h}=t,f=VL(t,SX),{basename:m}=x.useContext(Xo),g,p=!1;if(typeof d=="string"&&OX.test(d)&&(g=d,EX))try{let b=new URL(window.location.href),_=d.startsWith("//")?new URL(b.protocol+d):new URL(d),w=sh(_.pathname,m);_.origin===b.origin&&w!=null?d=w+_.search+_.hash:p=!0}catch{}let y=rX(d,{relative:a}),v=DX(d,{replace:o,state:l,target:c,preventScrollReset:u,relative:a,viewTransition:h});function j(b){s&&s(b),b.defaultPrevented||v(b)}return x.createElement("a",$v({},f,{href:g||y,onClick:p||i?s:j,ref:r,target:c}))}),Qn=x.forwardRef(function(t,r){let{"aria-current":s="page",caseSensitive:a=!1,className:i="",end:o=!1,style:l,to:c,viewTransition:d,children:u}=t,h=VL(t,CX),f=D0(c,{relative:h.relative}),m=Zo(),g=x.useContext(UL),{navigator:p,basename:y}=x.useContext(Xo),v=g!=null&&RX(f)&&d===!0,j=p.encodeLocation?p.encodeLocation(f).pathname:f.pathname,b=m.pathname,_=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;a||(b=b.toLowerCase(),_=_?_.toLowerCase():null,j=j.toLowerCase()),_&&y&&(_=sh(_,y)||_);const w=j!=="/"&&j.endsWith("/")?j.length-1:j.length;let N=b===j||!o&&b.startsWith(j)&&b.charAt(w)==="/",S=_!=null&&(_===j||!o&&_.startsWith(j)&&_.charAt(j.length)==="/"),C={isActive:N,isPending:S,isTransitioning:v},P=N?s:void 0,M;typeof i=="function"?M=i(C):M=[i,N?"active":null,S?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let D=typeof l=="function"?l(C):l;return x.createElement(_a,$v({},h,{"aria-current":P,className:M,ref:r,style:D,to:c,viewTransition:d}),typeof u=="function"?u(C):u)});var uN;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(uN||(uN={}));var GT;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(GT||(GT={}));function MX(e){let t=x.useContext(O0);return t||Lr(!1),t}function DX(e,t){let{target:r,replace:s,state:a,preventScrollReset:i,relative:o,viewTransition:l}=t===void 0?{}:t,c=di(),d=Zo(),u=D0(e,{relative:o});return x.useCallback(h=>{if(_X(h,r)){h.preventDefault();let f=s!==void 0?s:Mv(d)===Mv(u);c(e,{replace:f,state:a,preventScrollReset:i,relative:o,viewTransition:l})}},[d,c,u,s,a,r,e,i,o,l])}function RC(e){let t=x.useRef(dN(e)),r=x.useRef(!1),s=Zo(),a=x.useMemo(()=>NX(s.search,r.current?null:t.current),[s.search]),i=di(),o=x.useCallback((l,c)=>{const d=dN(typeof l=="function"?l(a):l);r.current=!0,i("?"+d,c)},[i,a]);return[a,o]}function RX(e,t){t===void 0&&(t={});let r=x.useContext(PX);r==null&&Lr(!1);let{basename:s}=MX(uN.useViewTransitionState),a=D0(e,{relative:t.relative});if(!r.isTransitioning)return!1;let i=sh(r.currentLocation.pathname,s)||r.currentLocation.pathname,o=sh(r.nextLocation.pathname,s)||r.nextLocation.pathname;return Dv(a.pathname,o)!=null||Dv(a.pathname,i)!=null}const $X="modulepreload",IX=function(e){return"/"+e},YT={},ag=function(t,r,s){let a=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));a=Promise.allSettled(r.map(c=>{if(c=IX(c),c in YT)return;YT[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":$X,d||(h.as="script"),h.crossOrigin="",h.href=c,l&&h.setAttribute("nonce",l),document.head.appendChild(h),d)return new Promise((f,m)=>{h.addEventListener("load",f),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function i(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return a.then(o=>{for(const l of o||[])l.status==="rejected"&&i(l.reason);return t().catch(i)})},LX=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...r)=>ag(async()=>{const{default:s}=await Promise.resolve().then(()=>Yh);return{default:s}},void 0).then(({default:s})=>s(...r)):t=fetch,(...r)=>t(...r)};
588class $C extends Error{constructor(t,r="FunctionsError",s){super(t),this.name=r,this.context=s}}class FX extends $C{constructor(t){super("Failed to send a request to the Edge Function","FunctionsFetchError",t)}}class QT extends $C{constructor(t){super("Relay Error invoking the Edge Function","FunctionsRelayError",t)}}class XT extends $C{constructor(t){super("Edge Function returned a non-2xx status code","FunctionsHttpError",t)}}var hN;(function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"})(hN||(hN={}));var UX=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};class zX{constructor(t,{headers:r={},customFetch:s,region:a=hN.Any}={}){this.url=t,this.headers=r,this.region=a,this.fetch=LX(s)}setAuth(t){this.headers.Authorization=`Bearer ${t}`}invoke(t,r={}){var s;return UX(this,void 0,void 0,function*(){try{const{headers:a,method:i,body:o}=r;let l={},{region:c}=r;c||(c=this.region);const d=new URL(`${this.url}/${t}`);c&&c!=="any"&&(l["x-region"]=c,d.searchParams.set("forceFunctionRegion",c));let u;o&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(l["Content-Type"]="application/octet-stream",u=o):typeof o=="string"?(l["Content-Type"]="text/plain",u=o):typeof FormData<"u"&&o instanceof FormData?u=o:(l["Content-Type"]="application/json",u=JSON.stringify(o)));const h=yield this.fetch(d.toString(),{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},l),this.headers),a),body:u}).catch(p=>{throw new FX(p)}),f=h.headers.get("x-relay-error");if(f&&f==="true")throw new QT(h);if(!h.ok)throw new XT(h);let m=((s=h.headers.get("Content-Type"))!==null&&s!==void 0?s:"text/plain").split(";")[0].trim(),g;return m==="application/json"?g=yield h.json():m==="application/octet-stream"?g=yield h.blob():m==="text/event-stream"?g=h:m==="multipart/form-data"?g=yield h.formData():g=yield h.text(),{data:g,error:null,response:h}}catch(a){return{data:null,error:a,response:a instanceof XT||a instanceof QT?a.context:void 0}}})}}var Ds={},IC={},R0={},ig={},$0={},I0={},BX=function(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")},ah=BX();const qX=ah.fetch,KL=ah.fetch.bind(ah),GL=ah.Headers,WX=ah.Request,HX=ah.Response,Yh=Object.freeze(Object.defineProperty({__proto__:null,Headers:GL,Request:WX,Response:HX,default:KL,fetch:qX},Symbol.toStringTag,{value:"Module"})),VX=nW(Yh);var L0={};Object.defineProperty(L0,"__esModule",{value:!0});let KX=class extends Error{constructor(t){super(t.message),this.name="PostgrestError",this.details=t.details,this.hint=t.hint,this.co
588de=t.code}};L0.default=KX;var YL=rs&&rs.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(I0,"__esModule",{value:!0});const GX=YL(VX),YX=YL(L0);let QX=class{constructor(t){var r,s;this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=(r=t.shouldThrowOnError)!==null&&r!==void 0?r:!1,this.signal=t.signal,this.isMaybeSingle=(s=t.isMaybeSingle)!==null&&s!==void 0?s:!1,t.fetch?this.fetch=t.fetch:typeof fetch>"u"?this.fetch=GX.default:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(t,r){return this.headers=new Headers(this.headers),this.headers.set(t,r),this}then(t,r){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");const s=this.fetch;let a=s(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,l,c,d;let u=null,h=null,f=null,m=i.status,g=i.statusText;if(i.ok){if(this.method!=="HEAD"){const j=await i.text();j===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&(!((o=this.headers.get("Accept"))===null||o===void 0)&&o.includes("application/vnd.pgrst.plan+text"))?h=j:h=JSON.parse(j))}const y=(l=this.headers.get("Prefer"))===null||l===void 0?void 0:l.match(/count=(exact|planned|estimated)/),v=(c=i.headers.get("content-range"))===null||c===void 0?void 0:c.split("/");y&&v&&v.length>1&&(f=parseInt(v[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(h)&&(h.length>1?(u={code:"PGRST116",details:`Results contain ${h.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},h=null,f=null,m=406,g="Not Acceptable"):h.length===1?h=h[0]:h=null)}else{const y=await i.text();try{u=JSON.parse(y),Array.isArray(u)&&i.status===404&&(h=[],u=null,m=200,g="OK")}catch{i.status===404&&y===""?(m=204,g="No Content"):u={message:y}}if(u&&this.isMaybeSingle&&(!((d=u==null?void 0:u.details)===null||d===void 0)&&d.includes("0 rows"))&&(u=null,m=200,g="OK"),u&&this.shouldThrowOnError)throw new YX.default(u)}return{error:u,data:h,count:f,status:m,statusText:g}});return this.shouldThrowOnError||(a=a.catch(i=>{var o,l,c;return{error:{message:`${(o=i==null?void 0:i.name)!==null&&o!==void 0?o:"FetchError"}: ${i==null?void 0:i.message}`,details:`${(l=i==null?void 0:i.stack)!==null&&l!==void 0?l:""}`,hint:"",code:`${(c=i==null?void 0:i.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),a.then(t,r)}returns(){return this}overrideTypes(){return this}};I0.default=QX;var XX=rs&&rs.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty($0,"__esModule",{value:!0});const ZX=XX(I0);let JX=class extends ZX.default{select(t){let r=!1;const s=(t??"*").split("").map(a=>/\s/.test(a)&&!r?"":(a==='"'&&(r=!r),a)).join("");return this.url.searchParams.set("select",s),this.headers.append("Prefer","return=representation"),this}order(t,{ascending:r=!0,nullsFirst:s,foreignTable:a,referencedTable:i=a}={}){const o=i?`${i}.order`:"order",l=this.url.searchParams.get(o);return this.url.searchParams.set(o,`${l?`${l},`:""}${t}.${r?"asc":"desc"}${s===void 0?"":s?".nullsfirst":".nullslast"}`),this}limit(t,{foreignTable:r,referencedTable:s=r}={}){const a=typeof s>"u"?"limit":`${s}.limit`;return this.url.searchParams.set(a,`${t}`),this}range(t,r,{foreignTable:s,referencedTable:a=s}={}){const i=typeof a>"u"?"offset":`${a}.offset`,o=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(i,`${t}`),this.url.searchParams.set(o,`${r-t+1}`),this}abortSignal(t){return this.signal=t,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}
588explain({analyze:t=!1,verbose:r=!1,settings:s=!1,buffers:a=!1,wal:i=!1,format:o="text"}={}){var l;const c=[t?"analyze":null,r?"verbose":null,s?"settings":null,a?"buffers":null,i?"wal":null].filter(Boolean).join("|"),d=(l=this.headers.get("Accept"))!==null&&l!==void 0?l:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${o}; for="${d}"; options=${c};`),o==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(t){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${t}`),this}};$0.default=JX;var eZ=rs&&rs.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(ig,"__esModule",{value:!0});const tZ=eZ($0);let rZ=class extends tZ.default{eq(t,r){return this.url.searchParams.append(t,`eq.${r}`),this}neq(t,r){return this.url.searchParams.append(t,`neq.${r}`),this}gt(t,r){return this.url.searchParams.append(t,`gt.${r}`),this}gte(t,r){return this.url.searchParams.append(t,`gte.${r}`),this}lt(t,r){return this.url.searchParams.append(t,`lt.${r}`),this}lte(t,r){return this.url.searchParams.append(t,`lte.${r}`),this}like(t,r){return this.url.searchParams.append(t,`like.${r}`),this}likeAllOf(t,r){return this.url.searchParams.append(t,`like(all).{${r.join(",")}}`),this}likeAnyOf(t,r){return this.url.searchParams.append(t,`like(any).{${r.join(",")}}`),this}ilike(t,r){return this.url.searchParams.append(t,`ilike.${r}`),this}ilikeAllOf(t,r){return this.url.searchParams.append(t,`ilike(all).{${r.join(",")}}`),this}ilikeAnyOf(t,r){return this.url.searchParams.append(t,`ilike(any).{${r.join(",")}}`),this}is(t,r){return this.url.searchParams.append(t,`is.${r}`),this}in(t,r){const s=Array.from(new Set(r)).map(a=>typeof a=="string"&&new RegExp("[,()]").test(a)?`"${a}"`:`${a}`).join(",");return this.url.searchParams.append(t,`in.(${s})`),this}contains(t,r){return typeof r=="string"?this.url.searchParams.append(t,`cs.${r}`):Array.isArray(r)?this.url.searchParams.append(t,`cs.{${r.join(",")}}`):this.url.searchParams.append(t,`cs.${JSON.stringify(r)}`),this}containedBy(t,r){return typeof r=="string"?this.url.searchParams.append(t,`cd.${r}`):Array.isArray(r)?this.url.searchParams.append(t,`cd.{${r.join(",")}}`):this.url.searchParams.append(t,`cd.${JSON.stringify(r)}`),this}rangeGt(t,r){return this.url.searchParams.append(t,`sr.${r}`),this}rangeGte(t,r){return this.url.searchParams.append(t,`nxl.${r}`),this}rangeLt(t,r){return this.url.searchParams.append(t,`sl.${r}`),this}rangeLte(t,r){return this.url.searchParams.append(t,`nxr.${r}`),this}rangeAdjacent(t,r){return this.url.searchParams.append(t,`adj.${r}`),this}overlaps(t,r){return typeof r=="string"?this.url.searchParams.append(t,`ov.${r}`):this.url.searchParams.append(t,`ov.{${r.join(",")}}`),this}textSearch(t,r,{config:s,type:a}={}){let i="";a==="plain"?i="pl":a==="phrase"?i="ph":a==="websearch"&&(i="w");const o=s===void 0?"":`(${s})`;return this.url.searchParams.append(t,`${i}fts${o}.${r}`),this}match(t){return Object.entries(t).forEach(([r,s])=>{this.url.searchParams.append(r,`eq.${s}`)}),this}not(t,r,s){return this.url.searchParams.append(t,`not.${r}.${s}`),this}or(t,{foreignTable:r,referencedTable:s=r}={}){const a=s?`${s}.or`:"or";return this.url.searchParams.append(a,`(${t})`),this}filter(t,r,s){return this.url.searchParams.append(t,`${r}.${s}`),this}};ig.default=rZ;var nZ=rs&&rs.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(R0,"__esModule",{value:!0});const Tf=nZ(ig);let sZ=class{constructor(t,{headers:r={},schema:s,fetch:a}){this.url=t,this.headers=new Headers(r),this.schema=s,this.fetch=a}select(t,{head:r=!1,count:s}={}){const a=r?"HEAD":"GET";let i=!1;const o=(t??"*").split("").map(l=>/\s/.test(l)&&!i?"":(l==='"'&&(i=!i),l)).join("");return this.url.searchParams.set("select",o),s&&this.headers.append("Prefer",`count=${s}`),new Tf.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(t,{count:r,defaultToNull:s=!0}={}){var a;const i="POST";if(r&&this.headers.append("Prefer",`count=${r}`),s||this.headers.append("Prefer","missing=default"),Array.isArray(t)){const o=t.reduce((l,c)=>l.concat(Object.keys(c)),[]);if(o.length>0){const l=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",l.join(","))}}return new Tf.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}upsert(t,{onConflict:r,ignoreDuplicates:s=!1,count:a,defaultToNull:i=!0}={}){var o;const l="POST";if(this.headers.append("Prefer",`resolution=${s?"ignore":"merge"}-duplicates`),r!==void 0&&this.url.searchParams.set("on_conflict",r),a&&this.headers.append("Prefer",`count=${a}`),i||this.headers.append("Prefer","missing=default"),Array.isArray(t)){const c=t.reduce((d,u)=>d.concat(Object.keys(u)),[]);if(c.length>0){const d=[...new Set(c)].map(u=>`"${u}"`);this.url.searchParams.set("columns",d.join(","))}}return new Tf.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}update(t,{count:r}={}){var s;const a="PATCH";return r&&this.headers.append("Prefer",`count=${r}`),new Tf.default({method:a,url:this.url,headers:this.headers,schema:this.schema,body:t,fetch:(s=this.fetch)!==null&&s!==void 0?s:fetch})}delete({count:t}={}){var r;const s="DELETE";return t&&this.headers.append("Prefer",`count=${t}`),new Tf.default({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:(r=this.fetch)!==null&&r!==void 0?r:fetch})}};R0.default=sZ;
588var QL=rs&&rs.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(IC,"__esModule",{value:!0});const aZ=QL(R0),iZ=QL(ig);let oZ=class XL{constructor(t,{headers:r={},schema:s,fetch:a}={}){this.url=t,this.headers=new Headers(r),this.schemaName=s,this.fetch=a}from(t){const r=new URL(`${this.url}/${t}`);return new aZ.default(r,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(t){return new XL(this.url,{headers:this.headers,schema:t,fetch:this.fetch})}rpc(t,r={},{head:s=!1,get:a=!1,count:i}={}){var o;let l;const c=new URL(`${this.url}/rpc/${t}`);let d;s||a?(l=s?"HEAD":"GET",Object.entries(r).filter(([h,f])=>f!==void 0).map(([h,f])=>[h,Array.isArray(f)?`{${f.join(",")}}`:`${f}`]).forEach(([h,f])=>{c.searchParams.append(h,f)})):(l="POST",d=r);const u=new Headers(this.headers);return i&&u.set("Prefer",`count=${i}`),new iZ.default({method:l,url:c,headers:u,schema:this.schemaName,body:d,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};IC.default=oZ;var Qh=rs&&rs.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ds,"__esModule",{value:!0});Ds.PostgrestError=Ds.PostgrestBuilder=Ds.PostgrestTransformBuilder=Ds.PostgrestFilterBuilder=Ds.PostgrestQueryBuilder=Ds.PostgrestClient=void 0;const ZL=Qh(IC);Ds.PostgrestClient=ZL.default;const JL=Qh(R0);Ds.PostgrestQueryBuilder=JL.default;const eF=Qh(ig);Ds.PostgrestFilterBuilder=eF.default;const tF=Qh($0);Ds.PostgrestTransformBuilder=tF.default;const rF=Qh(I0);Ds.PostgrestBuilder=rF.default;const nF=Qh(L0);Ds.PostgrestError=nF.default;var lZ=Ds.default={PostgrestClient:ZL.default,PostgrestQueryBuilder:JL.default,PostgrestFilterBuilder:eF.default,PostgrestTransformBuilder:tF.default,PostgrestBuilder:rF.default,PostgrestError:nF.default};const{PostgrestClient:cZ,PostgrestQueryBuilder:eRe,PostgrestFilterBuilder:tRe,PostgrestTransformBuilder:rRe,PostgrestBuilder:nRe,PostgrestError:sRe}=lZ;class dZ{static detectEnvironment(){var t;if(typeof WebSocket<"u")return{type:"native",constructor:WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocket<"u")return{type:"native",constructor:globalThis.WebSocket};if(typeof global<"u"&&typeof global.WebSocket<"u")return{type:"native",constructor:global.WebSocket};if(typeof globalThis<"u"&&typeof globalThis.WebSocketPair<"u"&&typeof globalThis.WebSocket>"u")return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if(typeof globalThis<"u"&&globalThis.EdgeRuntime||typeof navigator<"u"&&(!((t=navigator.userAgent)===null||t===void 0)&&t.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};if(typeof process<"u"){const r=process.versions;if(r&&r.node){const s=r.node,a=parseInt(s.replace(/^v/,"").split(".")[0]);return a>=22?typeof globalThis.WebSocket<"u"?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${a} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${a} detected without native WebSocket support.`,workaround:`For Node.js < 22, install "ws" package and provide it via the transport option:
589import ws from "ws"
590new RealtimeClient(url, { transport: ws })`}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){const t=this.detectEnvironment();if(t.constructor)return t.constructor;let r=t.error||"WebSocket not supported in this environment.";throw t.workaround&&(r+=`
591
592Suggested solution: ${t.workaround}`),new Error(r)}static createWebSocket(t,r){const s=this.getWebSocketConstructor();return new s(t,r)}static isWebSocketSupported(){try{const t=this.detectEnvironment();return t.type==="native"||t.type==="ws"}catch{return!1}}}const uZ="2.15.5",hZ=`realtime-js/${uZ}`,fZ="1.0.0",fN=1e4,mZ=1e3,pZ=100;var vm;(function(e){e[e.connecting=0]="connecting",e[e.open=1]="open",e[e.closing=2]="closing",e[e.closed=3]="closed"})(vm||(vm={}));var hn;(function(e){e.closed="closed",e.errored="errored",e.joined="joined",e.joining="joining",e.leaving="leaving"})(hn||(hn={}));var Ga;(function(e){e.close="phx_close",e.error="phx_error",e.join="phx_join",e.reply="phx_reply",e.leave="phx_leave",e.access_token="access_token"})(Ga||(Ga={}));var mN;(function(e){e.websocket="websocket"})(mN||(mN={}));var Lc;(function(e){e.Connecting="connecting",e.Open="open",e.Closing="closing",e.Closed="closed"})(Lc||(Lc={}));class gZ{constructor(){this.HEADER_LENGTH=1}decode(t,r){return t.constructor===ArrayBuffer?r(this._binaryDecode(t)):r(typeof t=="string"?JSON.parse(t):{})}_binaryDecode(t){const r=new DataView(t),s=new TextDecoder;return this._decodeBroadcast(t,r,s)}_decodeBroadcast(t,r,s){const a=r.getUint8(1),i=r.getUint8(2);let o=this.HEADER_LENGTH+2;const l=s.decode(t.slice(o,o+a));o=o+a;const c=s.decode(t.slice(o,o+i));o=o+i;const d=JSON.parse(s.decode(t.slice(o,t.byteLength)));return{ref:null,topic:l,event:c,payload:d}}}class sF{constructor(t,r){this.callback=t,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=r}reset(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}var xr;(function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"})(xr||(xr={}));const ZT=(e,t,r={})=>{var s;const a=(s=r.skipTypes)!==null&&s!==void 0?s:[];return Object.keys(t).reduce((i,o)=>(i[o]=xZ(o,e,t,a),i),{})},xZ=(e,t,r,s)=>{const a=t.find(l=>
vendor: 5,662 bytes, line 592
592l.name===e),i=a==null?void 0:a.type,o=r[e];return i&&!s.includes(i)?aF(i,o):pN(o)},aF=(e,t)=>{if(e.charAt(0)==="_"){const r=e.slice(1,e.length);return bZ(t,r)}switch(e){case xr.bool:return vZ(t);case xr.float4:case xr.float8:case xr.int2:case xr.int4:case xr.int8:case xr.numeric:case xr.oid:return yZ(t);case xr.json:case xr.jsonb:return jZ(t);case xr.timestamp:return wZ(t);case xr.abstime:case xr.date:case xr.daterange:case xr.int4range:case xr.int8range:case xr.money:case xr.reltime:case xr.text:case xr.time:case xr.timestamptz:case xr.timetz:case xr.tsrange:case xr.tstzrange:return pN(t);default:return pN(t)}},pN=e=>e,vZ=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},yZ=e=>{if(typeof e=="string"){const t=parseFloat(e);if(!Number.isNaN(t))return t}return e},jZ=e=>{if(typeof e=="string")try{return JSON.parse(e)}catch(t){return console.log(`JSON parse error: ${t}`),e}return e},bZ=(e,t)=>{if(typeof e!="string")return e;const r=e.length-1,s=e[r];if(e[0]==="{"&&s==="}"){let i;const o=e.slice(1,r);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(l=>aF(t,l))}return e},wZ=e=>typeof e=="string"?e.replace(" ","T"):e,iF=e=>{let t=e;return t=t.replace(/^ws/i,"http"),t=t.replace(/(\/socket\/websocket|\/socket|\/websocket)\/?$/i,""),t.replace(/\/+$/,"")+"/api/broadcast"};class zb{constructor(t,r,s={},a=fN){this.channel=t,this.event=r,this.payload=s,this.timeout=a,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}resend(t){this.timeout=t,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){this._hasReceived("timeout")||(this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()}))}updatePayload(t){this.payload=Object.assign(Object.assign({},this.payload),t)}receive(t,r){var s;return this._hasReceived(t)&&r((s=this.receivedResp)===null||s===void 0?void 0:s.response),this.recHooks.push({status:t,callback:r}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const t=r=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=r,this._matchReceive(r)};this.channel._on(this.refEvent,{},t),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(t,r){this.refEvent&&this.channel._trigger(this.refEvent,{status:t,response:r})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:t,response:r}){this.recHooks.filter(s=>s.status===t).forEach(s=>s.callback(r))}_hasReceived(t){return this.receivedResp&&this.receivedResp.status===t}}var JT;(function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"})(JT||(JT={}));class ym{constructor(t,r){this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const s=(r==null?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(s.state,{},a=>{const{onJoin:i,onLeave:o,onSync:l}=this.caller;this.joinRef=this.channel._joinRef(),this.state=ym.syncState(this.state,a,i,o),this.pendingDiffs.forEach(c=>{this.state=ym.syncDiff(this.state,c,i,o)}),this.pendingDiffs=[],l()}),this.channel._on(s.diff,{},a=>{const{onJoin:i,onLeave:o,onSync:l}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(a):(this.state=ym.syncDiff(this.state,a,i,o),l())}),this.onJoin((a,i,o)=>{this.channel._trigger("presence",{event:"join",key:a,currentPresences:i,newPresences:o})}),this.onLeave((a,i,o)=>{this.channel._trigger("presence",{event:"leave",key:a,currentPresences:i,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(t,r,s,a){const i=this.cloneDeep(t),o=this.transformState(r),l={},c={};return this.map(i,(d,u)=>{o[d]||(c[d]=u)}),this.map(o,(d,u)=>{const h=i[d];if(h){const f=u.map(y=>y.presence_ref),m=h.map(y=>y.presence_ref),g=u.filter(y=>m.indexOf(y.presence_ref)<0),p=h.filter(y=>f.indexOf(y.presence_ref)<0);g.length>0&&(l[d]=g),p.length>0&&(c[d]=p)}else l[d]=u}),this.syncDiff(i,{joins:l,leaves:c},s,a)}static syncDiff(t,r,s,a){const{joins:i,leaves:o}={joins:this.transformState(r.joins),leaves:this.transformState(r.leaves)};return s||(s=()=>{}),a||(a=()=>{}),this.map(i,(l,c)=>{var d;const u=(d=t[l])!==null&&d!==void 0?d:[];if(t[l]=this.cloneDeep(c),u.length>0){const h=t[l].map(m=>m.presence_ref),f=u.filter(m=>h.indexOf(m.presence_ref)<0);t[l].unshift(...f)}s(l,u,c)}),this.map(o,(l,c)=>{let d=t[l];if(!d)return;const u=c.map(h=>h.presence_ref);d=d.filter(h=>u.indexOf(h.presence_ref)<0),t[l]=d,a(l,d,c),d.length===0&&delete t[l]}),t}static map(t,r){return Object.getOwnPropertyNames(t).map(s=>r(s,t[s]))}static transformState(t){return t=this.cloneDeep(t),Object.getOwnPropertyNames(t).reduce((r,s)=>{const a=t[s];return"metas"in a?r[s]=a.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):r[s]=a,r},{})}static cloneDeep(t){return JSON.parse(JSON.stringify(t))}onJoin(t){this.caller.onJoin=t}onLeave(t){this.caller.onLeave=t}onSync(t){this.caller.onSync=t}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var eA;(function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"})(eA||(eA={}));var jm;(function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}
592)(jm||(jm={}));var lo;(function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"})(lo||(lo={}));class LC{constructor(t,r={config:{}},s){this.topic=t,this.params=r,this.socket=s,this.bindings={},this.state=hn.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config),this.timeout=this.socket.timeout,this.joinPush=new zb(this,Ga.join,this.params,this.timeout),this.rejoinTimer=new sF(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=hn.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(a=>a.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=hn.closed,this.socket._remove(this)}),this._onError(a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=hn.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=hn.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",a=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,a),this.state=hn.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Ga.reply,{},(a,i)=>{this._trigger(this._replyEventName(i),a)}),this.presence=new ym(this),this.broadcastEndpointURL=iF(this.socket.endPoint),this.private=this.params.config.private||!1}subscribe(t,r=this.timeout){var s,a,i;if(this.socket.isConnected()||this.socket.connect(),this.state==hn.closed){const{config:{broadcast:o,presence:l,private:c}}=this.params,d=(a=(s=this.bindings.postgres_changes)===null||s===void 0?void 0:s.map(m=>m.filter))!==null&&a!==void 0?a:[],u=!!this.bindings[jm.PRESENCE]&&this.bindings[jm.PRESENCE].length>0||((i=this.params.config.presence)===null||i===void 0?void 0:i.enabled)===!0,h={},f={broadcast:o,presence:Object.assign(Object.assign({},l),{enabled:u}),postgres_changes:d,private:c};this.socket.accessTokenValue&&(h.access_token=this.socket.accessTokenValue),this._onError(m=>t==null?void 0:t(lo.CHANNEL_ERROR,m)),this._onClose(()=>t==null?void 0:t(lo.CLOSED)),this.updateJoinPayload(Object.assign({config:f},h)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:m})=>{var g;if(this.socket.setAuth(),m===void 0){t==null||t(lo.SUBSCRIBED);return}else{const p=this.bindings.postgres_changes,y=(g=p==null?void 0:p.length)!==null&&g!==void 0?g:0,v=[];for(let j=0;j<y;j++){const b=p[j],{filter:{event:_,schema:w,table:N,filter:S}}=b,C=m&&m[j];if(C&&C.event===_&&C.schema===w&&C.table===N&&C.filter===S)v.push(Object.assign(Object.assign({},b),{id:C.id}));else{this.unsubscribe(),this.state=hn.errored,t==null||t(lo.CHANNEL_ERROR,new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=v,t&&t(lo.SUBSCRIBED);return}}).receive("error",m=>{this.state=hn.errored,t==null||t(lo.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(m).join(", ")||"error")))}).receive("timeout",()=>{t==null||t(lo.TIMED_OUT)})}return this}presenceState(){return this.presence.state}async track(t,r={}){return await this.send({type:"presence",event:"track",payload:t},r.timeout||this.timeout)}async untrack(t={}){return await this.send({type:"presence",event:"untrack"},t)}on(t,r,s){return this.state===hn.joined&&t===jm.PRESENCE&&(this.socket.log("channel",`resubscribe to ${this.topic} due to change in presence callbacks on joined channel`),this.unsubscribe().then(()=>this.subscribe())),this._on(t,r,s)}async send(t,r={}){var s,a;if(!this._canPush()&&t.type==="broadcast"){const{event:i,payload:o}=t,c={method:"POST",headers:{Authorization:this.socket.accessTokenValue?`Bearer ${this.socket.accessTokenValue}`:"",apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:o,private:this.private}]})};try{const d=await this._fetchWithTimeout(this.broadcastEndpointURL,c,(s=r.timeout)!==null&&s!==void 0?s:this.timeout);return await((a=d.body)===null||a===void 0?void 0:a.cancel()),d.ok?"ok":"error"}catch(d){return d.name==="AbortError"?"timed out":"error"}}else return new Promise(i=>{var o,l,c;const d=this._push(t.type,t,r.timeout||this.timeout);t.type==="broadcast"&&!(!((c=(l=(o=this.params)===null||o===void 0?void 0:o.config)===null||l===void 0?void 0:l.broadcast)===null||c===void 0)&&c.ack)&&i("ok"),d.receive("ok",()=>i("ok")),d.receive("error",()=>i("error")),d.receive("timeout",()=>i("timed out"))})}updateJoinPayload(t){this.joinPush.updatePayload(t)}unsubscribe(t=this.timeout){this.state=hn.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Ga.close,"leave",this._joinRef())};this.joinPush.destroy();let s=null;return new Promise(a=>{s=new zb(this,Ga.leave,{},t),s.receive("ok",()=>{r(),a("ok")}).receive("timeout",()=>{r(),a("timed out")}).receive("error",()=>{a("error")}),s.send(),this._canPush()||s.trigger("ok",{})}).finally(()=>{s==null||s.destroy()})}teardown(){this.pushBuffer.forEach(t=>t.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=hn.closed,this.bindings={}}async _fetchWithTimeout(t,r,s){const a=new AbortController,i=setTimeout(()=>a.abort(),s),o=await this.socket.fetch(t,Object.assign(Object.assign({},r),{signal:a.signal}));return clearTimeout(i),o}_push(t,r,s=this.timeout){if(!this.joinedOnce)throw`tried to push '${t}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let a=new zb(this,t,r,s);return this._canPush()?a.send():this._addToPushBuffer(a),a}_addToPushBuffer(t){if(t.startTimeout(),this.pushBuffer.push(t),this.pushBuffer.length>pZ){const r=this.pushBuffer.shift();r&&(r.destroy(),this.socket.log("channel",`discarded push due to buffer overflow: ${r.event}`,r.payload))}}_onMessage(t,r,s){return r}_isMember(t){return this.topic===t}_joinRef(){return this.joinPush.ref}_trigger(t,r,s){var a,i;const o=t.toLocaleLowerCase(),{close:l,error:c,leave:d,join:u}=Ga;if(s&&[l,c,d,u].indexOf(o)>=0&&s!==this._joinRef())return;let f=this._onMessage(o,r,s);if(r&&!f)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(a=this.bindings.postgres_changes)===null||a===void 0||a.filter(m=>{var g,p,y;return((g=m.filter)===null||g===void 0?void 0:g.event)==="*"||((y=(p=m.filter)===null||p===void 0?void 0:p.event)===null||y===void 0?void 0:y.toLocaleLowerCase())===o}).map(m=>
592m.callback(f,s)):(i=this.bindings[o])===null||i===void 0||i.filter(m=>{var g,p,y,v,j,b;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in m){const _=m.id,w=(g=m.filter)===null||g===void 0?void 0:g.event;return _&&((p=r.ids)===null||p===void 0?void 0:p.includes(_))&&(w==="*"||(w==null?void 0:w.toLocaleLowerCase())===((y=r.data)===null||y===void 0?void 0:y.type.toLocaleLowerCase()))}else{const _=(j=(v=m==null?void 0:m.filter)===null||v===void 0?void 0:v.event)===null||j===void 0?void 0:j.toLocaleLowerCase();return _==="*"||_===((b=r==null?void 0:r.event)===null||b===void 0?void 0:b.toLocaleLowerCase())}else return m.type.toLocaleLowerCase()===o}).map(m=>{if(typeof f=="object"&&"ids"in f){const g=f.data,{schema:p,table:y,commit_timestamp:v,type:j,errors:b}=g;f=Object.assign(Object.assign({},{schema:p,table:y,commit_timestamp:v,eventType:j,new:{},old:{},errors:b}),this._getPayloadRecords(g))}m.callback(f,s)})}_isClosed(){return this.state===hn.closed}_isJoined(){return this.state===hn.joined}_isJoining(){return this.state===hn.joining}_isLeaving(){return this.state===hn.leaving}_replyEventName(t){return`chan_reply_${t}`}_on(t,r,s){const a=t.toLocaleLowerCase(),i={type:a,filter:r,callback:s};return this.bindings[a]?this.bindings[a].push(i):this.bindings[a]=[i],this}_off(t,r){const s=t.toLocaleLowerCase();return this.bindings[s]&&(this.bindings[s]=this.bindings[s].filter(a=>{var i;return!(((i=a.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===s&&LC.isEqual(a.filter,r))})),this}static isEqual(t,r){if(Object.keys(t).length!==Object.keys(r).length)return!1;for(const s in t)if(t[s]!==r[s])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(t){this._on(Ga.close,{},t)}_onError(t){this._on(Ga.error,{},r=>t(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(t=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=hn.joining,this.joinPush.resend(t))}_getPayloadRecords(t){const r={new:{},old:{}};return(t.type==="INSERT"||t.type==="UPDATE")&&(r.new=ZT(t.columns,t.record)),(t.type==="UPDATE"||t.type==="DELETE")&&(r.old=ZT(t.columns,t.old_record)),r}}const Bb=()=>{},nx={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},_Z=[1e3,2e3,5e3,1e4],NZ=1e4,SZ=`
593  addEventListener("message", (e) => {
594    if (e.data.event === "start") {
595      setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);
596    }
597  });`;class CZ{constructor(t,r){var s;if(this.accessTokenValue=null,this.apiKey=null,this.channels=new Array,this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=fN,this.transport=null,this.heartbeatIntervalMs=nx.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=Bb,this.ref=0,this.reconnectTimer=null,this.logger=Bb,this.conn=null,this.sendBuffer=[],this.serializer=new gZ,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._resolveFetch=a=>{let i;return a?i=a:typeof fetch>"u"?i=(...o)=>ag(async()=>{const{default:l}=await Promise.resolve().then(()=>Yh);return{default:l}},void 0).then(({default:l})=>l(...o)).catch(l=>{throw new Error(`Failed to load @supabase/node-fetch: ${l.message}. This is required for HTTP requests in Node.js environments without native fetch.`)}):i=fetch,(...o)=>i(...o)},!(!((s=r==null?void 0:r.params)===null||s===void 0)&&s.apikey))throw new Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint=`${t}/${mN.websocket}`,this.httpEndpoint=iF(t),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(r==null?void 0:r.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.conn!==null&&this.isConnected())){if(this._setConnectionState("connecting"),this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=dZ.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");const r=t.message;throw r.includes("Node.js")?new Error(`${r}
598
599To use Realtime in Node.js, you need to provide a WebSocket implementation:
600
601Option 1: Use Node.js 22+ which has native WebSocket support
602Option 2: Install and provide the "ws" package:
603
604  npm install ws
605
606  import ws from "ws"
607  const client = new RealtimeClient(url, {
608    ...options,
609    transport: ws
610  })`):new Error(`WebSocket not available: ${r}`)}this._setupConnectionHandlers()}}endpointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:fZ}))}disconnect(t,r){if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){const s=setTimeout(()=>{this._setConnectionState("disconnected")},100);
610this.conn.onclose=()=>{clearTimeout(s),this._setConnectionState("disconnected")},t?this.conn.close(t,r??""):this.conn.close(),this._teardownConnection()}else this._setConnectionState("disconnected")}getChannels(){return this.channels}async removeChannel(t){const r=await t.unsubscribe();return this.channels.length===0&&this.disconnect(),r}async removeAllChannels(){const t=await Promise.all(this.channels.map(r=>r.unsubscribe()));return this.channels=[],this.disconnect(),t}log(t,r,s){this.logger(t,r,s)}connectionState(){switch(this.conn&&this.conn.readyState){case vm.connecting:return Lc.Connecting;case vm.open:return Lc.Open;case vm.closing:return Lc.Closing;default:return Lc.Closed}}isConnected(){return this.connectionState()===Lc.Open}isConnecting(){return this._connectionState==="connecting"}isDisconnecting(){return this._connectionState==="disconnecting"}channel(t,r={config:{}}){const s=`realtime:${t}`,a=this.getChannels().find(i=>i.topic===s);if(a)return a;{const i=new LC(`realtime:${t}`,r,this);return this.channels.push(i),i}}push(t){const{topic:r,event:s,payload:a,ref:i}=t,o=()=>{this.encode(t,l=>{var c;(c=this.conn)===null||c===void 0||c.send(l)})};this.log("push",`${r} ${s} (${i})`,a),this.isConnected()?o():this.sendBuffer.push(o)}async setAuth(t=null){this._authPromise=this._performAuth(t);try{await this._authPromise}finally{this._authPromise=null}}async sendHeartbeat(){var t;if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(r){this.log("error","error in heartbeat callback",r)}return}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(r){this.log("error","error in heartbeat callback",r)}this._wasManualDisconnect=!1,(t=this.conn)===null||t===void 0||t.close(mZ,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.sc
610heduleTimeout()},nx.HEARTBEAT_TIMEOUT_FALLBACK);return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(r){this.log("error","error in heartbeat callback",r)}this._setAuthSafely("heartbeat")}onHeartbeat(t){this.heartbeatCallback=t}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(t=>t()),this.sendBuffer=[])}_makeRef(){let t=this.ref+1;return t===this.ref?this.ref=0:this.ref=t,this.ref.toString()}_leaveOpenTopic(t){let r=this.channels.find(s=>s.topic===t&&(s._isJoined()||s._isJoining()));r&&(this.log("transport",`leaving duplicate topic "${t}"`),r.unsubscribe())}_remove(t){this.channels=this.channels.filter(r=>r.topic!==t.topic)}_onConnMessage(t){this.decode(t.data,r=>{if(r.topic==="phoenix"&&r.event==="phx_reply")try{this.heartbeatCallback(r.payload.status==="ok"?"ok":"error")}catch(d){this.log("error","error in heartbeat callback",d)}r.ref&&r.ref===this.pendingHeartbeatRef&&(this.pendingHeartbeatRef=null);const{topic:s,event:a,payload:i,ref:o}=r,l=o?`(${o})`:"",c=i.status||"";this.log("receive",`${c} ${s} ${a} ${l}`.trim(),i),this.channels.filter(d=>d._isMember(s)).forEach(d=>d._trigger(a,i,o)),this._triggerStateCallbacks("message",r)})}_clearTimer(t){var r;t==="heartbeat"&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):t==="reconnect"&&((r=this.reconnectTimer)===null||r===void 0||r.reset())}_clearAllTimers(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}_setupConnectionHandlers(){this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=t=>this._onConnError(t),this.conn.onmessage=t=>this._onConnMessage(t),this.conn.onclose=t=>this._onConnClose(t))}_teardownConnection(){this.conn&&(this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null),this._clearAllTimers(),this.channels.forEach(t=>t.teardown())}_onConnOpen(){this._setConnectionState("connected"),this.log("transport",`connected to ${this.endpointURL()}`),this.flushSendBuffer(),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}_startHeartbeat(){this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this.sendHeartbeat(),this.heartbeatIntervalMs)}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");const t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=r=>{this.log("worker","worker error",r.message),this.workerRef.terminate()},this.workerRef.onmessage=r=>{r.data.event==="keepAlive"&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_onConnClose(t){var r;this._setConnectionState("disconnected"),this.log("transport","close",t),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||(r=this.reconnectTimer)===null||r===void 0||r.sc
610heduleTimeout(),this._triggerStateCallbacks("close",t)}_onConnError(t){this._setConnectionState("disconnected"),this.log("transport",`${t}`),this._triggerChanError(),this._triggerStateCallbacks("error",t)}_triggerChanError(){this.channels.forEach(t=>t._trigger(Ga.error))}_appendParams(t,r){if(Object.keys(r).length===0)return t;const s=t.match(/\?/)?"&":"?",a=new URLSearchParams(r);return`${t}${s}${a}`}_workerObjectUrl(t){let r;if(t)r=t;else{const s=new Blob([SZ],{type:"application/javascript"});r=URL.createObjectURL(s)}return r}_setConnectionState(t,r=!1){this._connectionState=t,t==="connecting"?this._wasManualDisconnect=!1:t==="disconnecting"&&(this._wasManualDisconnect=r)}async _performAuth(t=null){let r;t?r=t:this.accessToken?r=await this.accessToken():r=this.accessTokenValue,this.accessTokenValue!=r&&(this.accessTokenValue=r,this.channels.forEach(s=>{const a={access_token:r,version:hZ};r&&s.updateJoinPayload(a),s.joinedOnce&&s._isJoined()&&s._push(Ga.access_token,{access_token:r})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(t="general"){this.setAuth().catch(r=>{this.log("error",`error setting auth in ${t}`,r)})}_triggerStateCallbacks(t,r){try{this.stateChangeCallbacks[t].forEach(s=>{try{s(r)}catch(a){this.log("error",`error in ${t} callback`,a)}})}catch(s){this.log("error",`error triggering ${t} callbacks`,s)}}_setupReconnectionTimer(){this.reconnectTimer=new sF(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},nx.RECONNECT_DELAY)},this.reconnectAfterMs)}_initializeOptions(t){var r,s,a,i,o,l,c,d,u;if(this.transport=(r=t==null?void 0:t.transport)!==null&&r!==void 0?r:null,this.timeout=(s=t==null?void 0:t.timeout)!==null&&s!==void 0?s:fN,this.heartbeatIntervalMs=(a=t==null?void 0:t.heartbeatIntervalMs)!==null&&a!==void 0?a:nx.HEARTBEAT_INTERVAL,this.worker=(i=t==null?void 0:t.worker)!==null&&i!==void 0?i:!1,this.accessToken=(o=t==null?void 0:t.accessToken)!==null&&o!==void 0?o:null,this.heartbeatCallback=(l=t==null?void 0:t.heartbeatCallback)!==null&&l!==void 0?l:Bb,t!=null&&t.params&&(this.params=t.params),t!=null&&t.logger&&(this.logger=t.logger),(t!=null&&t.logLevel||t!=null&&t.log_level)&&(this.logLevel=t.logLevel||t.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=(c=t==null?void 0:t.reconnectAfterMs)!==null&&c!==void 0?c:h=>_Z[h-1]||NZ,this.encode=(d=t==null?void 0:t.encode)!==null&&d!==void 0?d:(h,f)=>f(JSON.stringify(h)),this.decode=(u=t==null?void 0:t.decode)!==null&&u!==void 0?u:this.serializer.decode.bind(this.serializer),this.worker){if(typeof window<"u"&&!window.Worker)throw new Error("Web Worker is not supported");this.workerUrl=t==null?void 0:t.workerUrl}}}class FC extends Error{constructor(t){super(t),this.__isStorageError=!0,this.name="StorageError"}}function mn(e){return typeof e=="object"&&e!==null&&"__isStorageError"in e}class kZ extends FC{constructor(t,r,s){super(t),this.name="StorageApiError",this.status=r,this.statusCode=s}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}class gN extends FC{constructor(t,r){super(t),this.name="StorageUnknownError",this.originalError=r}}var PZ=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};const oF=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...r)=>ag(async()=>{const{default:s}=await Promise.resolve().then(()=>Yh);return{default:s}},void 0).then(({default:s})=>s(...r)):t=fetch,(...r)=>t(...r)},TZ=()=>PZ(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield ag(()=>Promise.resolve().then(()=>Yh),void 0)).Response:Response}),xN=e=>{if(Array.isArray(e))return e.map(r=>xN(r));if(typeof e=="function"||e!==Object(e))return e;const t={};return Object.entries(e).forEach(([r,s])=>{const a=r.replace(/([-_][a-z])/gi,i=>i.toUpperCase().replace(/[-_]/g,""));t[a]=xN(s)}),t},AZ=e=>{if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);
610return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)};var Od=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};const qb=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),EZ=(e,t,r)=>Od(void 0,void 0,void 0,function*(){const s=yield TZ();e instanceof s&&!(r!=null&&r.noResolveJson)?e.json().then(a=>{const i=e.status||500,o=(a==null?void 0:a.statusCode)||i+"";t(new kZ(qb(a),i,o))}).catch(a=>{t(new gN(qb(a),a))}):t(new gN(qb(e),e))}),OZ=(e,t,r,s)=>{const a={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"||!s?a:(AZ(s)?(a.headers=Object.assign({"Content-Type":"application/json"},t==null?void 0:t.headers),a.body=JSON.stringify(s)):a.body=s,t!=null&&t.duplex&&(a.duplex=t.duplex),Object.assign(Object.assign({},a),r))};function og(e,t,r,s,a,i){return Od(this,void 0,void 0,function*(){return new Promise((o,l)=>{e(r,OZ(t,s,a,i)).then(c=>{if(!c.ok)throw c;return s!=null&&s.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>EZ(c,l,s))})})}function Iv(e,t,r,s){return Od(this,void 0,void 0,function*(){return og(e,"GET",t,r,s)})}function bi(e,t,r,s,a){return Od(this,void 0,void 0,function*(){return og(e,"POST",t,s,a,r)})}function vN(e,t,r,s,a){return Od(this,void 0,void 0,function*(){return og(e,"PUT",t,s,a,r)})}function MZ(e,t,r,s){return Od(this,void 0,void 0,function*(){return og(e,"HEAD",t,Object.assign(Object.assign({},r),{noResolveJson:!0}),s)})}function lF(e,t,r,s,a){return Od(this,void 0,void 0,function*(){return og(e,"DELETE",t,s,a,r)})}var us=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};const DZ={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},tA={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class RZ{constructor(t,r={},s,a){this.shouldThrowOnError=!1,this.url=t,this.headers=r,this.bucketId=s,this.fetch=oF(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(t,r,s,a){return us(this,void 0,void 0,function*(){try{let i;const o=Object.assign(Object.assign({},tA),a);let l=Object.assign(Object.assign({},this.headers),t==="POST"&&{"x-upsert":String(o.upsert)});const c=o.metadata;typeof Blob<"u"&&s instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),c&&i.append("metadata",this.encodeMetadata(c)),i.append("",s)):typeof FormData<"u"&&s instanceof FormData?(i=s,i.append("cacheControl",o.cacheControl),c&&i.append("metadata",this.encodeMetadata(c))):(i=s,l["cache-control"]=`max-age=${o.cacheControl}`,l["content-type"]=o.contentType,c&&(l["x-metadata"]=this.toBase64(this.encodeMetadata(c)))),a!=null&&a.headers&&(l=Object.assign(Object.assign({},l),a.headers));const d=this._removeEmptyFolders(r),u=this._getFinalPath(d),h=yield(t=="PUT"?vN:bi)(this.fetch,`${this.url}/object/${u}`,i,Object.assign({headers:l},o!=null&&o.duplex?{duplex:o.duplex}:{}));return{data:{path:d,id:h.Id,fullPath:h.Key},error:null}}catch(i){if(this.shouldThrowOnError)throw i;if(mn(i))return{data:null,error:i};throw i}})}upload(t,r,s){return us(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",t,r,s)})}uploadToSignedUrl(t,r,s,a){return us(this,void 0,void 0,function*(){const i=this._removeEmptyFolders(t),o=this._getFinalPath(i),l=new URL(this.url+`/object/upload/sign/${o}`);l.searchParams.set("token",r);try{let c;const d=Object.assign({upsert:tA.upsert},a),u=Object.assign(Object.assign({},this.headers),{"x-upsert":String(d.upsert)});typeof Blob<"u"&&s instanceof Blob?(c=new FormData,c.append("cacheControl",d.cacheControl),c.append("",s)):typeof FormData<"u"&&s instanceof FormData?(c=s,c.append("cacheControl",d.cacheControl)):(c=s,u["cache-control"]=`max-age=${d.cacheControl}`,u["content-type"]=d.contentType);const h=yield vN(this.fetch,l.toString(),c,{headers:u});return{data:{path:i,fullPath:h.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(mn(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(t,r){return us(this,void 0,void 0,function*(){try{let s=this._getFinalPath(t);const a=Object.assign({},this.headers);r!=null&&r.upsert&&(a["x-upsert"]="true");const i=yield bi(this.fetch,`${this.url}/object/upload/sign/${s}`,{},{headers:a}),o=new URL(this.url+i.url),l=o.searchParams.get("token");if(!l)throw new FC("No token returned by API");return{data:{signedUrl:o.toString(),path:t,token:l},error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(mn(s))return{data:null,error:s};throw s}})}update(t,r,s){return us(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",t,r,s)})}move(t,r,s){return us(this,void 0,void 0,function*(){try{return{data:yield bi(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:t,destinationKey:r,destinationBucket:s==null?void 0:s.destinationBucket},{headers:this.headers}),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(mn(a))return{data:null,error:a};throw a}})}copy(t,r,s){return us(this,void 0,void 0,function*(){try{return{data:{path:(yield bi(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:t,destinationKey:r,destinationBucket:s==null?void 0:s.destinationBucket},{headers:this.headers})).Key},error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(mn(a))return{data:null,error:a};throw a}})}createSignedUrl(t,r,s){return us(this,void 0,void 0,function*(){try{let a=this._getFinalPath(t),i=yield bi(this.fetch,`${this.url}/object/sign/${a}
610`,Object.assign({expiresIn:r},s!=null&&s.transform?{transform:s.transform}:{}),{headers:this.headers});const o=s!=null&&s.download?`&download=${s.download===!0?"":s.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(mn(a))return{data:null,error:a};throw a}})}createSignedUrls(t,r,s){return us(this,void 0,void 0,function*(){try{const a=yield bi(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:r,paths:t},{headers:this.headers}),i=s!=null&&s.download?`&download=${s.download===!0?"":s.download}`:"";return{data:a.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${i}`):null})),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(mn(a))return{data:null,error:a};throw a}})}download(t,r){return us(this,void 0,void 0,function*(){const a=typeof(r==null?void 0:r.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((r==null?void 0:r.transform)||{}),o=i?`?${i}`:"";try{const l=this._getFinalPath(t);return{data:yield(yield Iv(this.fetch,`${this.url}/${a}/${l}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(l){if(this.shouldThrowOnError)throw l;if(mn(l))return{data:null,error:l};throw l}})}info(t){return us(this,void 0,void 0,function*(){const r=this._getFinalPath(t);try{const s=yield Iv(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:xN(s),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(mn(s))return{data:null,error:s};throw s}})}exists(t){return us(this,void 0,void 0,function*(){const r=this._getFinalPath(t);try{return yield MZ(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(mn(s)&&s instanceof gN){const a=s.originalError;if([400,404].includes(a==null?void 0:a.status))return{data:!1,error:s}}throw s}})}getPublicUrl(t,r){const s=this._getFinalPath(t),a=[],i=r!=null&&r.download?`download=${r.download===!0?"":r.download}`:"";i!==""&&a.push(i);const l=typeof(r==null?void 0:r.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((r==null?void 0:r.transform)||{});c!==""&&a.push(c);let d=a.join("&");return d!==""&&(d=`?${d}`),{data:{publicUrl:encodeURI(`${this.url}/${l}/public/${s}${d}`)}}}remove(t){return us(this,void 0,void 0,function*(){try{return{data:yield lF(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:t},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(mn(r))return{data:null,error:r};throw r}})}list(t,r,s){return us(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},DZ),r),{prefix:t||""});return{data:yield bi(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},s),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(mn(a))return{data:null,error:a};throw a}})}listV2(t,r){return us(this,void 0,void 0,function*(){try{const s=Object.assign({},t);return{data:yield bi(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(mn(s))return{data:null,error:s};throw s}})}encodeMetadata(t){return JSON.stringify(t)}toBase64(t){return typeof Buffer<"u"?Buffer.from(t).toString("base64"):btoa(t)}_getFinalPath(t){return`${this.bucketId}/${t.replace(/^\/+/,"")}`}_removeEmptyFolders(t){return t.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(t){const r=[];return t.width&&r.push(`width=${t.width}`),t.height&&r.push(`height=${t.height}`),t.resize&&r.push(`resize=${t.resize}`),t.format&&r.push(`format=${t.format}`),t.quality&&r.push(`quality=${t.quality}`),r.join("&")}}const $Z="2.12.1",IZ={"X-Client-Info":`storage-js/${$Z}`};var qd=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};class LZ{constructor(t,r={},s,a){this.shouldThrowOnError=!1;const i=new URL(t);a!=null&&a.useNewHostname&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase.")),this.url=i.href,this.headers=Object.assign(Object.assign({},IZ),r),this.fetch=oF(s)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(){return qd(this,void 0,void 0,function*(){try{return{data:yield Iv(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(t){if(this.shouldThrowOnError)throw t;if(mn(t))return{data:null,error:t};throw t}})}getBucket(t){return qd(this,void 0,void 0,function*(){try{return{data:yield Iv(this.fetch,`${this.url}/bucket/${t}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(mn(r))return{data:null,error:r};throw r}})}createBucket(t,r={public:!1}){return qd(this,void 0,void 0,function*(){try{return{data:yield bi(this.fetch,`${this.url}/bucket`,{id:t,name:t,type:r.type,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(mn(s))return{data:null,error:s};throw s}})}updateBucket(t,r){return qd(this,void 0,void 0,function*(){try{return{data:yield vN(this.fetch,`${this.url}/bucket/${t}`,{id:t,name:t,public:r.public,file_size_limit:r.fileSizeLimit,allowed_mime_types:r.allowedMimeTypes},{headers:this.headers}),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(mn(s))return{data:null,error:s};throw s}})}emptyBucket(t){return qd(this,void 0,void 0,function*(){try{return{data:yield bi(this.fetch,`${this.url}/bucket/${t}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(mn(r))return{data:null,error:r};throw r}})}deleteBucket(t){return qd(this,void 0,void 0,function*(){try{return{data:yield lF(this.fetch,`${this.url}/bucket/${t}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(mn(r))return{data:null,error:r};throw r}})}}class FZ extends LZ{constructor(t,r={},s,a){super(t,r,s,a)}from(t){return new RZ(this.url,this.headers,t,this.fetch)}}const UZ="2.57.4";let Jf="";typeof Deno<"u"?Jf="deno":typeof document<"u"?Jf="web":typeof navigator<"u"&&navigator.product==="ReactNative"?Jf="react-native":Jf="node";const zZ={"X-Client-Info":`supabase-js-${Jf}/${UZ}`},BZ={headers:zZ},qZ={schema:"public"},WZ={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},HZ={};var VZ=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};const KZ=e=>{let t;return e?t=e:typeof fetch>"u"?t=KL:t=fetch,(...r)=>t(...r)},GZ=()=>typeof Headers>"u"?GL:Headers,YZ=(e,t,r)=>{const s=KZ(r),a=GZ();return(i,o)=>VZ(void 0,void 0,void 0,function*(){var l;const c=(l=yield t())!==null&&l!==void 0?l:e;let d=new a(o==null?void 0:o.headers);return d.has("apikey")||d.set("apikey",e),d.has("Authorization")||d.set("Authorization",`Bearer ${c}`),s(i,Object.assign(Object.assign({},o),{headers:d}))})};var QZ=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};function XZ(e){return e.endsWith("/")?e:e+"/"}function ZZ(e,t){var r,s;const{db:a,auth:i,realtime:o,global:l}=e,{db:c,auth:d,realtime:u,global:h}=t,f={db:Object.assign(Object.assign({},c),a),auth:Object.assign(Object.assign({},d),i),realtime:Object.assign(Object.assign({},u),o),storage:{},global:Object.assign(Object.assign(Object.assign({},h),l),{headers:Object.assign(Object.assign({},(r=h==null?void 0:h.headers)!==null&&r!==void 0?r:{}),(s=l==null?void 0:l.headers)!==null&&s!==void 0?s:{})}),accessToken:()=>QZ(this,void 0,void 0,function*(){return""})};return e.accessToken?f.accessToken=e.accessToken:delete f.accessToken,f}function JZ(e){const t=e==null?void 0:e.trim();if(!t)throw new Error("supabaseUrl is required.");
610if(!t.match(/^https?:\/\//i))throw new Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(XZ(t))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const cF="2.71.1",nu=30*1e3,yN=3,Wb=yN*nu,eJ="http://localhost:9999",tJ="supabase.auth.token",rJ={"X-Client-Info":`gotrue-js/${cF}`},jN="X-Supabase-Api-Version",dF={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},nJ=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,sJ=10*60*1e3;class UC extends Error{constructor(t,r,s){super(t),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=s}}function vt(e){return typeof e=="object"&&e!==null&&"__isAuthError"in e}class aJ extends UC{constructor(t,r,s){super(t,r,s),this.name="AuthApiError",this.status=r,this.code=s}}function iJ(e){return vt(e)&&e.name==="AuthApiError"}class uF extends UC{constructor(t,r){super(t),this.name="AuthUnknownError",this.originalError=r}}class cc extends UC{constructor(t,r,s,a){super(t,s,a),this.name=r,this.status=s}}class dl extends cc{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function oJ(e){return vt(e)&&e.name==="AuthSessionMissingError"}class sx extends cc{constructor(){super("Auth session or user missing","AuthInvalidToken
610ResponseError",500,void 0)}}class ax extends cc{constructor(t){super(t,"AuthInvalidCredentialsError",400,void 0)}}class ix extends cc{constructor(t,r=null){super(t,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}function lJ(e){return vt(e)&&e.name==="AuthImplicitGrantRedirectError"}class rA extends cc{constructor(t,r=null){super(t,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=r}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class bN extends cc{constructor(t,r){super(t,"AuthRetryableFetchError",r,void 0)}}function Hb(e){return vt(e)&&e.name==="AuthRetryableFetchError"}class nA extends cc{constructor(t,r,s){super(t,"AuthWeakPasswordError",r,"weak_password"),this.reasons=s}}class wN extends cc{constructor(t){super(t,"AuthInvalidJwtError",400,"invalid_jwt")}}const Lv="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),sA=` 	
611\r=`.split(""),cJ=(()=>{const e=new Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<sA.length;t+=1)e[sA[t].charCodeAt(0)]=-2;for(let t=0;t<Lv.length;t+=1)e[Lv[t].charCodeAt(0)]=t;return e})();function aA(e,t,r){if(e!==null)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;){const s=t.queue>>t.queuedBits-6&63;r(Lv[s]),t.queuedBits-=6}else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;){const s=t.queue>>t.queuedBits-6&63;r(Lv[s]),t.queuedBits-=6}}function hF(e,t,r){const s=cJ[e];if(s>-1)for(t.queue=t.queue<<6|s,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else{if(s===-2)return;throw new Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}}function iA(e){const t=[],r=o=>{t.push(String.fromCodePoint(o))},s={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},i=o=>{hJ(o,s,r)};for(let o=0;o<e.length;o+=1)hF(e.charCodeAt(o),a,i);return t.join("")}function dJ(e,t){if(e<=127){t(e);return}else if(e<=2047){t(192|e>>6),t(128|e&63);return}else if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|e&63);return}else if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|e&63);return}throw new Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}function uJ(e,t){for(let r=0;r<e.length;r+=1){let s=e.charCodeAt(r);if(s>55295&&s<=56319){const a=(s-55296)*1024&65535;s=(e.charCodeAt(r+1)-56320&65535|a)+65536,r+=1}dJ(s,t)}}function hJ(e,t,r){if(t.utf8seq===0){if(e<=127){r(e);return}for(let s=1;s<6;s+=1)if(!(e>>7-s&1)){t.utf8seq=s;break}if(t.utf8seq===2)t.codepoint=e&31;else if(t.utf8seq===3)t.codepoint=e&15;else if(t.utf8seq===4)t.codepoint=e&7;else throw new Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw new Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|e&63,t.utf8seq-=1,t.utf8seq===0&&r(t.codepoint)}}function fJ(e){const t=[],r={queue:0,queuedBits:0},s=a=>{t.push(a)};for(let a=0;a<e.length;a+=1)hF(e.charCodeAt(a),r,s);return new Uint8Array(t)}function mJ(e){const t=[];return uJ(e,r=>t.push(r)),new Uint8Array(t)}function pJ(e){const t=[],r={queue:0,queuedBits:0},s=a=>{t.push(a)};return e.forEach(a=>aA(a,r,s)),aA(null,r,s),t.join("")}function gJ(e){return Math.round(Date.now()/1e3)+e}function xJ(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}const Ba=()=>typeof window<"u"&&typeof document<"u",bc={tested:!1,writable:!1},fF=()=>{if(!Ba())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(bc.tested)return bc.writable;const e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),bc.tested=!0,bc.writable=!0}catch{bc.tested=!0,bc.writable=!1}return bc.writable};function vJ(e){const t={},r=new URL(e);if(r.hash&&r.hash[0]==="#")try{new URLSearchParams(r.hash.substring(1)).forEach((a,i)=>{t[i]=a})}catch{}return r.searchParams.forEach((s,a)=>{t[a]=s}),t}const mF=e=>{let t;return e?t=e:typeof fetch>"u"?t=(...r)=>ag(async()=>{const{default:s}=await Promise.resolve().then(()=>Yh);return{default:s}},void 0).then(({default:s})=>s(...r)):t=fetch,(...r)=>t(...r)},yJ=e=>typeof e=="object"&&e!==null&&"status"in e&&"ok"in e&&"json"in e&&typeof e.json=="function",su=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},wc=async(e,t)=>{const r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch{return r}},ol=async(e,t)=>{await e.removeItem(t)};class F0{constructor(){this.promise=new F0.promiseConstructor((t,r)=>{this.resolve=t,this.reject=r})}}F0.promiseConstructor=Promise;function Vb(e){const t=e.split(".");if(t.length!==3)throw new wN("Invalid JWT structure");for(let s=0;s<t.length;s++)if(!nJ.test(t[s]))throw new wN("JWT not in base64url format");return{header:JSON.parse(iA(t[0])),payload:JSON.parse(iA(t[1])),signature:fJ(t[2]),raw:{header:t[0],payload:t[1]}}}async function jJ(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function bJ(e,t){return new Promise((s,a)=>{(async()=>{for(let i=0;i<1/0;i++)try{const o=await e(i);if(!t(i,null,o)){s(o);return}}catch(o){if(!t(i,o)){a(o);return}}})()})}function wJ(e){return("0"+e.toString(16)).substr(-2)}function _J(){const t=new Uint32Array(56);if(typeof crypto>"u"){const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",s=r.length;let a="";for(let i=0;i<56;i++)a+=r.charAt(Math.floor(Math.random()*s));return a}return crypto.getRandomValues(t),Array.from(t,wJ).join("")}async function NJ(e){const r=new TextEncoder().encode(e),s=await crypto.subtle.digest("SHA-256",r),a=new Uint8Array(s);return Array.from(a).map(i=>String.fromCharCode(i)).join("")}async function SJ(e){if(!(typeof crypto<"u"&&typeof crypto.subtle<"u"&&typeof TextEncoder<"u"))return console.warn("WebCrypto API is not supported. Code 
611challenge method will default to use plain instead of sha256."),e;const r=await NJ(e);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Wd(e,t,r=!1){const s=_J();let a=s;r&&(a+="/PASSWORD_RECOVERY"),await su(e,`${t}-code-verifier`,a);const i=await SJ(s);return[i,s===i?"plain":"s256"]}const CJ=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function kJ(e){const t=e.headers.get(jN);if(!t||!t.match(CJ))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch{return null}}function PJ(e){if(!e)throw new Error("Missing exp claim");const t=Math.floor(Date.now()/1e3);if(e<=t)throw new Error("JWT has expired")}function TJ(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw new Error("Invalid alg claim")}}const AJ=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function Hd(e){if(!AJ.test(e))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function Kb(){const e={};return new Proxy(e,{get:(t,r)=>{if(r==="__isUserNotAvailableProxy")return!0;if(typeof r=="symbol"){const s=r.toString();if(s==="Symbol(Symbol.toPrimitive)"||s==="Symbol(Symbol.toStringTag)"||s==="Symbol(util.inspect.custom)")return}throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${r}" property of the session object is not supported. Please use getUser() instead.`)},set:(t,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(t,r)=>{throw new Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${r}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function oA(e){return JSON.parse(JSON.stringify(e))}var EJ=function(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(r[s[a]]=e[s[a]]);return r};const Oc=e=>e.msg||e.message||e.error_description||e.error||JSON.stringify(e),OJ=[502,503,504];async function lA(e){var t;if(!yJ(e))throw new bN(Oc(e),0);if(OJ.includes(e.status))throw new bN(Oc(e),e.status);let r;try{r=await e.json()}catch(i){throw new uF(Oc(i),i)}let s;const a=kJ(e);if(a&&a.getTime()>=dF["2024-01-01"].timestamp&&typeof r=="object"&&r&&typeof r.code=="string"?s=r.code:typeof r=="object"&&r&&typeof r.error_code=="string"&&(s=r.error_code),s){if(s==="weak_password")throw new nA(Oc(r),e.status,((t=r.weak_password)===null||t===void 0?void 0:t.reasons)||[]);if(s==="session_not_found")throw new dl}else if(typeof r=="object"&&r&&typeof r.weak_password=="object"&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((i,o)=>i&&typeof o=="string",!0))throw new nA(Oc(r),e.status,r.weak_password.reasons);throw new aJ(Oc(r),e.status||500,s)}const MJ=(e,t,r,s)=>{const a={method:e,headers:(t==null?void 0:t.headers)||{}};return e==="GET"?a:(a.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},t==null?void 0:t.headers),a.body=JSON.stringify(s),Object.assign(Object.assign({},a),r))};async function kt(e,t,r,s){var a;const i=Object.assign({},s==null?void 0:s.headers);i[jN]||(i[jN]=dF["2024-01-01"].name),s!=null&&s.jwt&&(i.Authorization=`Bearer ${s.jwt}`);const o=(a=s==null?void 0:s.query)!==null&&a!==void 0?a:{};s!=null&&s.redirectTo&&(o.redirect_to=s.redirectTo);const l=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=await DJ(e,t,r+l,{headers:i,noResolveJson:s==null?void 0:s.noResolveJson},{},s==null?void 0:s.body);return s!=null&&s.xform?s==null?void 0:s.xform(c):{data:Object.assign({},c),error:null}}async function DJ(e,t,r,s,a,i){const o=MJ(t,s,a,i);let l;try{l=await e(r,Object.assign({},o))}catch(c){throw console.error(c),new bN(Oc(c),0)}if(l.ok||await lA(l),s!=null&&s.noResolveJson)return l;try{return await l.json()}catch(c){await lA(c)}}function io(e){var t;let r=null;LJ(e)&&(r=Object.assign({},e),e.expires_at||(r.expires_at=gJ(e.expires_in)));const s=(t=e.user)!==null&&t!==void 0?t:e;return{data:{session:r,user:s},error:null}}function cA(e){const t=io(e);return!t.error&&e.weak_password&&typeof e.weak_password=="object"&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&typeof e.weak_password.message=="string"&&e.weak_password.reasons.reduce((r,s)=>r&&typeof s=="string",!0)&&(t.data.weak_password=e.weak_password),t}function jl(e){var t;return{data:{user:(t=e.user)!==null&&t!==void 0?t:e},error:null}}function RJ(e){return{data:e,error:null}}function $J(e){const{action_link:t,email_otp:r,hashed_token:s,redirect_to:a,verification_type:i}=e,o=EJ(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),l={action_link:t,email_otp:r,hashed_token:s,redirect_to:a,verification_type:i},c=Object.assign({},o);return{data:{properties:l,user:c},error:null}}function IJ(e){return e}function LJ(e){return e.access_token&&e.refresh_token&&e.expires_in}const Gb=["global","local","others"];var FJ=function(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(r[s[a]]=e[s[a]]);return r};class UJ{constructor({url:t="",headers:r={},fetch:s}){this.url=t,this.headers=r,this.fetch=mF(s),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}async signOut(t,r=Gb[0]){if(Gb.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${Gb.join(", ")}`);try{return await kt(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:t,noResolveJson:!0}),{data:null,error:null}}catch(s){if(vt(s))return{data:null,error:s};throw s}}async inviteUserByEmail(t,r={}){try{return await kt(this.fetch,"POST",`${this.url}/invite`,{body:{email:t,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:jl})}catch(s){if(vt(s))return{data:{user:null},error:s};throw s}}async generateLink(t){try{const{options:r}=t,s=FJ(t,["options"]),a=Object.assign(Object.assign({},s),r);return"newEmail"in s&&(a.new_email=s==null?void 0:s.newEmail,delete a.newEmail),await kt(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:$J,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(vt(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(t){try{return await kt(this.fetch,"POST",`${this.url}/admin/users`,{body:t,headers:this.headers,xform:jl})}catch(r){if(vt(r))return{data:{user:null},error:r};throw r}}async listUsers(t){var r,s,a,i,o,l,c;try{const d={nextPage:null,lastPage:0,total:0},u=await kt(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(s=(r=t==null?void 0:t.page)===null||r===void 0?void 0:r.toString())!==null&&s!==void 0?s:"",per_page:(i=(a=t==null?void 0:t.perPage)===null||a===void 0?void 0:a.toString())!==null&&i!==void 0?i:""},xform:IJ});if(u.error)throw u.error;const h=await u.json(),f=(o=u.headers.get("x-total-count"))!==null&&o!==void 0?o:0,m=(c=(l=u.headers.get("link"))===null||l===void 0?void 0:l.split(","))!==null&&c!==void 0?c:[];return m.length>0&&(m.forEach(g=>{const p=parseInt(g.split(";")[0].split("=")[1].substring(0,1)),y=JSON.parse(g.split(";")[1].split("=")[1]);d[`${y}Page`]=p}),d.total=parseInt(f)),{data:Object.assign(Object.assign({},h),d),error:null}}catch(d){if(vt(d))return{data:{users:[]},error:d};throw d}}async getUserById(t){Hd(t);try{return await kt(this.fetch,"GET",`${this.url}/admin/users/${t}`,{headers:this.headers,xform:jl})}catch(r){if(vt(r))return{data:{user:null},error:r};throw r}}async updateUserById(t,r){Hd(t);try{return await kt(this.fetch,"PUT",`${this.url}/admin/users/${t}`,{body:r,headers:this.headers,xform:jl})}catch(s){if(vt(s))return{data:{user:null},error:s};throw s}}async deleteUser(t,r=!1){Hd(t);
611try{return await kt(this.fetch,"DELETE",`${this.url}/admin/users/${t}`,{headers:this.headers,body:{should_soft_delete:r},xform:jl})}catch(s){if(vt(s))return{data:{user:null},error:s};throw s}}async _listFactors(t){Hd(t.userId);try{const{data:r,error:s}=await kt(this.fetch,"GET",`${this.url}/admin/users/${t.userId}/factors`,{headers:this.headers,xform:a=>({data:{factors:a},error:null})});return{data:r,error:s}}catch(r){if(vt(r))return{data:null,error:r};throw r}}async _deleteFactor(t){Hd(t.userId),Hd(t.id);try{return{data:await kt(this.fetch,"DELETE",`${this.url}/admin/users/${t.userId}/factors/${t.id}`,{headers:this.headers}),error:null}}catch(r){if(vt(r))return{data:null,error:r};throw r}}}function dA(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}function zJ(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}const Vd={debug:!!(globalThis&&fF()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class pF extends Error{constructor(t){super(t),this.isAcquireTimeout=!0}}class BJ extends pF{}async function qJ(e,t,r){Vd.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);const s=new globalThis.AbortController;return t>0&&setTimeout(()=>{s.abort(),Vd.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,t===0?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:s.signal},async a=>{if(a){Vd.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,a.name);try{return await r()}finally{Vd.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,a.name)}}else{if(t===0)throw Vd.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new BJ(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(Vd.debug)try{const i=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(i,null,"  "))}catch(i){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",i)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),await r()}}))}zJ();const WJ={url:eJ,storageKey:tJ,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:rJ,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function uA(e,t,r){return await r()}const Kd={};class rp{constructor(t){var r,s;this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log,this.instanceID=rp.nextInstanceID,rp.nextInstanceID+=1,this.instanceID>0&&Ba()&&console.warn("Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");const a=Object.assign(Object.assign({},WJ),t);if(this.logDebugMessages=!!a.debug,typeof a.debug=="function"&&(this.logger=a.debug),this.persistSession=a.persistSession,this.storageKey=a.storageKey,this.autoRefreshToken=a.autoRefreshToken,this.admin=new UJ({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=mF(a.fetch),this.lock=a.lock||uA,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:Ba()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=qJ:this.lock=uA,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:fF()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=dA(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=dA(this.memoryStorage)),Ba()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(i){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",i)}(s=this.broadcastChannel)===null||s===void 0||s.addEventListener("message",async i=>{this._debug("received broadcast notification from other tab or client",i),await this._notifyAllSubscribers(i.data.event,i.data.session,!1)})}this.initialize()}get jwks(){var t,r;return(r=(t=Kd[this.storageKey])===null||t===void 0?void 0:t.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(t){Kd[this.storageKey]=Object.assign(Object.assign({},Kd[this.storageKey]),{jwks:t})}get jwks_cached_at(){var t,r;return(r=(t=Kd[this.storageKey])===null||t===void 0?void 0:t.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(t){Kd[this.storageKey]=Object.assign(Object.assign({},Kd[this.storageKey]),{cachedAt:t})}_debug(...t){return this.logDebugMessages&&this.logger(`GoTrueClient@${this.instanceID} (${cF}) ${new Date().toISOString()}`,...t),this}async initialize(){return this.initializePromise?await this.initializePromise:(this.initializePromise=(async()=>await this._acquireLock(-1,async()=>await this._initialize()))(),await this.initializePromise)}async _initialize(){var t;try{const r=vJ(window.location.href);let s="none";if(this._isImplicitGrantCallback(r)?s="implicit":await this._isPKCECallback(r)&&(s="pkce"),Ba()&&this.detectSessionInUrl&&s!=="none"){const{data:a,error:i}=await this._getSessionFromURL(r,s);if(i){if(this._debug("#_initialize()","error detecting session from URL",i),lJ(i)){const c=(t=i.details)===null||t===void 0?void 0:t.code;if(c==="identity_already_exists"||c==="identity_not_found"||c==="single_identity_not_deletable")return{error:i}}return await this._removeSession(),{error:i}}const{session:o,redirectType:l}=a;return this._debug("#_initialize()","detected session in URL",o,"redirect type",l),await this._saveSession(o),setTimeout(async()=>{l==="recovery"?await this._notifyAllSubscribers("PASSWORD_RECOVERY",o):await this._notifyAllSubscribers("SIGNED_IN",o)},0),{error:null}}return await this._recoverAndRefresh(),{error:null}}catch(r){return vt(r)?{error:r}:{error:new uF("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(t){var r,s,a;try{const i=await kt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{data:(s=(r=t==null?void 0:t.options)===null||r===void 0?void 0:r.data)!==null&&s!==void 0?s:{},gotrue_meta_security:{captcha_token:(a=t==null?void 0:t.options)===null||a===void 0?void 0:a.captchaToken}},xform:io}),{data:o,error:l}=i;if(l||!o)return{data:{user:null,session:null},error:l};const c=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:d,session:c},error:null}}catch(i){if(vt(i))return{data:{user:null,session:null},error:i};throw i}}async signUp(t){var r,s,a;try{let i;if("email"in t){const{email:u,password:h,options:f}=t;let m=null,g=null;this.flowType==="pkce"&&([m,g]=await Wd(this.storage,this.storageKey)),i=await kt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:f==null?void 0:f.emailRedirectTo,body:{email:u,password:h,data:(r=f==null?void 0:f.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken},code_challenge:m,code_challenge_method:g},xform:io})}else if("phone"in t){const{phone:u,password:h,options:f}=t;i=await kt(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:h,data:(s=f==null?void 0:f.data)!==null&&s!==void 0?s:{},channel:(a=f==null?void 0:f.channel)!==null&&a!==void 0?a:"sms",gotrue_meta_security:{captcha_token:f==null?void 0:f.captchaToken}},xform:io})}else throw new ax("You must provide either an email or phone number and a password");const{data:o,error:l}=i;if(l||!o)return{data:{user:null,session:null},error:l};const c=o.session,d=o.user;return o.session&&(await this._saveSession(o.session),await this._notifyAllSubscribers("SIGNED_IN",c)),{data:{user:d,session:c},error:null}}catch(i){if(vt(i))return{data:{user:null,session:null},error:i};throw i}}async signInWithPassword(t){try{let r;if("email"in t){const{email:i,password:o,options:l}=t;r=await kt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:cA})}else if("phone"in t){const{phone:i,password:o,options:l}=t;r=await kt(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:i,password:o,gotrue_meta_security:{captcha_token:l==null?void 0:l.captchaToken}},xform:cA})}else throw new ax("You must provide either an email or phone number and a password");const{data:s,error:a}=r;return a?{data:{user:null,session:null},error:a}:!s||!s.session||!s.user?{data:{user:null,session:null},error:new sx}:(s.session&&(await this._saveSession(s.session),await this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:Object.assign({user:s.user,session:s.session},s.weak_password?{weakPassword:s.weak_password}:null),error:a})}catch(r){if(vt(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOAuth(t){var r,s,a,i;return await this._handleProviderSignIn(t.provider,{redirectTo:(r=t.options)===null||r===void 0?void 0:r.redirectTo,scopes:(s=t.options)===null||s===void 0?void 0:s.scopes,queryParams:(a=t.options)===null||a===void 0?void 0:a.queryParams,skipBrowserRedirect:(i=t.options)===null||i===void 0?void 0:i.skipBrowserRedirect})}async exchangeCodeForSession(t){return await this.initializePromise,this._acquireLock(-1,async()=>this._exchangeCodeForSession(t))}async signInWithWeb3(t){const{chain:r}=t;if(r==="solana")return await this.signInWithSolana(t);throw new Error(`@supabase/auth-js: Unsupported chain "${r}"`)}async signInWithSolana(t){var r,s,a,i,o,l,c,d,u,h,f,m;let g,p;if("message"in t)g=t.message,p=t.signature;else{const{chain:y,wallet:v,statement:j,options:b}=t;let _;if(Ba())if(typeof v=="object")_=v;else{const N=window;if("solana"in N&&typeof N.solana=="object"&&("signIn"in N.solana&&typeof N.solana.signIn=="function"||"signMessage"in N.solana&&typeof N.solana.signMessage=="function"))_=N.solana;else throw new Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.")}else{if(typeof v!="object"||!(b!=null&&b.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");_=v}const w=new URL((r=b==null?void 0:b.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in _&&_.signIn){const N=await _.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},b==null?void 0:b.signInWithSolana),{version:"1",domain:w.host,uri:w.href}),j?{statement:j}:null));let S;if(Array.isArray(N)&&N[0]&&typeof N[0]=="object")S=N[0];else if(N&&typeof N=="object"&&"signedMessage"in N&&"signature"in N)S=N;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in S&&"signature"in S&&(typeof S.signedMessage=="string"||S.signedMessage instanceof Uint8Array)&&S.signature instanceof Uint8Array)g=typeof S.signedMessage=="string"?S.signedMessage:new TextDecoder().decode(S.signedMessage),p=S.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in _)||typeof _.signMessage!="function"||!("publicKey"in _)||typeof _!="object"||!_.publicKey||!("toBase58"in _.publicKey)||typeof _.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");g=[`${w.host} wants you to sign in with your Solana account:`,_.publicKey.toBase58(),...j?["",j,""]:[""],"Version: 1",`URI: ${w.href}`,`Issued At: ${(a=(s=b==null?void 0:b.signInWithSolana)===null||s===void 0?void 0:s.issuedAt)!==null&&a!==void 0?a:new Date().toISOString()}`,...!((i=b==null?void 0:b.signInWithSolana)===null||i===void 0)&&i.notBefore?[`Not Before: ${b.signInWithSolana.notBefore}`]:[],...!((o=b==null?void 0:b.signInWithSolana)===null||o===void 0)&&o.expirationTime?[`Expiration Time: ${b.signInWithSolana.expirationTime}`]:[],...!((l=b==null?void 0:b.signInWithSolana)===null||l===void 0)&&l.chainId?[`Chain ID: ${b.signInWithSolana.chainId}`]:[],...!((c=b==null?void 0:b.signInWithSolana)===null||c===void 0)&&c.nonce?[`Nonce: ${b.signInWithSolana.nonce}`]:[],...!((d=b==null?void 0:b.signInWithSolana)===null||d===void 0)&&d.requestId?[`Request ID: ${b.signInWithSolana.requestId}`]:[],...!((h=(u=b==null?void 0:b.signInWithSolana)===null||u===void 0?void 0:u.resources)===null||h===void 0)&&h.length?["Resources",...b.signInWithSolana.resources.map(S=>`- ${S}`)]:[]].join(`
612`);const N=await _.signMessage(new TextEncoder().encode(g),"utf8");if(!N||!(N instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=N}}try{const{data:y,error:v}=await kt(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:g,signature:pJ(p)},!((f=t.options)===null||f===void 0)&&f.captchaToken?{gotrue_meta_security:{captcha_token:(m=t.options)===null||m===void 0?void 0:m.captchaToken}}:null),xform:io});if(v)throw v;return!y||!y.session||!y.user?{data:{user:null,session:null},error:new sx}:(y.session&&(await this._saveSession(y.session),await this._notifyAllSubscribers("SIGNED_IN",y.session)),{data:Object.assign({},y),error:v})}catch(y){if(vt(y))return{data:{user:null,session:null},error:y};throw y}}async _exchangeCodeForSession(t){const r=await wc(this.storage,`${this.storageKey}-code-verifier`),[s,a]=(r??"").split("/");try{const{data:i,error:o}=await kt(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:t,code_verifier:s},xform:io});if(await ol(this.storage,`${this.storageKey}-code-verifier`),o)throw o;return!i||!i.session||!i.user?{data:{user:null,session:null,redirectType:null},error:new sx}:(i.session&&(await this._saveSession(i.session),await this._notifyAllSubscribers("SIGNED_IN",i.session)),{data:Object.assign(Object.assign({},i),{redirectType:a??null}),error:o})}catch(i){if(vt(i))return{data:{user:null,session:null,redirectType:null},error:i};throw i}}async signInWithIdToken(t){try{const{options:r,provider:s,token:a,access_token:i,nonce:o}=t,l=await kt(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:s,id_token:a,access_token:i,nonce:o,gotrue_meta_security:{captcha_token:r==null?void 0:r.captchaToken}},xform:io}),{data:c,error:d}=l;return d?{data:{user:null,session:null},error:d}:!c||!c.session||!c.user?{data:{user:null,session:null},error:new sx}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:d})}catch(r){if(vt(r))return{data:{user:null,session:null},error:r};throw r}}async signInWithOtp(t){var r,s,a,i,o;try{if("email"in t){
612const{email:l,options:c}=t;let d=null,u=null;this.flowType==="pkce"&&([d,u]=await Wd(this.storage,this.storageKey));const{error:h}=await kt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:l,data:(r=c==null?void 0:c.data)!==null&&r!==void 0?r:{},create_user:(s=c==null?void 0:c.shouldCreateUser)!==null&&s!==void 0?s:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},code_challenge:d,code_challenge_method:u},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:h}}if("phone"in t){const{phone:l,options:c}=t,{data:d,error:u}=await kt(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:l,data:(a=c==null?void 0:c.data)!==null&&a!==void 0?a:{},create_user:(i=c==null?void 0:c.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(o=c==null?void 0:c.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null,messageId:d==null?void 0:d.message_id},error:u}}throw new ax("You must provide either an email or phone number.")}catch(l){if(vt(l))return{data:{user:null,session:null},error:l};throw l}}async verifyOtp(t){var r,s;try{let a,i;"options"in t&&(a=(r=t.options)===null||r===void 0?void 0:r.redirectTo,i=(s=t.options)===null||s===void 0?void 0:s.captchaToken);const{data:o,error:l}=await kt(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},t),{gotrue_meta_security:{captcha_token:i}}),redirectTo:a,xform:io});if(l)throw l;if(!o)throw new Error("An error occurred on token verification.");const c=o.session,d=o.user;return c!=null&&c.access_token&&(await this._saveSession(c),await this._notifyAllSubscribers(t.type=="recovery"?"PASSWORD_RECOVERY":"SIGNED_IN",c)),{data:{user:d,session:c},error:null}}catch(a){if(vt(a))return{data:{user:null,session:null},error:a};throw a}}async signInWithSSO(t){var r,s,a;try{let i=null,o=null;return this.flowType==="pkce"&&([i,o]=await Wd(this.storage,this.storageKey)),await kt(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in t?{provider_id:t.providerId}:null),"domain"in t?{domain:t.domain}:null),{redirect_to:(s=(r=t.options)===null||r===void 0?void 0:r.redirectTo)!==null&&s!==void 0?s:void 0}),!((a=t==null?void 0:t.options)===null||a===void 0)&&a.captchaToken?{gotrue_meta_security:{captcha_token:t.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:i,code_challenge_method:o}),headers:this.headers,xform:RJ})}catch(i){if(vt(i))return{data:null,error:i};throw i}}async reauthenticate(){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._reauthenticate())}async _reauthenticate(){try{return await this._useSession(async t=>{const{data:{session:r},error:s}=t;if(s)throw s;if(!r)throw new dl;const{error:a}=await kt(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(t){if(vt(t))return{data:{user:null,session:null},error:t};throw t}}async resend(t){try{const r=`${this.url}/resend`;if("email"in t){const{email:s,type:a,options:i}=t,{error:o}=await kt(this.fetch,"POST",r,{headers:this.headers,body:{email:s,type:a,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}},redirectTo:i==null?void 0:i.emailRedirectTo});return{data:{user:null,session:null},error:o}}else if("phone"in t){const{phone:s,type:a,options:i}=t,{data:o,error:l}=await kt(this.fetch,"POST",r,{headers:this.headers,body:{phone:s,type:a,gotrue_meta_security:{captcha_token:i==null?void 0:i.captchaToken}}});return{data:{user:null,session:null,messageId:o==null?void 0:o.message_id},error:l}}throw new ax("You must provide either an email or phone number and a type")}catch(r){if(vt(r))return{data:{user:null,session:null},error:r};throw r}}async getSession(){return await this.initializePromise,await this._acquireLock(-1,async()=>this._useSession(async r=>r))}async _acquireLock(t,r){this._debug("#_acquireLock","begin",t);try{if(this.lockAcquired){const s=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),a=(async()=>(await s,await r()))();return this.pendingInLock.push((async()=>{try{await a}catch{}})()),a}return await this.lock(`lock:${this.storageKey}`,t,async()=>{this._debug("#_acquireLock","lock acquired for storage key",this.storageKey);try{this.lockAcquired=!0;const s=r();for(this.pendingInLock.push((async()=>{try{await s}catch{}})()),await s;this.pendingInLock.length;){const a=[...this.pendingInLock];await Promise.all(a),this.pendingInLock.splice(0,a.length)}return await s}finally{this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1}})}finally{this._debug("#_acquireLock","end")}}async _useSession(t){this._debug("#_useSession","begin");try{const r=await this.__loadSession();return await t(r)}finally{this._debug("#_useSession","end")}}async __loadSession(){this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",new Error().stack);try{let t=null;const r=await wc(this.storage,this.storageKey);if(this._debug("#getSession()","session from storage",r),r!==null&&(this._isValidSession(r)?t=r:(this._debug("#getSession()","session from storage is not val
612id"),await this._removeSession())),!t)return{data:{session:null},error:null};const s=t.expires_at?t.expires_at*1e3-Date.now()<Wb:!1;if(this._debug("#__loadSession()",`session has${s?"":" not"} expired`,"expires_at",t.expires_at),!s){if(this.userStorage){const o=await wc(this.userStorage,this.storageKey+"-user");o!=null&&o.user?t.user=o.user:t.user=Kb()}if(this.storage.isServer&&t.user){let o=this.suppressGetSessionWarning;t=new Proxy(t,{get:(c,d,u)=>(!o&&d==="user"&&(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),o=!0,this.suppressGetSessionWarning=!0),Reflect.get(c,d,u))})}return{data:{session:t},error:null}}const{session:a,error:i}=await this._callRefreshToken(t.refresh_token);return i?{data:{session:null},error:i}:{data:{session:a},error:null}}finally{this._debug("#__loadSession()","end")}}async getUser(t){return t?await this._getUser(t):(await this.initializePromise,await this._acquireLock(-1,async()=>await this._getUser()))}async _getUser(t){try{return t?await kt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:t,xform:jl}):await this._useSession(async r=>{var s,a,i;const{data:o,error:l}=r;if(l)throw l;return!(!((s=o.session)===null||s===void 0)&&s.access_token)&&!this.hasCustomAuthorizationHeader?{data:{user:null},error:new dl}:await kt(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:(i=(a=o.session)===null||a===void 0?void 0:a.access_token)!==null&&i!==void 0?i:void 0,xform:jl})})}catch(r){if(vt(r))return oJ(r)&&(await this._removeSession(),await ol(this.storage,`${this.storageKey}-code-verifier`)),{data:{user:null},error:r};throw r}}async updateUser(t,r={}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._updateUser(t,r))}async _updateUser(t,r={}){try{return await this._useSession(async s=>{const{data:a,error:i}=s;if(i)throw i;if(!a.session)throw new dl;const o=a.session;let l=null,c=null;this.flowType==="pkce"&&t.email!=null&&([l,c]=await Wd(this.storage,this.storageKey));const{data:d,error:u}=await kt(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:r==null?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},t),{code_challenge:l,code_challenge_method:c}),jwt:o.access_token,xform:jl});if(u)throw u;return o.user=d.user,await this._saveSession(o),await this._notifyAllSubscribers("USER_UPDATED",o),{data:{user:o.user},error:null}})}catch(s){if(vt(s))return{data:{user:null},error:s};throw s}}async setSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._setSession(t))}async _setSession(t){try{if(!t.access_token||!t.refresh_token)throw new dl;const r=Date.now()/1e3;let s=r,a=!0,i=null;const{payload:o}=Vb(t.access_token);if(o.exp&&(s=o.exp,a=s<=r),a){const{session:l,error:c}=await this._callRefreshToken(t.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!l)return{data:{user:null,session:null},error:null};i=l}else{const{data:l,error:c}=await this._getUser(t.access_token);if(c)throw c;i={access_token:t.access_token,refresh_token:t.refresh_token,user:l.user,token_type:"bearer",expires_in:s-r,expires_at:s},await this._saveSession(i),await this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(r){if(vt(r))return{data:{session:null,user:null},error:r};throw r}}async refreshSession(t){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._refreshSession(t))}async _refreshSession(t){try{return await this._useSession(async r=>{var s;if(!t){const{data:o,error:l}=r;if(l)throw l;t=(s=o.session)!==null&&s!==void 0?s:void 0}if(!(t!=null&&t.refresh_token))throw new dl;const{session:a,error:i}=await this._callRefreshToken(t.refresh_token);return i?{data:{user:null,session:null},error:i}:a?{data:{user:a.user,session:a},error:null}:{data:{user:null,session:null},error:null}})}catch(r){if(vt(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(t,r){try{if(!Ba())throw new ix("No browser detected.");
612if(t.error||t.error_description||t.error_code)throw new ix(t.error_description||"Error in URL with unspecified error_description",{error:t.error||"unspecified_error",code:t.error_code||"unspecified_code"});switch(r){case"implicit":if(this.flowType==="pkce")throw new rA("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new ix("Not a valid implicit grant flow url.");break;default:}if(r==="pkce"){if(this._debug("#_initialize()","begin","is PKCE flow",!0),!t.code)throw new rA("No code detected.");const{data:j,error:b}=await this._exchangeCodeForSession(t.code);if(b)throw b;const _=new URL(window.location.href);return _.searchParams.delete("code"),window.history.replaceState(window.history.state,"",_.toString()),{data:{session:j.session,redirectType:null},error:null}}const{provider_token:s,provider_refresh_token:a,access_token:i,refresh_token:o,expires_in:l,expires_at:c,token_type:d}=t;if(!i||!l||!o||!d)throw new ix("No session defined in URL");const u=Math.round(Date.now()/1e3),h=parseInt(l);let f=u+h;c&&(f=parseInt(c));const m=f-u;m*1e3<=nu&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${m}s, should have been closer to ${h}s`);const g=f-h;u-g>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",g,f,u):u-g<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",g,f,u);const{data:p,error:y}=await this._getUser(i);if(y)throw y;const v={provider_token:s,provider_refresh_token:a,access_token:i,expires_in:h,expires_at:f,refresh_token:o,token_type:d,user:p.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:v,redirectType:t.type},error:null}}catch(s){if(vt(s))return{data:{session:null,redirectType:null},error:s};throw s}}_isImplicitGrantCallback(t){return!!(t.access_token||t.error_description)}async _isPKCECallback(t){const r=await wc(this.storage,`${this.storageKey}-code-verifier`);return!!(t.code&&r)}async signOut(t={scope:"global"}){return await this.initializePromise,await this._acquireLock(-1,async()=>await this._signOut(t))}async _signOut({scope:t}={scope:"global"}){return await this._useSession(async r=>{var s;const{data:a,error:i}=r;if(i)return{error:i};const o=(s=a.session)===null||s===void 0?void 0:s.access_token;if(o){const{error:l}=await this.admin.signOut(o,t);if(l&&!(iJ(l)&&(l.status===404||l.status===401||l.status===403)))return{error:l}}return t!=="others"&&(await this._removeSession(),await ol(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(t){const r=xJ(),s={id:r,callback:t,unsubscribe:()=>{this._debug("#unsubscribe()","state change callback with id removed",r),this.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,s),(async()=>(await this.initializePromise,await this._acquireLock(-1,async()=>{this._emitInitialSession(r)})))(),{data:{subscription:s}}}async _emitInitialSession(t){return await this._useSession(async r=>{var s,a;try{const{data:{session:i},error:o}=r;if(o)throw o;await((s=this.stateChangeEmitters.get(t))===null||s===void 0?void 0:s.callback("INITIAL_SESSION",i)),this._debug("INITIAL_SESSION","callback id",t,"session",i)}catch(i){await((a=this.stateChangeEmitters.get(t))===null||a===void 0?void 0:a.callback("INITIAL_SESSION",null)),this._debug("INITIAL_SESSION","callback id",t,"error",i),console.error(i)}})}async resetPasswordForEmail(t,r={}){let s=null,a=null;this.flowType==="pkce"&&([s,a]=await Wd(this.storage,this.storageKey,!0));try{return await kt(this.fetch,"POST",`${this.url}/recover`,{body:{email:t,code_challenge:s,code_challenge_method:a,gotrue_meta_security:{captcha_token:r.captchaToken}},headers:this.headers,redirectTo:r.redirectTo})}catch(i){if(vt(i))return{data:null,error:i};throw i}}async getUserIdentities(){var t;try{const{data:r,error:s}=await this.getUser();if(s)throw s;return{data:{identities:(t=r.user.identities)!==null&&t!==void 0?t:[]},error:null}}catch(r){if(vt(r))return{data:null,error:r};throw r}}async linkIdentity(t){var r;try{const{data:s,error:a}=await this._useSession(async i=>{var o,l,c,d,u;const{data:h,error:f}=i;if(f)throw f;const m=await this._getUrlForProvider(`${this.url}/user/identities/authorize`,t.provider,{redirectTo:(o=t.options)===null||o===void 0?void 0:o.redirectTo,scopes:(l=t.options)===null||l===void 0?void 0:l.scopes,queryParams:(c=t.options)===null||c===void 0?void 0:c.queryParams,skipBrowserRedirect:!0});return await kt(this.fetch,"GET",m,{headers:this.headers,jwt:(u=(d=h.session)===null||d===void 0?void 0:d.access_token)!==null&&u!==void 0?u:void 0})});if(a)throw a;return Ba()&&!(!((r=t.options)===null||r===void 0)&&r.skipBrowserRedirect)&&window.location.assign(s==null?void 0:s.url),{data:{provider:t.provider,url:s==null?void 0:s.url},error:null}}catch(s){if(vt(s))return{data:{provider:t.provider,url:null},error:s};throw s}}async unlinkIdentity(t){try{return await this._useSession(async r=>{var s,a;const{data:i,error:o}=r;if(o)throw o;
612return await kt(this.fetch,"DELETE",`${this.url}/user/identities/${t.identity_id}`,{headers:this.headers,jwt:(a=(s=i.session)===null||s===void 0?void 0:s.access_token)!==null&&a!==void 0?a:void 0})})}catch(r){if(vt(r))return{data:null,error:r};throw r}}async _refreshAccessToken(t){const r=`#_refreshAccessToken(${t.substring(0,5)}...)`;this._debug(r,"begin");try{const s=Date.now();return await bJ(async a=>(a>0&&await jJ(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await kt(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:t},headers:this.headers,xform:io})),(a,i)=>{const o=200*Math.pow(2,a);return i&&Hb(i)&&Date.now()+o-s<nu})}catch(s){if(this._debug(r,"error",s),vt(s))return{data:{session:null,user:null},error:s};throw s}finally{this._debug(r,"end")}}_isValidSession(t){return typeof t=="object"&&t!==null&&"access_token"in t&&"refresh_token"in t&&"expires_at"in t}async _handleProviderSignIn(t,r){const s=await this._getUrlForProvider(`${this.url}/authorize`,t,{redirectTo:r.redirectTo,scopes:r.scopes,queryParams:r.queryParams});return this._debug("#_handleProviderSignIn()","provider",t,"options",r,"url",s),Ba()&&!r.skipBrowserRedirect&&window.location.assign(s),{data:{provider:t,url:s},error:null}}async _recoverAndRefresh(){var t,r;const s="#_recoverAndRefresh()";this._debug(s,"begin");try{const a=await wc(this.storage,this.storageKey);if(a&&this.userStorage){let o=await wc(this.userStorage,this.storageKey+"-user");!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!o&&(o={user:a.user},await su(this.userStorage,this.storageKey+"-user",o)),a.user=(t=o==null?void 0:o.user)!==null&&t!==void 0?t:Kb()}else if(a&&!a.user&&!a.user){const o=await wc(this.storage,this.storageKey+"-user");o&&(o!=null&&o.user)?(a.user=o.user,await ol(this.storage,this.storageKey+"-user"),await su(this.storage,this.storageKey,a)):a.user=Kb()}if(this._debug(s,"session from storage",a),!this._isValidSession(a)){this._debug(s,"session is not valid"),a!==null&&await this._removeSession();return}const i=((r=a.expires_at)!==null&&r!==void 0?r:1/0)*1e3-Date.now()<Wb;if(this._debug(s,`session has${i?"":" not"} expired with margin of ${Wb}s`),i){if(this.autoRefreshToken&&a.refresh_token){const{error:o}=await this._callRefreshToken(a.refresh_token);o&&(console.error(o),Hb(o)||(this._debug(s,"refresh failed with a non-retryable error, removing the session",o),await this._removeSession()))}}else if(a.user&&a.user.__isUserNotAvailableProxy===!0)try{const{data:o,error:l}=await this._getUser(a.access_token);!l&&(o!=null&&o.user)?(a.user=o.user,await this._saveSession(a),await this._notifyAllSubscribers("SIGNED_IN",a)):this._debug(s,"could not get user data, skipping SIGNED_IN notification")}catch(o){console.error("Error getting user data:",o),this._debug(s,"error getting user data, skipping SIGNED_IN notification",o)}else await this._notifyAllSubscribers("SIGNED_IN",a)}catch(a){this._debug(s,"error",a),console.error(a);return}finally{this._debug(s,"end")}}async _callRefreshToken(t){var r,s;if(!t)throw new dl;if(this.refreshingDeferred)return this.refreshingDeferred.promise;const a=`#_callRefreshToken(${t.substring(0,5)}...)`;this._debug(a,"begin");try{this.refreshingDeferred=new F0;const{data:i,error:o}=await this._refreshAccessToken(t);if(o)throw o;if(!i.session)throw new dl;await this._saveSession(i.session),await this._notifyAllSubscribers("TOKEN_REFRESHED",i.session);const l={session:i.session,error:null};return this.refreshingDeferred.resolve(l),l}catch(i){if(this._debug(a,"error",i),vt(i)){const o={session:null,error:i};return Hb(i)||await this._removeSession(),(r=this.refreshingDeferred)===null||r===void 0||r.resolve(o),o}throw(s=this.refreshingDeferred)===null||s===void 0||s.reject(i),i}finally{this.refreshingDeferred=null,this._debug(a,"end")}}async _notifyAllSubscribers(t,r,s=!0){const a=`#_notifyAllSubscribers(${t})`;this._debug(a,"begin",r,`broadcast = ${s}`);try{this.broadcastChannel&&s&&this.broadcastChannel.postMessage({event:t,session:r});const i=[],o=Array.from(this.stateChangeEmitters.values()).map(async l=>{try{await l.callback(t,r)}catch(c){i.push(c)}});if(await Promise.all(o),i.length>0){for(let l=0;l<i.length;l+=1)console.error(i[l]);throw i[0]}}finally{this._debug(a,"end")}}async _saveSession(t){this._debug("#_saveSession()",t),this.suppressGetSessionWarning=!0;const r=Object.assign({},t),s=r.user&&r.user.__isUserNotAvailableProxy===!0;if(this.userStorage){!s&&r.user&&await su(this.userStorage,this.storageKey+"-user",{user:r.user});const a=Object.assign({},r);delete a.user;const i=oA(a);await su(this.storage,this.storageKey,i)}else{const a=oA(r);await su(this.storage,this.storageKey,a)}}async _removeSession(){this._debug("#_removeSession()"),await ol(this.storage,this.storageKey),await ol(this.storage,this.storageKey+"-code-verifier"),await ol(this.storage,this.storageKey+"-user"),this.userStorage&&await ol(this.userStorage,this.storageKey+"-user"),await this._notifyAllSubscribers("SIGNED_OUT",null)}_removeVisibilityChangedCallback(){this._debug("#_removeVisibilityChangedCallback()");const t=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{t&&Ba()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",t)}
612catch(r){console.error("removing visibilitychange callback failed",r)}}async _startAutoRefresh(){await this._stopAutoRefresh(),this._debug("#_startAutoRefresh()");const t=setInterval(()=>this._autoRefreshTokenTick(),nu);this.autoRefreshTicker=t,t&&typeof t=="object"&&typeof t.unref=="function"?t.unref():typeof Deno<"u"&&typeof Deno.unrefTimer=="function"&&Deno.unrefTimer(t),setTimeout(async()=>{await this.initializePromise,await this._autoRefreshTokenTick()},0)}async _stopAutoRefresh(){this._debug("#_stopAutoRefresh()");const t=this.autoRefreshTicker;this.autoRefreshTicker=null,t&&clearInterval(t)}async startAutoRefresh(){this._removeVisibilityChangedCallback(),await this._startAutoRefresh()}async stopAutoRefresh(){this._removeVisibilityChangedCallback(),await this._stopAutoRefresh()}async _autoRefreshTokenTick(){this._debug("#_autoRefreshTokenTick()","begin");try{await this._acquireLock(0,async()=>{try{const t=Date.now();try{return await this._useSession(async r=>{const{data:{session:s}}=r;if(!s||!s.refresh_token||!s.expires_at){this._debug("#_autoRefreshTokenTick()","no session");return}const a=Math.floor((s.expires_at*1e3-t)/nu);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${nu}ms, refresh threshold is ${yN} ticks`),a<=yN&&await this._callRefreshToken(s.refresh_token)})}catch(r){console.error("Auto refresh tick failed with error. This is likely a transient error.",r)}}finally{this._debug("#_autoRefreshTokenTick()","end")}})}catch(t){if(t.isAcquireTimeout||t instanceof pF)this._debug("auto refresh token tick lock not available");else throw t}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!Ba()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=async()=>await this._onVisibilityChanged(!1),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),await this._onVisibilityChanged(!0)}catch(t){console.error("_handleVisibilityChange",t)}}async _onVisibilityChanged(t){const r=`#_onVisibilityChanged(${t})`;this._debug(r,"visibilityState",document.visibilityState),document.visibilityState==="visible"?(this.autoRefreshToken&&this._startAutoRefresh(),t||(await this.initializePromise,await this._acquireLock(-1,async()=>{if(document.visibilityState!=="visible"){this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting");return}await this._recoverAndRefresh()}))):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()}async _getUrlForProvider(t,r,s){const a=[`provider=${encodeURIComponent(r)}`];if(s!=null&&s.redirectTo&&a.push(`redirect_to=${encodeURIComponent(s.redirectTo)}`),s!=null&&s.scopes&&a.push(`scopes=${encodeURIComponent(s.scopes)}`),this.flowType==="pkce"){const[i,o]=await Wd(this.storage,this.storageKey),l=new URLSearchParams({code_challenge:`${encodeURIComponent(i)}`,code_challenge_method:`${encodeURIComponent(o)}`});a.push(l.toString())}if(s!=null&&s.queryParams){const i=new URLSearchParams(s.queryParams);a.push(i.toString())}return s!=null&&s.skipBrowserRedirect&&a.push(`skip_http_redirect=${s.skipBrowserRedirect}`),`${t}?${a.join("&")}`}async _unenroll(t){try{return await this._useSession(async r=>{var s;const{data:a,error:i}=r;return i?{data:null,error:i}:await kt(this.fetch,"DELETE",`${this.url}/factors/${t.factorId}`,{headers:this.headers,jwt:(s=a==null?void 0:a.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(vt(r))return{data:null,error:r};throw r}}async _enroll(t){try{return await this._useSession(async r=>{var s,a;const{data:i,error:o}=r;if(o)return{data:null,error:o};const l=Object.assign({friendly_name:t.friendlyName,factor_type:t.factorType},t.factorType==="phone"?{phone:t.phone}:{issuer:t.issuer}),{data:c,error:d}=await kt(this.fetch,"POST",`${this.url}/factors`,{body:l,headers:this.headers,jwt:(s=i==null?void 0:i.session)===null||s===void 0?void 0:s.access_token});return d?{data:null,error:d}:(t.factorType==="totp"&&(!((a=c==null?void 0:c.totp)===null||a===void 0)&&a.qr_code)&&(c.totp.qr_code=`data:image/svg+xml;utf-8,${c.totp.qr_code}`),{data:c,error:null})})}catch(r){if(vt(r))return{data:null,error:r};throw r}}async _verify(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var s;const{data:a,error:i}=r;if(i)return{data:null,error:i};const{data:o,error:l}=await kt(this.fetch,"POST",`${this.url}/factors/${t.factorId}/verify`,{body:{code:t.code,challenge_id:t.challengeId},headers:this.headers,jwt:(s=a==null?void 0:a.session)===null||s===void 0?void 0:s.access_token});return l?{data:null,error:l}:(await this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o)),await this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o),{data:o,error:l})})}catch(r){if(vt(r))return{data:null,error:r};throw r}})}async _challenge(t){return this._acquireLock(-1,async()=>{try{return await this._useSession(async r=>{var s;const{data:a,error:i}=r;return i?{data:null,error:i}:await kt(this.fetch,"POST",`${this.url}/factors/${t.factorId}/challenge`,{body:{channel:t.channel},headers:this.headers,jwt:(s=a==null?void 0:a.session)===null||s===void 0?void 0:s.access_token})})}catch(r){if(vt(r))return{data:null,error:r};throw r}})}async _challengeAndVerify(t){const{data:r,error:s}=await this._challenge({factorId:t.factorId});return s?{data:null,error:s}:await this._verify({factorId:t.factorId,challengeId:r.id,code:t.code})}async _listFactors(){const{data:{user:t},error:r}=await this.getUser();if(r)return{data:null,error:r};const s=(t==null?void 0:t.factors)||[],a=s.filter(o=>o.factor_type==="totp"&&o.status==="verified"),i=s.filter(o=>o.factor_type==="phone"&&o.status==="verified");return{data:{all:s,totp:a,phone:i},error:null}}async _getAuthenticatorAssuranceLevel(){return this._acquireLock(-1,async()=>await this._useSession(async t=>{var r,s;const{data:{session:a},error:i}=t;if(i)return{data:null,error:i};if(!a)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const{payload:o}=Vb(a.access_token);let l=null;o.aal&&(l=o.aal);let c=l;((s=(r=a.user.factors)===null||r===void 0?void 0:r.filter(h=>h.status==="verified"))!==null&&s!==void 0?s:[]).length>0&&(c="aal2");const u=o.amr||[];return{data:{currentLevel:l,nextLevel:c,currentAuthenticationMethods:u},error:null}}))}async fetchJwk(t,r={keys:[]}){let s=r.keys.find(l=>l.kid===t);if(s)return s;const a=Date.now();if(s=this.jwks.keys.find(l=>l.kid===t),s&&this.jwks_cached_at+sJ>a)return s;const{data:i,error:o}=await kt(this.fetch,"GET",`${this.url}/.well-known/jwks.json`,{headers:this.headers});if(o)throw o;return!i.keys||i.keys.length===0||(this.jwks=i,this.jwks_cached_at=a,s=i.keys.find(l=>l.kid===t),!s)?null:s}async getClaims(t,r={}){try{let s=t;if(!s){const{data:m,error:g}
612=await this.getSession();if(g||!m.session)return{data:null,error:g};s=m.session.access_token}const{header:a,payload:i,signature:o,raw:{header:l,payload:c}}=Vb(s);r!=null&&r.allowExpired||PJ(i.exp);const d=!a.alg||a.alg.startsWith("HS")||!a.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)?null:await this.fetchJwk(a.kid,r!=null&&r.keys?{keys:r.keys}:r==null?void 0:r.jwks);if(!d){const{error:m}=await this.getUser(s);if(m)throw m;return{data:{claims:i,header:a,signature:o},error:null}}const u=TJ(a.alg),h=await crypto.subtle.importKey("jwk",d,u,!0,["verify"]);if(!await crypto.subtle.verify(u,h,o,mJ(`${l}.${c}`)))throw new wN("Invalid JWT signature");return{data:{claims:i,header:a,signature:o},error:null}}catch(s){if(vt(s))return{data:null,error:s};throw s}}}rp.nextInstanceID=0;const HJ=rp;class VJ extends HJ{constructor(t){super(t)}}var KJ=function(e,t,r,s){function a(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function l(u){try{d(s.next(u))}catch(h){o(h)}}function c(u){try{d(s.throw(u))}catch(h){o(h)}}function d(u){u.done?i(u.value):a(u.value).then(l,c)}d((s=s.apply(e,t||[])).next())})};class GJ{constructor(t,r,s){var a,i,o;this.supabaseUrl=t,this.supabaseKey=r;const l=JZ(t);if(!r)throw new Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",l),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",l),this.storageUrl=new URL("storage/v1",l),this.functionsUrl=new URL("functions/v1",l);const c=`sb-${l.hostname.split(".")[0]}-auth-token`,d={db:qZ,realtime:HZ,auth:Object.assign(Object.assign({},WZ),{storageKey:c}),global:BZ},u=ZZ(s??{},d);this.storageKey=(a=u.auth.storageKey)!==null&&a!==void 0?a:"",this.headers=(i=u.global.headers)!==null&&i!==void 0?i:{},u.accessToken?(this.accessToken=u.accessToken,this.auth=new Proxy({},{get:(h,f)=>{throw new Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(f)} is not possible`)}})):this.auth=this._initSupabaseAuthClient((o=u.auth)!==null&&o!==void 0?o:{},this.headers,u.global.fetch),this.fetch=YZ(r,this._getAccessToken.bind(this),u.global.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers,accessToken:this._getAccessToken.bind(this)},u.realtime)),this.rest=new cZ(new URL("rest/v1",l).href,{headers:this.headers,schema:u.db.schema,fetch:this.fetch}),this.storage=new FZ(this.storageUrl.href,this.headers,this.fetch,s==null?void 0:s.storage),u.accessToken||this._listenForAuthEvents()}get functions(){return new zX(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(t){return this.rest.from(t)}schema(t){return this.rest.schema(t)}rpc(t,r={},s={}){return this.rest.rpc(t,r,s)}channel(t,r={config:{}}){return this.realtime.channel(t,r)}getChannels(){return this.realtime.getChannels()}removeChannel(t){return this.realtime.removeChannel(t)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var t,r;return KJ(this,void 0,void 0,function*(){if(this.accessToken)return yield this.accessToken();const{data:s}=yield this.auth.getSession();return(r=(t=s.session)===null||t===void 0?void 0:t.access_token)!==null&&r!==void 0?r:this.supabaseKey})}_initSupabaseAuthClient({autoRefreshToken:t,persistSession:r,detectSessionInUrl:s,storage:a,userStorage:i,storageKey:o,flowType:l,lock:c,debug:d},u,h){const f={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new VJ({url:this.authUrl.href,headers:Object.assign(Object.assign({},f),u),storageKey:o,autoRefreshToken:t,persistSession:r,detectSessionInUrl:s,storage:a,userStorage:i,flowType:l,lock:c,debug:d,fetch:h,hasCustomAuthorizationHeader:Object.keys(this.headers).some(m=>m.toLowerCase()==="authorization")})}_initRealtimeClient(t){return new CZ(this.realtimeUrl.href,Object.assign(Object.assign({},t),{params:Object.assign({apikey:this.supabaseKey},t==null?void 0:t.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((r,s)=>{this._handleTokenChanged(r,"CLIENT",s==null?void 0:s.access_token)})}_handleTokenChanged(t,r,s){(t==="TOKEN_REFRESHED"||t==="SIGNED_IN")&&this.changedAccessToken!==s?this.changedAccessToken=s:t==="SIGNED_OUT"&&(this.realtime.setAuth(),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const YJ=(e,t,r)=>new GJ(e,t,r);function QJ(){if(typeof window<"u"||typeof process>"u")return!1;const e=process.version;if(e==null)return!1;const t=e.match(/^v(\d+)\./);return t?parseInt(t[1],10)<=18:!1}QJ()&&console.warn("⚠️  Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to N
612ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");const XJ="https://qqtjkkdgmaeijclggrib.supabase.co",ZJ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFxdGpra2RnbWFlaWpjbGdncmliIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTc0NzU4OTEsImV4cCI6MjA3MzA1MTg5MX0.bRoHE2t_cLNHR_gnxip7eH9heJ83XTYTiWD7QNc_j6U",B=YJ(XJ,ZJ,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),gF=x.createContext(void 0);function JJ({children:e}){var N;const[t,r]=x.useState(null),[s,a]=x.useState(null),[i,o]=x.useState(null),[l,c]=x.useState([]),[d,u]=x.useState(null),[h,f]=x.useState(!0),m=(i==null?void 0:i.is_provider_admin)||!1,g=((N=t==null?void 0:t.user_metadata)==null?void 0:N.is_new_client_admin)===!0,p=async S=>{const C=S||t;if(!C){console.log("refreshProfile: No user found, user state:",t,"targetUser:",S);return}console.log("refreshProfile: Starting for user:",C.id);try{const{data:P,error:M}=await B.from("user_profiles").select("user_id").eq("user_id",C.id).limit(1);if(M||!P){console.log("Session invalid, forcing sign out. Error:",M),r(null),a(null),o(null),c([]),u(null);return}}catch(P){console.log("Session validation failed:",P),r(null),a(null),o(null),c([]),u(null);return}try{const{data:P,error:M}=await B.from("user_profiles").select("*").eq("user_id",C.id).single();if(console.log("Profile query result:",{profile:P,profileError:M}),M&&(console.error("Profile error:",M),M.code==="PGRST301")){console.log("Profile not found, signing out"),await b();return}o(P);const{data:D}=await B.from("client_members").select(`
613          *,
614          client:clients!fk_client_members_client_id (
615            id,
616            name,
617            slug,
618            status,
619            industry,
620            tenant_id
621          )
622        `).eq("user_id",C.id).eq("status","active");c(D||[]),!d&&D&&D.length>0&&u(D[0].client_id)}catch(P){console.error("Error fetching user profile:",P)}},y=async S=>{u(S),t&&S&&await B.from("audit_logs").insert({event_type:"context_switch",user_id:t.id,client_id:S,metadata:{event:"client_selected",client_id:S}})},v=async(S,C)=>{const{error:P}=await B.auth.signInWithPassword({email:S,password:C});return P||await B.from("audit_logs").insert({event_type:"auth_login",metadata:{event:"login_success",email:S}}),{error:P}},j=async(S,C,P,M)=>{const D=`${window.location.origin}/`,{data:A,error:U}=await B.auth.signUp({email:S,password:C,options:{emailRedirectTo:D,data:{first_name:P,last_name:M}}});if(!U&&A.user)try{const{data:F}=await B.functions.invoke("claim-invitations");(F==null?void 0:F.claimed)>0&&console.log(`Claimed ${F.claimed} pending invitations`)}catch(F){console.error("Error claiming invitations:",F)}return{error:U}},b=async()=>{t&&await B.from("audit_logs").insert({event_type:"auth_logout",user_id:t.id,client_id:d,metadata:{event:"logout"}}),await B.auth.signOut(),r(null),a(null),o(null),c([]),u(null)},_=()=>{t&&p()};x.useEffect(()=>{console.log("useAuth: Setting up auth listener");const{data:{subscription:S}}=B.auth.onAuthStateChange((C,P)=>{var M;console.log("Auth state change:",{event:C,user:(M=P==null?void 0:P.user)==null?void 0:M.id}),a(P),r((P==null?void 0:P.user)??null),f(!1),P!=null&&P.user?(console.log("User found, refreshing profile"),setTimeout(()=>{p(P.user)},0)):(console.log("No user, clearing profile"),o(null),c([]),u(null))});return B.auth.getSession().then(({data:{session:C},error:P})=>{var M;console.log("Initial session check:",{session:!!C,user:(M=C==null?void 0:C.user)==null?void 0:M.id,error:P}),a(C),r((C==null?void 0:C.user)??null),f(!1),C!=null&&C.user&&(console.log("Found existing session, refreshing profile"),setTimeout(()=>{p(C.user)},0))}),()=>S.unsubscribe()},[]),x.useEffect(()=>{if(!t)return;const S=B.channel("user-presence-admin");let C,P=!1;const M=5*60*1e3,D=async F=>{try{await S.track({user_id:t.id,online_at:new Date().toISOString(),status:F})}catch(L){console.error("Failed to update presence:",L)}},A=()=>{C&&clearTimeout(C),P&&(P=!1,D("online")),C=setTimeout(()=>{P=!0,D("idle")},M)},U=["mousedown","mousemove","keydown","scroll","touchstart","click"];
622return U.forEach(F=>{document.addEventListener(F,A,{passive:!0})}),S.subscribe(async F=>{F==="SUBSCRIBED"&&(await D("online"),A())}),()=>{C&&clearTimeout(C),U.forEach(F=>{document.removeEventListener(F,A)}),B.removeChannel(S)}},[t]);const w={user:t,session:s,userProfile:i,clientMemberships:l,selectedClientId:d,isLoading:h,isProviderAdmin:m,needsOnboarding:g,signIn:v,signUp:j,signOut:b,selectClient:y,refreshProfile:p,completeOnboarding:_};return n.jsx(gF.Provider,{value:w,children:e})}function Mt(){const e=x.useContext(gF);if(e===void 0)throw new Error("useAuth must be used within an AuthProvider");return e}const Yb="notification-preferences",hA=10,Qb=3,Xb=60;function zC(){const[e,t]=x.useState(()=>{try{const o=localStorage.getItem(Yb);if(o)return JSON.parse(o).popup_notifications_enabled??!0}catch(o){console.error("Error reading notification preferences:",o)}return!0}),[r,s]=x.useState(()=>{try{const o=localStorage.getItem(Yb);if(o){const c=JSON.parse(o).popup_duration_seconds??hA;return Math.min(Xb,Math.max(Qb,c))}}catch(o){console.error("Error reading notification preferences:",o)}return hA});x.useEffect(()=>{try{const o={popup_notifications_enabled:e,popup_duration_seconds:r};localStorage.setItem(Yb,JSON.stringify(o))}catch(o){console.error("Error saving notification preferences:",o)}},[e,r]);const a=x.useCallback(o=>{t(o)},[]),i=x.useCallback(o=>{const l=Math.min(Xb,Math.max(Qb,o));s(l)},[]);return{popupEnabled:e,setPopupEnabled:a,popupDuration:r,setPopupDuration:i,minDuration:Qb,maxDuration:Xb}}const fA=30;function eee({children:e}){const{selectedClientId:t,user:r}=Mt(),{popupEnabled:s,popupDuration:a}=zC(),i=Et(),o=a*1e3,l=x.useRef(new Map),c=x.useRef(null),d=x.useRef(new Map),u=x.useRef(new Map),h=x.useCallback(async j=>{if(u.current.has(j))return u.current.get(j);const{data:b}=await B.from("monitoring_agents").select("name").eq("id",j).single(),_=(b==null?void 0:b.name)||"Unknown Agent";return u.current.set(j,_),_},[]),f=async j=>{if(d.current.has(j))return d.current.get(j);const{data:b}=await B.from("monitoring_agents").select("name").eq("id",j).single(),_=(b==null?void 0:b.name)||"Unknown Monitor";return d.current.set(j,_),_},m=x.useCallback(async j=>{const{data:b}=await B.from("monitoring_agents").select("monitoring_config").eq("id",j).single(),_=b==null?void 0:b.monitoring_config,w=_==null?void 0:_.agent_alert_configuration;return(w==null?void 0:w.popup_notifications)!==!1},[]),g=x.useCallback(async j=>{const{data:b}=await B.from("monitoring_agents").select("monitoring_config").eq("id",j).single(),_=b==null?void 0:b.monitoring_config,w=_==null?void 0:_.alert_configuration;return(w==null?void 0:w.popup_notifications)!==!1},[]),p=x.useCallback(async()=>{if(!t)return;const{data:j}=await B.from("monitoring_agents").select("id, name").eq("client_id",t).eq("asset_type","local_device");if(!j)return;const{data:b}=await B.from("private_lan_agent_heartbeats").select("agent_id, created_at").eq("client_id",t).order("created_at",{ascending:!1}),_=new Date,w=new Map;b==null||b.forEach(N=>{w.has(N.agent_id)||w.set(N.agent_id,new Date(N.created_at))}),j.forEach(N=>{const S=w.get(N.id)||new Date(0),P=(_.getTime()-S.getTime())/1e3<fA;l.current.set(N.id,{agent_id:N.id,name:N.name,lastSeen:S,isOnline:P}),u.current.set(N.id,N.name)}),console.log("Initialized agent statuses:",l.current.size,"agents")},[t]),y=x.useCallback(async(j,b,_,w)=>{if(!t)return;const N=_?"online":"offline",S=_?"info":"critical",C={agent_name:b,last_seen:w.toISOString(),detected_by:"realtime_monitor"};try{await B.rpc("upsert_agent_monitor_state",{p_agent_id:j,p_client_id:t,p_monitor_id:"agent-status",p_monitor_type:"agent_heartbeat",p_new_state:N,p_severity:S,p_details:C}),i.invalidateQueries({queryKey:["agent-alerts",t]}),console.log("Updated agent_monitor_state:",b,N)}catch(P){console.error("Failed to update agent_monitor_state:",P)}},[t,i]),v=x.useCallback(async()=>{if(!t)return;const{data:j}=await B.from("private_lan_agent_heartbeats").select("agent_id, hostname, created_at").eq("client_id",t).order("created_at",{ascending:!1});if(!j)return;const b=new Date,_=new Map;
622j.forEach(w=>{_.has(w.agent_id)||_.set(w.agent_id,{createdAt:new Date(w.created_at)})});for(const[w,N]of _){const C=(b.getTime()-N.createdAt.getTime())/1e3<fA,P=l.current.get(w);if(P){if(P.isOnline&&!C){const M=await h(w);await y(w,M,!1,N.createdAt),s&&await m(w)&&(console.log("Agent went offline:",M),ye.error(`Agent Offline: ${M}`,{description:"Agent has stopped responding",duration:o}))}else if(!P.isOnline&&C){const M=await h(w);await y(w,M,!0,N.createdAt),s&&await m(w)&&(console.log("Agent came online:",M),ye.success(`Agent Online: ${M}`,{description:"Agent is back online",duration:o}))}l.current.set(w,{...P,lastSeen:N.createdAt,isOnline:C})}}},[t,s,o,m,h,y]);return x.useEffect(()=>{if(!t||!r)return;console.log("Setting up alert notification subscriptions for client:",t),p(),c.current=setInterval(()=>{v()},5e3);const j=B.channel(`heartbeat-popup-notifications-${t}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"private_lan_agent_heartbeats",filter:`client_id=eq.${t}`},async _=>{const w=_.new;if(!w||!w.agent_id)return;const N=l.current.get(w.agent_id);if(N&&!N.isOnline){const S=await h(w.agent_id);await y(w.agent_id,S,!0,new Date(w.created_at)),s&&await m(w.agent_id)&&(console.log("Agent came online (heartbeat):",S
622),ye.success(`Agent Online: ${S}`,{description:"Agent is back online",duration:o}))}N&&l.current.set(w.agent_id,{...N,lastSeen:new Date(w.created_at),isOnline:!0})}).subscribe(_=>{console.log("Heartbeat popup notification subscription status:",_)}),b=B.channel(`monitor-popup-notifications-${t}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"alerts",filter:`client_id=eq.${t}`},async _=>{const w=_.new;if(!w||!w.monitor_id||!s||!await g(w.monitor_id))return;const S=await f(w.monitor_id);w.alert_type==="incident_start"?ye.error(`Monitor Alert: ${S}`,{description:w.last_error_message||"Monitor is experiencing issues",duration:o}):w.alert_type==="recovery"&&ye.success(`Monitor Recovered: ${S}`,{description:"Monitor is back to normal",duration:o})}).subscribe(_=>{console.log("Monitor popup notification subscription status:",_)});return()=>{console.log("Cleaning up alert notification subscriptions"),c.current&&clearInterval(c.current),B.removeChannel(j),B.removeChannel(b)}},[t,r,s,o,p,v,m,g,h,y]),n.jsx(n.Fragment,{children:e})}const ee=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:we("rounded-lg border bg-card text-card-foreground shadow-sm",e),...t}));ee.displayName="Card";const de=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:we("flex flex-col space-y-1.5 p-6",e),...t}));de.displayName="CardHeader";const me=x.forwardRef(({className:e,...t},r)=>n.jsx("h3",{ref:r,className:we("text-2xl font-semibold leading-none tracking-tight",e),...t}));me.displayName="CardTitle";const De=x.forwardRef(({className:e,...t},r)=>n.jsx("p",{ref:r,className:we("text-sm text-muted-foreground",e),...t}));De.displayName="CardDescription";const re=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:we("p-6 pt-0",e),...t}));re.displayName="CardContent";const tee=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:we("flex items-center p-6 pt-0",e),...t}));tee.displayName="CardFooter";const U0=Ed("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90 shadow-enterprise",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",enterprise:"bg-gradient-primary text-white font-semibold shadow-enterprise hover:shadow-glow transition-all duration-300 hover:scale-[1.02]",professional:"bg-gradient-card text-foreground border border-border/50 shadow-card-custom hover:shadow-enterprise transition-all duration-300"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),H=x.forwardRef(({className:e,variant:t,size:r,asChild:s=!1,...a},i)=>{const o=s?oc:"button";return n.jsx(o,{className:we(U0({variant:t,size:r,className:e})),ref:i,...a})});H.displayName="Button";const ie=x.forwardRef(({className:e,type:t,...r},s)=>n.jsx("input",{type:t,className:we("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...r}));ie.displayName="Input";var ree="Label",xF=x.forwardRef((e,t)=>n.jsx(We.label,{...e,ref:t,onMouseDown:r=>{var a;r.target.closest("button, input, select, textarea")||((a=e.onMouseDown)==null||a.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));xF.displayName=ree;var vF=xF;const nee=Ed("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),z=x.forwardRef(({className:e,...t},r)=>n.jsx(vF,{ref:r,className:we(nee(),e),...t}));z.displayName=vF.displayName;const see=Ed("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Xh=x.forwardRef(({className:e,variant:t,...r},s)=>n.jsx("div",{ref:s,role:"alert",className:we(see({variant:t}),e),...r}));Xh.displayName="Alert";const aee=x.forwardRef(({className:e,...t},r)=>n.jsx("h5",{ref:r,className:we("mb-1 font-medium leading-none tracking-tight",e),...t}));aee.displayName="AlertTitle";const Zh=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,className:we("text-sm [&_p]:leading-relaxed",e),...t}));Zh.displayName="AlertDescription";
622function iee(){const[e,t]=x.useState(""),[r,s]=x.useState(""),[a,i]=x.useState(""),[o,l]=x.useState(!1),[c,d]=x.useState(!1),[u,h]=x.useState(""),f=async g=>{if(g.preventDefault(),!o){l(!0),h("");try{const{error:p}=await B.functions.invoke("send-access-request",{body:{firstName:e,lastName:r,email:a}});p?h("Failed to send request. Please try again."):d(!0)}catch{h("An unexpected error occurred. Please try again.")}finally{l(!1)}}};if(c)return n.jsx(ee,{className:"w-full max-w-md mx-auto bg-gradient-card shadow-enterprise",children:n.jsxs(re,{className:"pt-8 text-center space-y-4",children:[n.jsx(zs,{className:"h-16 w-16 text-green-500 mx-auto"}),n.jsx("h3",{className:"text-xl font-semibold text-foreground",children:"Request Submitted"}),n.jsx("p",{className:"text-muted-foreground",children:"Thank you for your interest! We've received your access request and will contact you shortly to set up your monitoring platform."}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Expected response time: 1-2 business days"})]})});const m=o||!e||!r||!a;return n.jsxs(ee,{className:"w-full max-w-md mx-auto bg-gradient-card shadow-enterprise",children:[n.jsxs(de,{className:"space-y-1",children:[n.jsx(me,{className:"text-2xl font-bold text-center bg-gradient-primary bg-clip-text text-transparent",children:"Request Platform Access"}),n.jsx(De,{className:"text-center text-muted-foreground",children:"Get started with professional monitoring services"})]}),n.jsxs(re,{className:"space-y-4",children:[u&&n.jsx(Xh,{variant:"destructive",children:n.jsx(Zh,{children:u})}),n.jsxs("form",{onSubmit:f,className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"firstName",children:"First Name"}),n.jsx(ie,{id:"firstName",type:"text",placeholder:"First name",value:e,onChange:g=>t(g.target.value),required:!0})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"lastName",children:"Last Name"}),n.jsx(ie,{id:"lastName",type:"text",placeholder:"Last name",value:r,onChange:g=>s(g.target.value),required:!0})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"email",children:"Email Address"}),n.jsx(ie,{id:"email",type:"email",placeholder:"[email protected]",value:a,onChange:g=>i(g.target.value),required:!0})]}),n.jsxs(H,{type:"submit",className:"w-full bg-gradient-primary hover:shadow-glow transition-all duration-300",disabled:m,children:[n.jsx(Ii,{className:"h-4 w-4 mr-2"}),o?"Sending Request...":"Request Access"]})]}),n.jsx("div",{className:"text-center pt-4 border-t",children:n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Already have access?",n.jsx(_a,{to:"/login",className:"text-primary hover:underline ml-1",children:"Sign in here"})]})})]})]})}const oee=Ed("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ve({className:e,variant:t,...r}){return n.jsx("div",{className:we(oee({variant:t}),e),...r})}function lee(){return n.jsxs("div",{className:"space-y-6",children:[n.jsxs(ee,{className:"bg-gradient-card shadow-card-custom border-border/50",children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2 text-lg",children:[n.jsx(yt,{className:"h-5 w-5 text-primary"}),"Multi-Tenant SaaS Platform"]})}),n.jsx(re,{className:"space-y-4",children:n.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ea,{className:"h-4 w-4 text-primary"}),n.jsx("span",{className:"text-sm font-medium",children:"Active Tenants"})]}),n.jsx(ve,{variant:"secondary",children:"247"})]}),n.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Rr,{className:"h-4 w-4 text-primary"}),n.jsx("span",{className:"text-sm font-medium",children:"Total Users"})]}),n.jsx(ve,{variant:"secondary",children:"12,847"})]}),n.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/50",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Wr,{className:"h-4 w-4 text-primary"}),n.jsx("span",{className:"text-sm font-medium",children:"System Status"})]}),n.jsx(ve,{className:"bg-green-100 text-green-800 border-green-200",children:"Operational"})]})]})})]}),n.jsxs(ee,{className:"bg-gradient-card shadow-card-custom border-border/50",children:[n.jsx(de,{children:n.jsx(me,{className:"text-lg",children:"Access Levels"})}),n.jsxs(re,{className:"space-y-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-4 w-4 text-blue-600"}),n.jsx("span",{className:"text-sm font-medium",children:"SaaS Provider"})]}),n.jsx("p",{className:"text-xs text-muted-foreground ml-6",children:"Platform-wide administration and tenant management"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ea,{className:"h-4 w-4 text-green-600"}),n.jsx("span",{className:"text-sm font-medium",children:"Client Administrator"})]}),n.jsx("p",{className:"text-xs text-muted-foreground ml-6",children:"Full control within your organization"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Rr,{className:"h-4 w-4 text-orange-600"}),n.jsx("span",{className:"text-sm font-medium",children:"Organization Admin"})]}),n.jsx("p",{className:"text-xs text-muted-foreground ml-6",children:"Department or team-level management"})]})]})]})]})}const cee="/assets/hero-bg-kO5uB56K.jpg",dee="/assets/griffin-logo-BJaFuV4-.png";function rr(e){const t=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&t==="[object Date]"?new e.constructor(+e):typeof e=="number"||t==="[object Number]"||typeof e=="string"||t==="[object String]"?new Date(e):new Date(NaN)}function zo(e,t){return e instanceof Date?new e.constructor(t):new Date(t)}function uee(e,t){const r=+rr(e);return zo(e,r+t)}const yF=6048e5,hee=864e5,fee=36e5,ox=43200,mA=1440;function mee(e,t){return uee(e,t*fee)}let pee={};function lg(){return pee}function np(e,t){var l,c,d,u;const r=lg(),s=(t==null?void 0:t.weekStartsOn)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.weekStartsOn)??r.weekStartsOn??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,a=rr(e),i=a.getDay(),o=(i<s?7:0)+i-s;return a.setDate(a.getDate()-o),a.setHours(0,0,0,0),a}function Fv(e){return np(e,{weekStartsOn:1}
vendor: 5,313 bytes, line 622
622)}function jF(e){const t=rr(e),r=t.getFullYear(),s=zo(e,0);s.setFullYear(r+1,0,4),s.setHours(0,0,0,0);const a=Fv(s),i=zo(e,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const o=Fv(i);return t.getTime()>=a.getTime()?r+1:t.getTime()>=o.getTime()?r:r-1}function pA(e){const t=rr(e);return t.setHours(0,0,0,0),t}function Uv(e){const t=rr(e),r=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return r.setUTCFullYear(t.getFullYear()),+e-+r}function bF(e,t){const r=pA(e),s=pA(t),a=+r-Uv(r),i=+s-Uv(s);return Math.round((a-i)/hee)}function gee(e){const t=jF(e),r=zo(e,0);return r.setFullYear(t,0,4),r.setHours(0,0,0,0),Fv(r)}function Xx(e,t){const r=rr(e),s=rr(t),a=r.getTime()-s.getTime();return a<0?-1:a>0?1:a}function xee(e){return zo(e,Date.now())}function vee(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function yee(e){if(!vee(e)&&typeof e!="number")return!1;const t=rr(e);return!isNaN(Number(t))}function jee(e,t){const r=rr(e),s=rr(t),a=r.getFullYear()-s.getFullYear(),i=r.getMonth()-s.getMonth();return a*12+i}function bee(e,t){const r=rr(e),s=rr(t),a=gA(r,s),i=Math.abs(bF(r,s));r.setDate(r.getDate()-a*i);const o=+(gA(r,s)===-a),l=a*(i-o);return l===0?0:l}function gA(e,t){const r=e.getFullYear()-t.getFullYear()||e.getMonth()-t.getMonth()||e.getDate()-t.getDate()||e.getHours()-t.getHours()||e.getMinutes()-t.getMinutes()||e.getSeconds()-t.getSeconds()||e.getMilliseconds()-t.getMilliseconds();return r<0?-1:r>0?1:r}function wee(e){return t=>{const s=(e?Math[e]:Math.trunc)(t);return s===0?0:s}}function _ee(e,t){return+rr(e)-+rr(t)}function Nee(e){const t=rr(e);return t.setHours(23,59,59,999),t}function See(e){const t=rr(e),r=t.getMonth();return t.setFullYear(t.getFullYear(),r+1,0),t.setHours(23,59,59,999),t}function Cee(e){const t=rr(e);return+Nee(t)==+See(t)}function kee(e,t){const r=rr(e),s=rr(t),a=Xx(r,s),i=Math.abs(jee(r,s));let o;if(i<1)o=0;else{r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*i);let l=Xx(r,s)===-a;Cee(rr(e))&&i===1&&Xx(e,s)===1&&(l=!1),o=a*(i-Number(l))}return o===0?0:o}function Pee(e,t,r){const s=_ee(e,t)/1e3;return wee(r==null?void 0:r.roundingMethod)(s)}function Tee(e){const t=rr(e),r=zo(e,0);return r.setFullYear(t.getFullYear(),0,1),r.setHours(0,0,0,0),r}const Aee={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Eee=(e,t,r)=>{let s;const a=Aee[e];return typeof a=="string"?s=a:t===1?s=a.one:s=a.other.replace("{{count}}",t.toString()),r!=null&&r.addSuffix?r.comparison&&r.comparison>0?"in "+s:s+" ago":s};function Zb(e){return(t={})=>{const r=t.width?String(t.width):e.defaultWidth;return e.formats[r]||e.formats[e.defaultWidth]}}const Oee={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Mee={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Dee={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Ree={date:Zb({formats:Oee,defaultWidth:"full"}),time:Zb({formats:Mee,defaultWidth:"full"}),dateTime:Zb({formats:Dee,defaultWidth:"full"})},$ee={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Iee=(e,t,r,s)=>$ee[e];function Af(e){return(t,r)=>{const s=r!=null&&r.context?String(r.context):"standalone";let a;if(s==="formatting"&&e.formattingValues){const o=e.defaultFormattingWidth||e.defaultWidth,l=r!=null&&r.width?String(r.width):o;a=e.formattingValues[l]||e.formattingValues[o]}else{const o=e.defaultWidth,l=r!=null&&r.width?String(r.width):e.defaultWidth;a=e.values[l]||e.values[o]}const i=e.argumentCallback?e.argumentCallback(t):t;return a[i]}}const Lee={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Fee={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Uee={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},zee={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Frid
622ay","Saturday"]},Bee={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},qee={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Wee=(e,t)=>{const r=Number(e),s=r%100;if(s>20||s<10)switch(s%10){case 1:return r+"st";case 2:return r+"nd";case 3:return r+"rd"}return r+"th"},Hee={ordinalNumber:Wee,era:Af({values:Lee,defaultWidth:"wide"}),quarter:Af({values:Fee,defaultWidth:"wide",argumentCallback:e=>e-1}),month:Af({values:Uee,defaultWidth:"wide"}),day:Af({values:zee,defaultWidth:"wide"}),dayPeriod:Af({values:Bee,defaultWidth:"wide",formattingValues:qee,defaultFormattingWidth:"wide"})};function Ef(e){return(t,r={})=>{const s=r.width,a=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(a);if(!i)return null;const o=i[0],l=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(l)?Kee(l,h=>h.test(o)):Vee(l,h=>h.test(o));let d;d=e.valueCallback?e.valueCallback(c):c,d=r.valueCallback?r.valueCallback(d):d;const u=t.slice(o.length);return{value:d,rest:u}}}function Vee(e,t){for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return r}function Kee(e,t){for(let r=0;r<e.length;r++)if(t(e[r]))return r}function Gee(e){return(t,r={})=>{const s=t.match(e.matchPattern);if(!s)return null;const a=s[0],i=t.match(e.parsePattern);if(!i)return null;let o=e.valueCallback?e.valueCallback(i[0]):i[0];o=r.valueCallback?r.valueCallback(o):o;const l=t.slice(a.length);return{value:o,rest:l}}}const Yee=/^(\d+)(th|st|nd|rd)?/i,Qee=/\d+/i,Xee={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Zee={any:[/^b/i,/^(a|c)/i]},Jee={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},ete={any:[/1/i,/2/i,/3/i,/4/i]},tte={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},rte={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},nte={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},ste={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},ate={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},ite={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},ote={ordinalNumber:Gee({matchPattern:Yee,parsePattern:Qee,valueCallback:e=>parseInt(e,10)}),era:Ef({matchPatterns:Xee,defaultMatchWidth:"wide",parsePatterns:Zee,defaultParseWidth:"any"}),quarter:Ef({matchPatterns:Jee,defaultMatchWidth:"wide",parsePatterns:ete,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ef({matchPatterns:tte,defaultMatchWidth:"wide",parsePatterns:rte,defaultParseWidth:"any"}),day:Ef({matchPatterns:nte,defaultMatchWidth:"wide",parsePatterns:ste,defaultParseWidth:"any"}),dayPeriod:Ef({matchPatterns:ate,defaultMatchWidth:"any",parsePatterns:ite,defaultParseWidth:"any"})},wF={code:"en-US",formatDistance:Eee,formatLong:Ree,formatRelative:Iee,localize:Hee,match:ote,options:{weekStartsOn:0,firstWeekContainsDate:1}};function lte(e){const t=rr(e);return bF(t,Tee(t))+1}function cte(e){const t=rr(e),r=+Fv(t)-+gee(t);return Math.round(r/yF)+1}function _F(e,t){var u,h,f,m;const r=rr(e),s=r.getFullYear(),a=lg(),i=(t==null?void 0:t.firstWeekContainsDate)??((h=(u=t==null?void 0:t.locale)==null?void 0:u.options)==null?void 0:h.firstWeekContainsDate)??a.firstWeekContainsDate??((m=(f=a.locale)==null?void 0:f.options)==null?void 0:m.firstWeekContainsDate)??1,o=zo(e,0);o.setFullYear(s+1,0,i),o.setHours(0,0,0,0);const l=np(o,t),c=zo(e,0);c.setFullYear(s,0,i),c.setHours(0,0,0,0);const d=np(c,t);return r.getTime()>=l.getTime()?s+1:r.getTime()>=d.getTime()?s:s-1}function dte(e,t){var l,c,d,u;const r=lg(),s=(t==null?void 0:t.firstWeekContainsDate)??((c=(l=t==null?void 0:t.locale)==null?void 0:l.options)==null?void 0:c.firstWeekContainsDate)??r.firstWeekContainsDate??((u=(d=r.locale)==null?void 0:d.options)==null?void 0:u.firstWeekContainsDate)??1,a=_F(e,t),i=zo(e,0);return i.setFullYear(a,0,s),i.setHours(0,0,0,0),np(i,t)}function ute(e,t){const r=rr(e),s=+np(r,t)-+dte(r,t);return Math.round(s/yF)+1}function ir(e,t){const r=e<0?"-":"",s=Math.abs(e).toString().padStart(t,"0");return r+s}const ll={y(e,t){const r=e.getFullYear(),s=r>0?r:1-r;return ir(t==="yy"?s%100:s,t.length)},M(e,t){const r=e.getMonth();return t==="M"?String(r+1):ir(r+1,2)},d(e,t){return ir(e.getDate(),t.length)},a(e,t){const r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.toUpperCase();case"aaa":return r;case"aaaaa":return r[0];case"aaaa":default:return r==="am"?"a.m.":"p.m."}},h(e,t){return ir(e.getHours()%12||12,t.length)},H(e,t){return ir(e.getHours(),t.length)},m(e,t){return ir(e.getMinutes(),t.length)},s(e,t){return ir(e.getSeconds(),t.length)},S(e,t){const r=t.length,s=e.getMilliseconds(),a=Math.trunc(s*Math.pow(10,r-3));return ir(a,t.length)}},Gd={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},xA={G:function(e,t,r){const s=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return r.era(s,{width:"abbreviated"});case"GGGGG":return r.era(s,{width:"narrow"});case"GGGG":default:return r.era(s,{width:"wide"})}},y:function(e,t,r){if(t==="yo"){const s=e.getFullYear(),a=s>0?s:1-s;return r.ordinalNumber(a,{unit:"year"})}return ll.y(e,t)},Y:function(e,t,r,s){const a=_F(e,s),i=a>0?a:1-a;if(t==="YY"){const o=i%100;return ir(o,2)}return t==="Yo"?r.ordinalNumber(i,{unit:"year"}):ir(i,t.length)},R:function(e,t){const r=jF(e);return ir(r,t.length)},u:function(e,t){const r=e.getFullYear();return ir(r,t.length)},Q:function(e,t,r){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(s);case"QQ":return ir(s,2);case"Qo":return r.ordinalNumber(s,{unit:"quarter"});case"QQQ":return r.quarter(s,{width:"abbreviated",context:"formatting"});case"QQQQQ":return r.quarter(s,{width:"narrow",context:"formatting"});case"QQQQ":default:return r.quarter(s,{width:"wide",context:"formatting"})}},q:function(e,t,r){const s=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(s);case"qq":return ir(s,2);case"qo":return r.ordinalNumber(s,{unit:"quarter"});case"qqq":return r.quarter(s,{width:"abbreviated",context:"standalone"});case"qqqqq":return r.quarter(s,{width:"narrow",context:"standalone"});case"qqqq":default:return r.quarter(s,{width:"wide",context:"standalone"})}},M:function(e,t,r){const s=e.getMonth();switch(t){case"M":case"MM":return ll.M(e,t);case"Mo":return r.ordinalNumber(s+1,{unit:"month"});case"MMM":return r.month(s,{width:"abbreviated",context:"formatting"});case"MMMMM":return r.month(s,{width:"narrow",context:"formatting"});case"MMMM":default:return r.month(s,{width:"wide",context:"formatting"})}},L:function(e,t,r){const s=e.getMonth();switch(t){case"L":return String(s+1);case"LL":return ir(s+1,2);case"Lo":return r.ordinalNumber(s+1,{unit:"month"});case"LLL":return r.month(s,{width:"abbreviated",context:"standalone"});case"LLLLL":return r.month(s,{width:"narrow",context:"standalone"});case"LLLL":default:return r.month(s,{width:"wide",context:"standalone"})}},w:function(e,t,r,s){const a=ute(e,s);return t==="wo"?r.ordinalNumber(a,{unit:"week"}
vendor: 4,428 bytes, line 622
622):ir(a,t.length)},I:function(e,t,r){const s=cte(e);return t==="Io"?r.ordinalNumber(s,{unit:"week"}):ir(s,t.length)},d:function(e,t,r){return t==="do"?r.ordinalNumber(e.getDate(),{unit:"date"}):ll.d(e,t)},D:function(e,t,r){const s=lte(e);return t==="Do"?r.ordinalNumber(s,{unit:"dayOfYear"}):ir(s,t.length)},E:function(e,t,r){const s=e.getDay();switch(t){case"E":case"EE":case"EEE":return r.day(s,{width:"abbreviated",context:"formatting"});case"EEEEE":return r.day(s,{width:"narrow",context:"formatting"});case"EEEEEE":return r.day(s,{width:"short",context:"formatting"});case"EEEE":default:return r.day(s,{width:"wide",context:"formatting"})}},e:function(e,t,r,s){const a=e.getDay(),i=(a-s.weekStartsOn+8)%7||7;switch(t){case"e":return String(i);case"ee":return ir(i,2);case"eo":return r.ordinalNumber(i,{unit:"day"});case"eee":return r.day(a,{width:"abbreviated",context:"formatting"});case"eeeee":return r.day(a,{width:"narrow",context:"formatting"});case"eeeeee":return r.day(a,{width:"short",context:"formatting"});case"eeee":default:return r.day(a,{width:"wide",context:"formatting"})}},c:function(e,t,r,s){const a=e.getDay(),i=(a-s.weekStartsOn+8)%7||7;switch(t){case"c":return String(i);case"cc":return ir(i,t.length);case"co":return r.ordinalNumber(i,{unit:"day"});case"ccc":return r.day(a,{width:"abbreviated",context:"standalone"});case"ccccc":return r.day(a,{width:"narrow",context:"standalone"});case"cccccc":return r.day(a,{width:"short",context:"standalone"});case"cccc":default:return r.day(a,{width:"wide",context:"standalone"})}},i:function(e,t,r){const s=e.getDay(),a=s===0?7:s;switch(t){case"i":return String(a);case"ii":return ir(a,t.length);case"io":return r.ordinalNumber(a,{unit:"day"});case"iii":return r.day(s,{width:"abbreviated",context:"formatting"});case"iiiii":return r.day(s,{width:"narrow",context:"formatting"});case"iiiiii":return r.day(s,{width:"short",context:"formatting"});case"iiii":default:return r.day(s,{width:"wide",context:"formatting"})}},a:function(e,t,r){const a=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"aaa":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"aaaa":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},b:function(e,t,r){const s=e.getHours();let a;switch(s===12?a=Gd.noon:s===0?a=Gd.midnight:a=s/12>=1?"pm":"am",t){case"b":case"bb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"bbb":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"bbbb":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},B:function(e,t,r){const s=e.getHours();let a;switch(s>=17?a=Gd.evening:s>=12?a=Gd.afternoon:s>=4?a=Gd.morning:a=Gd.night,t){case"B":case"BB":case"BBB":return r.dayPeriod(a,{width:"abbreviated",context:"formatting"});case"BBBBB":return r.dayPeriod(a,{width:"narrow",context:"formatting"});case"BBBB":default:return r.dayPeriod(a,{width:"wide",context:"formatting"})}},h:function(e,t,r){if(t==="ho"){let s=e.getHours()%12;return s===0&&(s=12),r.ordinalNumber(s,{unit:"hour"})}return ll.h(e,t)},H:function(e,t,r){return t==="Ho"?r.ordinalNumber(e.getHours(),{unit:"hour"}):ll.H(e,t)},K:function(e,t,r){const s=e.getHours()%12;return t==="Ko"?r.ordinalNumber(s,{unit:"hour"}):ir(s,t.length)},k:function(e,t,r){let s=e.getHours();return s===0&&(s=24),t==="ko"?r.ordinalNumber(s,{unit:"hour"}):ir(s,t.length)},m:function(e,t,r){return t==="mo"?r.ordinalNumber(e.getMinutes(),{unit:"minute"}):ll.m(e,t)},s:function(e,t,r){return t==="so"?r.ordinalNumber(e.getSeconds(),{unit:"second"}):ll.s(e,t)},S:function(e,t){return ll.S(e,t)},X:function(e,t,r){const s=e.getTimezoneOffset();if(s===0)return"Z";switch(t){case"X":return yA(s);case"XXXX":case"XX":return Mc(s);case"XXXXX":case"XXX":default:return Mc(s,":")}},x:function(e,t,r){const s=e.getTimezoneOffset();switch(t){case"x":return yA(s);case"xxxx":case"xx":return Mc(s);case"xxxxx":case"xxx":default:return Mc(s,":")}},O:function(e,t,r){const s=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+vA(s,":");case"OOOO":default:return"GMT"+Mc(s,":")}},z:function(e,t,r){const s=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+vA(s,":");
622case"zzzz":default:return"GMT"+Mc(s,":")}},t:function(e,t,r){const s=Math.trunc(e.getTime()/1e3);return ir(s,t.length)},T:function(e,t,r){const s=e.getTime();return ir(s,t.length)}};function vA(e,t=""){const r=e>0?"-":"+",s=Math.abs(e),a=Math.trunc(s/60),i=s%60;return i===0?r+String(a):r+String(a)+t+ir(i,2)}function yA(e,t){return e%60===0?(e>0?"-":"+")+ir(Math.abs(e)/60,2):Mc(e,t)}function Mc(e,t=""){const r=e>0?"-":"+",s=Math.abs(e),a=ir(Math.trunc(s/60),2),i=ir(s%60,2);return r+a+t+i}const jA=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},NF=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},hte=(e,t)=>{const r=e.match(/(P+)(p+)?/)||[],s=r[1],a=r[2];if(!a)return jA(e,t);let i;switch(s){case"P":i=t.dateTime({width:"short"});break;case"PP":i=t.dateTime({width:"medium"});break;case"PPP":i=t.dateTime({width:"long"});break;case"PPPP":default:i=t.dateTime({width:"full"});break}return i.replace("{{date}}",jA(s,t)).replace("{{time}}",NF(a,t))},fte={p:NF,P:hte},mte=/^D+$/,pte=/^Y+$/,gte=["D","DD","YY","YYYY"];function xte(e){return mte.test(e)}function vte(e){return pte.test(e)}function yte(e,t,r){const s=jte(e,t,r);if(console.warn(s),gte.includes(e))throw new RangeError(s)}function jte(e,t,r){const s=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${s} to the input \`${r}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const bte=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,wte=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,_te=/^'([^]*?)'?$/,Nte=/''/g,Ste=/[a-zA-Z]/;function $r(e,t,r){var u,h,f,m;const s=lg(),a=s.locale??wF,i=s.firstWeekContainsDate??((h=(u=s.locale)==null?void 0:u.options)==null?void 0:h.firstWeekContainsDate)??1,o=s.weekStartsOn??((m=(f=s.locale)==null?void 0:f.options)==null?void 0:m.weekStartsOn)??0,l=rr(e);if(!yee(l))throw new RangeError("Invalid time value");let c=t.match(wte).map(g=>{const p=g[0];if(p==="p"||p==="P"){const y=fte[p];return y(g,a.formatLong)}return g}).join("").match(bte).map(g=>{if(g==="''")return{isToken:!1,value:"'"};const p=g[0];if(p==="'")return{isToken:!1,value:Cte(g)};if(xA[p])return{isToken:!0,value:g};if(p.match(Ste))throw new RangeError("Format string contains an unescaped latin alphabet character `"+p+"`");return{isToken:!1,value:g}});a.localize.preprocessor&&(c=a.localize.preprocessor(l,c));const d={firstWeekContainsDate:i,weekStartsOn:o,locale:a};return c.map(g=>{if(!g.isToken)return g.value;const p=g.value;(vte(p)||xte(p))&&yte(p,t,String(e));const y=xA[p[0]];return y(l,p,a.localize,d)}).join("")}function Cte(e){const t=e.match(_te);return t?t[1].replace(Nte,"'"):e}function kte(e,t,r){const s=lg(),a=(r==null?void 0:r.locale)??s.locale??wF,i=2520,o=Xx(e,t);if(isNaN(o))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:o});let c,d;o>0?(c=rr(t),d=rr(e)):(c=rr(e),d=rr(t));const u=Pee(d,c),h=(Uv(d)-Uv(c))/1e3,f=Math.round((u-h)/60);let m;if(f<2)return r!=null&&r.includeSeconds?u<5?a.formatDistance("lessThanXSeconds",5,l):u<10?a.formatDistance("lessThanXSeconds",10,l):u<20?a.formatDistance("lessThanXSeconds",20,l):u<40?a.formatDistance("halfAMinute",0,l):u<60?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",1,l):f===0?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",f,l);if(f<45)return a.formatDistance("xMinutes",f,l);if(f<90)return a.formatDistance("aboutXHours",1,l);if(f<mA){const g=Math.round(f/60);return a.formatDistance("aboutXHours",g,l)}else{if(f<i)return a.formatDistance("xDays",1,l);if(f<ox){const g=Math.round(f/mA);return a.formatDistance("xDays",g,l)}else if(f<ox*2)return m=Math.round(f/ox),a.formatDistance("aboutXMonths",m,l)}if(m=kee(d,c),m<12){const g=Math.round(f/ox);return a.formatDistance("xMonths",g,l)}else{const g=m%12,p=Math.trunc(m/12);return g<3?a.formatDistance("aboutXYears",p,l):g<9?a.formatDistance("overXYears",p,l):a.formatDistance("almostXYears",p+1,l)}}function is(e,t){return kte(e,xee(e),t)}function Pte(e,t){return mee(e,-t)}const Tte=()=>{const r=bee(new Date("2026-02-13"),new Date);return n.jsxs("div",{className:"min-h-screen bg-background",children:[n.jsx("div",{className:"fixed top-0 left-0 right-0 z-30 bg-gradient-to-r from-primary via-primary/90 to-primary text-primary-foreground py-3 px-4 shadow-lg",children:n.jsxs("div",{className:"max-w-7xl mx-auto flex flex-col sm:flex-row items-center justify-center gap-3 text-center",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(H7,{className:"h-5 w-5 animate-pulse"}),n.jsx("span",{className:"font-semibold",children:"Start your 10-Day Free Trial"})]}),n.jsx("span",{className:"hidden sm:inline text-primary-foreground
622/60",children:"|"}),n.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary-foreground/90",children:[n.jsx(Xt,{className:"h-4 w-4"}),n.jsx("span",{children:"Sign-ups open Feb 13th, 2026"})]}),n.jsx("span",{className:"hidden sm:inline text-primary-foreground/60",children:"|"}),n.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-primary-foreground",children:[n.jsx(xC,{className:"h-4 w-4"}),n.jsxs("span",{children:[r," days to go"]})]}),n.jsx(H,{disabled:!0,variant:"secondary",size:"sm",className:"opacity-75 cursor-not-allowed",children:"Coming Soon"})]})}),n.jsx("div",{className:"absolute top-[70px] left-4 z-20",children:n.jsx("img",{src:dee,alt:"Griffin IT Group",className:"w-[375px] h-[165px]"})}),n.jsx("div",{className:"absolute inset-0 bg-cover bg-center bg-no-repeat opacity-5",style:{backgroundImage:`url(${cee})`}}),n.jsxs("div",{className:"relative z-10 min-h-screen flex",children:[n.jsx("div",{className:"hidden lg:flex lg:w-1/2 flex-col justify-center px-12 bg-gradient-hero",children:n.jsxs("div",{className:"max-w-lg mx-auto text-white",children:[n.jsxs("div",{className:"mb-8",children:[n.jsx("h1",{className:"text-4xl font-bold mb-4 animate-slide-in",children:"IsItUp.AI"}),n.jsx("p",{className:"text-xl text-white/90 animate-slide-in",style:{animationDelay:"0.1s"},children:"Smart Monitoring and Alerting for MSPs and SMBs"})]}),n.jsxs("div",{className:"space-y-4 animate-slide-in",style:{animationDelay:"0.2s"},children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),n.jsx("span",{className:"text-white/90",children:"24/7 uptime monitoring"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),n.jsx("span",{className:"text-white/90",children:"Instant alert notifications"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),n.jsx("span",{className:"text-white/90",children:"Internet and Private LAN Monitoring"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),n.jsx("span",{className:"text-white/90",children:"Global monitoring network"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),n.jsx("span",{className:"text-white/90",children:"IsItUp : Designed by an MSP for an MSP"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:"w-2 h-2 bg-white rounded-full"}),n.jsx("span",{className:"text-white/90",children:"Functionality: System is being designed with input from users. Not all functionality is available on day 1."})]})]})]})}),n.jsx("div",{className:"w-full lg:w-1/2 flex flex-col justify-center px-4 sm:px-6 lg:px-12",children:n.jsxs("div",{className:"max-w-md mx-auto w-full space-y-8",children:[n.jsxs("div",{className:"lg:hidden text-center mb-8",children:[n.jsx("h1",{className:"text-2xl font-bold text-foreground mb-2",children:"IsItUp.AI"}),n.jsx("p",{className:"text-muted-foreground",children:"Request platform access"})]}),n.jsx("div",{className:"animate-slide-in",children:n.jsx(iee,{})}),n.jsxs("div",{className:"text-center animate-slide-in",style:{animationDelay:"0.1s"},children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Already have an account?"}),n.jsx(_a,{to:"/login",className:"text-sm text-primary hover:text-primary/80 transition-colors font-medium",children:"Sign in to your dashboard →"})]}),n.jsx("div",{className:"lg:hidden animate-slide-in",style:{animationDelay:"0.2s"},children:n.jsx(lee,{})})]})})]}),n.jsx("div",{className:"relative z-10 py-16 bg-gradient-to-b from-background to-muted/20",children:n.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[n.jsxs("div",{className:"text-center mb-16",children:[n.jsx("h2",{className:"text-3xl font-bold text-foreground mb-4",children:"Comprehensive Website & Service Monitoring"}),n.jsx("p",{className:"text-lg text-muted-foreground max-w-3xl mx-auto",children:"IsItUp continuously monitors your websites, servers, APIs, SSL certificates, and other online services for availability and performance. Get real-time alerts when issues arise—downtime or performance slowdowns."})]}),n.jsx("div",{className:"mb-16 text-center",children:n.jsxs("div",{className:"bg-card border border-border rounded-lg p-8 max-w-4xl mx-auto",children:[n.jsx("h3",{className:"text-xl font-semibold text-foreground mb-4",children:"How It Works"}),n.jsx("p",{className:"text-muted-foreground",children:"Works by sending periodic checks (HTTP(S) requests, ping, port checks, keyword detection, and more) to monitored targets, ensuring they're up and running. If something goes wrong, you're alerted immediately with our global double-check mechanism to avoid false positives."})]})}),n.jsxs("div",{className:"mb-16",children:[n.jsx("h3",{className:"text-2xl font-bold text-center text-foreground mb-8",children:"Key Monitoring Types"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"HTTP(S) Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Simulates web requests to check if your site returns successful responses (HTTP 200)."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Ping (ICMP)"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Checks server responsiveness via ping. Useful for basic server availability."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Port Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Tests specific ports (SMTP, FTP, DNS) to ensure services respond properly."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Keyword Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Ensures specific content appears (or is absent) on web pages."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"SSL Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Tracks SSL certificate expiration and security anomalies."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Heartbeat (Cron)"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitored services send periodic pings to unique URLs, perfect for background jobs."})]})]})]}),n.jsxs("div",{className:"mb-16",children:[n.jsx("h3",{className:"text-2xl font-bold text-center text-foreground mb-4",children:"Private LAN Monitoring"}),n.jsx("p",{className:"text-lg text-muted-foreground text-center mb-8 max-w-3xl mx-auto",children:"Comprehensive monitoring and management of your private network infrastru
622cture with dedicated monitoring agents."}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Heartbeat Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Real-time status monitoring with up/down detection for all network devices and services."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Disk Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor disk usage, health, and performance across all connected systems."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Process Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Track running processes, resource usage, and service health on all monitored machines."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Port Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor network ports, detect unauthorized connections, and manage service availability."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Firewall Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor firewall status, rule changes, and security policy compliance."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"File & Folder Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Track file system changes, permissions, and critical directory monitoring."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Windows Update Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor update status, patch compliance, and system security updates."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Hyper-V Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor virtual machine status, resource allocation, and hypervisor health."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Application Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Track application performance, availability, and resource consumption."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"GPO Policies"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor Group Policy changes, compliance status, and policy deployment."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"Registry Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Track critical registry changes, security settings, and system configuration."})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6",children:[n.jsx("h4",{className:"font-semibold text-foreground mb-3",children:"BitLocker Management"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor encryption status, key management, and compliance across all devices."})]})]})]}),n.jsx("div",{className:"mb-16",children:n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[n.jsxs("div",{className:"bg-card border border-border rounded-lg p-8",children:[n.jsx("h3",{className:"text-xl font-semibold text-foreground mb-4",children:"Alerts & Notifications"}),n.jsxs("ul",{className:"space-y-2 text-muted-foreground",children:[n.jsx("li",{children:"• Email, SMS, voice call notifications"}),n.jsx("li",{children:"• Push notifications via mobile app"}),n.jsx("li",{children:"• Multiple global location verification"}),n.jsx("li",{children:"• Smart false-positive prevention"})]})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-8",children:[n.jsx("h3",{className:"text-xl font-semibold text-foreground mb-4",children:"Integrations"}),n.jsx("p",{className:"text-muted-foreground",children:"Coming soon."})]})]})}),n.jsx("div",{className:"mb-16",children:n.jsxs("div",{className:"bg-card border border-border rounded-lg p-8 text-center",children:[n.jsx("h3",{className:"text-xl font-semibold text-foreground mb-4",children:"Reporting & Status Pages"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8 mt-6",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium text-foreground mb-2",children:"Response Time Tracking"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Logs minimum, maximum, and average response times with performance charts."})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium text-foreground mb-2",children:"Public Status Pages"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Display real-time and past incidents to maintain transparency with users."})]})]})]})}),n.jsxs("div",{className:"mb-16",children:[n.jsx("h3",{className:"text-2xl font-bold text-center text-foreground mb-8",children:"Plans & Pricing"}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 max-w-4xl mx-auto",children:[n.jsxs("div",{className:"bg-primary/5 border-2 border-primary rounded-lg p-6 text-center relative",children:[n.jsx("div",{className:"absolute -top-3 left-1/2 transform -translate-x-1/2",children:n.jsx("span",{className:"bg-primary text-primary-foreground px-3 py-1 rounded-full text-xs font-medium",children:"Popular"})}),n.jsx("h4",{className:"text-lg font-semibold text-foreground mb-2",children:"Standard Plan"}),n.jsxs("div",{className:"text-2xl font-bold text-primary mb-1",children:["$39.99 USD",n.jsx("span",{className:"text-sm text-muted-foreground",children:"/month"})]}),n.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground text-left mt-4",children:[n.jsx("li",{children:"• Up to 400 monitors"}),n.jsx("li",{children:"• 30-second monitoring intervals"}),n.jsx("li",{children:"• Advanced alerting customization"}),n.jsx("li",{children:"• Team access controls"}),n.jsx("li",{children:"• SMS/voice alert credits available"})]})]}),n.jsxs("div",{className:"bg-card border border-border rounded-lg p-6 text-center",children:[n.jsx("h4",{className:"text-lg font-semibold text-foreground mb-2",children:"Professional Plan"}),n.jsxs("div",{className:"text-2xl font-bold text-primary mb-1",children:["$59.99 USD",n.jsx("span",{className:"text-sm text-muted-foreground",children:"/month"})]}),n.jsxs("ul",{className:"space-y-2 text-sm text-muted-foreground text-left mt-4",children:[n.jsx("li",{children:"• Up to 1,000 monitors"}),n.jsx("li",{children:"• 30-second monitoring intervals"}),n.jsx("li",{children:"• Priority support"}),n.jsx("li",{children:"• Advanced integrations"}),n.jsx("li",{children:"• Custom reporting features"})]})]})]})]})]})}),n.jsx("div",{className:"relative z-10 border-t border-border/50 bg-card/50 backdrop-blur-sm",children:n.jsx("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4",children:n.jsxs("div",{className:"flex flex-col sm:flex-row justify-between items-center gap-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground",children:"© 2025 IsItUp.AI. GRIFFIN IT GROUP. All rights reserved."}),n.jsxs("div",{className:"flex gap-6 text-sm",children:[n.jsx(_a,{to:"/privacy-policy",className:"text-muted-foreground hover:text-primary transition-colors",children:"Privacy Policy"}),n.jsx(_a,{to:"/terms-of-service",className:"text-muted-foreground hover:text-primary transition-colors",children:"Terms of Service"}),n.jsx(_a,{to:"/support",className:"text-muted-foreground hover:text-primary transition-colors",children:"Support"})]})]})})})]})};
622function Ate(){const[e,t]=x.useState(""),[r,s]=x.useState(""),[a,i]=x.useState(!1),[o,l]=x.useState(""),[c,d]=x.useState(""),[u,h]=x.useState(!1),[f,m]=x.useState(""),{signIn:g,signUp:p}=Mt(),y=di(),v=async b=>{if(b.preventDefault(),!u){h(!0),m("");try{let _;a?_=await p(e,r,o,c):_=await g(e,r),_.error?m(_.error.message):y("/dashboard")}catch{m("An unexpected error occurred")}finally{h(!1)}}},j=u||!e||!r||a&&(!o||!c);return n.jsxs(ee,{className:"w-full max-w-md mx-auto bg-gradient-card shadow-enterprise",children:[n.jsxs(de,{className:"space-y-1",children:[n.jsx(me,{className:"text-2xl font-bold text-center bg-gradient-primary bg-clip-text text-transparent",children:a?"Create Account":"Monitor Access"}),n.jsx(De,{className:"text-center text-muted-foreground",children:a?"Register for monitoring platform":"Sign in to your monitoring dashboard"})]}),n.jsxs(re,{className:"space-y-4",children:[f&&n.jsxs(Xh,{variant:"destructive",children:[n.jsx(kn,{className:"h-4 w-4"}),n.jsx(Zh,{children:f})]}),n.jsxs("form",{onSubmit:v,className:"space-y-4",children:[a&&n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"firstName",children:"First Name"}),n.jsx(ie,{id:"firstName",type:"text",placeholder:"First name",value:o,onChange:b=>l(b.target.value),required:!0})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"lastName",children:"Last Name"}),n.jsx(ie,{id:"lastName",type:"text",placeholder:"Last name",value:c,onChange:b=>d(b.target.value),required:!0})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"email",children:"Email"}),n.jsx(ie,{id:"email",type:"email",placeholder:"Enter your email",value:e,onChange:b=>t(b.target.value),required:!0})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"password",children:"Password"}),n.jsx(ie,{id:"password",type:"password",placeholder:"Enter your password",value:r,onChange:b=>s(b.target.value),required:!0})]}),n.jsx(H,{type:"submit",className:"w-full bg-gradient-primary hover:shadow-glow transition-all duration-300",disabled:j,children:u?"Processing...":a?"Create Account":"Sign In"})]}),n.jsxs("div",{className:"text-center space-y-2 pt-4 border-t",children:[n.jsx(H,{variant:"link",onClick:()=>{i(!a),m("")},className:"text-sm text-muted-foreground hover:text-primary",children:a?"Already have an account? Sign in":"Need an account? Sign up"}),!a&&n.jsx("div",{className:"text-xs text-muted-foreground",children:"Forgot your password? Contact your administrator"})]})]})]})}const Ete=()=>n.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-4",children:n.jsxs("div",{className:"w-full max-w-md 
622space-y-8",children:[n.jsxs("div",{className:"text-center",children:[n.jsx(_a,{to:"/",className:"inline-block mb-6",children:n.jsx("h1",{className:"text-2xl font-bold text-foreground hover:text-primary transition-colors",children:"IsItUp.AI"})}),n.jsx("p",{className:"text-muted-foreground",children:"Sign in to your monitoring dashboard"})]}),n.jsx("div",{className:"animate-slide-in",children:n.jsx(Ate,{})}),n.jsx("div",{className:"text-center p-4 rounded-lg bg-muted/50 border border-border",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Public account sign-up will begin ",n.jsx("span",{className:"font-semibold text-foreground",children:"March 8th, 2026"})]})}),n.jsx("div",{className:"text-center",children:n.jsx(_a,{to:"/",className:"text-sm text-muted-foreground hover:text-primary transition-colors",children:"← Back to homepage"})})]})});var Ote=x.createContext(void 0);function Md(e){const t=x.useContext(Ote);return e||t||"ltr"}var Jb="rovingFocusGroup.onEntryFocus",Mte={bubbles:!1,cancelable:!0}
vendor: 4,795 bytes, line 622
622,cg="RovingFocusGroup",[_N,SF,Dte]=eg(cg),[Rte,Jh]=Qr(cg,[Dte]),[$te,Ite]=Rte(cg),CF=x.forwardRef((e,t)=>n.jsx(_N.Provider,{scope:e.__scopeRovingFocusGroup,children:n.jsx(_N.Slot,{scope:e.__scopeRovingFocusGroup,children:n.jsx(Lte,{...e,ref:t})})}));CF.displayName=cg;var Lte=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,orientation:s,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...h}=e,f=x.useRef(null),m=nt(t,f),g=Md(i),[p,y]=Bs({prop:o,defaultProp:l??null,onChange:c,caller:cg}),[v,j]=x.useState(!1),b=Sr(d),_=SF(r),w=x.useRef(!1),[N,S]=x.useState(0);return x.useEffect(()=>{const C=f.current;if(C)return C.addEventListener(Jb,b),()=>C.removeEventListener(Jb,b)},[b]),n.jsx($te,{scope:r,orientation:s,dir:g,loop:a,currentTabStopId:p,onItemFocus:x.useCallback(C=>y(C),[y]),onItemShiftTab:x.useCallback(()=>j(!0),[]),onFocusableItemAdd:x.useCallback(()=>S(C=>C+1),[]),onFocusableItemRemove:x.useCallback(()=>S(C=>C-1),[]),children:n.jsx(We.div,{tabIndex:v||N===0?-1:0,"data-orientation":s,...h,ref:m,style:{outline:"none",...e.style},onMouseDown:Te(e.onMouseDown,()=>{w.current=!0}),onFocus:Te(e.onFocus,C=>{const P=!w.current;if(C.target===C.currentTarget&&P&&!v){const M=new CustomEvent(Jb,Mte);if(C.currentTarget.dispatchEvent(M),!M.defaultPrevented){const D=_().filter($=>$.focusable),A=D.find($=>$.active),U=D.find($=>$.id===p),L=[A,U,...D].filter(Boolean).map($=>$.ref.current);TF(L,u)}}w.current=!1}),onBlur:Te(e.onBlur,()=>j(!1))})})}),kF="RovingFocusGroupItem",PF=x.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:r,focusable:s=!0,active:a=!1,tabStopId:i,children:o,...l}=e,c=ta(),d=i||c,u=Ite(kF,r),h=u.currentTabStopId===d,f=SF(r),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:p}=u;return x.useEffect(()=>{if(s)return m(),()=>g()},[s,m,g]),n.jsx(_N.ItemSlot,{scope:r,id:d,focusable:s,active:a,children:n.jsx(We.span,{tabIndex:h?0:-1,"data-orientation":u.orientation,...l,ref:t,onMouseDown:Te(e.onMouseDown,y=>{s?u.onItemFocus(d):y.preventDefault()}),onFocus:Te(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:Te(e.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=zte(y,u.orientation,u.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=f().filter(_=>_.focusable).map(_=>_.ref.current);if(v==="last")b.reverse();else if(v==="prev"||v==="next"){v==="prev"&&b.reverse();const _=b.indexOf(y.currentTarget);b=u.loop?Bte(b,_+1):b.slice(_+1)}setTimeout(()=>TF(b))}}),children:typeof o=="function"?o({isCurrentTabStop:h,hasTabStop:p!=null}):o})})});PF.displayName=kF;var Fte={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Ute(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function zte(e,t,r){const s=Ute(e.key,r);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(s))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(s)))return Fte[s]}function TF(e,t=!1){const r=document.activeElement;for(const s of e)if(s===r||(s.focus({preventScroll:t}),document.activeElement!==r))return}function Bte(e,t){return e.map((r,s)=>e[(t+s)%e.length])}var BC=CF,qC=PF,z0="Tabs",[qte,aRe]=Qr(z0,[Jh]),AF=Jh(),[Wte,WC]=qte(z0),EF=x.forwardRef((e,t)=>{const{__scopeTabs:r,value:s,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=Md(l),[h,f]=Bs({prop:s,onChange:a,defaultProp:i??"",caller:z0});return n.jsx(Wte,{scope:r,baseId:ta(),value:h,onValueChange:f,orientation:o,dir:u,activationMode:c,children:n.jsx(We.div,{dir:u,"data-orientation":o,...d,ref:t})})});EF.displayName=z0;var OF="TabsList",MF=x.forwardRef((e,t)=>{const{__scopeTabs:r,loop:s=!0,...a}=e,i=WC(OF,r),o=AF(r);return n.jsx(BC,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:s,children:n.jsx(We.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:t})})});MF.displayName=OF;var DF="TabsTrigger",RF=x.forwardRef((e,t)=>{const{__scopeTabs:r,value:s,disabled:a=!1,...i}=e,o=WC(DF,r),l=AF(r),c=LF(o.baseId,s),d=FF(o.baseId,s),u=s===o.value;return n.jsx(qC,{asChild:!0,...l,focusable:!a,active:u,children:n.jsx(We.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:c,...i,ref:t,onMouseDown:Te(e.onMouseDown,h=>{!a&&h.button===0&&h.ctrlKey===!1?o.onValueChange(s):h.preventDefault()}),onKeyDown:Te(e.onKeyDown,h=>{[" ","Enter"].includes(h.key)&&o.onValueChange(s)}),onFocus:Te(e.onFocus,()=>{const h=o.activationMode!=="manual";!u&&!a&&h&&o.onValueChange(s)})})})});RF.displayName=DF;var $F="TabsContent",IF=x.forwardRef((e,t)=>
622{const{__scopeTabs:r,value:s,forceMount:a,children:i,...o}=e,l=WC($F,r),c=LF(l.baseId,s),d=FF(l.baseId,s),u=s===l.value,h=x.useRef(u);return x.useEffect(()=>{const f=requestAnimationFrame(()=>h.current=!1);return()=>cancelAnimationFrame(f)},[]),n.jsx(jn,{present:a||u,children:({present:f})=>n.jsx(We.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!f,id:d,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:h.current?"0s":void 0},children:f&&i})})});IF.displayName=$F;function LF(e,t){return`${e}-trigger-${t}`}function FF(e,t){return`${e}-content-${t}`}var Hte=EF,UF=MF,zF=RF,BF=IF;const cn=Hte,nn=x.forwardRef(({className:e,...t},r)=>n.jsx(UF,{ref:r,className:we("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));nn.displayName=UF.displayName;const at=x.forwardRef(({className:e,...t},r)=>n.jsx(zF,{ref:r,className:we("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));at.displayName=zF.displayName;const it=x.forwardRef(({className:e,...t},r)=>n.jsx(BF,{ref:r,className:we("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));it.displayName=BF.displayName;function dc(){const{selectedClientId:e}=Mt(),t=Et();x.useEffect(()=>{if(!e)return;const g=B.channel("agent_updates").on("postgres_changes",{event:"*",schema:"public",table:"agent_current_status",filter:`client_id=eq.${e}`},p=>{console.log("Agent status real-time update:",p),t.invalidateQueries({queryKey:["agent-current-status",e]}),t.invalidateQueries({queryKey:["agent-statuses",e]})}).on("postgres_changes",{event:"INSERT",schema:"public",table:"private_lan_agent_heartbeats",filter:`client_id=eq.${e}`},p=>{var y;console.log("Heartbeat history real-time update:",p),(y=p.new)!=null&&y.agent_id&&(t.invalidateQueries({queryKey:["agent-heartbeat-history",p.new.agent_id]}),t.invalidateQueries({queryKey:["agent-history",p.new.agent_id]}))}).subscribe();return()=>{B.removeChannel(g)}},[e,t]);const{data:r,isLoading:s,error:a}=Ve({queryKey:["agent-current-status",e],queryFn:async()=>{if(!e)return[];const{data:g,error:p}=await B.from("agent_current_status").select("*").eq("client_id",e).order("last_seen",{ascending:!1});if(p)throw p;return g},enabled:!!e,refetchInterval:5e3}),{data:i,isLoading:o,error:l}=Ve({queryKey:["agent-statuses",e],queryFn:async()=>{var b;if(!e)return[];const{data:g,error:p}=await B.from("monitoring_agents").select("id, name, hostname_or_url, status, created_at, monitoring_config").eq("client_id",e).eq("asset_type","local_device");if(p)throw p;let y=60;const{data:v}=await B.from("clients").select("enabled_modules").eq("id",e).single();if(v!=null&&v.enabled_modules)try{const _=typeof v.enabled_modules=="string"?JSON.parse(v.enabled_modules):v.enabled_modules;(b=_==null?void 0:_.agent_timing_defaults)!=null&&b.heartbeat_interval_seconds&&(y=_.agent_timing_defaults.heartbeat_interval_seconds)}catch{}const j=[];for(const _ of g){const{data:w}=await B.from("agent_current_status").select("*").eq("agent_id",_.id).maybeSingle(),S=(_.monitoring_config||{}).heartbeat_interval_seconds||y,C=Math.max(15,S*3),P=new Date,M=w?new Date(w.last_seen):null,D=M?Math.floor((P.getTime()-M.getTime())/1e3):null;let A="offline";w&&(w.status==="error"?A="error":D!==null&&D>C?A="offline":w.status==="online"&&D!==null&&D<=C?A="online":A="offline"),j.push({agent_id:_.id,agent_name:_.name,hostname:_.hostname_or_url||"Unknown",last_seen:w?w.last_seen:"Never",created_at:_.created_at,status:A,local_ip:w==null?void 0:w.local_ip,os_type:w==null?void 0:w.os_type,os_version:w==null?void 0:w.os_version,agent_version:w==null?void 0:w.agent_version,error_message:w==null?void 0:w.error_message})}return j},enabled:!!e,refetchInterval:5e3}),c=(g,p=24)=>Ve({queryKey:["agent-history",g,p],queryFn:async()=>
622{if(!g)return[];const y=new Date;y.setHours(y.getHours()-p);const{data:v,error:j}=await B.from("private_lan_agent_heartbeats").select("*").eq("agent_id",g).gte("created_at",y.toISOString()).order("created_at",{ascending:!1}).limit(1e3);return j?(console.warn("Failed to query agent history:",j),[]):(v||[]).map(_=>({id:_.id,agent_id:_.agent_id,client_id:_.client_id,hostname:_.hostname,local_ip:_.local_ip,os_type:_.os_type,os_version:_.os_version,agent_version:_.agent_version,status:_.status,error_message:_.error_message,last_seen:_.created_at,created_at:_.created_at}))},enabled:!!g&&!!e,refetchInterval:3e4}),d=(g,p=24)=>Ve({queryKey:["agent-heartbeat-history",g,p],queryFn:async()=>{if(!g)return[];const y=new Date;y.setHours(y.getHours()-3);const{data:v,error:j}=await B.from("private_lan_agent_heartbeats").select("*").eq("agent_id",g).gte("created_at",y.toISOString()).order("created_at",{ascending:!1});return j?(console.warn("Failed to query heartbeat history:",j),[]):(v||[]).map(_=>({id:_.id,agent_id:_.agent_id,client_id:_.client_id,hostname:_.hostname,local_ip:_.local_ip,os_type:_.os_type,os_version:_.os_version,agent_version:_.agent_version,status:_.status,error_message:_.error_message,last_seen:_.created_at,created_at:_.created_at}))},enabled:!!g&&!!e,refetchInterval:15e3,staleTime:1e4}),u=(i==null?void 0:i.filter(g=>g.status==="online").length)||0,h=(i==null?void 0:i.filter(g=>g.status==="offline").length)||0,f=(i==null?void 0:i.filter(g=>g.status==="error").length)||0,m=(i==null?void 0:i.length)||0;return{recentHeartbeats:r,agentStatuses:i,isLoading:s||o,error:a||l,getAgentHistory:c,getAgentHeartbeatHistory:d,stats:{total:m,online:u,offline:h,error:f}}}const Vte=e=>{const t=Et(),{agentStatuses:r}=dc(),s=Ve({queryKey:["agent-monitor-state",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("monitoring_agents").select("created_at, client_id").eq("id",e).single();i&&console.error("Error fetching agent details:",i);const{data:o,error:l}=await B.from("agent_monitor_state").select("*").eq("agent_id",e).order("monitor_id");if(l)throw console.error("Error fetching agent monitor state:",l),l;const{data:c,error:d}=await B.from("agent_monitor_configs").select("*").eq("agent_id",e);if(d)throw console.error("Error fetching agent monitor configs:",d),d;const u=[...(o==null?void 0:o.map(v=>({...v,state:v.state,details:v.details||{},severity:v.severity||void 0})))||[]],h=new Set((o==null?void 0:o.map(v=>v.monitor_id))||[]);if(c)for(const v of c){const j=v.configuration;if(j!=null&&j.monitors)for(const b of j.monitors)b.enabled&&!h.has(b.monitor_id)&&u.push({id:`config-${b.monitor_id}`,client_id:v.client_id,agent_id:v.agent_id,monitor_id:b.monitor_id,monitor_type:b.monitor_type,state:"configured",details:{configured:!0,thresholds:b.thresholds},state_since:v.created_at,updated_at:v.updated_at,created_at:v.created_at})}const f=r==null?void 0:r.find(v=>v.agent_id===e);let m="healthy",g;(f==null?void 0:f.status)==="offline"?(m="breached",g="critical"):(f==null?void 0:f.status)==="error"&&(m="breached",g="warning");const p={id:"heartbeat-monitor",client_id:(a==null?void 0:a.client_id)||"",agent_id:e,monitor_id:"heartbeat-monitor",monitor_type:"Connection Status",state:m,severity:g,details:{message:(f==null?void 0:f.status)==="online"?"Receiving active heartbeat":"Agent not responding",hostname:(f==null?void 0:f.hostname)||"Unknown",status:(f==null?void 0:f.status)||"unknown"},state_since:(a==null?void 0:a.created_at)||new Date().toISOString(),updated_at:new Date().toISOString(),created_at:(a==null?void 0:a.created_at)||new Date().toISOString()},y=u.sort((v,j)=>v.monitor_id.localeCompare(j.monitor_id));return[p,...y]},enabled:!!e});return x.useEffect(()=>{if(!e)return;const a=B.channel(`agent-monitor-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"agent_monitor_state",filter:`agent_id=eq.${e}`},i=>{console.log("Monitor state update:",i),t.invalidateQueries({queryKey:["agent-monitor-state",e]})}).on("postgres_changes",{event:"*",schema:"public",table:"agent_monitor_configs",filter:`agent_id=eq.${e}`},i=>{console.log("Monitor config update:",i),t.invalidateQueries({queryKey:["agent-monitor-state",e]})}).subscribe();return()=>{B.removeChannel(a)}},[e,t]),s},Kte=(e,t=50)=>{const r=Ve({queryKey:["agent-monitor-events",e,t],queryFn:async()=>
622{if(!e)return[];const{data:s,error:a}=await B.from("agent_events").select("*").eq("agent_id",e).order("created_at",{ascending:!1}).limit(t);if(a)throw console.error("Error fetching agent monitor events:",a),a;return s},enabled:!!e});return x.useEffect(()=>{if(!e)return;const s=B.channel(`agent-monitor-events-${e}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"agent_events",filter:`agent_id=eq.${e}`},a=>{console.log("New monitor event:",a),r.refetch()}).subscribe();return()=>{B.removeChannel(s)}},[e,r]),r},zv=(e,t)=>{const{toast:r}=qr(),s=Et(),{data:a=[],isLoading:i,error:o,refetch:l}=Ve({queryKey:["agent-commands",e,t],queryFn:async()=>{let m=B.from("agent_commands").select("*").order("created_at",{ascending:!1});e&&(m=m.eq("agent_id",e)),t&&(m=m.eq("client_id",t));const{data:g,error:p}=await m;if(p)throw p;return g},enabled:!!(e||t)}),c=mt({mutationFn:async m=>{const g=`cmd_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{data:p,error:y}=await B.from("agent_commands").insert({...m,cursor:g,status:"pending"}).select().single();if(y)throw y;return p},onSuccess:()=>{r({title:"Command Queued",description:"Command has been successfully queued for the agent."}),s.invalidateQueries({queryKey:["agent-commands"]})},onError:m=>{r({title:"Failed to Queue Command",description:"There was an error queuing the command.",variant:"destructive"}),console.error("Create command error:",m)}}),d=mt({mutationFn:async m=>{const{data:g,error:p}=await B.from("agent_commands").select("cursor, agent_id, client_id, status").eq("id",m).single();if(p)throw p;if(!g)throw new Error("Command not found");if(g.status==="completed"||g.status==="failed"||g.status==="cancelled")throw new Error("Command has already been processed and cannot be cancelled");const{error:y}=await B.from("agent_commands").update({status:"cancelled",finished_at:new Date().toISOString()}).eq("id",m).eq("status","pending");if(y)throw y;const v=`cancel_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{error:j}=await B.from("agent_commands").insert({agent_id:g.agent_id,client_id:g.client_id,cursor:v,op:"cancel_command",args:{target_cursor:g.cursor},status:"pending"});if(j)throw j;return{commandId:m,targetCursor:g.cursor}},onSuccess:m=>{r({title:"Command Cancelled",description:`Command has been cancelled and agent will be notified to stop processing cursor ${m.targetCursor.slice(-12)}...`}),s.invalidateQueries({queryKey:["agent-commands"]})},onError:m=>{var p,y;console.error("Cancel command error:",m);let g="There was an error cancelling the command.";(p=m.message)!=null&&p.includes("already been processed")?g="This command has already been completed and cannot be cancelled.":(y=m.message)!=null&&y.includes("Command not found")&&(g="Command not found or no longer available."),r({title:"Failed to Cancel Command",description:g,variant:"destructive"})}}),u=mt({mutationFn:async m=>{const{error:g}=await B.from("agent_commands").delete().eq("id",m);if(g)throw g;return m},onSuccess:()=>{r({title:"Command Deleted",description:"Command has been removed from the history."}),s.invalidateQueries({queryKey:["agent-commands"]})},onError:m=>{r({title:"Failed to Delete Command",description:"There was an error deleting the command.",variant:"destructive"}),console.error("Delete command error:",m)}});x.useEffect(()=>{if(!e&&!t)return;const m=B.channel(`agent-commands-${e||t}`).on("postgres_changes",{event:"INSERT",schema:"public",table:"agent_commands"},g=>{const p=g.new;p&&(e&&p.agent_id===e||t&&p.client_id===t)&&s.invalidateQueries({queryKey:["agent-commands"]})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"agent_commands"},g=>{const p=g.new,y=g.old;(e&&((p==null?void 0:p.agent_id)===e||(y==null?void 0:y.agent_id)===e)||t&&((p==null?void 0:p.client_id)===t||(y==null?void 0:y.client_id)===t))&&s.invalidateQueries({queryKey:["agent-commands"]})}).subscribe();return()=>{B.removeChannel(m)}},[e,t,s]);const h=a.filter(m=>m.status==="pending"),f=a.filter(m=>m.status!=="pending");return{commands:a,activeCommands:h,completedCommands:f,isLoading:i,error:o,refetch:l,createCommand:c.mutate,isCreating:c.isPending,cancelCommand:d.mutate,isCancelling:d.isPending,deleteCommand:u.mutate,isDeleting:u.isPending}};function dg(e){const t=x.useRef({value:e,previous:e});return x.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var B0="Switch",[Gte,iRe]=Qr(B0),[Yte,Qte]=Gte(B0),qF=x.forwardRef((e,t)=>
622{const{__scopeSwitch:r,name:s,checked:a,defaultChecked:i,required:o,disabled:l,value:c="on",onCheckedChange:d,form:u,...h}=e,[f,m]=x.useState(null),g=nt(t,b=>m(b)),p=x.useRef(!1),y=f?u||!!f.closest("form"):!0,[v,j]=Bs({prop:a,defaultProp:i??!1,onChange:d,caller:B0});return n.jsxs(Yte,{scope:r,checked:v,disabled:l,children:[n.jsx(We.button,{type:"button",role:"switch","aria-checked":v,"aria-required":o,"data-state":KF(v),"data-disabled":l?"":void 0,disabled:l,value:c,...h,ref:g,onClick:Te(e.onClick,b=>{j(_=>!_),y&&(p.current=b.isPropagationStopped(),p.current||b.stopPropagation())})}),y&&n.jsx(VF,{control:f,bubbles:!p.current,name:s,value:c,checked:v,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});qF.displayName=B0;var WF="SwitchThumb",HF=x.forwardRef((e,t)=>{const{__scopeSwitch:r,...s}=e,a=Qte(WF,r);return n.jsx(We.span,{"data-state":KF(a.checked),"data-disabled":a.disabled?"":void 0,...s,ref:t})});HF.displayName=WF;var Xte="SwitchBubbleInput",VF=x.forwardRef(({__scopeSwitch:e,control:t,checked:r,bubbles:s=!0,...a},i)=>{const o=x.useRef(null),l=nt(o,i),c=dg(r),d=Hh(t);return x.useEffect(()=>{const u=o.current;if(!u)return;const h=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==r&&m){const g=new Event("click",{bubbles:s});m.call(u,r),u.dispatchEvent(g)}},[c,r,s]),n.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});VF.displayName=Xte;function KF(e){return e?"checked":"unchecked"}var GF=qF,Zte=HF;const Rs=x.forwardRef(({className:e,...t},r)=>n.jsx(GF,{className:we("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...t,ref:r,children:n.jsx(Zte,{className:we("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Rs.displayName=GF.displayName;function sp(e,[t,r]){return Math.min(r,Math.max(t,e))}var YF=["PageUp","PageDown"],QF=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],XF={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},ef="Slider",[NN,Jte,ere]=eg(ef),[ZF,oRe]=Qr(ef,[ere]),[tre,q0]=ZF(ef),JF=x.forwardRef((e,t)=>{const{name:r,min:s=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:l=!1,minStepsBetweenThumbs:c=0,defaultValue:d=[s],value:u,onValueChange:h=()=>{},onValueCommit:f=()=>{},inverted:m=!1,form:g,...p}=e,y=x.useRef(new Set),v=x.useRef(0),b=o==="horizontal"?rre:nre,[_=[],w]=Bs({prop:u,defaultProp:d,onChange:D=>{var U;(U=[...y.current][v.current])==null||U.focus(),h(D)}}),N=x.useRef(_);function S(D){const A=lre(_,D);M(D,A)}function C(D){M(D,v.current)}function P(){const D=N.current[v.current];_[v.current]!==D&&f(_)}function M(D,A,{commit:U}={commit:!1}){const F=hre(i),L=fre(Math.round((D-s)/i)*i+s,F),$=sp(L,[s,a]);w((R=[])=>{const T=ire(R,$,A);if(ure(T,c*i)){v.current=T.indexOf($);const k=String(T)!==String(R);return k&&U&&f(T),k?T:R}else return R})}return n.jsx(tre,{scope:e.__scopeSlider,name:r,disabled:l,min:s,max:a,valueIndexToChangeRef:v,thumbs:y.current,values:_,orientation:o,form:g,children:n.jsx(NN.Provider,{scope:e.__scopeSlider,children:n.jsx(NN.Slot,{scope:e.__scopeSlider,children:n.jsx(b,{"aria-disabled":l,"data-disabled":l?"":void 0,...p,ref:t,onPointerDown:Te(p.onPointerDown,()=>{l||(N.current=_)}),min:s,max:a,inverted:m,onSlideStart:l?void 0:S,onSlideMove:l?void 0:C,onSlideEnd:l?void 0:P,onHomeKeyDown:()=>!l&&M(s,0,{commit:!0}),onEndKeyDown:()=>!l&&M(a,_.length-1,{commit:!0}),onStepKeyDown:({event:D,direction:A})=>
622{if(!l){const L=YF.includes(D.key)||D.shiftKey&&QF.includes(D.key)?10:1,$=v.current,R=_[$],T=i*L*A;M(R+T,$,{commit:!0})}}})})})})});JF.displayName=ef;var[e3,t3]=ZF(ef,{startEdge:"left",endEdge:"right",size:"width",direction:1}),rre=x.forwardRef((e,t)=>{const{min:r,max:s,dir:a,inverted:i,onSlideStart:o,onSlideMove:l,onSlideEnd:c,onStepKeyDown:d,...u}=e,[h,f]=x.useState(null),m=nt(t,b=>f(b)),g=x.useRef(void 0),p=Md(a),y=p==="ltr",v=y&&!i||!y&&i;function j(b){const _=g.current||h.getBoundingClientRect(),w=[0,_.width],S=HC(w,v?[r,s]:[s,r]);return g.current=_,S(b-_.left)}return n.jsx(e3,{scope:e.__scopeSlider,startEdge:v?"left":"right",endEdge:v?"right":"left",direction:v?1:-1,size:"width",children:n.jsx(r3,{dir:p,"data-orientation":"horizontal",...u,ref:m,style:{...u.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:b=>{const _=j(b.clientX);o==null||o(_)},onSlideMove:b=>{const _=j(b.clientX);l==null||l(_)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:b=>{const w=XF[v?"from-left":"from-right"].includes(b.key);d==null||d({event:b,direction:w?-1:1})}})})}),nre=x.forwardRef((e,t)=>{const{min:r,max:s,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:l,onStepKeyDown:c,...d}=e,u=x.useRef(null),h=nt(t,u),f=x.useRef(void 0),m=!a;function g(p){const y=f.current||u.current.getBoundingClientRect(),v=[0,y.height],b=HC(v,m?[s,r]:[r,s]);return f.current=y,b(p-y.top)}return n.jsx(e3,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:n.jsx(r3,{"data-orientation":"vertical",...d,ref:h,style:{...d.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:p=>{const y=g(p.clientY);i==null||i(y)},onSlideMove:p=>{const y=g(p.clientY);o==null||o(y)},onSlideEnd:()=>{f.current=void 0,l==null||l()},onStepKeyDown:p=>{const v=XF[m?"from-bottom":"from-top"].includes(p.key);c==null||c({event:p,direction:v?-1:1})}})})}),r3=x.forwardRef((e,t)=>{const{__scopeSlider:r,onSlideStart:s,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:l,onStepKeyDown:c,...d}=e,u=q0(ef,r);return n.jsx(We.span,{...d,ref:t,onKeyDown:Te(e.onKeyDown,h=>{h.key==="Home"?(o(h),h.preventDefault()):h.key==="End"?(l(h),h.preventDefault()):YF.concat(QF).includes(h.key)&&(c(h),h.preventDefault())}),onPointerDown:Te(e.onPointerDown,h=>{const f=h.target;f.setPointerCapture(h.pointerId),h.preventDefault(),u.thumbs.has(f)?f.focus():s(h)}),onPointerMove:Te(e.onPointerMove,h=>{h.target.hasPointerCapture(h.pointerId)&&a(h)}),onPointerUp:Te(e.onPointerUp,h=>{const f=h.target;f.hasPointerCapture(h.pointerId)&&(f.releasePointerCapture(h.pointerId),i(h))})})}),n3="SliderTrack",s3=x.forwardRef((e,t)=>{const{__scopeSlider:r,...s}=e,a=q0(n3,r);return n.jsx(We.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...s,ref:t})});s3.displayName=n3;var SN="SliderRange",a3=x.forwardRef((e,t)=>{const{__scopeSlider:r,...s}=e,a=q0(SN,r),i=t3(SN,r),o=x.useRef(null),l=nt(t,o),c=a.values.length,d=a.values.map(f=>l3(f,a.min,a.max)),u=c>1?Math.min(...d):0,h=100-Math.max(...d);return n.jsx(We.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...s,ref:l,style:{...e.style,[i.startEdge]:u+"%",[i.endEdge]:h+"%"}})});a3.displayName=SN;var CN="SliderThumb",i3=x.forwardRef((e,t)=>{const r=Jte(e.__scopeSlider),[s,a]=x.useState(null),i=nt(t,l=>a(l)),o=x.useMemo(()=>s?r().findIndex(l=>l.ref.current===s):-1,[r,s]);return n.jsx(sre,{...e,ref:i,index:o})}),sre=x.forwardRef((e,t)=>{const{__scopeSlider:r,index:s,name:a,...i}=e,o=q0(CN,r),l=t3(CN,r),[c,d]=x.useState(null),u=nt(t,j=>d(j)),h=c?o.form||!!c.closest("form"):!0,f=Hh(c),m=o.values[s],g=m===void 0?0:l3(m,o.min,o.max),p=ore(s,o.values.length),y=f==null?void 0:f[l.size],v=y?cre(y,g,l.direction):0;return x.useEffect(()=>{if(c)return o.thumbs.add(c),()=>{o.thumbs.delete(c)}},[c,o.thumbs]),n.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[l.startEdge]:`calc(${g}% + ${v}px)`},children:[n.jsx(NN.ItemSlot,{scope:e.__scopeSlider,children:n.jsx(We.span,{role:"slider","aria-label":e["aria-label"]||p,"aria-valuemin":o.min,"aria-valuenow":m,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:u,style:m===void 0?{display:"none"}:e.style,onFocus:Te(e.onFocus,()=>{o.valueIndexToChangeRef.current=s})})}),h&&n.jsx(o3,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:m},s)]})});
622i3.displayName=CN;var are="RadioBubbleInput",o3=x.forwardRef(({__scopeSlider:e,value:t,...r},s)=>{const a=x.useRef(null),i=nt(a,s),o=dg(t);return x.useEffect(()=>{const l=a.current;if(!l)return;const c=window.HTMLInputElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&u){const h=new Event("input",{bubbles:!0});u.call(l,t),l.dispatchEvent(h)}},[o,t]),n.jsx(We.input,{style:{display:"none"},...r,ref:i,defaultValue:t})});o3.displayName=are;function ire(e=[],t,r){const s=[...e];return s[r]=t,s.sort((a,i)=>a-i)}function l3(e,t,r){const i=100/(r-t)*(e-t);return sp(i,[0,100])}function ore(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function lre(e,t){if(e.length===1)return 0;const r=e.map(a=>Math.abs(a-t)),s=Math.min(...r);return r.indexOf(s)}function cre(e,t,r){const s=e/2,i=HC([0,50],[0,s]);return(s-i(t)*r)*r}function dre(e){return e.slice(0,-1).map((t,r)=>e[r+1]-t)}function ure(e,t){if(t>0){const r=dre(e);return Math.min(...r)>=t}return!0}function HC(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(r-e[0])}}function hre(e){return(String(e).split(".")[1]||"").length}function fre(e,t){const r=Math.pow(10,t);return Math.round(e*r)/r}var c3=JF,mre=s3,pre=a3,gre=i3;const sd=x.forwardRef(({className:e,...t},r)=>n.jsxs(c3,{ref:r,className:we("relative flex w-full touch-none select-none items-center",e),...t,children:[n.jsx(mre,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:n.jsx(pre,{className:"absolute h-full bg-primary"})}),n.jsx(gre,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));sd.displayName=c3.displayName;var ew="focusScope.autoFocusOnMount",tw="focusScope.autoFocusOnUnmount",bA={bubbles:!1,cancelable:!0},xre="FocusScope",ug=x.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...o}=e,[l,c]=x.useState(null),d=Sr(a),u=Sr(i),h=x.useRef(null),f=nt(t,p=>c(p)),m=x.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;x.useEffect(()=>{if(s){let p=function(b){if(m.paused||!l)return;const _=b.target;l.contains(_)?h.current=_:ul(h.current,{select:!0})},y=function(b){if(m.paused||!l)return;const _=b.relatedTarget;_!==null&&(l.contains(_)||ul(h.current,{select:!0}))},v=function(b){if(document.activeElement===document.body)for(const w of b)w.removedNodes.length>0&&ul(l)};document.addEventListener("focusin",p),document.addEventListener("focusout",y);const j=new MutationObserver(v);return l&&j.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",y),j.disconnect()}}},[s,l,m.paused]),x.useEffect(()=>{if(l){_A.add(m);const p=document.activeElement;if(!l.contains(p)){const v=new CustomEvent(ew,bA);l.addEventListener(ew,d),l.dispatchEvent(v),v.defaultPrevented||(vre(_re(d3(l)),{select:!0}),document.activeElement===p&&ul(l))}return()=>{l.removeEventListener(ew,d),setTimeout(()=>{const v=new CustomEvent(tw,bA);l.addEventListener(tw,u),l.dispatchEvent(v),v.defaultPrevented||ul(p??document.body,{select:!0}),l.removeEventListener(tw,u),_A.remove(m)},0)}}},[l,d,u,m]);const g=x.useCallback(p=>{if(!r&&!s||m.paused)return;const y=p.key==="Tab"&&!p.altKey&&!p.ctrlKey&&!p.metaKey,v=document.activeElement;if(y&&v){const j=p.currentTarget,[b,_]=yre(j);b&&_?!p.shiftKey&&v===_?(p.preventDefault(),r&&ul(b,{select:!0})):p.shiftKey&&v===b&&(p.preventDefault(),r&&ul(_,{select:!0})):v===j&&p.preventDefault()}},[r,s,m.paused]);return n.jsx(We.div,{tabIndex:-1,...o,ref:f,onKeyDown:g})});ug.displayName=xre;function vre(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(ul(s,{select:t}),document.activeElement!==r)return}function yre(e){const t=d3(e),r=wA(t,e),s=wA(t.reverse(),e);return[r,s]}function d3(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const a=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||a?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function wA(e,t){for(const r of e)if(!jre(r,{upTo:t}))return r}function jre(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function bre(e){return e instanceof HTMLInputElement&&"select"in e}function ul(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&bre(e)&&t&&e.select()}}var _A=wre();function wre(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=NA(e,t),e.unshift(t)},remove(t){var r;e=NA(e,t),(r=e[0])==null||r.resume()}}}function NA(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function _re(e){return e.filter(t=>t.tagName!=="A")}var rw=0;function W0(){x.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??SA()),document.body.insertAdjacentElement("beforeend",e[1]??SA()),rw++,()=>{rw===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),rw--}},[])}function SA(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.
vendor: 7,338 bytes, lines 622-659
622style.position="fixed",e.style.pointerEvents="none",e}var Ci=function(){return Ci=Object.assign||function(t){for(var r,s=1,a=arguments.length;s<a;s++){r=arguments[s];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Ci.apply(this,arguments)};function u3(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(r[s[a]]=e[s[a]]);return r}function Nre(e,t,r){if(r||arguments.length===2)for(var s=0,a=t.length,i;s<a;s++)(i||!(s in t))&&(i||(i=Array.prototype.slice.call(t,0,s)),i[s]=t[s]);return e.concat(i||Array.prototype.slice.call(t))}var Zx="right-scroll-bar-position",Jx="width-before-scroll-bar",Sre="with-scroll-bars-hidden",Cre="--removed-body-scroll-bar-size";function nw(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function kre(e,t){var r=x.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(s){var a=r.value;a!==s&&(r.value=s,r.callback(s,a))}}}})[0];return r.callback=t,r.facade}var Pre=typeof window<"u"?x.useLayoutEffect:x.useEffect,CA=new WeakMap;function Tre(e,t){var r=kre(null,function(s){return e.forEach(function(a){return nw(a,s)})});return Pre(function(){var s=CA.get(r);if(s){var a=new Set(s),i=new Set(e),o=r.current;a.forEach(function(l){i.has(l)||nw(l,null)}),i.forEach(function(l){a.has(l)||nw(l,o)})}CA.set(r,e)},[e]),r}function Are(e){return e}function Ere(e,t){t===void 0&&(t=Are);var r=[],s=!1,a={read:function(){if(s)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var o=t(i,s);return r.push(o),function(){r=r.filter(function(l){return l!==o})}},assignSyncMedium:function(i){for(s=!0;r.length;){var o=r;r=[],o.forEach(i)}r={push:function(l){return i(l)},filter:function(){return r}}},assignMedium:function(i){s=!0;var o=[];if(r.length){var l=r;r=[],l.forEach(i),o=r}var c=function(){var u=o;o=[],u.forEach(i)},d=function(){return Promise.resolve().then(c)};d(),r={push:function(u){o.push(u),d()},filter:function(u){return o=o.filter(u),r}}}};return a}function Ore(e){e===void 0&&(e={});var t=Ere(null);return t.options=Ci({async:!0,ssr:!1},e),t}var h3=function(e){var t=e.sideCar,r=u3(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var s=t.read();if(!s)throw new Error("Sidecar medium not found");return x.createElement(s,Ci({},r))};h3.isSideCarExport=!0;function Mre(e,t){return e.useMedium(t),h3}var f3=Ore(),sw=function(){},H0=x.forwardRef(function(e,t){var r=x.useRef(null),s=x.useState({onScrollCapture:sw,onWheelCapture:sw,onTouchMoveCapture:sw}),a=s[0],i=s[1],o=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,u=e.enabled,h=e.shards,f=e.sideCar,m=e.noRelative,g=e.noIsolation,p=e.inert,y=e.allowPinchZoom,v=e.as,j=v===void 0?"div":v,b=e.gapMode,_=u3(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),w=f,N=Tre([r,t]),S=Ci(Ci({},_),a);return x.createElement(x.Fragment,null,u&&x.createElement(w,{sideCar:f3,removeScrollBar:d,shards:h,noRelative:m,noIsolation:g,inert:p,setCallbacks:i,allowPinchZoom:!!y,lockRef:r,gapMode:b}),o?x.cloneElement(x.Children.only(l),Ci(Ci({},S),{ref:N})):x.createElement(j,Ci({},S,{className:c,ref:N}),l))});H0.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};H0.classNames={fullWidth:Jx,zeroRight:Zx};var Dre=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Rre(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Dre();return t&&e.setAttribute("nonce",t),e}function $re(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Ire(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Lre=function(){var e=0,t=null;return{add:function(r){e==0&&(t=Rre())&&($re(t,r),Ire(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Fre=function(){var e=Lre();return function(t,r){x.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},m3=function(){var e=Fre(),t=function(r){var s=r.styles,a=r.dynamic;return e(s,a),null};return t},Ure={left:0,top:0,right:0,gap:0},aw=function(e){return parseInt(e||"",10)||0},zre=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],s=t[e==="padding"?"paddingTop":"marginTop"],a=t[e==="padding"?"paddingRight":"marginRight"];return[aw(r),aw(s),aw(a)]},Bre=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Ure;var t=zre(e),r=document.documentElement.clientWidth,s=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,s-r+t[2]-t[0])}},qre=m3(),Ou="data-scroll-locked",Wre=function(e,t,r,s){var a=e.left,i=e.top,o=e.right,l=e.gap;return r===void 0&&(r="margin"),`
623  .`.concat(Sre,` {
624   overflow: hidden `).concat(s,`;
625   padding-right: `).concat(l,"px ").concat(s,`;
626  }
627  body[`).concat(Ou,`] {
628    overflow: hidden `).concat(s,`;
629    overscroll-behavior: contain;
630    `).concat([t&&"position: relative ".concat(s,";"),r==="margin"&&`
631    padding-left: `.concat(a,`px;
632    padding-top: `).concat(i,`px;
633    padding-right: `).concat(o,`px;
634    margin-left:0;
635    margin-top:0;
636    margin-right: `).concat(l,"px ").concat(s,`;
637    `),r==="padding"&&"padding-right: ".concat(l,"px ").concat(s,";")].filter(Boolean).join(""),`
638  }
639  
640  .`).concat(Zx,` {
641    right: `).concat(l,"px ").concat(s,`;
642  }
643  
644  .`).concat(Jx,` {
645    margin-right: `).concat(l,"px ").concat(s,`;
646  }
647  
648  .`).concat(Zx," .").concat(Zx,` {
649    right: 0 `).concat(s,`;
650  }
651  
652  .`).concat(Jx," .").concat(Jx,` {
653    margin-right: 0 `).concat(s,`;
654  }
655  
656  body[`).concat(Ou,`] {
657    `).concat(Cre,": ").concat(l,`px;
658  }
659`)},kA=function(){var e=parseInt(document.body.getAttribute(Ou)||"0",10);return isFinite(e)?e:0},Hre=function(){x.useEffect(function(){return document.body.setAttribute(Ou,(kA()+1).toString()),function(){var e=kA()-1;e<=0?document.body.removeAttribute(Ou):document.body.setAttribute(Ou,e.toString())}},[])},Vre=function(e){var t=e.noRelative,r=e.noImportant,s=e.gapMode,a=s===void 0?"margin":s;Hre();var i=x.useMemo(function(){return Bre(a)},[a]);return x.createElement(qre,{styles:Wre(i,!t,a,r?"":"!important")})},kN=!1;if(typeof window<"u")try{var lx=Object.defineProperty({},"passive",{get:function(){return kN=!0,!0}});window.addEventListener("test",lx,lx),window.removeEventListener("test",lx,lx)}catch{kN=!1}var Yd=kN?{passive:!1}:!1,Kre=function(e){return e.tagName==="TEXTAREA"},p3=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!Kre(e)&&r[t]==="visible")},Gre=function(e){return p3(e,"overflowY")},Yre=function(e){return p3(e,"overflowX")},PA=function(e,t){var r=t.ownerDocument,s=t;do{typeof ShadowRoot<"u"&&s instanceof ShadowRoot&&(s=s.host);var a=g3(e,s);if(a){var i=x3(e,s),o=i[1],l=i[2];if(o>l)return!0}s=s.parentNode}while(s&&s!==r.body);return!1}
vendor: 4,599 bytes, lines 659-662
659,Qre=function(e){var t=e.scrollTop,r=e.scrollHeight,s=e.clientHeight;return[t,r,s]},Xre=function(e){var t=e.scrollLeft,r=e.scrollWidth,s=e.clientWidth;return[t,r,s]},g3=function(e,t){return e==="v"?Gre(t):Yre(t)},x3=function(e,t){return e==="v"?Qre(t):Xre(t)},Zre=function(e,t){return e==="h"&&t==="rtl"?-1:1},Jre=function(e,t,r,s,a){var i=Zre(e,window.getComputedStyle(t).direction),o=i*s,l=r.target,c=t.contains(l),d=!1,u=o>0,h=0,f=0;do{if(!l)break;var m=x3(e,l),g=m[0],p=m[1],y=m[2],v=p-y-i*g;(g||v)&&g3(e,l)&&(h+=v,f+=g);var j=l.parentNode;l=j&&j.nodeType===Node.DOCUMENT_FRAGMENT_NODE?j.host:j}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(u&&(Math.abs(h)<1||!a)||!u&&(Math.abs(f)<1||!a))&&(d=!0),d},cx=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},TA=function(e){return[e.deltaX,e.deltaY]},AA=function(e){return e&&"current"in e?e.current:e},ene=function(e,t){return e[0]===t[0]&&e[1]===t[1]},tne=function(e){return`
660  .block-interactivity-`.concat(e,` {pointer-events: none;}
661  .allow-interactivity-`).concat(e,` {pointer-events: all;}
662`)},rne=0,Qd=[];function nne(e){var t=x.useRef([]),r=x.useRef([0,0]),s=x.useRef(),a=x.useState(rne++)[0],i=x.useState(m3)[0],o=x.useRef(e);x.useEffect(function(){o.current=e},[e]),x.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(a));var p=Nre([e.lockRef.current],(e.shards||[]).map(AA),!0).filter(Boolean);return p.forEach(function(y){return y.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),p.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(a))})}}},[e.inert,e.lockRef.current,e.shards]);var l=x.useCallback(function(p,y){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!o.current.allowPinchZoom;var v=cx(p),j=r.current,b="deltaX"in p?p.deltaX:j[0]-v[0],_="deltaY"in p?p.deltaY:j[1]-v[1],w,N=p.target,S=Math.abs(b)>Math.abs(_)?"h":"v";if("touches"in p&&S==="h"&&N.type==="range")return!1;var C=PA(S,N);if(!C)return!0;if(C?w=S:(w=S==="v"?"h":"v",C=PA(S,N)),!C)return!1;if(!s.current&&"changedTouches"in p&&(b||_)&&(s.current=w),!w)return!0;var P=s.current||w;return Jre(P,y,p,P==="h"?b:_,!0)},[]),c=x.useCallback(function(p){var y=p;if(!(!Qd.length||Qd[Qd.length-1]!==i)){var v="deltaY"in y?TA(y):cx(y),j=t.current.filter(function(w){return w.name===y.type&&(w.target===y.target||y.target===w.shadowParent)&&ene(w.delta,v)})[0];if(j&&j.should){y.cancelable&&y.preventDefault();return}if(!j){var b=(o.current.shards||[]).map(AA).filter(Boolean).filter(function(w){return w.contains(y.target)}),_=b.length>0?l(y,b[0]):!o.current.noIsolation;_&&y.cancelable&&y.preventDefault()}}},[]),d=x.useCallback(function(p,y,v,j){var b={name:p,delta:y,target:v,should:j,shadowParent:sne(v)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(_){return _!==b})},1)},[]),u=x.useCallback(function(p){r.current=cx(p),s.current=void 0},[]),h=x.useCallback(function(p){d(p.type,TA(p),p.target,l(p,e.lockRef.current))},[]),f=x.useCallback(function(p){d(p.type,cx(p),p.target,l(p,e.lockRef.current))},[]);x.useEffect(function(){return Qd.push(i),e.setCallbacks({onScrollCapture:h,onWheelCapture:h,onTouchMoveCapture:f}),document.addEventListener("wheel",c,Yd),document.addEventListener("touchmove",c,Yd),document.addEventListener("touchstart",u,Yd),function(){Qd=Qd.filter(function(p){return p!==i}),document.removeEventListener("wheel",c,Yd),document.removeEventListener("touchmove",c,Yd),document.removeEventListener("touchstart",u,Yd)}},[]);var m=e.removeScrollBar,g=e.inert;return x.createElement(x.Fragment,null,g?x.createElement(i,{styles:tne(a)}):null,m?x.createElement(Vre,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function sne(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const ane=Mre(f3,nne);var hg=x.forwardRef(function(e,t){return x.createElement(H0,Ci({},e,{ref:t,sideCar:ane}))});hg.classNames=H0.classNames;var ine=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Xd=new WeakMap,dx=new WeakMap,ux={},iw=0,v3=function(e){return e&&(e.host||v3(e.parentNode))},one=function(e,t){return t.map(function(r){if(e.contains(r))return r;var s=v3(r);return s&&e.contains(s)?s:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},lne=function(e,t,r,s){var a=one(t,Array.isArray(e)?e:[e]);ux[r]||(ux[r]=new WeakMap);
vendor: 7,065 bytes, lines 662-666
662var i=ux[r],o=[],l=new Set,c=new Set(a),d=function(h){!h||l.has(h)||(l.add(h),d(h.parentNode))};a.forEach(d);var u=function(h){!h||c.has(h)||Array.prototype.forEach.call(h.children,function(f){if(l.has(f))u(f);else try{var m=f.getAttribute(s),g=m!==null&&m!=="false",p=(Xd.get(f)||0)+1,y=(i.get(f)||0)+1;Xd.set(f,p),i.set(f,y),o.push(f),p===1&&g&&dx.set(f,!0),y===1&&f.setAttribute(r,"true"),g||f.setAttribute(s,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return u(t),l.clear(),iw++,function(){o.forEach(function(h){var f=Xd.get(h)-1,m=i.get(h)-1;Xd.set(h,f),i.set(h,m),f||(dx.has(h)||h.removeAttribute(s),dx.delete(h)),m||h.removeAttribute(r)}),iw--,iw||(Xd=new WeakMap,Xd=new WeakMap,dx=new WeakMap,ux={})}},V0=function(e,t,r){r===void 0&&(r="data-aria-hidden");var s=Array.from(Array.isArray(e)?e:[e]),a=ine(e);return a?(s.push.apply(s,Array.from(a.querySelectorAll("[aria-live]"))),lne(s,a,r,"aria-hidden")):function(){return null}},K0="Dialog",[y3,j3]=Qr(K0),[cne,ui]=y3(K0),b3=e=>{const{__scopeDialog:t,children:r,open:s,defaultOpen:a,onOpenChange:i,modal:o=!0}=e,l=x.useRef(null),c=x.useRef(null),[d,u]=Bs({prop:s,defaultProp:a??!1,onChange:i,caller:K0});return n.jsx(cne,{scope:t,triggerRef:l,contentRef:c,contentId:ta(),titleId:ta(),descriptionId:ta(),open:d,onOpenChange:u,onOpenToggle:x.useCallback(()=>u(h=>!h),[u]),modal:o,children:r})};b3.displayName=K0;var w3="DialogTrigger",_3=x.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=ui(w3,r),i=nt(t,a.triggerRef);return n.jsx(We.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":GC(a.open),...s,ref:i,onClick:Te(e.onClick,a.onOpenToggle)})});_3.displayName=w3;var VC="DialogPortal",[dne,N3]=y3(VC,{forceMount:void 0}),S3=e=>{const{__scopeDialog:t,forceMount:r,children:s,container:a}=e,i=ui(VC,t);return n.jsx(dne,{scope:t,forceMount:r,children:x.Children.map(s,o=>n.jsx(jn,{present:r||i.open,children:n.jsx(Uh,{asChild:!0,container:a,children:o})}))})};S3.displayName=VC;var Bv="DialogOverlay",C3=x.forwardRef((e,t)=>{const r=N3(Bv,e.__scopeDialog),{forceMount:s=r.forceMount,...a}=e,i=ui(Bv,e.__scopeDialog);return i.modal?n.jsx(jn,{present:s||i.open,children:n.jsx(hne,{...a,ref:t})}):null});C3.displayName=Bv;var une=Jl("DialogOverlay.RemoveScroll"),hne=x.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=ui(Bv,r);return n.jsx(hg,{as:une,allowPinchZoom:!0,shards:[a.contentRef],children:n.jsx(We.div,{"data-state":GC(a.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),gd="DialogContent",k3=x.forwardRef((e,t)=>{const r=N3(gd,e.__scopeDialog),{forceMount:s=r.forceMount,...a}=e,i=ui(gd,e.__scopeDialog);return n.jsx(jn,{present:s||i.open,children:i.modal?n.jsx(fne,{...a,ref:t}):n.jsx(mne,{...a,ref:t})})});k3.displayName=gd;var fne=x.forwardRef((e,t)=>{const r=ui(gd,e.__scopeDialog),s=x.useRef(null),a=nt(t,r.contentRef,s);return x.useEffect(()=>{const i=s.current;if(i)return V0(i)},[]),n.jsx(P3,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,i=>{var o;i.preventDefault(),(o=r.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,i=>{const o=i.detail.originalEvent,l=o.button===0&&o.ctrlKey===!0;(o.button===2||l)&&i.preventDefault()}),onFocusOutside:Te(e.onFocusOutside,i=>i.preventDefault())})}),mne=x.forwardRef((e,t)=>{const r=ui(gd,e.__scopeDialog),s=x.useRef(!1),a=x.useRef(!1);return n.jsx(P3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(s.current||(l=r.triggerRef.current)==null||l.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((d=r.triggerRef.current)==null?void 0:d.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),P3=x.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,...o}=e,l=ui(gd,r),c=x.useRef(null),d=nt(t,c);return W0(),n.jsxs(n.Fragment,{children:[n.jsx(ug,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:n.jsx(Fh,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":GC(l.open),...o,ref:d,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(gne,{titleId:l.titleId}),n.jsx(vne,{contentRef:c,descriptionId:l.descriptionId})]})]})}),KC="DialogTitle",T3=x.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=ui(KC,r);return n.jsx(We.h2,{id:a.titleId,...s,ref:t})});T3.displayName=KC;var A3="DialogDescription",E3=x.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=ui(A3,r);return n.jsx(We.p,{id:a.descriptionId,...s,ref:t})});E3.displayName=A3;var O3="DialogClose",M3=x.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,a=ui(O3,r);return n.jsx(We.button,{type:"button",...s,ref:t,onClick:Te(e.onClick,()=>a.onOpenChange(!1))})});M3.displayName=O3;function GC(e){return e?"open":"closed"}var D3="DialogTitleWarning",[pne,R3]=MV(D3,{contentName:gd,titleName:KC,docsSlug:"dialog"}),gne=({titleId:e})=>{const t=R3(D3),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
663
664If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
665
666For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return x.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},xne="DialogDescriptionWarning",vne=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${R3(xne).contentName}}.`;return x.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},YC=b3,$3=_3,QC=S3,fg=C3,mg=k3,pg=T3,gg=E3,G0=M3;const er=YC,Y0=$3,yne=QC,I3=x.forwardRef(({className:e,...t},r)=>n.jsx(fg,{ref:r,className:we("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));I3.displayName=fg.displayName;const Kt=x.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(yne,{children:[n.jsx(I3,{}),n.jsxs(mg,{ref:s,className:we("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[t,n.jsxs(G0,{className:"absolute right-4 top-4 roun
666ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[n.jsx(vn,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Kt.displayName=mg.displayName;const zr=({className:e,...t})=>n.jsx("div",{className:we("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});zr.displayName="DialogHeader";const xg=({className:e,...t})=>n.jsx("div",{className:we("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});xg.displayName="DialogFooter";const Br=x.forwardRef(({className:e,...t},r)=>n.jsx(pg,{ref:r,className:we("text-lg font-semibold leading-none tracking-tight",e),...t}));Br.displayName=pg.displayName;const _s=x.forwardRef(({className:e,...t},r)=>n.jsx(gg,{ref:r,className:we("text-sm text-muted-foreground",e),...t}));_s.displayName=gg.displayName;var XC="Popper",[L3,tf]=Qr(XC),[jne,F3]=L3(XC),U3=e=>{const{__scopePopper:t,children:r}=e,[s,a]=x.useState(null);return n.jsx(jne,{scope:t,anchor:s,onAnchorChange:a,children:r})};U3.displayName=XC;var z3="PopperAnchor",B3=x.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:s,...a}=e,i=F3(z3,r),o=x.useRef(null),l=nt(t,o);return x.useEffect(()=>{i.onAnchorChange((s==null?void 0:s.current)||o.current)}),s?null:n.jsx(We.div,{...a,ref:l})});B3.displayName=z3;var ZC="PopperContent",[bne,wne]=L3(ZC),q3=x.forwardRef((e,t)=>{var ce,se,oe,V,fe,ne;const{__scopePopper:r,side:s="bottom",sideOffset:a=0,align:i="center",alignOffset:o=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:h="partial",hideWhenDetached:f=!1,updatePositionStrategy:m="optimized",onPlaced:g,...p}=e,y=F3(ZC,r),[v,j]=x.useState(null),b=nt(t,Ce=>j(Ce)),[_,w]=x.useState(null),N=Hh(_),S=(N==null?void 0:N.width)??0,C=(N==null?void 0:N.height)??0,P=s+(i!=="center"?"-"+i:""),M=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(d)?d:[d],A=D.length>0,U={padding:M,boundary:D.filter(Nne),altBoundary:A},{refs:F,floatingStyles:L,placement:$,isPositioned:R,middlewareData:T}=GI({strategy:"fixed",placement:P,whileElementsMounted:(...Ce)=>VI(...Ce,{animationFrame:m==="always"}),elements:{reference:y.anchor},middleware:[YI({mainAxis:a+C,alignmentAxis:o}),c&&QI({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?XI():void 0,...U}),c&&ZI({...U}),JI({...U,apply:({elements:Ce,rects:Pe,availableWidth:he,availableHeight:ke})=>{const{width:Me,height:Je}=Pe.reference,Ke=Ce.floating.style;Ke.setProperty("--radix-popper-available-width",`${he}px`),Ke.setProperty("--radix-popper-available-height",`${ke}px`),Ke.setProperty("--radix-popper-anchor-width",`${Me}px`),Ke.setProperty("--radix-popper-anchor-height",`${Je}px`)}}),_&&tL({element:_,padding:l}),Sne({arrowWidth:S,arrowHeight:C}),f&&eL({strategy:"referenceHidden",...U})]}),[k,W]=V3($),q=Sr(g);Ur(()=>{R&&(q==null||q())},[R,q]);const Q=(ce=T.arrow)==null?void 0:ce.x,ue=(se=T.arrow)==null?void 0:se.y,X=((oe=T.arrow)==null?void 0:oe.centerOffset)!==0,[le,pe]=x.useState();return Ur(()=>{v&&pe(window.getComputedStyle(v).zIndex)},[v]),n.jsx("div",{ref:F.setFloating,"data-radix-popper-content-wrapper":"",style:{...L,transform:R?L.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:le,"--radix-popper-transform-origin":[(V=T.transformOrigin)==null?void 0:V.x,(fe=T.transformOrigin)==null?void 0:fe.y].join(" "),...((ne=T.hide)==null?void 0:ne.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:n.jsx(bne,{scope:r,placedSide:k,onArrowChange:w,arrowX:Q,arrowY:ue,shouldHideArrow:X,children:n.jsx(We.div,{"data-side":k,"data-align":W,...p,ref:b,style:{...p.style,animation:R?void 0:"none"}})})})});q3.displayName=ZC;var W3="PopperArrow",_ne={top:"bottom",right:"left",bottom:"top",left:"right"},H3=x.forwardRef(function(t,r){const{__scopePopper:s,...a}=t,i=wne(W3,s),o=_ne[i.placedSide];return n.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:n.jsx(nL,{...a,ref:r,style:{...a.style,display:"block"}})})});H3.displayName=W3;function Nne(e){return e!==null}var Sne=e=>({name:"transformOrigin",options:e,fn(t){var y,v,j;const{placement:r,rects:s,middlewareData:a}=t,o=((y=a.arrow)==null?void 0:y.centerOffset)!==0,l=o?0:e.arrowWidth,c=o?0:e.arrowHeight,[d,u]=V3(r),h={start:"0%",center:"50%",end:"100%"}[u],f=(((v=a.arrow)==null?void 0:v.x)??0)+l/2,m=(((j=a.arrow)==null?void 0:j.y)??0)+c/2;let g="",p="";return d==="bottom"?(g=o?h:`${f}px`,p=`${-c}px`):d==="top"?(g=o?h:`${f}px`,p=`${s.floating.height+c}px`):d==="right"?(g=`${-c}px`,p=o?h:`${m}px`):d==="left"&&(g=`${s.floating.width+c}px`,p=o?h:`${m}px`),{data:{x:g,y:p}}}});function V3(e){const[t,r="center"]=e.split("-");return[t,r]}var JC=U3,Q0=B3,ek=q3,tk=H3,Cne=[" ","Enter","ArrowUp","ArrowDown"],kne=[" ","Enter"],xd="Select",[X0,Z0,Pne]=eg(xd),[rf,lRe]=Qr(xd,[Pne,tf]),J0=tf(),[Tne,uc]=rf(xd),[Ane,Ene]=rf(xd),K3=e=>{const{__scopeSelect:t,children:r,open:s,defaultOpen:a,onOpenChange:i,value:o,defaultValue:l,onValueChange:c,dir:d,name:u,autoComplete:h,disabled:f,required:m,form:g}
vendor: 4,205 bytes, line 666
666=e,p=J0(t),[y,v]=x.useState(null),[j,b]=x.useState(null),[_,w]=x.useState(!1),N=Md(d),[S,C]=Bs({prop:s,defaultProp:a??!1,onChange:i,caller:xd}),[P,M]=Bs({prop:o,defaultProp:l,onChange:c,caller:xd}),D=x.useRef(null),A=y?g||!!y.closest("form"):!0,[U,F]=x.useState(new Set),L=Array.from(U).map($=>$.props.value).join(";");return n.jsx(JC,{...p,children:n.jsxs(Tne,{required:m,scope:t,trigger:y,onTriggerChange:v,valueNode:j,onValueNodeChange:b,valueNodeHasChildren:_,onValueNodeHasChildrenChange:w,contentId:ta(),value:P,onValueChange:M,open:S,onOpenChange:C,dir:N,triggerPointerDownPosRef:D,disabled:f,children:[n.jsx(X0.Provider,{scope:t,children:n.jsx(Ane,{scope:e.__scopeSelect,onNativeOptionAdd:x.useCallback($=>{F(R=>new Set(R).add($))},[]),onNativeOptionRemove:x.useCallback($=>{F(R=>{const T=new Set(R);return T.delete($),T})},[]),children:r})}),A?n.jsxs(x5,{"aria-hidden":!0,required:m,tabIndex:-1,name:u,autoComplete:h,value:P,onChange:$=>M($.target.value),disabled:f,form:g,children:[P===void 0?n.jsx("option",{value:""}):null,Array.from(U)]},L):null]})})};K3.displayName=xd;var G3="SelectTrigger",Y3=x.forwardRef((e,t)=>{const{__scopeSelect:r,disabled:s=!1,...a}=e,i=J0(r),o=uc(G3,r),l=o.disabled||s,c=nt(t,o.onTriggerChange),d=Z0(r),u=x.useRef("touch"),[h,f,m]=y5(p=>{const y=d().filter(b=>!b.disabled),v=y.find(b=>b.value===o.value),j=j5(y,p,v);j!==void 0&&o.onValueChange(j.value)}),g=p=>{l||(o.onOpenChange(!0),m()),p&&(o.triggerPointerDownPosRef.current={x:Math.round(p.pageX),y:Math.round(p.pageY)})};return n.jsx(Q0,{asChild:!0,...i,children:n.jsx(We.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":v5(o.value)?"":void 0,...a,ref:c,onClick:Te(a.onClick,p=>{p.currentTarget.focus(),u.current!=="mouse"&&g(p)}),onPointerDown:Te(a.onPointerDown,p=>{u.current=p.pointerType;const y=p.target;y.hasPointerCapture(p.pointerId)&&y.releasePointerCapture(p.pointerId),p.button===0&&p.ctrlKey===!1&&p.pointerType==="mouse"&&(g(p),p.preventDefault())}),onKeyDown:Te(a.onKeyDown,p=>{const y=h.current!=="";!(p.ctrlKey||p.altKey||p.metaKey)&&p.key.length===1&&f(p.key),!(y&&p.key===" ")&&Cne.includes(p.key)&&(g(),p.preventDefault())})})})});Y3.displayName=G3;var Q3="SelectValue",X3=x.forwardRef((e,t)=>{const{__scopeSelect:r,className:s,style:a,children:i,placeholder:o="",...l}=e,c=uc(Q3,r),{onValueNodeHasChildrenChange:d}=c,u=i!==void 0,h=nt(t,c.onValueNodeChange);return Ur(()=>{d(u)},[d,u]),n.jsx(We.span,{...l,ref:h,style:{pointerEvents:"none"},children:v5(c.value)?n.jsx(n.Fragment,{children:o}):i})});X3.displayName=Q3;var One="SelectIcon",Z3=x.forwardRef((e,t)=>{const{__scopeSelect:r,children:s,...a}=e;return n.jsx(We.span,{"aria-hidden":!0,...a,ref:t,children:s||"▼"})});Z3.displayName=One;var Mne="SelectPortal",J3=e=>n.jsx(Uh,{asChild:!0,...e});J3.displayName=Mne;var vd="SelectContent",e5=x.forwardRef((e,t)=>{const r=uc(vd,e.__scopeSelect),[s,a]=x.useState();if(Ur(()=>{a(new DocumentFragment)},[]),!r.open){const i=s;return i?Ad.createPortal(n.jsx(t5,{scope:e.__scopeSelect,children:n.jsx(X0.Slot,{scope:e.__scopeSelect,children:n.jsx("div",{children:e.children})})}),i):null}return n.jsx(r5,{...e,ref:t})});e5.displayName=vd;var qa=10,[t5,hc]=rf(vd),Dne="SelectContentImpl",Rne=Jl("SelectContent.RemoveScroll"),r5=x.forwardRef((e,t)=>{const{__scopeSelect:r,position:s="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:m,sticky:g,hideWhenDetached:p,avoidCollisions:y,...v}=e,j=uc(vd,r),[b,_]=x.useState(null),[w,N]=x.useState(null),S=nt(t,ce=>_(ce)),[C,P]=x.useState(null),[M,D]=x.useState(null),A=Z0(r),[U,F]=x.useState(!1),L=x.useRef(!1);x.useEffect(()=>{if(b)return V0(b)},[b]),W0();const $=x.useCallback(ce=>{const[se,...oe]=A().map(ne=>ne.ref.current),[V]=oe.slice(-1),fe=document.activeElement;for(const ne of ce)if(ne===fe||(ne==null||ne.scrollIntoView({block:"nearest"}),ne===se&&w&&(w.scrollTop=0),ne===V&&w&&(w.scrollTop=w.scrollHeight),ne==null||ne.focu
vendor: 4,728 bytes, line 666
666s(),document.activeElement!==fe))return},[A,w]),R=x.useCallback(()=>$([C,b]),[$,C,b]);x.useEffect(()=>{U&&R()},[U,R]);const{onOpenChange:T,triggerPointerDownPosRef:k}=j;x.useEffect(()=>{if(b){let ce={x:0,y:0};const se=V=>{var fe,ne;ce={x:Math.abs(Math.round(V.pageX)-(((fe=k.current)==null?void 0:fe.x)??0)),y:Math.abs(Math.round(V.pageY)-(((ne=k.current)==null?void 0:ne.y)??0))}},oe=V=>{ce.x<=10&&ce.y<=10?V.preventDefault():b.contains(V.target)||T(!1),document.removeEventListener("pointermove",se),k.current=null};return k.current!==null&&(document.addEventListener("pointermove",se),document.addEventListener("pointerup",oe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",se),document.removeEventListener("pointerup",oe,{capture:!0})}}},[b,T,k]),x.useEffect(()=>{const ce=()=>T(!1);return window.addEventListener("blur",ce),window.addEventListener("resize",ce),()=>{window.removeEventListener("blur",ce),window.removeEventListener("resize",ce)}},[T]);const[W,q]=y5(ce=>{const se=A().filter(fe=>!fe.disabled),oe=se.find(fe=>fe.ref.current===document.activeElement),V=j5(se,ce,oe);V&&setTimeout(()=>V.ref.current.focus())}),Q=x.useCallback((ce,se,oe)=>{const V=!L.current&&!oe;(j.value!==void 0&&j.value===se||V)&&(P(ce),V&&(L.current=!0))},[j.value]),ue=x.useCallback(()=>b==null?void 0:b.focus(),[b]),X=x.useCallback((ce,se,oe)=>{const V=!L.current&&!oe;(j.value!==void 0&&j.value===se||V)&&D(ce)},[j.value]),le=s==="popper"?PN:n5,pe=le===PN?{side:l,sideOffset:c,align:d,alignOffset:u,arrowPadding:h,collisionBoundary:f,collisionPadding:m,sticky:g,hideWhenDetached:p,avoidCollisions:y}:{};return n.jsx(t5,{scope:r,content:b,viewport:w,onViewportChange:N,itemRefCallback:Q,selectedItem:C,onItemLeave:ue,itemTextRefCallback:X,focusSelectedItem:R,selectedItemText:M,position:s,isPositioned:U,searchRef:W,children:n.jsx(hg,{as:Rne,allowPinchZoom:!0,children:n.jsx(ug,{asChild:!0,trapped:j.open,onMountAutoFocus:ce=>{ce.preventDefault()},onUnmountAutoFocus:Te(a,ce=>{var se;(se=j.trigger)==null||se.focus({preventScroll:!0}),ce.preventDefault()}),children:n.jsx(Fh,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:ce=>ce.preventDefault(),onDismiss:()=>j.onOpenChange(!1),children:n.jsx(le,{role:"listbox",id:j.contentId,"data-state":j.open?"open":"closed",dir:j.dir,onContextMenu:ce=>ce.preventDefault(),...v,...pe,onPlaced:()=>F(!0),ref:S,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:Te(v.onKeyDown,ce=>{const se=ce.ctrlKey||ce.altKey||ce.metaKey;if(ce.key==="Tab"&&ce.preventDefault(),!se&&ce.key.length===1&&q(ce.key),["ArrowUp","ArrowDown","Home","End"].includes(ce.key)){let V=A().filter(fe=>!fe.disabled).map(fe=>fe.ref.current);if(["ArrowUp","End"].includes(ce.key)&&(V=V.slice().reverse()),["ArrowUp","ArrowDown"].includes(ce.key)){const fe=ce.target,ne=V.indexOf(fe);V=V.slice(ne+1)}setTimeout(()=>$(V)),ce.preventDefault()}})})})})})})});r5.displayName=Dne;var $ne="SelectItemAlignedPosition",n5=x.forwardRef((e,t)=>{const{__scopeSelect:r,onPlaced:s,...a}=e,i=uc(vd,r),o=hc(vd,r),[l,c]=x.useState(null),[d,u]=x.useState(null),h=nt(t,S=>u(S)),f=Z0(r),m=x.useRef(!1),g=x.useRef(!0),{viewport:p,selectedItem:y,selectedItemText:v,focusSelectedItem:j}=o,b=x.useCallback(()=>{if(i.trigger&&i.valueNode&&l&&d&&p&&y&&v){const S=i.trigger.getBoundingClientRect(),C=d.getBoundingClientRect(),P=i.valueNode.getBoundingClientRect(),M=v.getBoundingClientRect();if(i.dir!=="rtl"){const fe=M.left-C.left,ne=P.left-fe,Ce=S.left-ne,Pe=S.width+Ce,he=Math.max(Pe,C.width),ke=window.innerWidth-qa,Me=sp(ne,[qa,Math.max(qa,ke-he)]);l.style.minWidth=Pe+"px",l.style.left=Me+"px"}else{const fe=C.right-M.right,ne=window.innerWidth-P.right-fe,Ce=window.innerWidth-S.right-ne,Pe=S.width+Ce,he=Math.max(Pe,C.width),ke=window.innerWidth-qa,Me=sp(ne,[qa,Math.max(qa,ke-he)]);l.style.minWidth=Pe+"px",l.style.right=Me+"px"}const D=f(),A=window.innerHeight-qa*2,U=p.scrollHeight,F=window.getComputedStyle(d),L=parseInt(F.borderTopWidth,10),$=parseInt(F.paddingTop,10),R=parseInt(F.borderBottomWidth,10),T=parseInt(F.paddingBottom,10),k=L+$+U+T+R,W=Math.min(y.offsetHeight*5,k),q=window.getComputedStyle(p),Q=parseInt(q.paddingTop,10),ue=parseInt(q.paddingBottom,10),X=S.top+S.height/2-qa,le=A-X,pe=y.offsetHeight/2,ce=y.offsetTop+pe,se=L+$+ce,oe=k-se;if(se<=X){const fe=D.length>0&&y===D[D.length-1].ref.current;l.style.bottom="0px";const ne=d.clientHeight-p.offsetTop-p.offsetHeight,Ce=Math.max(le,pe+(fe?ue:0)+ne+R),Pe=se+Ce;l.style.height=Pe+"px"}else{const fe=D.length>0&&y===D[0].ref.current;l.style.top="0px";const Ce=Math.max(X,L+p.offsetTop+(fe?Q:0)+pe)+oe;l.style.height=Ce+"px",p.scrollTop=se-X+p.offsetTop}l.style.margin=`${qa}
666px 0`,l.style.minHeight=W+"px",l.style.maxHeight=A+"px",s==null||s(),requestAnimationFrame(()=>m.current=!0)}},[f,i.trigger,i.valueNode,l,d,p,y,v,i.dir,s]);Ur(()=>b(),[b]);const[_,w]=x.useState();Ur(()=>{d&&w(window.getComputedStyle(d).zIndex)},[d]);const N=x.useCallback(S=>{S&&g.current===!0&&(b(),j==null||j(),g.current=!1)},[b,j]);return n.jsx(Lne,{scope:r,contentWrapper:l,shouldExpandOnScrollRef:m,onScrollButtonChange:N,children:n.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:n.jsx(We.div,{...a,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});n5.displayName=$ne;var Ine="SelectPopperPosition",PN=x.forwardRef((e,t)=>{const{__scopeSelect:r,align:s="start",collisionPadding:a=qa,...i}=e,o=J0(r);return n.jsx(ek,{...o,...i,ref:t,align:s,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});PN.displayName=Ine;var[Lne,rk]=rf(vd,{}),TN="SelectViewport",s5=x.forwardRef((e,t)=>{const{__scopeSelect:r,nonce:s,...a}=e,i=hc(TN,r),o=rk(TN,r),l=nt(t,i.onViewportChange),c=x.useRef(0);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:s}),n.jsx(X0.Slot,{scope:r,children:n.jsx(We.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Te(a.onScroll,d=>{const u=d.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:f}=o;if(f!=null&&f.current&&h){const m=Math.abs(c.current-u.scrollTop);if(m>0){const g=window.innerHeight-qa*2,p=parseFloat(h.style.minHeight),y=parseFloat(h.style.height),v=Math.max(p,y);if(v<g){const j=v+m,b=Math.min(g,j),_=j-b;h.style.height=b+"px",h.style.bottom==="0px"&&(u.scrollTop=_>0?_:0,h.style.justifyContent="flex-end")}}}c.current=u.scrollTop})})})]})});s5.displayName=TN;var a5="SelectGroup",[Fne,Une]=rf(a5),zne=x.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e,a=ta();return n.jsx(Fne,{scope:r,id:a,children:n.jsx(We.div,{role:"group","aria-labelledby":a,...s,ref:t})})});zne.displayName=a5;var i5="SelectLabel",o5=x.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e,a=Une(i5,r);return n.jsx(We.div,{id:a.id,...s,ref:t})});o5.displayName=i5;var qv="SelectItem",[Bne,l5]=rf(qv),c5=x.forwardRef((e,t)=>{const{__scopeSelect:r,value:s,disabled:a=!1,textValue:i,...o}=e,l=uc(qv,r),c=hc(qv,r),d=l.value===s,[u,h]=x.useState(i??""),[f,m]=x.useState(!1),g=nt(t,j=>{var b;return(b=c.itemRefCallback)==null?void 0:b.call(c,j,s,a)}),p=ta(),y=x.useRef("touch"),v=()=>{a||(l.onValueChange(s),l.onOpenChange(!1))};if(s==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return n.jsx(Bne,{scope:r,value:s,disabled:a,textId:p,isSelected:d,onItemTextChange:x.useCallback(j=>{h(b=>b||((j==null?void 0:j.textContent)??"").trim())},[]),children:n.jsx(X0.ItemSlot,{scope:r,value:s,disabled:a,textValue:u,children:n.jsx(We.div,{role:"option","aria-labelledby":p,"data-highlighted":f?"":void 0,"aria-selected":d&&f,"data-state":d?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:g,onFocus:Te(o.onFocus,()=>m(!0)),onBlur:Te(o.onBlur,()=>m(!1)),onClick:Te(o.onClick,()=>{y.current!=="mouse"&&v()}),onPointerUp:Te(o.onPointerUp,()=>{y.current==="mouse"&&v()}),onPointerDown:Te(o.onPointerDown,j=>{y.current=j.pointerType}),onPointerMove:Te(o.onPointerMove,j=>{var b;y.current=j.pointerType,a?(b=c.onItemLeave)==null||b.call(c):y.current==="mouse"&&j.currentTarget.focu
vendor: 4,921 bytes, line 666
666s({preventScroll:!0})}),onPointerLeave:Te(o.onPointerLeave,j=>{var b;j.currentTarget===document.activeElement&&((b=c.onItemLeave)==null||b.call(c))}),onKeyDown:Te(o.onKeyDown,j=>{var _;((_=c.searchRef)==null?void 0:_.current)!==""&&j.key===" "||(kne.includes(j.key)&&v(),j.key===" "&&j.preventDefault())})})})})});c5.displayName=qv;var em="SelectItemText",d5=x.forwardRef((e,t)=>{const{__scopeSelect:r,className:s,style:a,...i}=e,o=uc(em,r),l=hc(em,r),c=l5(em,r),d=Ene(em,r),[u,h]=x.useState(null),f=nt(t,v=>h(v),c.onItemTextChange,v=>{var j;return(j=l.itemTextRefCallback)==null?void 0:j.call(l,v,c.value,c.disabled)}),m=u==null?void 0:u.textContent,g=x.useMemo(()=>n.jsx("option",{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:p,onNativeOptionRemove:y}=d;return Ur(()=>(p(g),()=>y(g)),[p,y,g]),n.jsxs(n.Fragment,{children:[n.jsx(We.span,{id:c.textId,...i,ref:f}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren?Ad.createPortal(i.children,o.valueNode):null]})});d5.displayName=em;var u5="SelectItemIndicator",h5=x.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e;return l5(u5,r).isSelected?n.jsx(We.span,{"aria-hidden":!0,...s,ref:t}):null});h5.displayName=u5;var AN="SelectScrollUpButton",f5=x.forwardRef((e,t)=>{const r=hc(AN,e.__scopeSelect),s=rk(AN,e.__scopeSelect),[a,i]=x.useState(!1),o=nt(t,s.onScrollButtonChange);return Ur(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollTop>0;i(d)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?n.jsx(p5,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop-c.offsetHeight)}}):null});f5.displayName=AN;var EN="SelectScrollDownButton",m5=x.forwardRef((e,t)=>{const r=hc(EN,e.__scopeSelect),s=rk(EN,e.__scopeSelect),[a,i]=x.useState(!1),o=nt(t,s.onScrollButtonChange);return Ur(()=>{if(r.viewport&&r.isPositioned){let l=function(){const d=c.scrollHeight-c.clientHeight,u=Math.ceil(c.scrollTop)<d;i(u)};const c=r.viewport;return l(),c.addEventListener("scroll",l),()=>c.removeEventListener("scroll",l)}},[r.viewport,r.isPositioned]),a?n.jsx(p5,{...e,ref:o,onAutoScroll:()=>{const{viewport:l,selectedItem:c}=r;l&&c&&(l.scrollTop=l.scrollTop+c.offsetHeight)}}):null});m5.displayName=EN;var p5=x.forwardRef((e,t)=>{const{__scopeSelect:r,onAutoScroll:s,...a}=e,i=hc("SelectScrollButton",r),o=x.useRef(null),l=Z0(r),c=x.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return x.useEffect(()=>()=>c(),[c]),Ur(()=>{var u;const d=l().find(h=>h.ref.current===document.activeElement);(u=d==null?void 0:d.ref.current)==null||u.scrollIntoView({block:"nearest"})},[l]),n.jsx(We.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:Te(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(s,50))}),onPointerMove:Te(a.onPointerMove,()=>{var d;(d=i.onItemLeave)==null||d.call(i),o.current===null&&(o.current=window.setInterval(s,50))}),onPointerLeave:Te(a.onPointerLeave,()=>{c()})})}),qne="SelectSeparator",g5=x.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e;return n.jsx(We.div,{"aria-hidden":!0,...s,ref:t})});g5.displayName=qne;var ON="SelectArrow",Wne=x.forwardRef((e,t)=>{const{__scopeSelect:r,...s}=e,a=J0(r),i=uc(ON,r),o=hc(ON,r);return i.open&&o.position==="popper"?n.jsx(tk,{...a,...s,ref:t}):null});Wne.displayName=ON;var Hne="SelectBubbleInput",x5=x.forwardRef(({__scopeSelect:e,value:t,...r},s)=>{const a=x.useRef(null),i=nt(s,a),o=dg(t);return x.useEffect(()=>{const l=a.current;if(!l)return;const c=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(c,"value").set;if(o!==t&&u){const h=new Event("change",{bubbles:!0});u.call(l,t),l.dispatchEvent(h)}},[o,t]),n.jsx(We.select,{...r,style:{...H$,...r.style},ref:i,defaultValue:t})});x5.displayName=Hne;function v5(e){return e===""||e===void 0}function y5(e){const t=Sr(e),r=x.useRef(""),s=x.useRef(0),a=x.useCallback(o=>{const l=r.current+o;t(l),function c(d){r.current=d,window.clearTimeout(s.current),d!==""&&(s.current=window.setTimeout(()=>c(""),1e3))}(l)},[t]),i=x.useCallback(()=>{r.current="",window.clearTimeout(s.current)},[]);return x.useEffect(()=>()=>window.clearTimeout(s.current),[]),[r,a,i]}function j5(e,t,r){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let o=Vne(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==r));const c=o.find(d=>d.textValue.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function Vne(e,t){return e.map((r,s)=>e[(t+s)%e.length])}var Kne=K3,b5=Y3,Gne=X3,Yne=Z3,Qne=J3,w5=e5,Xne=s5,_5=o5,N5=c5,Zne=d5,Jne=h5,S5=f5,C5=m5,k5=g5;const Fe=Kne,Ue=Gne,Ie=x.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(b5,{ref:s,className:we("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
666ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[t,n.jsx(Yne,{asChild:!0,children:n.jsx(dr,{className:"h-4 w-4 opacity-50"})})]}));Ie.displayName=b5.displayName;const P5=x.forwardRef(({className:e,...t},r)=>n.jsx(S5,{ref:r,className:we("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(Ar,{className:"h-4 w-4"})}));P5.displayName=S5.displayName;const T5=x.forwardRef(({className:e,...t},r)=>n.jsx(C5,{ref:r,className:we("flex cursor-default items-center justify-center py-1",e),...t,children:n.jsx(dr,{className:"h-4 w-4"})}));T5.displayName=C5.displayName;const Le=x.forwardRef(({className:e,children:t,position:r="popper",...s},a)=>n.jsx(Qne,{children:n.jsxs(w5,{ref:a,className:we("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:r,...s,children:[n.jsx(P5,{}),n.jsx(Xne,{className:we("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),n.jsx(T5,{})]})}));Le.displayName=w5.displayName;const ese=x.forwardRef(({className:e,...t},r)=>n.jsx(_5,{ref:r,className:we("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));ese.displayName=_5.displayName;const J=x.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(N5,{ref:s,className:we("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...r,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(Jne,{children:n.jsx(oi,{className:"h-4 w-4"})})}),n.jsx(Zne,{children:t})]}));J.displayName=N5.displayName;const tse=x.forwardRef(({className:e,...t},r)=>n.jsx(k5,{ref:r,className:we("-mx-1 my-1 h-px bg-muted",e),...t}));tse.displayName=k5.displayName;async function rse(e){const r=new TextEncoder().encode(JSON.stringify(e)),s=await crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(s)).map(i=>i.toString(16).padStart(2,"0")).join("")}function nse(e){const t=e.toUpperCase();return t.endsWith(":")?t:`${t}:`}function EA(e){const t=Array.from(new Set(e.monitored_drives.map(nse)));if(e.warning_threshold>=e.critical_threshold)throw new Error("Warning threshold must be less than critical threshold");const r=Math.max(0,Math.min(100,e.warning_threshold)),s=Math.max(0,Math.min(100,e.critical_threshold)),a=Math.max(60,Math.min(3600,e.check_interval));return{version:1,monitors:t.map(o=>({monitor_id:`volume:${o}`,monitor_type:"DiskFree",enabled:e.enabled,schedule:{interval_seconds:a,jitter_pct:10},thresholds:{warn_pct:r,crit_pct:s},trend:e.alert_on_trend,data_to_transmit:["drive","free_gb","total_gb","used_pct","free_pct"]}))}}function sse(e){if(!e.monitors.length)return{enabled:!1,monitored_drives:[],warning_threshold:80,critical_threshold:90,check_interval:300,alert_on_trend:!1,drive_discovery_interval_hours:6,auto_discover_drives:!0};const t=e.monitors[0];return{enabled:t.enabled,monitored_drives:e.monitors.map(r=>r.monitor_id.replace("volume:","")),warning_threshold:t.thresholds.warn_pct,critical_threshold:t.thresholds.crit_pct,check_interval:t.schedule.interval_seconds,alert_on_trend:t.trend,drive_discovery_interval_hours:6,auto_discover_drives:!0}}const ase=e=>{const{toast:t}=qr(),r=Et(),s=Ve({queryKey:["agent-config",e],queryFn:async()=>{if(!e)return null;const{data:l,error:c}=await B.from("agent_monitor_configs").select("*").eq("agent_id",e).maybeSingle();if(c)throw console.error("Error fetching agent config:",c),c;return l},enabled:!!e}),a=mt({mutationFn:async l=>{if(!e)throw new Error("Agent ID is required");if(l.warning_threshold>=l.critical_threshold)throw new Error("Warning threshold must be less than critical threshold");if(l.enabled&&l.monitored_drives.length===0)throw new Error("At least one drive must be monitored when enabled");const{data:{user:c}}=await B.auth.getUser();if(!c)throw new Error("User not authenticated");const{data:d}=await B.from("client_members").select("client_id").eq("user_id",c.id).eq("status","active").single();if(!d)throw new Error("Client not found");const u=EA(l),h=await rse(u),{data:f,error:m}=await B.from("agent_monitor_configs").upsert({client_id:d.client_id,agent_id:e,configuration:u,config_hash:h},{onConflict:"client_id,agent_id"}).select().single();if(m)throw console.error("Error saving agent config:",m),m;return f},onSuccess:l=>{r.invalidateQueries({queryKey:["agent-config",e]}),r.invalidateQueries({queryKey:["agent-monitor-state",e]}),t({title:"Configuration Saved",description:`Configuration saved successfully (version ${l.ver
666sion})`})},onError:l=>{t({title:"Save Failed",description:l.message,variant:"destructive"})}}),i=l=>EA(l),o=l=>{if(!e)return;const c=i(l);let d;const u=Array.from(new Set(l.monitored_drives.map(g=>{const p=g.toUpperCase();return p.endsWith(":")?p.slice(0,-1):p})));u.length===1?d=`agent-${e}-volume-${u[0]}.json`:u.length>1?d=`agent-${e}-volumes-${u.join("-")}.json`:d=`agent-${e}-config.json`;const h=new Blob([JSON.stringify(c,null,2)],{type:"application/json"}),f=URL.createObjectURL(h),m=document.createElement("a");m.href=f,m.download=d,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(f),t({title:"Configuration Downloaded",description:"Agent configuration file downloaded successfully"})};return{config:s.data,isLoading:s.isLoading,error:s.error,saveConfig:a.mutate,isSaving:a.isPending,generateAgentJSON:i,downloadConfigFile:o,getUIConfig:()=>s.data?sse(s.data.configuration):null}};function A5(e,t=!1){const r=Et(),{data:s=[],isLoading:a,error:i,refetch:o}=Ve({queryKey:["system-script-templates",e,t],queryFn:async()=>{let u=B.from("system_script_templates").select("*").eq("is_active",!0).order("name");e&&(u=u.eq("script_type",e)),t||(u=u.eq("is_internal",!1));const{data:h,error:f}=await u;if(f)throw console.error("Error fetching system script templates:",f),f;return h}}),l=mt({mutationFn:async u=>{const{data:h,error:f}=await B.from("system_script_templates").insert([u]).select().single();if(f)throw f;return h},onSuccess:()=>{ye.success("System template created successfully"),r.invalidateQueries({queryKey:["system-script-templates"]})},onError:u=>{console.error("Error creating system template:",u),ye.error("Failed to create system template")}}),c=mt({mutationFn:async({id:u,...h})=>{const{data:f,error:m}=await B.from("system_script_templates").update(h).eq("id",u).select().single();if(m)throw m;return f},onSuccess:()=>{ye.success("System template updated successfully"),r.invalidateQueries({queryKey:["system-script-templates"]})},onError:u=>{console.error("Error updating system template:",u),ye.error("Failed to update system template")}}),d=mt({mutationFn:async u=>{const{data:h,error:f}=await B.from("system_script_templates").update({is_active:!1}).eq("id",u);if(f)throw f},onSuccess:()=>{ye.success("System template deactivated successfully"),r.invalidateQueries({queryKey:["system-script-templates"]})},onError:u=>{console.error("Error deactivating system template:",u),ye.error("Failed to deactivate system template")}});return{systemTemplates:s,isLoading:a,error:i,refetch:o,createSystemTemplate:l.mutate,updateSystemTemplate:c.mutate,deleteSystemTemplate:d.mutate,isCreating:l.isPending,isUpdating:c.isPending,isDeleting:d.isPending}}const ise=e=>{const t=Et(),{systemTemplates:r}=A5("powershell"),s=x.useRef(null),a=6e4;x.useEffect(()=>{if(!e)return;const m=B.channel(`agent-drive-discovery-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"agent_drive_info",filter:`agent_id=eq.${e}`},()=>{t.invalidateQueries({queryKey:["agent-drives",e]})}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"agent_commands",filter:`agent_id=eq.${e}`},g=>{var p,y,v,j,b;((p=g.new)==null?void 0:p.op)==="execute_powershell"&&((y=g.new)==null?void 0:y.status)==="completed"&&((b=(j=(v=g.new)==null?void 0:v.result_details)==null?void 0:j.output)!=null&&b.includes("drive_letter"))&&(i(g.new),t.invalidateQueries({queryKey:["agent-drives",e]}))}).subscribe();return()=>{B.removeChannel(m)}},[e,t]);const i=async m=>{var g;if(!(!e||!((g=m.result_details)!=null&&g.output)))try{const p=JSON.parse(m.result_details.output),y=Array.isArray(p)?p:[p],{data:v}=await B.from("monitoring_agents").select("client_id").eq("id",e).single();if(!v)return;for(const j of y)await B.from("agent_drive_info").upsert({client_id:v.client_id,agent_id:e,drive_letter:j.drive_letter,drive_type:j.drive_type,total_size_gb:j.total_size_gb,free_space_gb:j.free_space_gb,discovered_at:new Date().toISOString()});ye.success(`Discovered ${y.length} drive${y.length===1?"":"s"}`)}catch(p){console.error("Error processing drive discovery result:",p),ye.error("Failed to process drive discovery results")}},{data:o,isLoading:l,error:c}=Ve({queryKey:["agent-drives",e],queryFn:async()=>
666{if(!e)return[];const{data:m,error:g}=await B.from("agent_drive_info").select("*").eq("agent_id",e).order("drive_letter");if(g)throw g;return m},enabled:!!e,refetchInterval:3e4}),d=mt({mutationFn:async m=>{const g=r.find(v=>v.name==="Drive Discovery"&&v.category==="monitoring");if(!g)throw new Error("Drive Discovery template not found. Please ensure system templates are properly configured.");const{data:p,error:y}=await B.functions.invoke("send-agent-command",{body:{agent_id:m,command_type:"execute_powershell",script:g.script_content,script_name:g.name||"Drive Discovery",timeout:60}});if(y)throw y;if(!p.success)throw new Error(p.error||"Failed to send drive discovery command");return p},onSuccess:()=>{ye.success("Drive discovery command sent - agent is scanning for drives...")},onError:m=>{console.error("Drive discovery error:",m),ye.error(`Failed to discover drives: ${m.message}`)},retry:!1}),u=x.useCallback((m=6)=>{if(!o||o.length===0)return!0;const g=o.reduce((v,j)=>{const b=new Date(j.discovered_at).getTime();return b>v?b:v},0),p=Date.now(),y=m*60*60*1e3;return p-g>y},[o]),h=x.useCallback(()=>{if(!o||o.length===0)return null;const m=o.reduce((g,p)=>{const y=new Date(p.discovered_at).getTime();return y>g?y:g},0);return m>0?new Date(m):null},[o]),f=x.useCallback((m=6)=>{if(!e||!u(m)||d.isPending)return;const g=Date.now();s.current&&g-s.current<a||(s.current=g,d.mutate(e))},[e,u,d.isPending]);return{availableDrives:o||[],lastDiscoveryTime:h(),isDrivesLoading:l,isDiscovering:d.isPending,isDiscoveryNeeded:m=>u(m),drivesError:c,discoveryError:d.error,discoverDrives:m=>d.mutate(m),autoDiscoverIfNeeded:f}},ose=({agentId:e,onSave:t})=>{const{toast:r}=qr(),[s,a]=x.useState({enabled:!1,monitored_drives:[],warning_threshold:80,critical_threshold:90,check_interval:300,alert_on_trend:!1,drive_discovery_interval_hours:6,auto_discover_drives:!1}),[i,o]=x.useState(!1),[l,c]=x.useState(null),{availableDrives:d,lastDiscoveryTime:u,isDrivesLoading:h,isDiscovering:f,isDiscoveryNeeded:m,discoverDrives:g,autoDiscoverIfNeeded:p}=ise(e);console.log("VolumeMonitorConfig render - availableDrives:",d),console.log("VolumeMonitorConfig render - config.monitored_drives:",s.monitored_drives);const{config:y,isLoading:v,saveConfig:j,isSaving:b,generateAgentJSON:_,downloadConfigFile:w,getUIConfig:N}=ase(e);x.useEffect(()=>{if(y){const A=N();A&&a(A)}},[y]),x.useEffect(()=>{s.auto_discover_drives&&e&&d.length>0&&p(s.drive_discovery_interval_hours)},[s.auto_discover_drives,s.drive_discovery_interval_hours,e,d.length,p]);const S=A=>{a(U=>{const F=U.monitored_drives.includes(A)?U.monitored_drives.filter(L=>L!==A):[...U.monitored_drives,A];return{...U,monitored_drives:F}})},C=()=>{j(s),t==null||t(s)},P=()=>{const A=_(s);c(A),o(!0)},M=()=>{w(s)},D=()=>{e&&g(e)};return v?n.jsx(ee,{children:n.jsxs(de,{children:[n.jsx(me,{children:"Volume Monitor Configuration"}),n.jsx(De,{children:"Loading configuration..."})]})}):n.jsxs(n.Fragment,{children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Pu,{className:"h-5 w-5"}),"Volume Manager Monitor"]})}),n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(z,{className:"text-base font-medium",children:"Enable Volume Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor disk space usage and send alerts when thresholds are breached"})]}),n.jsx(Rs,{checked:s.enabled,onCheckedChange:A=>a(U=>({...U,enabled:A}))})]}),s.enabled&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"space-y-4 p-4 bg-muted/30 rounded-lg border",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(qt,{className:"h-4 w-4"}),n.jsx(z,{className:"text-base font-medium",children:"Drive Discovery Settings"})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(z,{children:"Auto-discover drives"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically discover available drives periodically"})]}),n.jsx(Rs,{checked:s.auto_discover_drives,onCheckedChange:A=>a(U=>({...U,auto_discover_drives:A}))})]}),s.auto_discover_drives&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{children:"Discovery interval"}),n.jsxs(Fe,{value:s.drive_discovery_interval_hours.toString(),onValueChange:A=>a(U=>({...U,drive_discovery_interval_hours:parseInt(A)})),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"1",children:"Every 1 hour"}),n.jsx(J,{value:"6",children:"Every 6 hours"}),n.jsx(J,{value:"12",children:"Every 12 hours"}),n.jsx(J,{value:"24",children:"Every 24 hours"})]})]})]})]}),n.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsx(Xt,{className:"h-4 w-4"}),u?n.jsxs("span",{children:["Last discovered: ",$r(u,"MMM d, h:mm a")]}):n.jsx("span",{children:"No drives discovered yet"}),d.length>0&&n.jsxs(ve,{variant:"secondary",className:"ml-2",children:[d.length," drives found"]}
666)]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:D,disabled:f,children:[f?n.jsx(sr,{className:"h-4 w-4 animate-spin mr-2"}):n.jsx(qt,{className:"h-4 w-4 mr-2"}),f?"Discovering...":"Discover Now"]})]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(z,{className:"text-base font-medium",children:"Monitored Drives"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to select individual drives for monitoring. Available drives are discovered from the agent."}),h?n.jsxs("div",{className:"flex items-center justify-center p-8 text-muted-foreground",children:[n.jsx(sr,{className:"h-4 w-4 animate-spin mr-2"}),"Loading available drives..."]}):d.length===0?n.jsxs("div",{className:"p-4 border border-dashed rounded-lg text-center text-muted-foreground",children:[n.jsx(Pu,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),f?n.jsxs(n.Fragment,{children:[n.jsx(sr,{className:"h-4 w-4 animate-spin mx-auto mb-2"}),n.jsx("p",{className:"text-sm",children:"Agent is scanning for drives..."}),n.jsx("p",{className:"text-xs",children:"This may take a few seconds"})]}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"text-sm",children:"No drives discovered yet"}),n.jsx("p",{className:"text-xs",children:'Use "Discover Now" to find available drives'})]})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:d.map(A=>n.jsxs("div",{className:`p-3 border rounded-lg cursor-pointer transition-all duration-200 ${s.monitored_drives.includes(A.drive_letter)?"border-primary bg-primary/10 shadow-sm ring-1 ring-primary/20":"border-border hover:border-primary/50 hover:bg-primary/5"}`,onClick:()=>S(A.drive_letter),children:[n.jsxs("div",{className:"flex items-center justify-between mb-1",children:[n.jsx("span",{className:"font-mono font-medium",children:A.drive_letter}),s.monitored_drives.includes(A.drive_letter)&&n.jsx(Tt,{className:"h-4 w-4 text-primary"})]}),A.total_size_gb&&n.jsxs("div",{className:"text-xs text-muted-foreground",children:[A.total_size_gb.toFixed(0),"GB total"]})]},A.id))}),s.monitored_drives.length>0&&n.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[n.jsxs(ve,{variant:"secondary",className:"text-xs",children:[s.monitored_drives.length," drive",s.monitored_drives.length!==1?"s":""," selected"]}),n.jsxs("span",{children:["• ",s.monitored_drives.join(", ")]})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(z,{className:"text-base font-medium",children:"Alert Thresholds"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(z,{children:"Warning Threshold"}),n.jsxs(ve,{variant:"secondary",children:[s.warning_threshold,"% used"]})]}),n.jsx(sd,{value:[s.warning_threshold],onValueChange:([A])=>a(U=>({...U,warning_threshold:A})),max:95,min:50,step:5,className:"w-full"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(z,{children:"Critical Threshold"}),n.jsxs(ve,{variant:"destructive",children:[s.critical_threshold,"% used"]})]}),n.jsx(sd,{value:[s.critical_threshold],onValueChange:([A])=>a(U=>({...U,critical_threshold:A})),max:98,min:60,step:5,className:"w-full"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{children:"Check Interval (seconds)"}),n.jsx(ie,{type:"number",value:s.check_interval,onChange:A=>a(U=>({...U,check_interval:parseInt(A.target.value)||300})),min:60,max:3600,step:60}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"How often to check disk space usage (60-3600 seconds)"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(z,{children:"Trend Monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Alert on rapid disk space consumption trends"})]}),n.jsx(Rs,{checked:s.alert_on_trend,onCheckedChange:A=>a(U=>({...U,alert_on_trend:A}))})]}),n.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[n.jsxs("h4",{className:"font-medium mb-2 flex items-center gap-2",children:[n.jsx(Qo,{className:"h-4 w-4"}),"Configuration Preview"]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Monitored Drives:"}),n.jsx("div",{className:"font-mono",children:s.monitored_drives.join(", ")})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Check Interval:"}),n.jsxs("div",{children:[s.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Warning:"}),n.jsxs("div",{className:"text-yellow-600",children:[s.warning_threshold,"%"]})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Critical:"}),n.jsxs("div",{className:"text-red-600",children:[s.critical_threshold,"%"]})]})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{onClick:C,disabled:b,className:"flex-1",children:[n.jsx(Lo,{className:"w-4 h-4 mr-2"}),b?"Saving...":"Save Configuration"]}),n.jsxs(H,{onClick:P,variant:"outline",children:[n.jsx(Dl,{className:"w-4 h-4 mr-2"}),"Export JSON"]}),n.jsxs(H,{onClick:M,variant:"outline",children:[n.jsx(wa,{className:"w-4 h-4 mr-2"}),"Download"]})]}),y&&n.jsxs("div",{className:"text-sm text-muted-foreground mt-2",children:["Current version: ",y.version," | Last updated: ",new Date(y.updated_at).toLocaleStr
666ing()]})]})]})]}),n.jsx(er,{open:i,onOpenChange:o,children:n.jsxs(Kt,{className:"max-w-3xl",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Agent Configuration JSON"}),n.jsx(_s,{children:"This is the exact JSON configuration that will be downloaded by the agent."})]}),n.jsx("div",{className:"max-h-96 overflow-auto",children:n.jsx("pre",{className:"bg-muted p-4 rounded text-sm",children:l?JSON.stringify(l,null,2):""})}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(H,{variant:"outline",onClick:()=>{l&&(navigator.clipboard.writeText(JSON.stringify(l,null,2)),r({title:"Copied to Clipboard",description:"Configuration JSON copied to clipboard"}))},children:"Copy to Clipboard"}),n.jsx(H,{onClick:()=>o(!1),children:"Close"})]})]})})]})},Hn=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{className:"relative w-full overflow-auto",children:n.jsx("table",{ref:r,className:we("w-full caption-bottom text-sm",e),...t})}));Hn.displayName="Table";const Vn=x.forwardRef(({className:e,...t},r)=>n.jsx("thead",{ref:r,className:we("[&_tr]:border-b",e),...t}));Vn.displayName="TableHeader";const Kn=x.forwardRef(({className:e,...t},r)=>n.jsx("tbody",{ref:r,className:we("[&_tr:last-child]:border-0",e),...t}));Kn.displayName="TableBody";const lse=x.forwardRef(({className:e,...t},r)=>n.jsx("tfoot",{ref:r,className:we("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));lse.displayName="TableFooter";const gt=x.forwardRef(({className:e,...t},r)=>n.jsx("tr",{ref:r,className:we("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",e),...t}));gt.displayName="TableRow";const Se=x.forwardRef(({className:e,...t},r)=>n.jsx("th",{ref:r,className:we("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",e),...t}));Se.displayName="TableHead";const be=x.forwardRef(({className:e,...t},r)=>n.jsx("td",{ref:r,className:we("p-4 align-middle [&:has([role=checkbox])]:pr-0",e),...t}));be.displayName="TableCell";const cse=x.forwardRef(({className:e,...t},r)=>n.jsx("caption",{ref:r,className:we("mt-4 text-sm text-muted-foreground",e),...t}));cse.displayName="TableCaption";const dse=(e,t)=>{const s=e.getTime()+e.getTimezoneOffset()*6e4,a=new Date(s+-5*36e5);return $r(a,t)},nk=({commands:e,onViewDetails:t,onDeleteCommand:r})=>{const[s,a]=x.useState(""),[i,o]=x.useState("all"),l=h=>{const f=h.args;if(f!=null&&f.template_name)return f.template_name;if(f!=null&&f.script){const m=f.script.toLowerCase();return m.includes("systeminfo")&&m.includes("computername")&&m.includes("totalphysicalmemory")?"System Information":m.includes("get-service")&&m.includes("running")&&m.includes("converttojson")?"Running Services":m.includes("win32_logicaldisk")&&m.includes("drivetype")&&m.includes("total_gb")?"Disk Usage":m.includes("echo %date% %time%")?"System Time":m.includes("ipconfig /all")?"Network Configuration":m.includes("tasklist /fo csv")?"Running Processes":m.includes("platform.platform()")&&m.includes("psutil")&&m.includes("virtual_memory")||m.includes("win32_computersystem")&&m.includes("wscript.echo")?"System Information":"Custom Script"}return h.op.replace(/_/g," ").replace(/\b\w/g,m=>m.toUpperCase())},c=e.filter(h=>{const f=l(h),m=h.op.toLowerCase().includes(s.toLowerCase())||f.toLowerCase().includes(s.toLowerCase()),g=i==="all"||h.status===i;return m&&g}),d=h=>{switch(h){case"completed":return"default";case"pending":return"secondary";case"failed":return"destructive";case"expired":return"outline";default:return"outline"}},u=h=>{var v,j;const f=new Date(h.created_at),m=h.finished_at?new Date(h.finished_at):null,g=b=>{const _=b/1e3;return _<0?null:_<1?`${Math.round(_*1e3)}ms`:`${_.toFixed(2)}s`};if(m){const b=m.getTime()-f.getTime(),_=g(b);if(_)return _}const p=(v=h.result_details)!=null&&v.started_at?new Date(h.result_details.started_at):null,y=(j=h.result_details)!=null&&j.finished_at?new Date(h.result_details.finished_at):null;if(p&&y){const b=y.getTime()-p.getTime(),_=g(b);if(_)return _}return h.status==="pending"?"—":"N/A"};return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(qt,{className:"h-5 w-5"}),"Command History"]}),n.jsx(De,{children:"Complete audit trail of all commands sent to this agent"}),n.jsxs("div",{className:"flex gap-4 items-center",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search commands or script types...",value:s,onChange:h=>a(h.target.value),className:"pl-10"})]}),n.jsxs(Fe,{value:i,onValueChange:o,children:[n.jsxs(Ie,{className:"w-48",children:[n.jsx(Ui,{className:"h-4 w-4 mr-2"}),n.jsx(Ue,{placeholder:"Filter by status"})]}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Statuses"}),n.jsx(J,{value:"pending",children:"Pending"}),n.jsx(J,{value:"completed",children:"Completed"}),n.jsx(J,{value:"failed",children:"Failed"}),n.jsx(J,{value:"expired",children:"Expired"})]})]})]})]}),n.jsx(re,{children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{children:"Command"}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:"Created"}),n.jsx(Se,{children:"Duration"}),n.jsx(Se,{children:"Script Type"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:c.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No commands found"})}):c.map(h=>{var f;return n.jsxs(gt,{children:[n.jsx(be,{className:"font-medium",children:((f=h.args)==null?void 0:f.script_name)||l(h)}),n.jsx(be,{children:n.jsx(ve,{variant:d(h.status),children:h.status})}),n.jsx(be,{children:dse(new Date(h.created_at),"MMM d, HH:mm:ss")}),n.jsx(be,{children:u(h)}),n.jsx(be,{className:"font-medium",children:l(h)}),n.jsx(be,{className:"text-right",children:n.jsxs("div",{className:"flex gap-1 justify-end",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>t(h),children:[n.jsx($o,{className:"h-4 w-4 mr-2"}),"View"]}
vendor: 9,384 bytes, line 666
666),r&&n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>r(h.id),className:"text-red-600 hover:text-red-700 hover:bg-red-50",children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},h.id)})})]})})]})};var use="Separator",OA="horizontal",hse=["horizontal","vertical"],E5=x.forwardRef((e,t)=>{const{decorative:r,orientation:s=OA,...a}=e,i=fse(s)?s:OA,l=r?{role:"none"}:{"aria-orientation":i==="vertical"?i:void 0,role:"separator"};return n.jsx(We.div,{"data-orientation":i,...l,...a,ref:t})});E5.displayName=use;function fse(e){return hse.includes(e)}var O5=E5;const ja=x.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...s},a)=>n.jsx(O5,{ref:a,decorative:r,orientation:t,className:we("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...s}));ja.displayName=O5.displayName;function mse(e,t){return x.useReducer((r,s)=>t[r][s]??r,e)}var sk="ScrollArea",[M5,cRe]=Qr(sk),[pse,Da]=M5(sk),D5=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,type:s="hover",dir:a,scrollHideDelay:i=600,...o}=e,[l,c]=x.useState(null),[d,u]=x.useState(null),[h,f]=x.useState(null),[m,g]=x.useState(null),[p,y]=x.useState(null),[v,j]=x.useState(0),[b,_]=x.useState(0),[w,N]=x.useState(!1),[S,C]=x.useState(!1),P=nt(t,D=>c(D)),M=Md(a);return n.jsx(pse,{scope:r,type:s,dir:M,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:m,onScrollbarXChange:g,scrollbarXEnabled:w,onScrollbarXEnabledChange:N,scrollbarY:p,onScrollbarYChange:y,scrollbarYEnabled:S,onScrollbarYEnabledChange:C,onCornerWidthChange:j,onCornerHeightChange:_,children:n.jsx(We.div,{dir:M,...o,ref:P,style:{position:"relative","--radix-scroll-area-corner-width":v+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})});D5.displayName=sk;var R5="ScrollAreaViewport",$5=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,children:s,nonce:a,...i}=e,o=Da(R5,r),l=x.useRef(null),c=nt(t,l,o.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),n.jsx(We.div,{"data-radix-scroll-area-viewport":"",...i,ref:c,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});$5.displayName=R5;var Hi="ScrollAreaScrollbar",ak=x.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=Da(Hi,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,l=e.orientation==="horizontal";return x.useEffect(()=>(l?i(!0):o(!0),()=>{l?i(!1):o(!1)}),[l,i,o]),a.type==="hover"?n.jsx(gse,{...s,ref:t,forceMount:r}):a.type==="scroll"?n.jsx(xse,{...s,ref:t,forceMount:r}):a.type==="auto"?n.jsx(I5,{...s,ref:t,forceMount:r}):a.type==="always"?n.jsx(ik,{...s,ref:t}):null});ak.displayName=Hi;var gse=x.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=Da(Hi,e.__scopeScrollArea),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=a.scrollArea;let c=0;if(l){const d=()=>{window.clearTimeout(c),o(!0)},u=()=>{c=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return l.addEventListener("pointerenter",d),l.addEventListener("pointerleave",u),()=>{window.clearTimeout(c),l.removeEventListener("pointerenter",d),l.removeEventListener("pointerleave",u)}}},[a.scrollArea,a.scrollHideDelay]),n.jsx(jn,{present:r||i,children:n.jsx(I5,{"data-state":i?"visible":"hidden",...s,ref:t})})}),xse=x.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=Da(Hi,e.__scopeScrollArea),i=e.orientation==="horizontal",o=tj(()=>c("SCROLL_END"),100),[l,c]=mse("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return x.useEffect(()=>{if(l==="idle"){const d=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(d)}},[l,a.scrollHideDelay,c]),x.useEffect(()=>{const d=a.viewport,u=i?"scrollLeft":"scrollTop";if(d){let h=d[u];const f=()=>{const m=d[u];h!==m&&(c("SCROLL"),o()),h=m};return d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[a.viewport,i,c,o]),n.jsx(jn,{present:r||l!=="hidden",children:n.jsx(ik,{"data-state":l==="hidden"?"hidden":"visible",...s,ref:t,onPointerEnter:Te(e.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Te(e.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),I5=x.forwardRef((e,t)=>{const r=Da(Hi,e.__scopeScrollArea),{forceMount:s,...a}=e,[i,o]=x.useState(!1),l=e.orientation==="horizontal",c=tj(()=>{if(r.viewport){const d=r.viewport.offsetWidth<r.viewport.scrollWidth,u=r.viewport.offsetHeight<r.viewport.scrollHeight;o(l?d:u)}},10);return ih(r.viewport,c),ih(r.content,c),n.jsx(jn,{present:s||i,children:n.jsx(ik,{"data-state":i?"visible":"hidden",...a,ref:t})})}),ik=x.forwardRef((e,t)=>{const{orientation:r="vertical",...s}=e,a=Da(Hi,e.__scopeScrollArea),i=x.useRef(null),o=x.useRef(0),[l,c]=x.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=B5(l.viewport,l.content),u={...s,sizes:l,onSizesChange:c,hasThumb:d>0&&d<1,onThumbChange:f=>i.current=f,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:f=>o.current=f};function h(f,m){return _se(f,o.current,l,m)}return r==="horizontal"?n.jsx(vse,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const f=a.viewport.scrollLeft,m=MA(f,l,a.dir);i.current.style.transform=`translate3d(${m}px, 0, 0)`}},onWheelScroll:f=>{a.viewport&&(a.viewport.scrollLeft=f)},onDragScroll:f=>{a.viewport&&(a.viewport.scrollLeft=h(f,a.dir))}}):r==="vertical"?n.jsx(yse,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const f=a.viewport.scrollTop,m=MA(f,l);i.current.style.transform=`translate3d(0, ${m}px, 0)`}},onWheelScroll:f=>{a.viewport&&(a.viewport.scrollTop=f)},onDragScroll:f=>{a.viewport&&(a.viewport.scrollTop=h(f))}}):null}),vse=x.forwardRef((e,t)=>{const{sizes:r,onSizesChange:s,...a}=e,i=Da(Hi,e.__scopeScrollArea),[o,l]=x.useState(),c=x.useRef(null),d=nt(t,c,i.onScrollbarXChange);return x.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),n.jsx(F5,{"data-orientation":"horizontal",...a,ref:d,sizes:r,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ej(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.x),onDragScroll:u=>e.onDragScroll(u.x),onWheelScroll:(u,h)=>{if(i.viewport){const f=i.viewport.scrollLeft+u.deltaX;e.onWheelScroll(f),W5(f,h)&&u.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&s({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:Hv(o.paddingLeft),paddingEnd:Hv(o.paddingRight)}})}})}),yse=x.forwardRef((e,t)=>{const{sizes:r,onSizesChange:s,...a}=e,i=Da(Hi,e.__scopeScrollArea),[o,l]=x.useState(),c=x.useRef(null),d=nt(t,c,i.onScrollbarYChange);return x.useEffect(()=>{c.current&&l(getComputedStyle(c.current))},[c]),n.jsx(F5,{"data-orientation":"vertical",...a,ref:d,sizes:r,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ej(r)+"px",...e.style},onThumbPointerDown:u=>e.onThumbPointerDown(u.y),onDragScroll:u=>e.onDragScroll(u.y),onWheelScroll:(u,h)=>{if(i.viewport){const f=i.viewport.scrollTop+u.deltaY;e.onWheelScroll(f),W5(f,h)&&u.preventDefault()}},onResize:()=>{c.current&&i.viewport&&o&&s({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:Hv(o.paddingTop),paddingEnd:Hv(o.paddingBottom)}})}})}),[jse,L5]=M5(Hi),F5=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,sizes:s,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,m=Da(Hi,r),[g,p]=x.useState(null),y=nt(t,P=>p(P)),v=x.useRef(null),j=x.useRef(""),b=m.viewport,_=s.content-s.viewport,w=Sr(u),N=Sr(c),S=tj(h,10);function C(P){if(v.current){const M=P.clientX-v.current.left,D=P.clientY-v.current.top;d({x:M,y:D})}}return x.useEffect(()=>{const P=M=>{const D=M.target;(g==null?void 0:g.contains(D))&&w(M,_)};return document.addEventListener("wheel",P,{passive:!1}),()=>document.removeEventListener("wheel",P,{passive:!1})},[b,g,_,w]),x.useEffect(N,[s,N]),ih(g,S),ih(m.content,S),n.jsx(jse,{scope:r,scrollbar:g,hasThumb:a,onThumbChange:Sr(i),onThumbPointerUp:Sr(o),onThumbPositionChange:N,onThumbPointerDown:Sr(l),children:n.jsx(We.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Te(e.onPointerDown,P=>{P.button===0&&(P.target.setPointerCapture(P.pointerId),v.current=g.getBoundingClientRect(),j.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),C(P))}),onPointerMove:Te(e.onPointerMove,C),onPointerUp:Te(e.onPointerUp,P=>{const M=P.target;M.hasPointerCapture(P.pointerId)&&M.releasePointerCapture(P.pointerId),document.body.style.webkitUserSelect=j.current,m.viewport&&(m.viewport.style.scrollBehavior=""),v.current=null})})})}),Wv="ScrollAreaThumb",U5=x.forwardRef((e,t)=>
vendor: 4,198 bytes, line 666
666{const{forceMount:r,...s}=e,a=L5(Wv,e.__scopeScrollArea);return n.jsx(jn,{present:r||a.hasThumb,children:n.jsx(bse,{ref:t,...s})})}),bse=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,style:s,...a}=e,i=Da(Wv,r),o=L5(Wv,r),{onThumbPositionChange:l}=o,c=nt(t,h=>o.onThumbChange(h)),d=x.useRef(void 0),u=tj(()=>{d.current&&(d.current(),d.current=void 0)},100);return x.useEffect(()=>{const h=i.viewport;if(h){const f=()=>{if(u(),!d.current){const m=Nse(h,l);d.current=m,l()}};return l(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[i.viewport,u,l]),n.jsx(We.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...s},onPointerDownCapture:Te(e.onPointerDownCapture,h=>{const m=h.target.getBoundingClientRect(),g=h.clientX-m.left,p=h.clientY-m.top;o.onThumbPointerDown({x:g,y:p})}),onPointerUp:Te(e.onPointerUp,o.onThumbPointerUp)})});U5.displayName=Wv;var ok="ScrollAreaCorner",z5=x.forwardRef((e,t)=>{const r=Da(ok,e.__scopeScrollArea),s=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&s?n.jsx(wse,{...e,ref:t}):null});z5.displayName=ok;var wse=x.forwardRef((e,t)=>{const{__scopeScrollArea:r,...s}=e,a=Da(ok,r),[i,o]=x.useState(0),[l,c]=x.useState(0),d=!!(i&&l);return ih(a.scrollbarX,()=>{var h;const u=((h=a.scrollbarX)==null?void 0:h.offsetHeight)||0;a.onCornerHeightChange(u),c(u)}),ih(a.scrollbarY,()=>{var h;const u=((h=a.scrollbarY)==null?void 0:h.offsetWidth)||0;a.onCornerWidthChange(u),o(u)}),d?n.jsx(We.div,{...s,ref:t,style:{width:i,height:l,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function Hv(e){return e?parseInt(e,10):0}function B5(e,t){const r=e/t;return isNaN(r)?0:r}function ej(e){const t=B5(e.viewport,e.content),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=(e.scrollbar.size-r)*t;return Math.max(s,18)}function _se(e,t,r,s="ltr"){const a=ej(r),i=a/2,o=t||i,l=a-o,c=r.scrollbar.paddingStart+o,d=r.scrollbar.size-r.scrollbar.paddingEnd-l,u=r.content-r.viewport,h=s==="ltr"?[0,u]:[u*-1,0];return q5([c,d],h)(e)}function MA(e,t,r="ltr"){const s=ej(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-a,o=t.content-t.viewport,l=i-s,c=r==="ltr"?[0,o]:[o*-1,0],d=sp(e,c);return q5([0,o],[0,l])(d)}function q5(e,t){return r=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const s=(t[1]-t[0])/(e[1]-e[0]);return t[0]+s*(r-e[0])}}function W5(e,t){return e>0&&e<t}var Nse=(e,t=()=>{})=>{let r={left:e.scrollLeft,top:e.scrollTop},s=0;return function a(){const i={left:e.scrollLeft,top:e.scrollTop},o=r.left!==i.left,l=r.top!==i.top;(o||l)&&t(),r=i,s=window.requestAnimationFrame(a)}(),()=>window.cancelAnimationFrame(s)};function tj(e,t){const r=Sr(e),s=x.useRef(0);return x.useEffect(()=>()=>window.clearTimeout(s.current),[]),x.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(r,t)},[r,t])}function ih(e,t){const r=Sr(t);Ur(()=>{let s=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(r)});return a.observe(e),()=>{window.cancelAnimationFrame(s),a.unobserve(e)}}},[e,r])}var H5=D5,Sse=$5,Cse=z5;const yd=x.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(H5,{ref:s,className:we("relative overflow-hidden",e),...r,children:[n.jsx(Sse,{className:"h-full w-full rounded-[inherit]",children:t}),n.jsx(V5,{}),n.jsx(Cse,{})]}));yd.displayName=H5.displayName;const V5=x.forwardRef(({className:e,orientation:t="vertical",...r},s)=>n.jsx(ak,{ref:s,orientation:t,className:we("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...r,children:n.jsx(U5,{className:"relative flex-1 rounded-full bg-border"})}));V5.displayName=ak.displayName;const hx=(e,t)=>{const s=e.getTime()+e.getTimezoneOffset()*6e4,a=new Date(s+-5*36e5);return $r(a,t)},lk=({command:e,open:t,onOpenChange:r})=>{if(!e)return null;const s=h=>{switch(h){case"completed":return n.jsx(Tt,{className:"h-4 w-4 text-green-500"});case"failed":return n.jsx(sa,{className:"h-4 w-4 text-red-500"});
666case"pending":return n.jsx(Xt,{className:"h-4 w-4 text-yellow-500"});case"expired":return n.jsx(kn,{className:"h-4 w-4 text-gray-500"});default:return n.jsx(Xt,{className:"h-4 w-4"})}},a=h=>{switch(h){case"completed":return"default";case"pending":return"secondary";case"failed":return"destructive";case"expired":return"outline";default:return"outline"}},i=()=>{const h=new Date(e.created_at),f=e.result_details,m=f!=null&&f.started_at?new Date(f.started_at):null,g=f!=null&&f.finished_at?new Date(f.finished_at):null,p=e.finished_at?new Date(e.finished_at):null;let y=null,v=null,j=null;if(m&&g){const b=g.getTime()-m.getTime();b>=0&&(v=(b/1e3).toFixed(3))}if(p){const b=p.getTime()-h.getTime();b>=0&&(j=(b/1e3).toFixed(3))}if(m){const b=m.getTime()-h.getTime();if(b>=0)y=(b/1e3).toFixed(3);else if(j&&v){const _=parseFloat(j)-parseFloat(v);_>=0&&(y=_.toFixed(3))}}return{created:h,startedAt:m,finishedAt:g||p,queueTime:y,executionTime:v,totalTime:j}},o=h=>{if(!h)return"—";const f=parseFloat(h);return isNaN(f)?"—":f<0?"Invalid":f<1?`${(f*1e3).toFixed(0)}ms`:`${f.toFixed(2)}s`},l=h=>h==null?"":h===""?n.jsx("div",{className:"text-muted-foreground italic",children:"No output produced"}):h.replace(/\r\n/g,`
667`).replace(/\r/g,`
668`).split(`
669`).map((f,m)=>n.jsx("div",{style:{fontFamily:'Consolas, Monaco, "Courier New", monospace'},children:f||" "},m)),{toast:c}=qr(),d=h=>{navigator.clipboard.writeText(h).then(()=>{c({title:"Success",description:"Copied to clipboard"})}).catch(()=>{c({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})})},u=i();return n.jsx(er,{open:t,onOpenChange:r,children:n.jsxs(Kt,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[n.jsxs(zr,{children:[n.jsxs(Br,{className:"flex items-center gap-2",children:[n.jsx(ws,{className:"h-5 w-5"}),"Command Details"]}),n.jsx(_s,{children:"Complete information about command execution"})]}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[s(e.status),n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:e.op}),n.jsx("div",{className:"text-sm text-muted-foreground",children:hx(new Date(e.created_at),"PPpp")})]})]}),n.jsx(ve,{variant:a(e.status),children:e.status})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4"}),"Execution Timeline"]}),n.jsxs("div",{className:"grid grid-cols-3 gap-6 p-4 bg-muted/30 rounded-lg",children:[n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"flex items-center justify-center mb-2",children:n.jsx(mI,{className:"h-4 w-4 text-blue-500"})}),n.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"QUEUED"}),n.jsx("div",{className:"text-sm",children:hx(u.created,"HH:mm:ss.SSS")}),u.queueTime&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Queue: ",o(u.queueTime)]})]}),u.startedAt&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"flex items-center justify-center mb-2",children:n.jsx(ws,{className:"h-4 w-4 text-green-500"})}),n.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"STARTED"}),n.jsx("div",{className:"text-sm",children:hx(u.startedAt,"HH:mm:ss.SSS")}),u.executionTime&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Execution: ",o(u.executionTime)]})]}),u.finishedAt&&n.jsxs("div",{className:"text-center",children:[n.jsx("div",{className:"flex items-center justify-center mb-2",children:n.jsx(k7,{className:"h-4 w-4 text-purple-500"})}),n.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"FINISHED"}),n.jsx("div",{className:"text-sm",children:hx(u.finishedAt,"HH:mm:ss.SSS")}),u.totalTime&&n.jsxs("div",{className:"text-xs text-muted-foreground mt-1",children:["Total: ",o(u.totalTime)]})]})]})]}),n.jsx(ja,{}),e.result_details&&e.result_details.output!==void 0&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[n.jsx(ws,{className:"h-4 w-4"}),"Command Output"]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>d(e.result_details.output),className:"flex items-center gap-2",children:[n.jsx(rg,{className:"h-3 w-3"}),"Copy"]})]}),n.jsx("div",{className:"bg-black text-green-400 p-4 rounded-lg border",children:n.jsx(yd,{className:"h-64",children:n.jsx("div",{className:"text-sm leading-relaxed",children:l(e.result_details.output)})})})]}),e.result_details&&e.result_details.error_message&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("h4",{className:"font-medium text-red-600 flex items-center gap-2",children:[n.jsx(sa,{className:"h-4 w-4"}),"Error Message"]}),n.jsx("div",{className:"bg-red-50 border border-red-200 text-red-800 p-3 rounded-lg",children:n.jsx("code",{className:"text-sm",children:e.result_details.error_message})})]}),n.jsx(ja,{}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h4",{className:"font-medium",children:"Command Information"}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("h5",{className:"font-medium text-sm mb-2",children:"Operation"}),n.jsx("p",{className:"text-sm bg-muted p-2 rounded font-mono",children:e.op})]}),n.jsxs("div",{children:[n.jsx("h5",{className:"font-medium text-sm mb-2",children:"Command Cursor"}),n.jsx("p",{className:"text-sm bg-muted p-2 rounded font-mono",children:e.cursor})]})]}),n.jsxs("div",{children:[n.jsx("h5",{className:"font-medium text-sm mb-2",children:"Arguments"}),n.jsx(yd,{className:"h-32",children:n.jsx("pre",{className:"text-xs bg-muted p-3 rounded whitespace-pre-wrap break-all overflow-hidden",children:JSON.stringify(e.args,null,2)})})]})]}),n.jsx(ja,{}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Command ID:"}),n.jsx("p",{className:"font-mono text-xs break-all",children:e.id})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Agent ID:"}),n.jsx("p",{className:"font-mono text-xs break-all",children:e.agent_id})]})]})]})]})})};var ck="Progress",dk=100,[kse,dRe]=Qr(ck),[Pse,Tse]=kse(ck),K5=x.forwardRef((e,t)=>
669{const{__scopeProgress:r,value:s=null,max:a,getValueLabel:i=Ase,...o}=e;(a||a===0)&&!DA(a)&&console.error(Ese(`${a}`,"Progress"));const l=DA(a)?a:dk;s!==null&&!RA(s,l)&&console.error(Ose(`${s}`,"Progress"));const c=RA(s,l)?s:null,d=Vv(c)?i(c,l):void 0;return n.jsx(Pse,{scope:r,value:c,max:l,children:n.jsx(We.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":Vv(c)?c:void 0,"aria-valuetext":d,role:"progressbar","data-state":Q5(c,l),"data-value":c??void 0,"data-max":l,...o,ref:t})})});K5.displayName=ck;var G5="ProgressIndicator",Y5=x.forwardRef((e,t)=>{const{__scopeProgress:r,...s}=e,a=Tse(G5,r);return n.jsx(We.div,{"data-state":Q5(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...s,ref:t})});Y5.displayName=G5;function Ase(e,t){return`${Math.round(e/t*100)}%`}function Q5(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function Vv(e){return typeof e=="number"}function DA(e){return Vv(e)&&!isNaN(e)&&e>0}function RA(e,t){return Vv(e)&&!isNaN(e)&&e<=t&&e>=0}function Ese(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${dk}\`.`}function Ose(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
670  - a positive number
671  - less than the value passed to \`max\` (or ${dk} if no \`max\` prop is set)
672  - \`null\` or \`undefined\` if the progress is indeterminate.
673
674Defaulting to \`null\`.`}var X5=K5,Mse=Y5;const ap=x.forwardRef(({className:e,value:t,...r},s)=>n.jsx(X5,{ref:s,className:we("relative h-4 w-full overflow-hidden rounded-full bg-secondary",e),...r,children:n.jsx(Mse,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(t||0)}%)`}})}));ap.displayName=X5.displayName;const Z5=({commands:e,onViewDetails:t,onCancelCommand:r})=>{const s=l=>{const c=new Date(l);return(new Date().getTime()-c.getTime())/(1e3*60)},a=l=>{const c=s(l);return c>30?"critical":c>10?"warning":"normal"},i=l=>{switch(l){case"critical":return"text-red-600";case"warning":return"text-yellow-600";default:return"text-green-600"}},o=l=>{const c=s(l);return Math.min(c/30*100,100)};return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(S0,{className:"h-5 w-5"}),"Active Commands",e.length>0&&n.jsx(ve,{variant:"secondary",className:"ml-2",children:e.length})]}),n.jsx(De,{children:"Commands currently being processed by the agent"})]}),n.jsx(re,{children:e.length===0?n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(Xt,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:"No active commands"}),n.jsx("p",{className:"text-sm",children:"All commands have been processed"})]}):n.jsx("div",{className:"space-y-4",children:e.map(l=>{const c=a(l.created_at),d=o(l.created_at);return n.jsxs("div",{className:"border rounded-lg p-4 hover:bg-muted/50 transition-colors",children:[n.jsxs("div",{className:"flex items-start justify-between mb-3",children:[n.jsxs("div",{className:"space-y-1 flex-1 cursor-pointer",onClick:()=>t(l),children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("h4",{className:"font-medium",children:l.op}),c==="critical"&&n.jsx(tn,{className:"h-4 w-4 text-red-500"})]}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Started ",is(new Date(l.created_at))," ago"]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ve,{variant:"secondary",children:"Pending"}),r&&n.jsx(H,{variant:"ghost",size:"sm",onClick:u=>{u.stopPropagation(),r(l.id)},className:"h-8 w-8 p-0 text-muted-foreground hover:text-red-600",children:n.jsx(vn,{className:"h-4 w-4"})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Progress"}),n.jsx("span",{className:i(c),children:c==="critical"?"Overdue":c==="warning"?"Taking longer than expected":"Processing"})]}),n.jsx(ap,{value:d,className:"h-2"})]}),n.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:[n.jsxs("span",{className:"font-mono",children:[l.cursor.slice(-12),"..."]}),n.jsx("span",{className:"mx-2",children:"•"}),n.jsx("span",{children:$r(new Date(l.created_at),"HH:mm:ss")})]})]},l.id)})})})]})},kr=x.forwardRef(({className:e,...t},r)=>n.jsx("textarea",{className:we("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm r
674ing-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...t}));kr.displayName="Textarea";function MN(e,t){const r=Et(),{data:s=[],isLoading:a,error:i,refetch:o}=Ve({queryKey:["script-templates",e,t],queryFn:async()=>{if(!e)return[];let h=B.from("script_templates").select("*").eq("is_active",!0).eq("client_id",e).order("name");t&&(h=h.eq("script_type",t));const{data:f,error:m}=await h;if(m)throw console.error("Error fetching script templates:",m),m;return f||[]},enabled:!!e}),l=mt({mutationFn:async h=>{const{data:f,error:m}=await B.from("script_templates").insert([h]).select().single();if(m)throw m;return f},onSuccess:()=>{ye.success("Script template created successfully"),r.invalidateQueries({queryKey:["script-templates"]})},onError:h=>{console.error("Error creating script template:",h),ye.error("Failed to create script template")}}),c=mt({mutationFn:async({id:h,...f})=>{const{data:m,error:g}=await B.from("script_templates").update(f).eq("id",h).select().single();if(g)throw g;return m},onSuccess:()=>{ye.success("Script template updated successfully"),r.invalidateQueries({queryKey:["script-templates"]})},onError:h=>{console.error("Error updating script template:",h),ye.error("Failed to update script template")}}),d=mt({mutationFn:async h=>{const{error:f}=await B.from("script_templates").delete().eq("id",h);if(f)throw f},onSuccess:()=>{ye.success("Script template deleted successfully"),r.invalidateQueries({queryKey:["script-templates"]})},onError:h=>{console.error("Error deleting script template:",h),ye.error("Failed to delete script template")}}),u=mt({mutationFn:async h=>{const{error:f}=await B.rpc("copy_system_templates_to_client",{target_client_id:h});if(f)throw f},onSuccess:()=>{ye.success("System templates copied successfully"),r.invalidateQueries({queryKey:["script-templates"]})},onError:h=>{console.error("Error copying system templates:",h),ye.error("Failed to copy system templates")}});return{templates:s,isLoading:a,error:i,refetch:o,createTemplate:l.mutate,updateTemplate:c.mutate,deleteTemplate:d.mutate,copySystemTemplates:u.mutate,isCreating:l.isPending,isUpdating:c.isPending,isDeleting:d.isPending,isCopyingSystemTemplates:u.isPending}}const Dse={powershell:"execute_powershell",batch:"run_cmd"},ow=[{value:"powershell",op:"execute_powershell",label:"PowerShell",icon:ws,description:"Execute PowerShell commands and scripts"},{value:"batch",op:"run_cmd",label:"Batch/DOS",icon:pI,description:"Execute Windows Command Prompt commands"}],uk=({agentId:e,clientId:t,onTriggerCommand:r,isLoading:s=!1,open:a,onOpenChange:i})=>{const[o,l]=x.useState(!1),c=a!==void 0?a:o,d=i||l,[u,h]=x.useState(""),[f,m]=x.useState(""),[g,p]=x.useState(""),[y,v]=x.useState("30"),[j,b]=x.useState(!1),[_,w]=x.useState(""),[N,S]=x.useState(""),{templates:C,copySystemTemplates:P,isCopyingSystemTemplates:M,createTemplate:D,isCreating:A}=MN(t,u),{templates:U}=MN(t);x.useEffect(()=>{t&&U.length===0&&P(t)},[t,U.length,P]);const F=()=>{var ue;if(!u)return;let k=g;if(f&&!g.trim()){const X=C.find(le=>le.id===f);X&&(k=X.script_content)}if(!k.trim())return;const W=f?(ue=C.find(X=>X.id===f))==null?void 0:ue.name:null,q=Dse[u]||u,Q={script:k.trim(),timeout:parseInt(y)||30,script_name:W||"Custom Script",...f&&{template_id:f}};r({agent_id:e,client_id:t,op:q,args:Q}),d(!1),h(""),m(""),p(""),v("30")},L=()=>{!u||!_.trim()||!g.trim()||(D({client_id:t,name:_.trim(),description:N.trim()||void 0,script_type:u,script_content:g.trim(),category:"user_created",tags:[],is_active:!0,is_system_template:!1,created_by_user_id:void 0}),b(!1),w(""),S(""),p(""))},$=ow.find(k=>k.value===u),R=C||[],T=R.find(k=>k.id===f);return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ws,{className:"h-5 w-5"}),"Manual Commands"]}),n.jsx(De,{children:"Execute PowerShell or DOS/CMD commands on the agent"})]}),n.jsxs(re,{children:[n.jsxs(er,{open:c,onOpenChange:d,children:[n.jsx(Y0,{asChild:!0,children:n.jsxs(H,{
674className:"w-full",children:[n.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Send Command"]})}),n.jsxs(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Execute Script Command"}),n.jsx(_s,{children:"Select a script type and either choose a template or write custom code"})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"script-type",children:"Script Type"}),n.jsxs(Fe,{value:u,onValueChange:k=>{h(k),m(""),p("")},children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select script type..."})}),n.jsx(Le,{className:"z-50 bg-background",children:ow.map(k=>{const W=k.icon;return n.jsx(J,{value:k.value,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(W,{className:"h-4 w-4"}),n.jsx("span",{children:k.label})]})},k.value)})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"timeout",children:"Timeout (seconds)"}),n.jsx(ie,{id:"timeout",type:"number",min:"1",max:"300",value:y,onChange:k=>v(k.target.value),placeholder:"30"})]})]}),$&&n.jsxs("div",{className:"p-3 bg-muted rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx($.icon,{className:"h-4 w-4"}),n.jsx("span",{className:"font-medium",children:$.label})]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:$.description})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"template",children:"Pre-built Scripts (Optional)"}),n.jsxs(Fe,{value:f,onValueChange:k=>{if(k!=="__none__"&&(m(k),k)){const W=R.find(q=>q.id===k);W&&p(W.script_content)}},children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:R.length?"Choose a template or write custom...":"No templates available for this script type"})}),n.jsx(Le,{className:"z-50 bg-background",children:R.length?R.map(k=>n.jsx(J,{value:k.id,children:n.jsxs("div",{children:[n.jsxs("div",{className:"font-medium flex items-center gap-2",children:[k.name,k.is_system_template&&n.jsx(ve,{variant:"secondary",className:"text-xs",children:"Global"})]}),n.jsx("div",{className:"text-xs text-muted-foreground",children:k.description})]})},k.id)):n.jsx(J,{disabled:!0,value:"__none__",children:"No templates available"})})]})]}),T&&!g&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{children:"Template Preview"}),n.jsx("pre",{className:"text-xs bg-muted p-3 rounded-lg overflow-x-auto max-h-32",children:T.script_content})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"custom-script",children:f?"Edit Script":"Custom Script"}),n.jsx(kr,{id:"custom-script",placeholder:`Write your ${($==null?void 0:$.label.toLowerCase())||"script"} here...`,value:g,onChange:k=>p(k.target.value),rows:12,className:"font-mono text-sm"}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:f?"You can modify the template script above":"Write your custom script or select a template"}),u&&g.trim()&&n.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:()=>b(!0),className:"text-xs",children:"Save as Template"})]})]}),j&&n.jsxs("div",{className:"space-y-4 p-4 border rounded-lg bg-muted/20",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(z,{className:"text-sm font-medium",children:"Create New Template"}),n.jsx(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>{b(!1),w(""),S("")},children:"Cancel"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"template-name",children:"Template Name *"}),n.jsx(ie,{id:"template-name",value:_,onChange:k=>w(k.target.value),placeholder:"Enter template name..."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"template-description",children:"Description"}),n.jsx(ie,{id:"template-description",value:N,onChange:k=>S(k.target.value),placeholder:"Optional description..."})]})]}),n.jsx(H,{type:"button",onClick:L,disabled:!_.trim()||!g.trim()||A,className:"w-full",children:A?"Creating Template...":"Create Template"})]}),n.jsxs("div",{className:"flex gap-2 pt-4",children:[n.jsx(H,{onClick:()=>{d(!1),h(""),m(""),p(""),v("30")},variant:"outline",className:"flex-1",children:"Cancel"}),n.jsx(H,{onClick:F,disabled:!u||!g.trim()&&!f||s,className:"flex-1",children:s?"Executing...":"Execute Script"})]})]})]})]}),n.jsxs("div",{className:"mt-4 space-y-2",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Supported Script Types:"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:ow.map(k=>n.jsx(ve,{variant:"outline",className:"text-xs",children:k.label},k.value))})]})]})]})},Rse=({state:e,severity:t,monitorType:r})=>{const s=()=>e==="healthy"?"default":e==="breached"?t==="critical"?"destructive":"secondary":"outline",a=()=>e==="healthy"?"text-green-600 bg-green-50 border-green-200":e==="configured"?"text-blue-600 bg-blue-50 border-blue-200":e==="breached"?t==="critical"?"text-red-600 bg-red-50 border-red-200":"text-yellow-600 bg-yellow-50 border-yellow-200":"",i=()=>
674{if(r==="Connection Status"){if(e==="healthy")return"Up";if(e==="breached")return"Down"}return e==="healthy"?"Healthy":e==="configured"?"Configured":e==="breached"?"Breached":e};return n.jsx(ve,{variant:s(),className:a(),children:i()})},$se=({eventType:e})=>e==="enter"?n.jsx(tn,{className:"h-4 w-4 text-red-500"}):n.jsx(Wr,{className:"h-4 w-4 text-green-500"});function Ise(){const{agentId:e}=qL(),t=di(),[r]=RC(),[s,a]=x.useState(null),[i,o]=x.useState("status");x.useEffect(()=>{const w=r.get("tab");w&&["status","configure","commands"].includes(w)&&o(w)},[r]);const{data:l,isLoading:c}=Vte(e),{data:d,isLoading:u}=Kte(e),{recentHeartbeats:h}=dc(),{commands:f,activeCommands:m,createCommand:g,isCreating:p,cancelCommand:y,isCancelling:v,deleteCommand:j,isDeleting:b}=zv(e),_=h==null?void 0:h.find(w=>w.agent_id===e);return e?n.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>t("/dashboard/agents"),className:"flex items-center gap-2",children:[n.jsx(Ma,{className:"h-4 w-4"}),"Back to Agents"]}),n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:"Agent Monitors"}),n.jsxs("p",{className:"text-muted-foreground",children:["Monitor status and events for ",(_==null?void 0:_.hostname)||"Unknown Agent"]})]})]}),_&&n.jsx(ee,{children:n.jsx(re,{className:"p-6",children:n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Hostname"}),n.jsx("p",{className:"font-medium",children:_.hostname})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"IP Address"}),n.jsx("p",{className:"font-medium",children:_.local_ip})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"OS"}),n.jsxs("p",{className:"font-medium",children:[_.os_type," ",_.os_version]})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Last Seen"}),n.jsx("p",{className:"font-medium",children:$r(new Date(_.created_at),"MMM d, h:mm a")})]})]})})}),n.jsxs(cn,{value:i,onValueChange:o,className:"space-y-6",children:[n.jsxs(nn,{className:"grid w-full grid-cols-3",children:[n.jsx(at,{value:"status",children:"Monitor Status"}),n.jsx(at,{value:"configure",children:"Configure Monitors"}),n.jsx(at,{value:"commands",children:"Command Activity"})]}),n.jsx(it,{value:"status",className:"space-y-6",children:n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Pu,{className:"h-5 w-5"}),"Active Monitors"]})}),n.jsx(re,{children:c?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading monitor states..."})}):l&&l.length>0?n.jsx("div",{className:"space-y-4",children:l.map(w=>n.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Pu,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:w.monitor_id.includes("volume:")?`Volume (${w.monitor_id.split(":")[1]})`:w.monitor_id}),n.jsx("p",{className:"text-sm text-muted-foreground",children:w.monitor_type})]})]}),n.jsxs("div",{className:"text-right",children:[n.jsx(Rse,{state:w.state,severity:w.severity,monitorType:w.monitor_type}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:w.state==="configured"?`Configured ${$r(new Date(w.state_since),"MMM d, h:mm a")}`:`Since ${$r(new Date(w.state_since),"MMM d, h:mm a")}`})]})]},w.id))}):n.jsxs("div",{className:"text-center py-8",children:[n.jsx(Pu,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("p",{className:"text-muted-foreground",children:"No active monitors"}),n.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:'To get started, go to the "Configure Monitors" tab and:'}),n.jsx("div",{className:"text-left bg-muted/50 rounded-lg p-4 max-w-md mx-auto",children:n.jsxs("ol",{className:"text-sm text-muted-foreground space-y-1",children:[n.jsx("li",{children:'1. Toggle "Enable Volume Monitoring" to ON'}
674),n.jsx("li",{children:"2. Click on drive letters to select them (C:, D:, etc.)"}),n.jsx("li",{children:"3. Adjust thresholds if needed"}),n.jsx("li",{children:'4. Click "Save Configuration"'})]})})]})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-5 w-5"}),"Recent Events"]})}),n.jsx(re,{children:u?n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading events..."})}):d&&d.length>0?n.jsx("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:d.map(w=>n.jsx("div",{children:n.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-lg border",children:[n.jsx($se,{eventType:w.event_type}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("p",{className:"font-medium text-sm",children:w.monitor_id.includes("volume:")?`Volume (${w.monitor_id.split(":")[1]})`:w.monitor_id}),n.jsx(ve,{variant:"outline",className:"text-xs",children:w.event_type==="enter"?"Breach":"Recovery"})]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:w.event_type==="enter"?"Threshold breached":"Threshold cleared"}),n.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:$r(new Date(w.timestamp),"MMM d, h:mm:ss a")}),w.severity&&n.jsx(ve,{variant:"outline",className:"text-xs",children:w.severity})]})]})]})},w.id))}):n.jsxs("div",{className:"text-center py-8",children:[n.jsx(Xt,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("p",{className:"text-muted-foreground",children:"No events yet"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Monitor events will appear here as they occur"})]})})]})]})}),n.jsx(it,{value:"configure",className:"space-y-6",children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Qo,{className:"h-5 w-5"}),"Available Monitors"]})}),n.jsx(re,{children:n.jsx("p",{className:"text-muted-foreground",children:"Configure and enable monitors for this Private LAN agent. Changes are applied immediately to the agent."})})]}),n.jsx(ose,{agentId:e,onSave:w=>{console.log("Volume monitor config saved:",w)}}),n.jsx(ee,{className:"border-dashed",children:n.jsx(re,{className:"p-6",children:n.jsxs("div",{className:"text-center",children:[n.jsx(Ws,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("h3",{className:"text-lg font-medium mb-2",children:"More Monitors Coming Soon"}),n.jsx("p",{className:"text-muted-foreground",children:"Additional monitors like Process Manager, Service Manager, and Network Monitor will be available in future updates."})]})})})]})}),n.jsxs(it,{value:"commands",className:"space-y-6",children:[n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[n.jsx(Z5,{commands:m,onViewDetails:a,onCancelCommand:y}),n.jsx(uk,{agentId:e,clientId:(_==null?void 0:_.client_id)||"",onTriggerCommand:g,isLoading:p})]}),n.jsx(nk,{commands:f,onViewDetails:a,onDeleteCommand:j}),n.jsx(lk,{command:s,open:!!s,onOpenChange:w=>!w&&a(null)})]})]})]}):n.jsx("div",{children:"Agent ID not found"})}const Lse=()=>{const e=Zo();return x.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),n.jsx("div",{className:"flex min-h-screen items-center justify-center bg-gray-100",children:n.jsxs("div",{className:"text-center",children:[n.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),n.jsx("p",{className:"mb-4 text-xl text-gray-600",children:"Oops! Page not found"}),n.jsx(_a,{to:"/",className:"text-blue-500 underline hover:text-blue-700",children:"Return to Home"})]})})},Fse=()=>n.jsx("div",{className:"min-h-screen bg-background",children:n.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[n.jsxs("div",{className:"bg-card border border-border rounded-lg p-8",children:[n.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Privacy Policy"}),n.jsxs("div",{className:"prose prose-neutral dark:prose-invert max-w-none",children:[n.jsx("p",{className:"text-muted-foreground mb-6",children:"Last updated: January 2025"}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Information We Collect"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"We collect information you provide directly to us, such as when you create an account, configure monitoring services, or contact us for support."}),n.jsxs("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:[n.jsx("li",{children:"Account information (name, email, password)"}),n.jsx("li",{children:"Monitoring configuration data"}),n.jsx("li",{children:"Usage and performance data"}),n.jsx("li",{children:"Communications with our support team"})]})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"How We Use Your Information"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"We use the information we collect to provide, maintain, and improve our services:"}),n.jsxs("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:[n.jsx("li",{children:"To provide monitoring services and send alerts"}),n.jsx("li",{children:"To process transactions and send related information"}),n.jsx("li",{children:"To respond to your comments, questions, and customer service requests"}),n.jsx("li",{children:"To improve our services and develop new features"})]})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Data Security"}),n.jsx("p",{className:"text-muted-foreground",children:"We implement appropriate security measures to protect your personal information against unauthorized access, alteration, disclosure, or destruction. All data is encrypted in transit and at rest."})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Contact Us"}),n.jsxs("p",{className:"text-muted-foreground",children:["If you have any questions about this Privacy Policy, please contact us at"," ",n.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"})]})]})]})]}),n.jsx("div",{className:"mt-8 text-center",children:n.jsx(_a,{to:"/",className:"text-primary hover:underline",children:"← Back to Home"})})]})}),Use=()=>n.jsx("div",{className:"min-h-screen bg-background",children:n.jsxs("div",{className:"max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[n.jsxs("div",{className:"bg-card border border-border rounded-lg p-8",children:[n.jsx("h1",{className:"text-3xl font-bold text-foreground mb-8",children:"Terms of Service"}),n.jsxs("div",{className:"prose prose-neutral dark:prose-invert max-w-none",children:[n.jsx("p",{className:"text-muted-foreground mb-6",children:"Last updated: January 2025"}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Acceptance of Terms"}),n.jsx("p",{className:"text-muted-foreground",children:"By accessing and using IsItUp.AI services, you accept and agree to be bound by the terms and provision of this agreement. These Terms of Service govern your use of our website monitoring and alerting services."})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Service Description"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"IsItUp.AI provides website and service monitoring solutions including:"}),n.jsxs("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:[n.jsx("li",{children:"HTTP(S) monitoring and uptime checking"}),n.jsx("li",{children:"SSL certificate monitoring"}),n.jsx("li",{children:"Port and ping monitoring"}),n.jsx("li",{children:"Real-time alerting and notifications"}),n.jsx("li",{children:"Status pages and reporting"})]})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"User Responsibilities"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"You agree to:"}),n.jsxs("ul",{className:"list-disc list-inside text-muted-foreground space-y-2",children:[n.jsx("li",{children:"Provide accurate and complete registration information"}),n.jsx("li",{children:"Maintain the security of your account credentials"}),n.jsx("li",{children:"Use the service in compliance with applicable laws"}),n.jsx("li",{children:"Not attempt to disrupt or interfere with our services"}),n.jsx("li",{children:"Pay all applicable fees when due"})]})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Service Availability"}),n.jsx("p",{className:"text-muted-foreground",children:"While we strive to maintain high service availability, we do not guarantee uninterrupted service. We reserve the right to perform maintenance and updates that may temporarily affect service availability."})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Limitation of Liability"}),n.jsx("p",{className:"text-muted-foreground",children:"IsItUp.AI shall not be liable for any indirect, incidental, special, consequential, or punitive damages resulting from your use of the service."})]}),n.jsxs("section",{className:"mb-8",children:[n.jsx("h2",{className:"text-xl font-semibold text-foreground mb-4",children:"Contact Information"}),n.jsxs("p",{className:"text-muted-foreground",children:["For questions about these Terms of Service, contact us at"," ",n.jsx("a",{href:"mailto:[email protected]",className:"text-primary hover:underline",children:"[email protected]"})]})]})]})]}),n.jsx("div",{className:"mt-8 text-center",children:n.jsx(_a,{to:"/",className:"text-primary hover:underline",children:"← Back to Home"})})]})}),zse=()=>n.jsx("div",{className:"min-h-screen bg-background",children:n.jsxs("div",{className:"max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-16",children:[n.jsxs("div",{className:"text-center mb-12",children:[n.jsx("h1",{className:"text-3xl font-bold text-foreground mb-4",children:"Support Center"}),n.jsx("p",{className:"text-lg text-muted-foreground",children:"We're here to help you get the most out of IsItUp.AI"})]}),n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 mb-12",children:[n.jsxs("div",{className:"space-y-6",children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(aa,{className:"h-5 w-5"}),"Email Support"]})}),n.jsxs(re,{children:[n.jsx("p",{className:"text-muted-foreground mb-4",children:"Get help via email for general questions and technical issues."}),n.jsx("p",{className:"font-medium",children:"[email protected]"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Response time: 24-48 hours"})]})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(I7,{className:"h-5 w-5"}),"Live Chat"]})}),n.jsxs(re,{children:[n.jsx("p",{className:"text-muted-foreground mb-4",children:"Chat with our support team for immediate assistance."}),n.jsx(H,{className:"w-full",children:"Start Live Chat"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"Available 9 AM - 6 PM EST"})]})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(q7,{className:"h-5 w-5"}),"Phone Support"]})}),n.jsxs(re,{children:[n.jsx("p",{className:"text-muted-foreground mb-4",children:"Call us for urgent issues (Premium plans only)."}),n.jsx("p",{className:"font-medium",children:"+1 (555) 123-4567"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Business hours only"})]})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-5 w-5"}),"Support Hours"]})}),n.jsx(re,{children:n.jsxs("div",{className:"space-y-2 text-sm",children:[n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Monday - Friday:"}),n.jsx("span",{children:"9:00 AM - 6:00 PM EST"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Saturday:"}),n.jsx("span",{children:"10:00 AM - 4:00 PM EST"})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx("span",{children:"Sunday:"}),n.jsx("span",{children:"Closed"})]})]})})]})]}),n.jsx("div",{children:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{children:"Send us a message"})}),n.jsx(re,{children:n.jsxs("form",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-foreground mb-2",children:"Name"}),n.jsx(ie,{id:"name",placeholder:"Your name"})]}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"email",className:"block text-sm font-medium text-foreground mb-2",children:"Email"}),n.jsx(ie,{id:"email",type:"email",placeholder:"[email protected]"})]}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"subject",className:"block text-sm font-medium text-foreground mb-2",children:"Subject"}),n.jsx(ie,{id:"subject",placeholder:"How can we help?"})]}),n.jsxs("div",{children:[n.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-foreground mb-2",children:"Message"}),n.jsx(kr,{id:"message",placeholder:"Describe your issue or question...",className:"min-h-[120px]"})]}),n.jsx(H,{type:"submit",className:"w-full",children:"Send Message"})]})})]})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{children:"Frequently Asked Questions"})}),n.jsx(re,{children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"font-medium text-foreground mb-2",children:"How often are monitoring checks performed?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Check intervals range from 30 seconds (premium plans) to 5 minutes (free plan)."})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"font-medium text-foreground mb-2",children:"What happens when downtime is detected?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"We perform a double-check from multiple locations before sending alerts to avoid false positives."})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"font-medium text-foreground mb-2",children:"Can I monitor internal services?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Yes, you can monitor any service accessible from the internet, including specific ports and protocols."})]}),n.jsxs("div",{children:[n.jsx("h3",{className:"font-medium text-foreground mb-2",children:"How do I upgrade my plan?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Log into your dashboard and navigate to the billing section to upgrade your monitoring plan."})]})]})})]}),n.jsx("div",{className:"mt-8 text-center",children:n.jsx(_a,{to:"/",className:"text-primary hover:underline",children:"← Back to Home"})})]})}),Bse=(e,t,r)=>{const{data:s,isLoading:a,error:i,refetch:o,dataUpdatedAt:l}=Ve({queryKey:["public-watchlist-monitors",e,t],queryFn:async()=>
674{if(!e||!t||!r)return[];const{data:c,error:d}=await B.functions.invoke("get-watchlist-monitors",{body:{clientId:e,watchlistId:t,sessionToken:r}});if(d)throw d;if(c!=null&&c.revoked)throw new Error("Session revoked");return(c==null?void 0:c.monitors)||[]},enabled:!!e&&!!t&&!!r,refetchInterval:15e3,staleTime:0,gcTime:0});return{monitors:s||[],isLoading:a,error:i,refetch:o,dataUpdatedAt:l}},qse=(e,t)=>{const{data:r,isLoading:s,error:a,refetch:i,dataUpdatedAt:o}=Ve({queryKey:["watchlist-monitors",e,t],queryFn:async()=>{if(!e)return[];if(t){const{data:h,error:f}=await B.from("watchlist_monitors").select(`
675            monitor_id,
676            monitoring_agents!inner (
677              id, name, asset_type, status, hostname_or_url, 
678              ip_address, protocol, monitoring_config, last_activated_at
679            )
680          `).eq("watchlist_id",t).eq("monitoring_agents.status","active");if(f)throw f;const m=(h==null?void 0:h.map(p=>p.monitoring_agents).filter(p=>p&&p.status==="active"))||[];return await Promise.all(m.map(async p=>{if(p.asset_type==="local_device"){const{data:y}=await B.from("agent_current_status").select("status, last_seen").eq("agent_id",p.id).eq("client_id",e).maybeSingle();let v=(y==null?void 0:y.status)||null;if(y!=null&&y.last_seen){const j=new Date(y.last_seen);(new Date().getTime()-j.getTime())/1e3>90&&(v="offline")}return{...p,agent_status:v,last_seen:(y==null?void 0:y.last_seen)||null}}return p}))}const{data:c,error:d}=await B.from("monitoring_agents").select("id, name, asset_type, status, hostname_or_url, ip_address, protocol, monitoring_config, last_activated_at").eq("client_id",e).eq("status","active").order("name",{ascending:!0});if(d)throw d;return await Promise.all(c.map(async h=>{if(h.asset_type==="local_device"){const{data:f}=await B.from("agent_current_status").select("status, last_seen").eq("agent_id",h.id).eq("client_id",e).maybeSingle();let m=(f==null?void 0:f.status)||null;if(f!=null&&f.last_seen){const g=new Date(f.last_seen);(new Date().getTime()-g.getTime())/1e3>90&&(m="offline")}return{...h,agent_status:m,last_seen:(f==null?void 0:f.last_seen)||null}}return h}))},enabled:!!e,refetchInterval:15e3});x.useEffect(()=>{if(!e)return;const c=[B.channel("watchlist-monitors-changes").on("postgres_changes",{event:"*",schema:"public",table:"monitoring_agents",filter:`client_id=eq.${e}`},()=>i()).subscribe(),B.channel("watchlist-monitor-assignments").on("postgres_changes",{event:"*",schema:"public",table:"watchlist_monitors"},()=>i()).subscribe()];return()=>{c.forEach(d=>B.removeChannel(d))}},[e,i]);const l={total:(r==null?void 0:r.length)||0,active:(r==null?void 0:r.filter(c=>c.status==="active").length)||0,inactive:(r==null?void 0:r.filter(c=>c.status!=="active").length)||0};return{monitors:r||[],stats:l,isLoading:s,error:a,refetch:i,dataUpdatedAt:o}};function Wse(){const{clientSlug:e,watchlistSlug:t}=qL(),{toast:r}=qr();di();const[s,a]=x.useState(""),[i,o]=x.useState(!1),[l,c]=x.useState(!1),[d,u]=x.useState(),[h,f]=x.useState(),[m,g]=x.useState(),[p,y]=x.useState(""),[v,j]=x.useState("all"),[b,_]=x.useState(),{monitors:w,isLoading:N,refetch:S,dataUpdatedAt:C}=Bse(d,h,b),[P,M]=x.useState("");x.useEffect(()=>{if(!C)return;const T=()=>{const W=Math.floor((Date.now()-C)/1e3);W<5?M("just now"):W<60?M(`${W}s ago`):M(`${Math.floor(W/60)}m ago`)};T();const k=setInterval(T,1e3);return()=>clearInterval(k)},[C]);const D=x.useMemo(()=>{const T=w.filter(W=>W.asset_type==="local_device"),k=w.filter(W=>W.asset_type!=="local_device");return{lanAgents:T,internetMonitors:k,stats:{totalAgents:T.length,totalMonitors:k.length,total:w.length}}},[w]);x.useEffect(()=>{const T=sessionStorage.getItem(`watchlist_${e}_${t}`);if(T){const k=JSON.parse(T);c(!0),u(k.client_id),f(k.watchlist_id),g(k.watchlist_name),_(k.session_token)}},[e,t]),x.useEffect(()=>{if(!l||!d||!h||!b)return;const T=async()=>{try{const{data:W,error:q}=await B.functions.invoke("watchlist-session-heartbeat",{body:{watchlistId:h,clientId:d,sessionToken:b,action:"heartbeat"}});if(q){console.error("Session heartbeat error:",q);return}W!=null&&W.revoked&&(console.log("Session revoked:",W.reason),sessionStorage.removeItem(`watchlist_${e}_${t}`),c(!1),u(void 0),f(void 0),g(void 0),_(void 0),r({title:"Session expired",description:W.reason==="Watchlist deactivated"?"This watchlist has been deactivated. Please contact the administrator.":"Your session has been revoked. Please log in again.",variant:"destructive"}))}catch(W){console.error("Session heartbeat error:",W)}};T();const k=setInterval(T,3e4);return()=>clearInterval(k)},[l,d,h,b,e,t,r]);const A=async T=>{T.preventDefault(),o(!0);try{const{data:k,error:W}=await B.functions.invoke("validate-watchlist-token",{body:{clientSlug:e,watchlistSlug:t,password:s}});if(W)throw W;if(k.valid){const q={client_id:k.client_id,watchlist_id:k.watchlist_id,watchlist_name:k.watchlist_name,session_token:k.session_token};sessionStorage.setItem(`watchlist_${e}_${t}`,JSON.stringify(q)),c(!0),u(k.client_id),f(k.watchlist_id),g(k.watchlist_name),_(k.session_token),r({t
680itle:"Access granted",description:`Welcome to ${k.watchlist_name}`})}else r({title:"Access denied",description:"Invalid password",variant:"destructive"})}catch(k){console.error("Validation error:",k),r({title:"Error",description:"Failed to validate access",variant:"destructive"})}finally{o(!1)}},U=(T,k)=>k==="local_device"?T==="online"?"bg-success":T==="offline"?"bg-destructive":"bg-muted":T==="active"?"bg-success":"bg-muted",F=x.useMemo(()=>{let T=D.lanAgents.filter(k=>k.name.toLowerCase().includes(p.toLowerCase())||k.hostname_or_url&&k.hostname_or_url.toLowerCase().includes(p.toLowerCase()));return v==="online"?T=T.filter(k=>k.agent_status==="online"):v==="offline"&&(T=T.filter(k=>k.agent_status==="offline")),T.sort((k,W)=>{const q={online:0,offline:1},Q=q[k.agent_status||""]??2,ue=q[W.agent_status||""]??2;return Q-ue})},[D.lanAgents,p,v]),L=x.useMemo(()=>{let T=D.internetMonitors.filter(k=>k.name.toLowerCase().includes(p.toLowerCase())||k.hostname_or_url&&k.hostname_or_url.toLowerCase().includes(p.toLowerCase()));return v==="online"?T=T.filter(k=>k.status==="active"):v==="offline"&&(T=T.filter(k=>k.status!=="active")),T.sort((k,W)=>{const q=k.status==="active"?0:1,Q=W.status==="active"?0:1;return q-Q})},[D.internetMonitors,p,v]),$=()=>{S()},R=async()=>{if(b)try{await B.functions.invoke("watchlist-session-heartbeat",{body:{sessionToken:b,action:"logout"}})}catch(T){console.error("Logout error:",T)}sessionStorage.removeItem(`watchlist_${e}_${t}`),c(!1),u(void 0),f(void 0),g(void 0),_(void 0),a(""),r({title:"Logged out",description:"You have been logged out of this watchlist."})};return l?n.jsxs("div",{className:"min-h-screen bg-background",children:[n.jsx("div",{className:"border-b bg-card",children:n.jsxs("div",{className:"container mx-auto px-4 py-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-4",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-2xl font-bold",children:m||"Watchlist Dashboard"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Private LAN Agents & Internet Monitors - Live Status"})]}),n.jsxs("div",{className:"flex flex-col items-end gap-1",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:$,children:[n.jsx(sr,{className:"h-4 w-4 mr-2"}),"Refresh"]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:R,children:[n.jsx(Gm,{className:"h-4 w-4 mr-2"}),"Logout"]})]}),P&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last refreshed: ",P]})]})]}),n.jsxs("div",{className:"flex gap-4 flex-wrap",children:[n.jsxs(ve,{variant:"outline",className:"text-base px-4 py-2",children:["LAN Agents: ",D.stats.totalAgents]}),n.jsxs(ve,{variant:"outline",className:"text-base px-4 py-2 border-primary text-primary",children:["Internet Monitors: ",D.stats.totalMonitors]}),n.jsxs(ve,{variant:"outline",className:"text-base px-4 py-2 border-accent text-accent",children:["Total: ",D.stats.total]})]})]})}),n.jsx("div",{className:"container mx-auto px-4 py-6",children:n.jsxs(cn,{defaultValue:"agents",className:"w-full",children:[n.jsxs(nn,{className:"mb-6",children:[n.jsx(at,{value:"agents",children:"Private LAN Agents"}),n.jsx(at,{value:"monitors",children:"Internet Monitors"})]}),n.jsxs("div",{className:"mb-4 flex gap-3",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search...",value:p,onChange:T=>y(T.target.value),className:"pl-10"})]}),n.jsxs(Fe,{value:v,onValueChange:T=>j(T),children:[n.jsx(Ie,{className:"w-[180px]",children:n.jsx(Ue,{placeholder:"Filter by status"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Status"}),n.jsx(J,{value:"online",children:"Online Only"}),n.jsx(J,{value:"offline",children:"Offline Only"})]})]})]}),n.jsx(it,{value:"agents",children:N?n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:"Loading agents..."})}):F.length===0?n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:p?"No agents found matching your search":"No LAN agents assigned to this wat
680chlist"})}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:F.map(T=>n.jsx(ee,{className:"hover:shadow-lg transition-shadow",children:n.jsx(re,{className:"pt-6",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ht,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"font-semibold truncate",children:T.name}),n.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${U(T.agent_status,T.asset_type)}`})]}),T.ip_address&&n.jsxs("p",{className:"text-xs text-muted-foreground mb-1 truncate",children:["IP: ",T.ip_address]}),(T.last_seen||T.last_activated_at)&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last Seen: ",$r(new Date(T.last_seen||T.last_activated_at),"MMM d, yyyy h:mm a")]})]})]})})},T.id))})}),n.jsx(it,{value:"monitors",children:N?n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:"Loading monitors..."})}):L.length===0?n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:p?"No monitors found matching your search":"No internet monitors assigned to this watchlist"})}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:L.map(T=>n.jsx(ee,{className:"hover:shadow-lg transition-shadow",children:n.jsx(re,{className:"pt-6",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(Wr,{className:"h-5 w-5 text-primary flex-shrink-0 mt-0.5"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx("h3",{className:"font-semibold truncate",children:T.name}),n.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${U(T.status,T.asset_type)}`})]}),T.hostname_or_url&&n.jsx("p",{className:"text-xs text-muted-foreground mb-1 truncate",children:T.hostname_or_url}),T.last_activated_at&&n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last Seen: ",$r(new Date(T.last_activated_at),"MMM d, yyyy h:mm a")]})]})]})})},T.id))})})]})}),n.jsx("div",{className:"fixed bottom-4 right-4",children:n.jsx(ve,{variant:"outline",className:"bg-background",children:"Auto-refresh: 15s"})})]}):n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:n.jsx(ee,{className:"w-full max-w-md",children:n.jsxs(re,{className:"pt-6",children:[n.jsxs("div",{className:"text-center mb-6",children:[n.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 bg-primary/10 rounded-full mb-4",children:n.jsx(Io,{className:"h-6 w-6 text-primary"})}),n.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Watchlist Dashboard"}),n.jsx("p",{className:"text-muted-foreground",children:"Enter password to access this watchlist"})]}),n.jsxs("form",{onSubmit:A,className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"password",children:"Password"}),n.jsx(ie,{id:"password",type:"password",placeholder:"Enter password",value:s,onChange:T=>a(T.target.value),disabled:i})]}),n.jsx(H,{type:"submit",className:"w-full",disabled:i,children:i?"Validating...":"Access Dashboard"})]})]})})})}const lw=768;function Hse(){const[e,t]=x.useState(void 0);return x.useEffect(()=>{const r=window.matchMedia(`(max-width: ${lw-1}px)`),s=()=>{t(window.innerWidth<lw)};return r.addEventListener("change",s),t(window.innerWidth<lw),()=>r.removeEventListener("change",s)},[]),!!e}const Vse=YC,Kse=QC,J5=x.forwardRef(({className:e,...t},r)=>n.jsx(fg,{className:we("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:r}));J5.displayName=fg.displayName;const Gse=Ed("fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",{variants:{side:{top:"inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",bottom:"inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",left:"inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",right:"inset-y-0 right-0 h-full w-3/4  border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"}},defaultVariants:{side:"right"}}),e6=x.forwardRef(({side:e="right",className:t,children:r,...s},a)=>n.jsxs(Kse,{children:[n.jsx(J5,{}),n.jsxs(mg,{ref:a,className:we(Gse({side:e}),t),...s,children:[r,n.jsxs(G0,{className:"absolute right-4 top-4 roun
680ded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-secondary hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[n.jsx(vn,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));e6.displayName=mg.displayName;const Yse=x.forwardRef(({className:e,...t},r)=>n.jsx(pg,{ref:r,className:we("text-lg font-semibold text-foreground",e),...t}));Yse.displayName=pg.displayName;const Qse=x.forwardRef(({className:e,...t},r)=>n.jsx(gg,{ref:r,className:we("text-sm text-muted-foreground",e),...t}));Qse.displayName=gg.displayName;function tt({className:e,...t}){return n.jsx("div",{className:we("animate-pulse rounded-md bg-muted",e),...t})}const Xse="sidebar:state",Zse=60*60*24*7,Jse="16rem",eae="18rem",tae="3rem",rae="b",t6=x.createContext(null);function vg(){const e=x.useContext(t6);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}const r6=x.forwardRef(({defaultOpen:e=!0,open:t,onOpenChange:r,className:s,style:a,children:i,...o},l)=>{const c=Hse(),[d,u]=x.useState(!1),[h,f]=x.useState(e),m=t??h,g=x.useCallback(j=>{const b=typeof j=="function"?j(m):j;r?r(b):f(b),document.cookie=`${Xse}=${b}; path=/; max-age=${Zse}`},[r,m]),p=x.useCallback(()=>c?u(j=>!j):g(j=>!j),[c,g,u]);x.useEffect(()=>{const j=b=>{b.key===rae&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),p())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[p]);const y=m?"expanded":"collapsed",v=x.useMemo(()=>({state:y,open:m,setOpen:g,isMobile:c,openMobile:d,setOpenMobile:u,toggleSidebar:p}),[y,m,g,c,d,u,p]);return n.jsx(t6.Provider,{value:v,children:n.jsx(Eu,{delayDuration:0,children:n.jsx("div",{style:{"--sidebar-width":Jse,"--sidebar-width-icon":tae,...a},className:we("group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",s),ref:l,...o,children:i})})})});r6.displayName="SidebarProvider";const n6=x.forwardRef(({side:e="left",variant:t="sidebar",collapsible:r="offcanvas",className:s,children:a,...i},o)=>{const{isMobile:l,state:c,openMobile:d,setOpenMobile:u}=vg();return r==="none"?n.jsx("div",{className:we("flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",s),ref:o,...i,children:a}):l?n.jsx(Vse,{open:d,onOpenChange:u,...i,children:n.jsx(e6,{"data-sidebar":"sidebar","data-mobile":"true",className:"w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":eae},side:e,children:n.jsx("div",{className:"flex h-full w-full flex-col",children:a})})}):n.jsxs("div",{ref:o,className:"group peer hidden text-sidebar-foreground md:block","data-state":c,"data-collapsible":c==="collapsed"?r:"","data-variant":t,"data-side":e,children:[n.jsx("div",{className:we("relative h-svh w-[--sidebar-width] bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon]")}),n.jsx("div",{className:we("fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] duration-200 ease-linear md:flex",e==="left"?"left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]":"right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]":"group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",s),...i,children:n.jsx("div",{"data-sidebar":"sidebar",className:"flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow",children:a})})]})});n6.displayName="Sidebar";const s6=x.forwardRef(({className:e,onClick:t,...r},s)=>{const{toggleSidebar:a}=vg();return n.jsxs(H,{ref:s,"data-sidebar":"trigger",variant:"ghost",size:"icon",className:we("h-7 w-7",e),onClick:i=>{t==null||t(i),a()},...r,children:[n.jsx(F7,{}),n.jsx("span",{className:"sr-only",children:"Toggle Sidebar"})]})});s6.displayName="SidebarTrigger";const nae=x.forwardRef(({className:e,...t},r)=>{const{toggleSidebar:s}=vg();return n.jsx("button",{ref:r,"data-sidebar":"rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:s,title:"Toggle Sidebar",className:we("absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] group-data-[side=left]:-right-4 group-data-[side=right]:left-0 hover:after:bg-sidebar-border sm:flex","[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})});nae.displayName="SidebarRail";const a6=x.forwardRef(({className:e,...t},r)=>n.jsx("main",{ref:r,className:we("relative flex min-h-svh flex-1 flex-col bg-background","peer-data-[variant=inset]:min-
680h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",e),...t}));a6.displayName="SidebarInset";const sae=x.forwardRef(({className:e,...t},r)=>n.jsx(ie,{ref:r,"data-sidebar":"input",className:we("h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",e),...t}));sae.displayName="SidebarInput";const aae=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"header",className:we("flex flex-col gap-2 p-2",e),...t}));aae.displayName="SidebarHeader";const iae=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"footer",className:we("flex flex-col gap-2 p-2",e),...t}));iae.displayName="SidebarFooter";const oae=x.forwardRef(({className:e,...t},r)=>n.jsx(ja,{ref:r,"data-sidebar":"separator",className:we("mx-2 w-auto bg-sidebar-border",e),...t}));oae.displayName="SidebarSeparator";const i6=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"content",className:we("flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t}));i6.displayName="SidebarContent";const hl=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"group",className:we("relative flex w-full min-w-0 flex-col p-2",e),...t}));hl.displayName="SidebarGroup";const tm=x.forwardRef(({className:e,asChild:t=!1,...r},s)=>{const a=t?oc:"div";return n.jsx(a,{ref:s,"data-sidebar":"group-label",className:we("flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",e),...r})});tm.displayName="SidebarGroupLabel";const lae=x.forwardRef(({className:e,asChild:t=!1,...r},s)=>{const a=t?oc:"button";return n.jsx(a,{ref:s,"data-sidebar":"group-action",className:we("absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","group-data-[collapsible=icon]:hidden",e),...r})});lae.displayName="SidebarGroupAction";const cae=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"group-content",className:we("w-full text-sm",e),...t}));cae.displayName="SidebarGroupContent";const Dc=x.forwardRef(({className:e,...t},r)=>n.jsx("ul",{ref:r,"data-sidebar":"menu",className:we("flex w-full min-w-0 flex-col gap-1",e),...t}));Dc.displayName="SidebarMenu";const hs=x.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,"data-sidebar":"menu-item",className:we("group/menu-item relative",e),...t}));hs.displayName="SidebarMenuItem";const dae=Ed("peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:!p-0"}},defaultVariants:{variant:"default",size:"default"}}),fs=x.forwardRef(({asChild:e=!1,isActive:t=!1,variant:r="default",size:s="default",tooltip:a,className:i,...o},l)=>{const c=e?oc:"button",{isMobile:d,state:u}=vg(),h=n.jsx(c,{ref:l,"data-sidebar":"menu-button","data-size":s,"data-active":t,className:we(dae({variant:r,size:s}),i),...o});
680return a?(typeof a=="string"&&(a={children:a}),n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:h}),n.jsx(Pi,{side:"right",align:"center",hidden:u!=="collapsed"||d,...a})]})):h});fs.displayName="SidebarMenuButton";const uae=x.forwardRef(({className:e,asChild:t=!1,showOnHover:r=!1,...s},a)=>{const i=t?oc:"button";return n.jsx(i,{ref:a,"data-sidebar":"menu-action",className:we("absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform peer-hover/menu-button:text-sidebar-accent-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0","after:absolute after:-inset-2 after:md:hidden","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",r&&"group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",e),...s})});uae.displayName="SidebarMenuAction";const hae=x.forwardRef(({className:e,...t},r)=>n.jsx("div",{ref:r,"data-sidebar":"menu-badge",className:we("pointer-events-none absolute right-1 flex h-5 min-w-5 select-none items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground","peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground","peer-data-[size=sm]/menu-button:top-1","peer-data-[size=default]/menu-button:top-1.5","peer-data-[size=lg]/menu-button:top-2.5","group-data-[collapsible=icon]:hidden",e),...t}));hae.displayName="SidebarMenuBadge";const fae=x.forwardRef(({className:e,showIcon:t=!1,...r},s)=>{const a=x.useMemo(()=>`${Math.floor(Math.random()*40)+50}%`,[]);return n.jsxs("div",{ref:s,"data-sidebar":"menu-skeleton",className:we("flex h-8 items-center gap-2 rounded-md px-2",e),...r,children:[t&&n.jsx(tt,{className:"size-4 rounded-md","data-sidebar":"menu-skeleton-icon"}),n.jsx(tt,{className:"h-4 max-w-[--skeleton-width] flex-1","data-sidebar":"menu-skeleton-text",style:{"--skeleton-width":a}})]})});fae.displayName="SidebarMenuSkeleton";const DN=x.forwardRef(({className:e,...t},r)=>n.jsx("ul",{ref:r,"data-sidebar":"menu-sub",className:we("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5","group-data-[collapsible=icon]:hidden",e),...t}));DN.displayName="SidebarMenuSub";const rm=x.forwardRef(({...e},t)=>n.jsx("li",{ref:t,...e}));rm.displayName="SidebarMenuSubItem";const nm=x.forwardRef(({asChild:e=!1,size:t="md",isActive:r,className:s,...a},i)=>{const o=e?oc:"a";return n.jsx(o,{ref:i,"data-sidebar":"menu-sub-button","data-size":t,"data-active":r,className:we("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground","data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",t==="sm"&&"text-xs",t==="md"&&"text-sm","group-data-[collapsible=icon]:hidden",s),...a})});nm.displayName="SidebarMenuSubButton";const mae="/assets/isitup-logo-BlQMWwxL.png",cw="show-monitoring-menu",dw="monitoring-visibility-change";function o6(){const[e,t]=x.useState(()=>localStorage.getItem(cw)==="true"),r=x.useCallback(s=>{t(a=>{const i=typeof s=="function"?s(a):s;return localStorage.setItem(cw,String(i)),window.dispatchEvent(new CustomEvent(dw,{detail:i})),i})},[]);return x.useEffect(()=>{const s=i=>{i.key===cw&&t(i.newValue==="true")},a=i=>{t(i.detail)};return window.addEventListener("storage",s),window.addEventListener(dw,a),()=>{window.removeEventListener("storage",s),window.removeEventListener(dw,a)}},[]),{showMonitoringMenu:e,setShowMonitoringMenu:r}}function Vi(e,t){const r=Et(),{toast:s}=qr(),{data:a=[],isLoading:i,error:o}=Ve({queryKey:["monitor-groups",e],queryFn:async()=>
680{if(!e)return[];const{data:m,error:g}=await B.from("monitor_groups").select("*").eq("client_id",e).order("sort_order",{ascending:!0}).order("name");if(g)throw g;return m},enabled:!!e,refetchInterval:3e4}),l=mt({mutationFn:async m=>{if(!e)throw new Error("Client ID is required");const{data:g,error:p}=await B.from("monitor_groups").insert({client_id:e,name:m.name,description:m.description,notes:m.notes,is_critical:m.is_critical||!1,sort_order:m.sort_order||0}).select().single();if(p)throw p;return g},onSuccess:()=>{r.invalidateQueries({queryKey:["monitor-groups"]}),s({title:"Success",description:"Group created successfully"})},onError:m=>{s({title:"Error",description:m.message||"Failed to create group",variant:"destructive"})}}),c=mt({mutationFn:async({id:m,...g})=>{const{error:p}=await B.from("monitor_groups").update(g).eq("id",m);if(p)throw p},onSuccess:()=>{r.invalidateQueries({queryKey:["monitor-groups"]}),s({title:"Success",description:"Group updated successfully"})},onError:m=>{s({title:"Error",description:m.message||"Failed to update group",variant:"destructive"})}}),d=mt({mutationFn:async m=>{const{error:g}=await B.from("monitor_groups").delete().eq("id",m);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["monitor-groups"]}),s({title:"Success",description:"Group deleted successfully"})},onError:m=>{s({title:"Error",description:m.message||"Failed to delete group",variant:"destructive"})}}),u=mt({mutationFn:async({agentId:m,groupId:g})=>{if(!e)throw new Error("Client ID is required");const{error:p}=await B.from("agent_groups").insert({client_id:e,agent_id:m,group_id:g});if(p)throw p},onSuccess:()=>{r.invalidateQueries({queryKey:["agent-groups"]}),r.invalidateQueries({queryKey:["agent-statuses"]}),r.invalidateQueries({queryKey:["group-members"]}),r.invalidateQueries({queryKey:["group-member-counts"]})},onError:m=>{throw console.error("Failed to assign agent to group:",m),m}}),h=mt({mutationFn:async({agentId:m,groupId:g})=>{const{error:p}=await B.from("agent_groups").delete().eq("agent_id",m).eq("group_id",g);if(p)throw p},onSuccess:()=>{r.invalidateQueries({queryKey:["agent-groups"]}),r.invalidateQueries({queryKey:["agent-statuses"]}),r.invalidateQueries({queryKey:["group-members"]}),r.invalidateQueries({queryKey:["group-member-counts"]})},onError:m=>{throw console.error("Failed to remove agent from group:",m),m}}),{data:f=[]}=Ve({queryKey:["group-members",t],queryFn:async()=>{if(!t||!e)return[];const{data:m,error:g}=await B.from("agent_groups").select("agent_id").eq("group_id",t).eq("client_id",e);if(g)throw g;return m.map(p=>p.agent_id)},enabled:!!t&&!!e});return{groups:a,isLoading:i,error:o,currentGroupMembers:f,createGroup:l.mutate,updateGroup:c.mutate,deleteGroup:d.mutate,assignAgentToGroup:u.mutateAsync,removeAgentFromGroup:h.mutateAsync,isCreating:l.isPending,isUpdating:c.isPending,isDeleting:d.isPending}}var rj="Collapsible",[pae,uRe]=Qr(rj),[gae,hk]=pae(rj),l6=x.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:s,defaultOpen:a,disabled:i,onOpenChange:o,...l}=e,[c,d]=Bs({prop:s,defaultProp:a??!1,onChange:o,caller:rj});return n.jsx(gae,{scope:r,disabled:i,contentId:ta(),open:c,onOpenToggle:x.useCallback(()=>d(u=>!u),[d]),children:n.jsx(We.div,{"data-state":mk(c),"data-disabled":i?"":void 0,...l,ref:t})})});l6.displayName=rj;var c6="CollapsibleTrigger",d6=x.forwardRef((e,t)=>{const{__scopeCollapsible:r,...s}=e,a=hk(c6,r);return n.jsx(We.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":mk(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...s,ref:t,onClick:Te(e.onClick,a.onOpenToggle)})});d6.displayName=c6;var fk="CollapsibleContent",u6=x.forwardRef((e,t)=>{const{forceMount:r,...s}=e,a=hk(fk,e.__scopeCollapsible);return n.jsx(jn,{present:r||a.open,children:({present:i})=>n.jsx(xae,{...s,ref:t,present:i})})});u6.displayName=fk;var xae=x.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:s,children:a,...i}=e,o=hk(fk,r),[l,c]=x.useState(s),d=x.useRef(null),u=nt(t,d),h=x.useRef(0),f=h.current,m=x.useRef(0),g=m.current,p=o.open||l,y=x.useRef(p),v=x.useRef(void 0);return x.useEffect(()=>{const j=requestAnimationFrame(()=>y.current=!1);return()=>cancelAnimationFrame(j)},[]),Ur(()=>{const j=d.current;if(j){v.current=v.current||{transitionDuration:j.style.transitionDuration,animationName:j.style.animationName},j.style.transitionDuration="0s",j.style.animationName="none";const b=j.getBoundingClientRect();h.current=b.height,m.current=b.width,y.current||(j.style.transitionDuration=v.current.transitionDuration,j.style.animationName=v.current.animationName),c(s)}},[o.open,s]),n.jsx(We.div,{"data-state":mk(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!p,...i,ref:u,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:p&&a})});function mk(e){return e?"open":"closed"}var vae=l6;const ur=vae,Jr=d6,Er=u6,yae=[{title:"HTTP/Website",url:"/dashboard/monitors/http",icon:Pn,disabled:!1},{title:"SSL Certificate",url:"/dashboard/monitors/ssl",icon:yt,disabled:!1},{title:"TCP/UDP Port",url:"/dashboard/monitors/tcp-udp",icon:N0,disabled:!1},{title:"DNS",url:"/dashboard/monitors/dns",icon:E7,disabled:!1},{title:"Ping",url:"/dashboard/monitors/ping",icon:Wr,disabled:!1},{title:"Keyword",url:"/dashboard/monitors/keyword",icon:qt,disabled:!1},{title:"SMTP",url:"/dashboard/monitors/smtp",icon:aa,disabled:!1},{title:"FTP",url:"/dashboard/monitors/ftp",icon:Pu,disabled:!0},{title:"SFTP",url:"/dashboard/monitors/sftp",icon:Io,disabled:!0},{title:"FTPS",url:"/dashboard/monitors/ftps",icon:Io,disabled:!0}];function jae(){var j;const{open:e}=vg(),{isProviderAdmin:t,clientMemberships:r,selectedClientId:s}=Mt(),{showMonitoringMenu:a}=o6(),i=Zo(),[o]=RC(),l=r.find(b=>b.client_id===s),c=(l==null?void 0:l.role)||(t?"provider_admin":"user"),{groups:d=[]}=Vi(s),{agentStatuses:u}=dc(),{data:h=[]}=Ve({queryKey:["agent-groups-sidebar",s],enabled:!!s,queryFn:async()=>{const{data:b,error:_}=await B.from("agent_groups").select("agent_id, group_id").eq("client_id",s);if(_)throw _;return b||[]}}),{data:f=[]}=Ve({queryKey:["private-agents-sidebar",s],enabled:!!s,queryFn:async()=>{const{data:b,error:_}=await B.from("monitoring_agents").select("id").eq("client_id",s).eq("asset_type","local_device");if(_)throw _;return b||[]}}),m=x.useMemo(()=>{const b={};return h.forEach(_=>{b[_.agent_id]||(b[_.agent_id]=[]),b[_.agent_id].push(_.group_id)}),b},[h]),g=x.useMemo(()=>{const b={};d.forEach(w=>{const N=Object.entries(m).filter(([C,P])=>P.includes(w.id)).map(([C])=>C),S=f.filter(C=>N.includes(C.id));b[w.id]={total:S.length,online:S.filter(C=>{const P=u==null?void 0:u.find(M=>M.agent_id===C.id);return(P==null?void 0:P.status)==="online"}).length}});const _=f.filter(w=>!(m[w.id]&&m[w.id].length>0));return b.ungrouped={total:_.length,online:_.filter(w=>{const N=u==null?void 0:u.find(S=>S.agent_id===w.id);return(N==null?void 0:N.status)==="online"}).length},b},[f,u,d,m]),p=i.pathname==="/dashboard/agents"?o.get("group"):null,y=b=>b?"bg-sidebar-accent text-sidebar-accent-foreground font-medium":"hover:bg-sidebar-accent/50",v=b=>i.pathname==="/dashboard/agents"&&p===b?"bg-sidebar-accent text-sidebar-accent-foreground font-medium":"hover:bg-sidebar-accent/50";return n.jsx(n6,{collapsible:"icon",children:n.jsxs(i6,{children:[n.jsx(hl,{children:n.jsxs("div",{className:"px-4 py-3 flex items-center gap-2",children:[n.jsx("img",{src:mae,alt:"IsItUp.AI",className:"h-10 w-10"}),e&&n.jsx("span",{className:"font-semibold text-lg",children:"IsItUp.AI"})]})}),n.jsx(hl,{children:n.jsx(Dc,{children:n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/overview",className:({isActive:b})=>y(b),children:[n.jsx(M7,{className:"h-4 w-4"}),n.jsx("span",{children:"Dashboard"})]})})})})}),c==="provider_admin"&&n.jsxs(hl,{children:[n.jsx(tm,{children:"Platform Admin"}),n.jsxs(Dc,{children:[n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/clients",className:({isActive:b})=>y(b),children:[n.jsx(Ea,{className:"h-4 w-4"}),n.jsx("span",{children:"Clients"})]})})}),n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/system-templates",className:({isActive:b})=>y(b),children:[n.jsx(Dl,{className:"h-4 w-4"}),n.jsx("span",{children:"Platform Scripts"})]})})}),n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/platform-stats",className:({isActive:b})=>y(b),children:[n.jsx(C7,{className:"h-4 w-4"}),n.jsx("span",{children:"Platform Stats"})]})})})]})]}),c==="provider_admin"&&n.jsxs(hl,{children:[n.jsx(tm,{children:"Security"}),n.jsxs(Dc,{children:[n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/audit-logs",className:({isActive:b})=>y(b),children:[n.jsx(W7,{className:"h-4 w-4"}),n.jsx("span",{children:"Audit Logs"})]})})}),n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/user-sessions",className:({isActive:b})=>y(b),children:[n.jsx(Y7,{className:"h-4 w-4"}),n.jsx("span",{children:"User Sessions"})]})})})]})]}),(c!=="provider_admin"||a)&&n.jsxs(hl,{children:[n.jsx(tm,{children:"Monitoring"}),n.jsxs(Dc,{children:[n.jsx(ur,{className:"group/collapsible",children:n.jsxs(hs,{children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(fs,{children:[n.jsx(Pn,{className:"h-4 w-4"}),n.jsx("span",{children:"Internet Monitors"}),n.jsx(dr,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible:rotate-180"})]})}),n.jsx(Er,{children:n.jsx(DN,{children:yae.map(b=>n.jsx(rm,{children:n.jsx(nm,{asChild:!b.disabled,children:b.disabled?n.jsxs("span",{className:"flex items-center gap-2 opacity-50 cursor-not-allowed",children:[n.jsx(b.icon,{className:"h-4 w-4"}),n.jsx("span",{children:b.title}),n.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:"Soon"})]}):n.jsxs(Qn,{to:b.url,className:({isActive:_})=>y(_),children:[n.jsx(b.icon,{className:"h-4 w-4"}),n.jsx("span",{children:b.title})]})})},b.url))})})]})}),(c==="provider_admin"||c==="client_admin"||c==="org_admin"||c==="manager")&&n.jsx(ur,{className:"group/collapsible-agents",defaultOpen:i.pathname==="/dashboard/agents",children:n.jsxs(hs,{children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(fs,{children:[n.jsx(ht,{className:"h-4 w-4"}),n.jsx("span",{children:"Private LAN Agents"}),n.jsx(dr,{className:"ml-auto h-4 w-4 transition-transform group-data-[state=open]/collapsible-agents:rotate-180"})]})}),n.jsx(Er,{children:n.jsxs(DN,{children:[n.jsx(rm,{children:n.jsx(nm,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/agents",className:v(null),end:!0,children:[n.jsx(ht,{className:"h-4 w-4"}),n.jsx("span",{children:"All Agents"})]})})}),((j=g.ungrouped)==null?void 0:j.total)>0&&n.jsx(rm,{children:n.jsx(nm,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/agents?group=ungrouped",className:v("ungrouped"),children:[n.jsx(Vm,{className:"h-4 w-4"}),n.jsx("span",{children:"Ungrouped"}),n.jsxs(ve,{variant:"secondary",className:"ml-auto text-xs px-1.5 py-0",children:[g.ungrouped.online,"/",g.ungrouped.total]})]})})}),d.filter(b=>b.is_critical).map(b=>{var _,w;return n.jsx(rm,{children:n.jsx(nm,{asChild:!0,children:n.jsxs(Qn,{to:`/dashboard/agents?group=${b.id}`,className:v(b.id),children:[n.jsx(Sv,{className:"h-4 w-4 text-yellow-500"}),n.jsx("span",{className:"truncate",children:b.name}),n.jsxs(ve,{variant:"secondary",className:"ml-auto text-xs px-1.5 py-0",children:[((_=g[b.id])==null?void 0:_.online)||0,"/",((w=g[b.id])==null?void 0:w.total)||0]})]})})},b.id)})]})})]})})]})]}),n.jsxs(hl,{children:[n.jsx(tm,{children:"Management"}),n.jsxs(Dc,{children:[n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/alerts",className:({isActive:b})=>y(b),children:[n.jsx(ii,{className:"h-4 w-4"}),n.jsx("span",{children:"Alerts"})]})})}),(c==="provider_admin"||c==="client_admin"||c==="org_admin")&&n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/groups",className:({isActive:b})=>y(b),children:[n.jsx(Rr,{className:"h-4 w-4"}),n.jsx("span",{children:"Groups"})]})})}),(c==="provider_admin"||c==="client_admin"||c==="org_admin"||c==="manager")&&n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/commands",className:({isActive:b})=>y(b),children:[n.jsx(ws,{className:"h-4 w-4"}),n.jsx("span",{children:"Scripts"})]})})}),(c==="provider_admin"||c==="client_admin")&&n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/watchlists",className:({isActive:b})=>y(b),children:[n.jsx($o,{className:"h-4 w-4"}),n.jsx("span",{children:"Dashboards"})]})})})]})]}),n.jsx(hl,{children:n.jsxs(Dc,{children:[n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/settings",className:({isActive:b})=>y(b),children:[n.jsx(Qo,{className:"h-4 w-4"}),n.jsx("span",{children:"Settings"})]})})}),n.jsx(hs,{children:n.jsx(fs,{asChild:!0,children:n.jsxs(Qn,{to:"/dashboard/help",className:({isActive:b})=>y(b),children:[n.jsx(Hm,{className:"h-4 w-4"}),n.jsx("span",{children:"Help"})]})})})]})})]})})}const h6=e=>{const{user:t}=Mt(),{toast:r}=qr(),s=Et(),{data:a,isLoading:i,error:o,refetch:l}=Ve({queryKey:["help-requests",e,t==null?void 0:t.id],queryFn:async()=>
680{if(!e||!(t!=null&&t.id))return[];const{data:u,error:h}=await B.from("help_requests").select("*").eq("client_id",e).order("created_at",{ascending:!1});if(h)throw h;return u},enabled:!!e&&!!(t!=null&&t.id)}),c=mt({mutationFn:async u=>{if(!e||!(t!=null&&t.id))throw new Error("Missing client ID or user authentication");const{data:h,error:f}=await B.from("help_requests").insert([{client_id:e,user_id:t.id,tenant_customer_id:u.tenant_customer_id,title:u.title,description:u.description,type:u.type,priority:u.priority}]).select().single();if(f)throw f;return h},onSuccess:()=>{s.invalidateQueries({queryKey:["help-requests"]}),r({title:"Help request submitted",description:"Your request has been submitted successfully. We'll get back to you soon!"})},onError:u=>{r({title:"Error submitting request",description:u instanceof Error?u.message:"Failed to submit help request",variant:"destructive"})}});return{helpRequests:a||[],isLoading:i,error:o,refetch:l,createHelpRequest:u=>{c.mutate(u)},isCreating:c.isPending}};function bae({isOpen:e,onClose:t,onSubmit:r,isSubmitting:s,tenantCustomerId:a,context:i}){const[o,l]=x.useState({title:"",description:"",type:"general_help",priority:"medium",tenant_customer_id:a}),c=h=>{h.preventDefault(),!(!o.title.trim()||!o.description.trim())&&r(o)},d=()=>{l({title:"",description:"",type:"general_help",priority:"medium",tenant_customer_id:a}),t()},u=()=>i==="internet"?"Submit a help request related to Internet Monitoring (HTTP, SSL, API, DNS, etc.)":"Submit a help request related to Private LAN Agent monitoring";return n.jsx(er,{open:e,onOpenChange:d,children:n.jsxs(Kt,{className:"sm:max-w-[500px]",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Submit Help Request"}),n.jsx(_s,{children:u()})]}),n.jsxs("form",{onSubmit:c,className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"type",children:"Request Type"}),n.jsxs(Fe,{value:o.type,onValueChange:h=>l({...o,type:h}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"general_help",children:"General Help"}),n.jsx(J,{value:"bug_report",children:"Bug Report"}),n.jsx(J,{value:"feature_request",children:"Feature Request"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"priority",children:"Priority"}),n.jsxs(Fe,{value:o.priority,onValueChange:h=>l({...o,priority:h}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"low",children:"Low"}),n.jsx(J,{value:"medium",children:"Medium"}),n.jsx(J,{value:"high",children:"High"})]})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"title",children:"Title"}),n.jsx(ie,{id:"title",value:o.title,onChange:h=>l({...o,title:h.target.value}),placeholder:"Brief summary of your request...",required:!0})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:o.description,onChange:h=>l({...o,description:h.target.value}),placeholder:"Provide detailed information about your request...",rows:4,required:!0})]}),n.jsxs("div",{className:"flex gap-2 pt-4",children:[n.jsx(H,{type:"submit",disabled:s,className:"flex-1",children:s?"Submitting...":"Submit Request"}),n.jsx(H,{type:"button",variant:"outline",onClick:d,disabled:s,children:"Cancel"})]})]})]})})}const f6=x.createContext(null);function wae({children:e,selectedClientId:t}){const[r,s]=x.useState(!1),[a,i]=x.useState("internet"),[o,l]=x.useState(),[c,d]=x.useState(null),{createHelpRequest:u,isCreating:h}=h6(t||""),f=(y,v)=>{i(y),l(v),s(!0)},m=()=>{s(!1),i("internet"),l(void 0)},g=y=>{u(y),m(),setTimeout(()=>{c&&c(a)},500)},p={openHelpModal:f,isModalOpen:r,closeModal:m,navigateToHelpTab:c,setNavigateToHelpTab:d};return n.jsxs(f6.Provider,{value:p,children:[e,n.jsx(bae,{isOpen:r,onClose:m,onSubmit:g,isSubmitting:h,tenantCustomerId:o,context:a})]})}function _ae(){const e=x.useContext(f6);if(!e)throw new Error("useHelpRequestModal must be used within a HelpRequestProvider");return e}function Nae({children:e}){const{user:t,selectedClientId:r}=Mt(),s=di(),{toast:a}=qr(),i=async()=>{try{await B.auth.signOut(),s("/"),a({title:"Signed out successfully",description:"You have been signed out of your account."})}catch{a({title:"Error signing out",description:"There was a problem signing out. Please try again.",variant:"destructive"})}};return n.jsx(wae,{selectedClientId:r||"",children:n.jsx(r6,{children:n.jsxs("div",{className:"min-h-screen flex w-full bg-background",children:[n.jsx(jae,{}),n.jsxs(a6,{className:"flex-1",children:[n.jsxs("header",{className:"sticky top-0 z-10 flex h-14 items-center gap-4 border-b bg-background px-4",children:[n.jsx(s6,{}),n.jsx("div",{className:"flex-1"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:t==null?void 0:t.email}),n.jsx(H,{variant:"ghost",size:"icon",onClick:i,title:"Sign Out",children:n.jsx(Gm,{className:"h-4 w-4"})})]})]}),n.jsx("main",{className:"flex-1 p-6",children:e})]})]})})})}function Sae(e){const t=Et();x.useEffect(()=>{if(!e)return;const i=B.channel("monitoring-agent-changes").on("postgres_changes",{event:"*",schema:"public",table:"monitoring_agents",filter:`client_id=eq.${e}`},()=>{t.invalidateQueries({queryKey:["internet-monitor-stats",e]})}).on("postgres_changes",{event:"*",schema:"public",table:"monitor_checks"},()=>{t.invalidateQueries({queryKey:["internet-monitor-stats",e]})}).subscribe();return()=>{B.removeChannel(i)}},[e]);const{data:r,isLoading:s,error:a}=Ve({queryKey:["internet-monitor-stats",e],queryFn:async()=>
680{if(!e)return{total:0,active:0,up:0,down:0};const{data:i,error:o}=await B.from("monitoring_agents").select("id, status").eq("client_id",e).neq("asset_type","local_device");if(o)throw o;const l=(i==null?void 0:i.length)||0,c=(i==null?void 0:i.filter(N=>N.status==="active"))||[],d=c.length;if(d===0)return{total:l,active:d,up:0,down:0};const u=c.map(N=>N.id),{data:h,error:f}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",u);if(f)throw f;if(!h||h.length===0)return{total:l,active:d,up:0,down:0};const m=h.map(N=>N.id),{data:g,error:p}=await B.from("monitor_checks").select("monitor_id, status, timestamp").in("monitor_id",m).order("timestamp",{ascending:!1});if(p)throw p;const y=new Map;g==null||g.forEach(N=>{y.has(N.monitor_id)||y.set(N.monitor_id,N)});let v=0,j=0;y.forEach(N=>{N.status==="success"?v++:j++});const b=y.size,w=h.length-b;return j+=w,{total:l,active:d,up:v,down:j}},enabled:!!e,refetchInterval:3e4});return{stats:r||{total:0,active:0,up:0,down:0},isLoading:s,error:(a==null?void 0:a.message)||null}}function Cae(){return{check_interval:300,timeout_seconds:30,alert_threshold:3,escalation_enabled:!1,expected_status_codes:"200,201,202,204",follow_redirects:!0,status_monitoring_strategy:"standard"}}function kae(e){const t=Cae();return{...e,check_interval:typeof(e==null?void 0:e.check_interval)=="number"&&e.check_interval>0?e.check_interval:t.check_interval,timeout_seconds:typeof(e==null?void 0:e.timeout_seconds)=="number"&&e.timeout_seconds>0?e.timeout_seconds:t.timeout_seconds,alert_threshold:typeof(e==null?void 0:e.alert_threshold)=="number"&&e.alert_threshold>0?e.alert_threshold:t.alert_threshold,escalation_enabled:typeof(e==null?void 0:e.escalation_enabled)=="boolean"?e.escalation_enabled:t.escalation_enabled,expected_status_codes:typeof(e==null?void 0:e.expected_status_codes)=="string"&&e.expected_status_codes.match(/^[0-9]+(,[0-9]+)*$/)?e.expected_status_codes:t.expected_status_codes,follow_redirects:typeof(e==null?void 0:e.follow_redirects)=="boolean"?e.follow_redirects:t.follow_redirects,status_monitoring_strategy:["standard","restricted","custom"].includes(e==null?void 0:e.status_monitoring_strategy)?e.status_monitoring_strategy:t.status_monitoring_strategy}}function Ra(){const{toast:e}=qr(),t=Et(),r=mt({mutationFn:async()=>{const{data:a,error:i}=await B.from("monitoring_agents").select("id, monitoring_config").eq("asset_type","website").eq("status","active");if(i)throw i;if(a){const c=a.filter(d=>{const u=d.monitoring_config;return!(u!=null&&u.expected_status_codes)||u.expected_status_codes===void 0}).map(d=>({id:d.id,monitoring_config:kae(d.monitoring_config)}));if(c.length>0){console.log(`Updating ${c.length} agents with missing HTTP status code configuration`);for(const d of c)await B.from("monitoring_agents").update({monitoring_config:d.monitoring_config}).eq("id",d.id)}}const{data:o,error:l}=await B.functions.invoke("monitor-websites",{body:{}});if(l)throw l;return o},onSuccess:a=>{t.invalidateQueries({queryKey:["monitor-checks"]}),t.invalidateQueries({queryKey:["monitor-status"]}),e({title:"Monitoring Check Complete",description:`Successfully checked ${a.checked||0} websites`})},onError:a=>{e({title:"Monitoring Check Failed",description:a.message,variant:"destructive"})}}),s=mt({mutationFn:async a=>{const{data:i,error:o}=await B.from("monitoring_agents").select("*").eq("id",a).single();if(o)throw o;const{data:l,error:c}=await B.functions.invoke("monitor-websites",{body:{agentId:a}});if(c)throw c;return{...l,agentName:i.name,assetType:i.asset_type,clientId:i.client_id}},onSuccess:(a,i)=>{t.invalidateQueries({queryKey:["monitor-checks"]}),t.invalidateQueries({queryKey:["monitor-status",i]}),a.assetType==="dns"?(t.invalidateQueries({queryKey:["dns-monitors",a.clientId]}),t.invalidateQueries({queryKey:["dns-monitor-metrics",a.clientId]})):a.assetType==="http"||a.assetType==="website"?(t.invalidateQueries({queryKey:["http-monitors",a.clientId]}),t.invalidateQueries({queryKey:["http-monitor-metrics",a.clientId]})):a.assetType==="ssl"&&(t.invalidateQueries({queryKey:["ssl-monitors",a.clientId]}),t.invalidateQueries({queryKey:["ssl-monitor-metrics",a.clientId]})),e({title:"Monitor Check Complete",description:`Successfully checked ${a.agentName} (${a.assetType} monitor)`})},onError:a=>{e({title:"Monitor Check Failed",description:a.message,variant:"destructive"})}});return{runMonitoringChecks:r.mutate,runSingleMonitorCheck:s.mutate,isRunning:r.isPending,isSingleCheckRunning:s.isPending,lastResult:r.data}}function Lt(e){const t=Et(),{toast:r}=qr(),{runMonitoringChecks:s}=Ra();x.useEffect(()=>{if(!e)return;console.log("useMonitoringAgents: Setting up real-time subscription for client:",e);
680const m=B.channel("monitoring_agents_changes").on("postgres_changes",{event:"*",schema:"public",table:"monitoring_agents",filter:`client_id=eq.${e}`},g=>{console.log("useMonitoringAgents: Real-time update received:",g),t.invalidateQueries({queryKey:["monitoring-agents",e]}),t.invalidateQueries({queryKey:["agent-heartbeats"]}),t.invalidateQueries({queryKey:["agent-statuses"]}),t.invalidateQueries({queryKey:["agent-api-keys"]})}).subscribe();return()=>{console.log("useMonitoringAgents: Cleaning up real-time subscription"),B.removeChannel(m)}},[e,t]);const{data:a=[],isLoading:i,error:o,refetch:l}=Ve({queryKey:["monitoring-agents",e],queryFn:async()=>{if(!e)return[];console.log("useMonitoringAgents: Fetching agents for client:",e);const{data:m,error:g}=await B.from("monitoring_agents").select("*").eq("client_id",e).order("created_at",{ascending:!1});if(g)throw g;return console.log("useMonitoringAgents: Raw agents fetched:",(m==null?void 0:m.map(p=>({id:p.id,name:p.name,asset_type:p.asset_type})))||[]),m||[]},enabled:!!e}),c=mt({mutationFn:async m=>{console.log("createAgent: Starting with data:",m);const{data:g,error:p}=await B.from("monitoring_agents").insert([m]).select().single();if(p)throw console.error("createAgent: Database error:",p),p;return console.log("createAgent: Success, created agent:",g),g},onSuccess:m=>{t.invalidateQueries({queryKey:["monitoring-agents"]}),t.invalidateQueries({queryKey:["dns-monitors"]}),t.invalidateQueries({queryKey:["http-monitors"]}),t.invalidateQueries({queryKey:["ssl-monitors"]}),t.invalidateQueries({queryKey:["dns-monitor-metrics"]}),t.invalidateQueries({queryKey:["http-monitor-metrics"]}),t.invalidateQueries({queryKey:["ssl-monitor-metrics"]}),(m.asset_type==="website"||m.asset_type==="saas"||m.asset_type==="ping")&&setTimeout(()=>{s(),t.invalidateQueries({queryKey:["monitor-status"]}),t.invalidateQueries({queryKey:["monitor-checks"]})},500),r({title:"Success",description:"Monitoring agent created successfully"})},onError:m=>{r({title:"Error",description:m.message,variant:"destructive"})}}),d=mt({mutationFn:async({id:m,...g})=>{const{data:p,error:y}=await B.from("monitoring_agents").update(g).eq("id",m).select().single();if(y)throw y;return p},onSuccess:m=>{t.invalidateQueries({queryKey:["monitoring-agents",m.client_id]}),t.invalidateQueries({queryKey:["monitoring-agents"]}),t.invalidateQueries({queryKey:["dns-monitors"]}),t.invalidateQueries({queryKey:["http-monitors"]}),t.invalidateQueries({queryKey:["ssl-monitors"]}),t.invalidateQueries({queryKey:["dns-monitor-metrics"]}),t.invalidateQueries({queryKey:["http-monitor-metrics"]}),t.invalidateQueries({queryKey:["ssl-monitor-metrics"]}),(m.asset_type==="website"||m.asset_type==="saas")&&setTimeout(()=>{s()},1e3),r({title:"Success",description:"Monitoring agent updated successfully"})},onError:m=>{r({title:"Error",description:m.message,variant:"destructive"})}}),u=mt({mutationFn:async m=>{console.log("deleteAgent: Starting deletion for agent:",m);const{data:g,error:p}=await B.from("monitoring_agents").select("id, name, client_id, asset_type, hostname_or_url").eq("id",m).single();if(p)throw console.error("deleteAgent: Failed to fetch agent details:",p),p;console.log("deleteAgent: Agent details fetched:",g);const{data:y,error:v}=await B.from("monitors").select("id").eq("monitoring_agent_id",m);if(v)throw v;if(y&&y.length>0){const S=y.map(M=>M.id),{error:C}=await B.from("monitor_checks").delete().in("monitor_id",S);if(C)throw C;const{error:P}=await B.from("monitors").delete().in("id",S);if(P)throw P}console.log("deleteAgent: Deleting heartbeats...");const{error:j}=await B.from("private_lan_agent_heartbeats").delete().eq("agent_id",m);if(j)throw console.error("deleteAgent: Failed to delete heartbeats:",j),j;console.log("deleteAgent: Deleting API keys...");const{error:b}=await B.from("private_lan_agent_keys").delete().eq("agent_id",m);if(b)throw console.error("deleteAgent: Failed to delete API keys:",b),b;console.log("deleteAgent: Deleting registration tokens...");const{error:_}=await B.from("agent_registration_tokens").delete().eq("agent_id",m);if(_)throw console.error("deleteAgent: Failed to delete registration tokens:",_),_;console.log("deleteAgent: Deleting agent_current_status...");const{error:w}=await B.from("agent_current_status").delete().eq("agent_id",m);if(w)throw console.error("deleteAgent: Failed to delete agent_current_status:",w),w;console.log("deleteAgent: Cleaning up auxiliary tables..."),await B.from("agent_monitor_configs").delete().eq("agent_id",m),await B.from("agent_monitor_state").delete().eq("agent_id",m),await B.from("agent_drive_info").delete().eq("agent_id",m),await B.from("agent_events").delete().eq("agent_id",m),console.log("deleteAgent: Deleting monitoring_agents record...");const{error:N}=await B.from("monitoring_agents").delete().eq("id",m);if(N)throw console.error("deleteAgent: Failed to delete monitoring agent:",N),N;return console.log("deleteAgent: Successfully deleted agent"),await B.rpc("create_audit_log",{p_event_type:"agent_deleted",p_client_id:g.client_id,p_metadata:{agent_id:m,agent_name:g.name,asset_type:g.asset_type,hostname_or_url:g.hostname_or_url,monitors_deleted:(y==null?void 0:y.length)||0,deleted_by:"manual_action"}}),g},onSuccess:()=>{t.invalidateQueries({queryKey:["monitoring-agents"],exact:!1}),t.invalidateQueries({queryKey:["dns-monitors"]}),t.invalidateQueries({queryKey:["http-monitors"]}),t.invalidateQueries({queryKey:["ssl-monitors"]}),t.invalidateQueries({queryKey:["dns-monitor-metrics"]}),t.invalidateQueries({queryKey:["http-monitor-metrics"]}),t.invalidateQueries({queryKey:["ssl-monitor-metrics"]}),t.invalidateQueries({queryKey:["agent-heartbeats"]}),t.invalidateQueries({queryKey:["agent-statuses"]}),t.invalidateQueries({queryKey:["agent-api-keys"]}),t.invalidateQueries({queryKey:["agent-history"]}
680),r({title:"Success",description:"Monitoring agent deleted successfully"})},onError:m=>{r({title:"Error",description:m.message,variant:"destructive"})}}),h=mt({mutationFn:async m=>{const g=m.status==="active"?"suspended":"active",p=g==="active"?{status:g,last_activated_at:new Date().toISOString()}:{status:g},{data:y,error:v}=await B.from("monitoring_agents").update(p).eq("id",m.id).select().single();if(v)throw v;return y},onSuccess:()=>{t.invalidateQueries({queryKey:["monitoring-agents"]}),t.invalidateQueries({queryKey:["dns-monitors"]}),t.invalidateQueries({queryKey:["http-monitors"]}),t.invalidateQueries({queryKey:["ssl-monitors"]}),r({title:"Success",description:"Agent status updated successfully"})},onError:m=>{r({title:"Error",description:m.message,variant:"destructive"})}}),f=mt({mutationFn:async({clientId:m,newStatus:g,assetTypeFilter:p,excludeAssetTypes:y})=>{if(g==="active"){let w=B.from("monitors").select("id").eq("client_id",m);if(p||y){let C=B.from("monitoring_agents").select("id").eq("client_id",m);p&&(C=C.eq("asset_type",p)),y&&y.length>0&&(C=C.not("asset_type","in",`(${y.join(",")})`));const{data:P}=await C;if(P&&P.length>0){const M=P.map(D=>D.id);w=w.in("monitoring_agent_id",M)}}const{data:N,error:S}=await w;if(S)throw S;if(N&&N.length>0){const C=N.map(M=>M.id),{error:P}=await B.from("monitor_checks").delete().in("monitor_id",C);if(P)throw P}}const v=g==="active"?{status:g,last_activated_at:new Date().toISOString()}:{status:g};let j=B.from("monitoring_agents").update(v).eq("client_id",m);p&&(j=j.eq("asset_type",p)),y&&y.length>0&&(j=j.not("asset_type","in",`(${y.join(",")})`));const{data:b,error:_}=await j.select();if(_)throw _;return b},onSuccess:(m,g)=>{t.invalidateQueries({queryKey:["monitoring-agents"]}),t.invalidateQueries({queryKey:["monitor-checks"]});const p=g.newStatus==="active"?"started":"stopped";let y="";g.assetTypeFilter?y=` ${g.assetTypeFilter.toUpperCase()}`:g.excludeAssetTypes&&(y=` (excluding ${g.excludeAssetTypes.join(", ")})`),r({title:"Success",description:`All${y} monitors ${p} successfully`})},onError:m=>{r({title:"Error",description:m.message,variant:"destructive"})}});return{agents:a,isLoading:i,error:(o==null?void 0:o.message)||null,refetch:l,createAgent:c.mutate,createAgentAsync:c.mutateAsync,updateAgent:d.mutate,updateAgentAsync:d.mutateAsync,deleteAgent:u.mutate,toggleAgentStatus:h.mutate,toggleAllAgentsStatus:f.mutate,isCreating:c.isPending,isUpdating:d.isPending,isDeleting:u.isPending,isTogglingStatus:h.isPending,isTogglingAllStatus:f.isPending}}function m6({clientId:e,clientName:t,open:r,onOpenChange:s}){const[a,i]=x.useState(!0),[o,l]=x.useState({totalMonitors:0,activeMonitors:0,downMonitors:0,totalAgents:0,onlineAgents:0,offlineAgents:0,activeAlerts:0,totalUsers:0,uptimePercentage:100,monitorsByType:{},recentIncidents:[]});x.useEffect(()=>{if(!e||!r)return;(async()=>{i(!0);try{const[{count:u},{count:h},{count:f},{data:m},{count:g},{count:p},{data:y},{data:v}]=await Promise.all([B.from("monitors").select("id",{count:"exact",head:!0}).eq("client_id",e),B.from("monitors").select("id",{count:"exact",head:!0}).eq("client_id",e).eq("status","active"),B.from("monitoring_agents").select("id",{count:"exact",head:!0}).eq("client_id",e),B.from("monitoring_agents").select("status").eq("client_id",e),B.from("alerts").select("id",{count:"exact",head:!0}).eq("client_id",e).eq("status","sent"),B.from("client_members").select("id",{count:"exact",head:!0}).eq("client_id",e).eq("status","active"),B.from("monitors").select("monitor_type").eq("client_id",e),B.from("incidents").select("id, title, status, severity, started_at, monitor_id").order("started_at",{ascending:!1}).limit(5)]),j={};y==null||y.forEach(D=>{j[D.monitor_type]=(j[D.monitor_type]||0)+1});const b=(m==null?void 0:m.filter(D=>D.status==="active").length)||0,_=(f||0)-b,{count:w}=await B.from("monitor_checks").select("monitor_id",{count:"exact",head:!0}).eq("status","down").gte("timestamp",new Date(Date.now()-5*60*1e3).toISOString()),N=u||0,S=w||0,C=N>0?Math.round((N-S)/N*100):100,P=(y==null?void 0:y.map(D=>D.id))||[],M=(v==null?void 0:v.filter(D=>P.includes(D.monitor_id)))||[];l({totalMonitors:u||0,activeMonitors:h||0,downMonitors:S,totalAgents:f||0,onlineAgents:b,offlineAgents:_,activeAlerts:g||0,totalUsers:p||0,uptimePercentage:C,monitorsByType:j,recentIncidents:M})}catch(u){console.error("Error fetching client health:",u)}finally{i(!1)}})()},[e,r]);const c=o.downMonitors>0||o.activeAlerts>0||o.offlineAgents>0;return n.jsx(er,{open:r,onOpenChange:s,children:n.jsxs(Kt,{className:"max-w-2xl max-h-[85vh] overflow-y-auto",children:[n.jsx(zr,{children:n.jsxs(Br,{className:"flex items-center gap-3",children:[c?n.jsx(tn,{className:"h-5 w-5 text-orange-500"}):n.jsx(zs,{className:"h-5 w-5 text-green-500"}),t||"Client"," Health Overview"]})}),a?n.jsx("div",{className:"space-y-4",children:n.jsx("div",{className:"grid grid-cols-2 gap-4",children:[...Array(4)].map((d,u)=>n.jsx(tt,{className:"h-24"},u))})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:`p-4 rounded-lg ${c?"bg-orange-500/10 border border-orange-500/30":"bg-green-500/10 border border-green-500/30"}`,children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[c?n.jsx(tn,{className:"h-5 w-5 text-orange-500"}):n.jsx(zs,{className:"h-5 w-5 text-green-500"}),n.jsx("span",{className:"font-medium",children:c?"Issues Detected":"All Systems Operational"})]}),n.jsxs(ve,{variant:o.uptimePercentage>=99?"default":o.uptimePercentage>=95?"secondary":"destructive",children:[o.uptimePercentage,"% Uptime"]})]}),c&&n.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:[o.downMonitors>0&&`${o.downMonitors} monitors down. `,o.offlineAgents>0&&`${o.offlineAgents} agents offline. `,o.activeAlerts>0&&`${o.activeAlerts} active alerts.`]})]}),n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Pn,{className:"h-4 w-4 text-blue-500"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Monitors"})]}),n.jsx("p",{className:"text-2xl font-bold mt-1",children:o.totalMonitors}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[o.activeMonitors," active"]})]})}),n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-4 w-4 text-purple-500"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Agents"})]}),n.jsx("p",{className:"text-2xl font-bold mt-1",children:o.totalAgents}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[o.onlineAgents," online"]})]})}),n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ii,{className:"h-4 w-4 text-orange-500"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Alerts"})]}),n.jsx("p",{className:"text-2xl font-bold mt-1",children:o.activeAlerts}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"active"})]})}),n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Rr,{className:"h-4 w-4 text-green-500"}),n.jsx("span",{className:"text-sm text-muted-foreground",children:"Users"})]}),n.jsx("p",{className:"text-2xl font-bold mt-1",children:o.totalUsers}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"active members"})]})})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("span",{className:"text-sm font-medium",children:"Monitor Health"}),n.jsx("div",{className:"flex items-center gap-1",children:o.downMonitors>0?n.jsx(sa,{className:"h-4 w-4 text-red-500"}):n.jsx(zs,{className:"h-4 w-4 text-green-500"})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Up"}),n.jsx("span",{className:"text-green-500",children:o.totalMonitors-o.downMonitors})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Down"}),n.jsx("span",{className:o.downMonitors>0?"text-red-500":"",children:o.downMonitors})]}),n.jsx(ap,{value:o.totalMonitors>0?(o.totalMonitors-o.downMonitors)/o.totalMonitors*100:100,className:"h-2"})]})]})}),n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx("span",{className:"text-sm font-medium",children:"Agent Health"}),n.jsx("div",{className:"flex items-center gap-1",children:o.offlineAgents>0?n.jsx(tn,{className:"h-4 w-4 text-orange-500"}):n.jsx(Wr,{className:"h-4 w-4 text-green-500"})})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Online"}),n.jsx("span",{className:"text-green-500",children:o.onlineAgents})]}),n.jsxs("div",{className:"flex justify-between text-sm",children:[n.jsx("span",{className:"text-muted-foreground",children:"Offline"}),n.jsx("span",{className:o.offlineAgents>0?"text-orange-500":"",children:o.offlineAgents})]}),n.jsx(ap,{value:o.totalAgents>0?o.onlineAgents/o.totalAgents*100:100,className:"h-2"})]})]})})]}),Object.keys(o.monitorsByType).length>0&&n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsx("h4",{className:"text-sm font-medium mb-3",children:"Monitors by Type"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(o.monitorsByType).sort(([,d],[,u])=>u-d).map(([d,u])=>n.jsxs(ve,{variant:"outline",className:"capitalize",children:[d.replace("_"," "),": ",u]},d))})]})}),o.recentIncidents.length>0&&n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("h4",{className:"text-sm font-medium mb-3 flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4"}),"Recent Incidents"]}),n.jsx("div",{className:"space-y-2",children:o.recentIncidents.map(d=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-muted/50",children:[n.jsx("span",{className:"text-sm",children:d.title}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ve,{variant:d.severity==="critical"||d.severity==="high"?"destructive":"secondary",children:d.severity}),n.jsx(ve,{variant:d.status==="open"?"destructive":"outline",children:d.status})]})]},d.id))})]})})]})]})})}
680function Pae(){const e=di(),[t,r]=x.useState({totalClients:0,activeClients:0,totalUsers:0,totalMonitors:0,activeMonitors:0,downMonitors:0,totalAgents:0,onlineAgents:0,offlineAgents:0,activeAlerts:0,totalScripts:0,uptimePercentage:100,clientsWithIssues:0}),[s,a]=x.useState(!0),[i,o]=x.useState([]),[l,c]=x.useState({}),[d,u]=x.useState(null),[h,f]=x.useState(!1),m=y=>{u({id:y.id,name:y.name}),f(!0)};x.useEffect(()=>{const y=async()=>{try{a(!0);const[{count:j},{count:b},{count:_},{count:w},{count:N},{count:S},{count:C},{data:P},{data:M},{data:D},{count:A},{count:U}]=await Promise.all([B.from("clients").select("id",{count:"exact",head:!0}),B.from("clients").select("id",{count:"exact",head:!0}).eq("status","active"),B.from("client_members").select("user_id",{count:"exact",head:!0}).eq("status","active"),B.from("monitors").select("id",{count:"exact",head:!0}),B.from("monitors").select("id",{count:"exact",head:!0}).eq("status","active"),B.from("monitoring_agents").select("id",{count:"exact",head:!0}).eq("asset_type","local_device"),B.from("alerts").select("id",{count:"exact",head:!0}).eq("status","sent"),B.from("monitors").select("monitor_type"),B.from("clients").select("id, name, slug, status, industry, created_at").order("created_at",{ascending:!1}).limit(5),B.from("agent_current_status").select("agent_id, last_seen, status"),B.from("script_templates").select("id",{count:"exact",head:!0}),B.from("system_script_templates").select("id",{count:"exact",head:!0})]),F={};P==null||P.forEach(ue=>{F[ue.monitor_type]=(F[ue.monitor_type]||0)+1}),c(F);const L=new Date,$=90*1e3;let R=0;D==null||D.forEach(ue=>{if(ue.last_seen){const X=new Date(ue.last_seen);L.getTime()-X.getTime()<=$&&ue.status==="online"&&R++}});const T=(S||0)-R,{count:k}=await B.from("monitor_checks").select("monitor_id",{count:"exact",head:!0}).eq("status","down").gte("timestamp",new Date(Date.now()-5*60*1e3).toISOString()),W=w||0,q=k||0,Q=W>0?Math.round((W-q)/W*100):100;r({totalClients:j||0,activeClients:b||0,totalUsers:_||0,totalMonitors:w||0,activeMonitors:N||0,downMonitors:q,totalAgents:S||0,onlineAgents:R,offlineAgents:T,activeAlerts:C||0,totalScripts:(A||0)+(U||0),uptimePercentage:Q,clientsWithIssues:0}),o(M||[])}catch(j){console.error("Error fetching platform stats:",j)}finally{a(!1)}};y();const v=B.channel("platform-overview").on("postgres_changes",{event:"*",schema:"public",table:"monitors"},y).on("postgres_changes",{event:"*",schema:"public",table:"alerts"},y).on("postgres_changes",{event:"*",schema:"public",table:"clients"},y).subscribe();return()=>{B.removeChannel(v)}},[]);const g=[{title:"Total Clients",value:t.totalClients,description:`${t.activeClients} active`,icon:Ea,color:"text-primary",onClick:()=>e("/dashboard/clients")},{title:"Total Users",value:t.totalUsers,description:"Active client members",icon:Rr,color:"text-blue-500"},{title:"Total Monitors",value:t.totalMonitors,description:`${t.activeMonitors} active`,icon:Pn,color:"text-green-500"},{title:"Total Agents",value:t.totalAgents,description:`${t.onlineAgents} online`,icon:ht,color:"text-purple-500"},{title:"Active Alerts",value:t.activeAlerts,description:"Requiring attention",icon:ii,color:t.activeAlerts>0?"text-orange-500":"text-muted-foreground",onClick:()=>e("/dashboard/alerts")}],p=[{title:"Monitors Up",value:t.totalMonitors-t.downMonitors,total:t.totalMonitors,icon:zs,color:"text-green-500",bgColor:"bg-green-500/10"},{title:"Monitors Down",value:t.downMonitors,total:t.totalMonitors,icon:sa,color:"text-red-500",bgColor:"bg-red-500/10"},{title:"Agents Online",value:t.onlineAgents,total:t.totalAgents,icon:Wr,color:"text-green-500",bgColor:"bg-green-500/10"},{title:"Agents Offline",value:t.offlineAgents,total:t.totalAgents,icon:tn,color:"text-orange-500",bgColor:"bg-orange-500/10"}];return s?n.jsx("div",{className:"space-y-6",children:n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-3 lg:grid-cols-5",children:[...Array(5)].map((y,v)=>n.jsxs(ee,{className:"animate-pulse",children:[n.jsx(de,{className:"pb-2",children:n.jsx("div",{className:"h-4 bg-muted rounded w-24"})}),n.jsxs(re,{children:[n.jsx("div",{className:"h-8 bg-muted rounded w-16 mb-2"}),n.jsx("div",{className:"h-3 bg-muted rounded w-32"})]})]},v))})}):n.jsxs("div",{className:"space-y-6",children:[n.jsx(ee,{className:t.downMonitors>0||t.activeAlerts>0?"border-orange-500/50 bg-orange-500/5":"border-green-500/50 bg-green-500/5",children:n.jsx(re,{className:"py-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[t.downMonitors>0||t.activeAlerts>0?n.jsx(tn,{className:"h-6 w-6 text-orange-500"}):n.jsx(zs,{className:"h-6 w-6 text-green-500"}),n.jsxs("div",{children:[n.jsx("h3",{className:"font-semibold",children:t.downMonitors>0||t.activeAlerts>0?"Issues Detected Across Platform":"All Systems Operational"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.downMonitors>0?`${t.downMonitors} monitors down. `:"",t.activeAlerts>0?`${t.activeAlerts} active alerts.`:"",t.downMonitors===0&&t.activeAlerts===0&&"All monitors and agents are functioning normally."]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:"Platform Uptime"}),n.jsxs(ve,{variant:t.uptimePercentage>=99?"default":t.uptimePercentage>=95?"secondary":"destructive",children:[t.uptimePercentage,"%"]})]})]})})}),n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-3 lg:grid-cols-5",children:g.map(y=>{const v=y.icon;return n.jsxs(ee,{className:y.onClick?"cursor-pointer hover:bg-accent/50 transition-colors":"",onClick:y.onClick,children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:y.title}),n.jsx(v,{className:`h-4 w-4 ${y.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:y.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:y.description})]})]},y.title)})}),n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:p.map(y=>{const v=y.icon,j=y.total>0?Math.round(y.value/y.total*100):0;return n.jsx(ee,{children:n.jsxs(re,{className:"pt-4",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:`p-2 rounded-lg ${y.bgColor}`,children:n.jsx(v,{className:`h-5 w-5 ${y.color}`})}),n.jsxs("div",{className:"flex-1",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:y.title}),n.jsxs("p",{className:"text-xl font-bold",children:[y.value," ",n.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["/ ",y.total]})]})]})]}),n.jsx(ap,{value:j,className:"mt-3 h-1.5"})]})},y.title)})}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Pn,{className:"h-4 w-4"}),"Monitors by Type"]})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-3",children:Object.entries(l).length>0?Object.entries(l).sort(([,y],[,v])=>
680v-y).slice(0,6).map(([y,v])=>n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-sm capitalize",children:y.replace("_"," ")}),n.jsx(ve,{variant:"secondary",children:v})]},y)):n.jsx("p",{className:"text-sm text-muted-foreground",children:"No monitors configured"})})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Ea,{className:"h-4 w-4"}),"Recent Clients",n.jsx("span",{className:"text-xs text-muted-foreground font-normal ml-auto",children:"Click to view health"})]})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-2",children:i.length>0?i.map(y=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-accent/50 cursor-pointer transition-colors group",onClick:()=>m(y),children:[n.jsxs("div",{className:"flex-1",children:[n.jsxs("p",{className:"text-sm font-medium flex items-center gap-1",children:[y.name,n.jsx(_0,{className:"h-3 w-3 opacity-0 group-hover:opacity-100 transition-opacity text-muted-foreground"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:y.industry||"No industry"})]}),n.jsx(ve,{variant:y.status==="active"?"default":"secondary",children:y.status})]},y.id)):n.jsx("p",{className:"text-sm text-muted-foreground",children:"No clients found"})})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Bi,{className:"h-4 w-4"}),"Platform Resources"]})}),n.jsx(re,{children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(hd,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Script Templates"})]}),n.jsx("span",{className:"font-medium",children:t.totalScripts})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Active Monitors"})]}),n.jsx("span",{className:"font-medium",children:t.activeMonitors})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Online Agents"})]}),n.jsx("span",{className:"font-medium",children:t.onlineAgents})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Rr,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-sm",children:"Active Clients"})]}),n.jsx("span",{className:"font-medium",children:t.activeClients})]})]})})]})]}),n.jsx(m6,{clientId:(d==null?void 0:d.id)||null,clientName:(d==null?void 0:d.name)||null,open:h,onOpenChange:f})]})}function Tae(){const{isProviderAdmin:e,clientMemberships:t,selectedClientId:r}=Mt(),s=di(),[a,i]=x.useState(!1),o=t.find(p=>p.client_id===r),l=(o==null?void 0:o.role)||(e?"provider_admin":"user"),{data:c}=Ve({queryKey:["client-details",r],queryFn:async()=>{if(!r)return null;const{data:p,error:y}=await B.from("clients").select("tenant_id, name").eq("id",r).single();if(y)throw y;return p},enabled:!!r&&!e}),d=async()=>{c!=null&&c.tenant_id&&(await navigator.clipboard.writeText(c.tenant_id),i(!0),L$({title:"Copied!",description:"Tenant ID copied to clipboard"}),setTimeout(()=>i(!1),2e3))},{stats:u}=Sae(r||""),{agents:h}=Lt(r||"");if(l==="provider_admin")return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Platform Overview"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor all clients and infrastructure across the platform"})]}),n.jsx(Pae,{})]});const f=h.filter(p=>p.asset_type==="local_device"&&p.status!=="active").length,m=u.down||0,g=[{title:"Internet Monitors",value:u.total||0,description:`${u.up||0} up, ${u.down||0} down`,icon:Pn,color:"text-blue-500",onClick:()=>s("/dashboard/monitors/http")},{title:"Private LAN Agents",value:h.filter(p=>p.asset_type==="local_device").length||0,description:"Monitoring internal systems",icon:ht,color:"text-purple-500",onClick:()=>s("/dashboard/agents"),show:l==="client_admin"||l==="org_admin"||l==="manager"},{title:"Offline LAN Agents",value:f,description:"Agents not responding",icon:ht,color:"text-red-500",onClick:()=>s("/dashboard/agents"),show:l==="client_admin"||l==="org_admin"||l==="manager"},{title:"Offline Internet Monitors",value:m,description:"Monitors currently down",icon:Pn,color:"text-red-500",onClick:()=>s("/dashboard/monitors/http")},{title:"Active Alerts",value:0,description:"Current notifications",icon:ii,color:"text-orange-500",onClick:()=>s("/dashboard/alerts")}];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Dashboard Overview"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor your infrastru
680cture and systems at a glance"})]}),(c==null?void 0:c.tenant_id)&&n.jsx(ee,{className:"bg-muted/50",children:n.jsx(re,{className:"py-3 px-4",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Km,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground",children:"Tenant ID"}),n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(ve,{variant:"outline",className:"font-mono text-xs",children:c.tenant_id}),n.jsx("button",{onClick:d,className:"p-1 hover:bg-accent rounded transition-colors",title:"Copy to clipboard",children:a?n.jsx(oi,{className:"h-3.5 w-3.5 text-green-500"}):n.jsx(rg,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-foreground"})})]})]})]})})})]}),n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-3 lg:grid-cols-5",children:g.map(p=>{if(p.show===!1)return null;const y=p.icon;return n.jsxs(ee,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:p.onClick,children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:p.title}),n.jsx(y,{className:`h-4 w-4 ${p.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:p.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:p.description})]})]},p.title)})}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{children:"Recent Activity"})}),n.jsx(re,{children:n.jsx("div",{className:"text-sm text-muted-foreground",children:"No recent activity to display"})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{children:"System Health"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-2",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-sm",children:"All Systems Operational"}),n.jsx(Wr,{className:"h-4 w-4 text-green-500"})]})})})]})]})]})}const Aae=["website","saas","server","database"];function Eae(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["http-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("*").eq("client_id",e).in("asset_type",Aae).eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0,statusCodeDistribution:{}};const{data:o,error:l}=await B.from("monitors").select("id").in("monitoring_agent_id",a.map(R=>R.id));if(l)throw l;if(!o||o.length===0)return{total:a.length,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0,statusCodeDistribution:{}};const c=o.map(R=>R.id),d=new Date,u=new Date(d.getTime()-24*60*60*1e3),h=new Date(d.getTime()-7*24*60*60*1e3),f=new Date(d.getTime()-30*24*60*60*1e3),{data:m,error:g}=await B.from("monitor_checks").select("*").in("monitor_id",c).order("timestamp",{ascending:!1}).limit(c.length*5);if(g)throw g;const{data:p,error:y}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",u.toISOString()),{data:v,error:j}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",h.toISOString()),{data:b,error:_}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",f.toISOString());if(y||j||_)throw y||j||_;const w=new Map;m==null||m.forEach(R=>{(!w.has(R.monitor_id)||new Date(R.timestamp)>new Date(w.get(R.monitor_id).timestamp))&&w.set(R.monitor_id,R)});let N=0,S=0,C=0,P=0,M=0;const D={};w.forEach(R=>{if(R.status==="success"?N++:R.status==="failed"?S++:C++,R.response_time_ms&&(P+=R.response_time_ms,M++),R.http_status_code){const T=R.http_status_code.toString();D[T]=(D[T]||0)+1}});const A=p&&p.length>0?p.filter(R=>R.status==="success").length/p.length*100:100,U=v&&v.length>0?v.filter(R=>R.status==="success").length/v.length*100:100,F=b&&b.length>0?b.filter(R=>R.status==="success").length/b.length*100:100,L=(p==null?void 0:p.filter(R=>R.status==="failed").length)||0,$=M>0?Math.round(P/M):0;return{total:a.length,online:N,offline:S,warning:C,avgResponseTime:$,uptime24h:Math.round(A*100)/100,uptime7d:Math.round(U*100)/100,uptime30d:Math.round(F*100)/100,recentIncidents:L,statusCodeDistribution:D}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function Oae({clientId:e}){const{stats:t,isLoading:r}=Eae(e);if(r)return n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}
680),n.jsx(tt,{className:"h-4 w-4 rounded-full"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-1"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total HTTP Monitors",value:t.total,description:"Active monitors",icon:Wr,color:"text-primary"},{title:"Online",value:t.online,description:`${t.total>0?Math.round(t.online/t.total*100):0}% of monitors`,icon:zs,color:"text-green-500"},{title:"Offline",value:t.offline,description:t.offline>0?"Requires attention":"All systems operational",icon:sa,color:t.offline>0?"text-red-500":"text-muted-foreground"},{title:"Avg Response Time",value:`${t.avgResponseTime}ms`,description:"Across all monitors",icon:Xt,color:t.avgResponseTime<500?"text-green-500":t.avgResponseTime<1e3?"text-orange-500":"text-red-500"},{title:"Uptime (24h)",value:`${t.uptime24h.toFixed(2)}%`,description:`7d: ${t.uptime7d.toFixed(1)}% | 30d: ${t.uptime30d.toFixed(1)}%`,icon:Bi,color:t.uptime24h>=99?"text-green-500":t.uptime24h>=95?"text-orange-500":"text-red-500"},{title:"Recent Incidents",value:t.recentIncidents,description:"Last 24 hours",icon:tn,color:t.recentIncidents>0?"text-orange-500":"text-muted-foreground"}];return n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>n.jsxs(ee,{className:"hover:bg-accent/50 transition-colors cursor-pointer",children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(a.icon,{className:`h-4 w-4 ${a.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a.description})]})]},a.title))})}const Mae=["website","saas","server","database"];function Dae(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["http-monitor-metrics",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("monitoring_agents").select("id").eq("client_id",e).in("asset_type",Mae).eq("status","active");if(i)throw i;if(!a||a.length===0)return[];const o=a.map(g=>g.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",o);if(c)throw c;if(!l||l.length===0)return[];const d=l.map(g=>g.id),u=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:h,error:f}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",d).gte("timestamp",u).order("timestamp",{ascending:!1});if(f)throw f;const m=new Map;return l.forEach(g=>{const p=(h==null?void 0:h.filter(w=>w.monitor_id===g.id))||[],y=p.filter(w=>w.response_time_ms).map(w=>w.response_time_ms),v=y.length>0?Math.round(y.reduce((w,N)=>w+N,0)/y.length):0,j=p.filter(w=>w.status==="success").length,b=p.length>0?Math.round(j/p.length*1e4)/100:100,_=p.length>0?p[0].timestamp:null;m.set(g.monitoring_agent_id,{monitorId:g.id,agentId:g.monitoring_agent_id,avgResponseTime:v,uptime24h:b,lastCheckTime:_})}),Array.from(m.values())},enabled:!!e,refetchInterval:6e4});return{metrics:t||[],isLoading:r,error:(s==null?void 0:s.message)||null}}var nj="Popover",[p6,hRe]=Qr(nj,[tf]),yg=tf(),[Rae,fc]=p6(nj),g6=e=>{const{__scopePopover:t,children:r,open:s,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,l=yg(t),c=x.useRef(null),[d,u]=x.useState(!1),[h,f]=Bs({prop:s,defaultProp:a??!1,onChange:i,caller:nj});return n.jsx(JC,{...l,children:n.jsx(Rae,{scope:t,contentId:ta(),triggerRef:c,open:h,onOpenChange:f,onOpenToggle:x.useCallback(()=>f(m=>!m),[f]),hasCustomAnchor:d,onCustomAnchorAdd:x.useCallback(()=>u(!0),[]),onCustomAnchorRemove:x.useCallback(()=>u(!1),[]),modal:o,children:r})})};g6.displayName=nj;var x6="PopoverAnchor",$ae=x.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=fc(x6,r),i=yg(r),{onCustomAnchorAdd:o,onCustomAnchorRemove:l}=a;return x.useEffect(()=>(o(),()=>l()),[o,l]),n.jsx(Q0,{...i,...s,ref:t})});$ae.displayName=x6;var v6="PopoverTrigger",y6=x.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=fc(v6,r),i=yg(r),o=nt(t,a.triggerRef),l=n.jsx(We.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":N6(a.open),...s,ref:o,onClick:Te(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?l:n.jsx(Q0,{asChild:!0,...i,children:l})});y6.displayName=v6;var pk="PopoverPortal",[Iae,Lae]=p6(pk,{forceMount:void 0}),j6=e=>{const{__scopePopover:t,forceMount:r,children:s,container:a}=e,i=fc(pk,t);return n.jsx(Iae,{scope:t,forceMount:r,children:n.jsx(jn,{present:r||i.open,children:n.jsx(Uh,{asChild:!0,container:a,children:s})})})};j6.displayName=pk;var oh="PopoverContent",b6=x.forwardRef((e,t)=>
vendor: 8,432 bytes, line 680
680{const r=Lae(oh,e.__scopePopover),{forceMount:s=r.forceMount,...a}=e,i=fc(oh,e.__scopePopover);return n.jsx(jn,{present:s||i.open,children:i.modal?n.jsx(Uae,{...a,ref:t}):n.jsx(zae,{...a,ref:t})})});b6.displayName=oh;var Fae=Jl("PopoverContent.RemoveScroll"),Uae=x.forwardRef((e,t)=>{const r=fc(oh,e.__scopePopover),s=x.useRef(null),a=nt(t,s),i=x.useRef(!1);return x.useEffect(()=>{const o=s.current;if(o)return V0(o)},[]),n.jsx(hg,{as:Fae,allowPinchZoom:!0,children:n.jsx(w6,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Te(e.onCloseAutoFocus,o=>{var l;o.preventDefault(),i.current||(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Te(e.onPointerDownOutside,o=>{const l=o.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;i.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Te(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),zae=x.forwardRef((e,t)=>{const r=fc(oh,e.__scopePopover),s=x.useRef(!1),a=x.useRef(!1);return n.jsx(w6,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o,l;(o=e.onCloseAutoFocus)==null||o.call(e,i),i.defaultPrevented||(s.current||(l=r.triggerRef.current)==null||l.focus(),i.preventDefault()),s.current=!1,a.current=!1},onInteractOutside:i=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,i),i.defaultPrevented||(s.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;((d=r.triggerRef.current)==null?void 0:d.contains(o))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),w6=x.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:s,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...h}=e,f=fc(oh,r),m=yg(r);return W0(),n.jsx(ug,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:a,onUnmountAutoFocus:i,children:n.jsx(Fh,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>f.onOpenChange(!1),children:n.jsx(ek,{"data-state":N6(f.open),role:"dialog",id:f.contentId,...m,...h,ref:t,style:{...h.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),_6="PopoverClose",Bae=x.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=fc(_6,r);return n.jsx(We.button,{type:"button",...s,ref:t,onClick:Te(e.onClick,()=>a.onOpenChange(!1))})});Bae.displayName=_6;var qae="PopoverArrow",Wae=x.forwardRef((e,t)=>{const{__scopePopover:r,...s}=e,a=yg(r);return n.jsx(tk,{...a,...s,ref:t})});Wae.displayName=qae;function N6(e){return e?"open":"closed"}var Hae=g6,Vae=y6,Kae=j6,S6=b6;const gk=Hae,xk=Vae,sj=x.forwardRef(({className:e,align:t="center",sideOffset:r=4,...s},a)=>n.jsx(Kae,{children:n.jsx(S6,{ref:a,align:t,sideOffset:r,className:we("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));sj.displayName=S6.displayName;function C6({monitorId:e,clientId:t,currentGroupId:r,onGroupChange:s}){const[a,i]=x.useState(!1),[o,l]=x.useState(!1),{groups:c,isLoading:d}=Vi(t),u=Et(),h=c.find(m=>m.id===r),f=async m=>{l(!0);try{const{error:g}=await B.from("monitoring_agents").update({group_id:m}).eq("id",e);if(g)throw g;ye.success(m?"Monitor added to group":"Monitor removed from group"),u.invalidateQueries({queryKey:["monitoring-agents"]}),u.invalidateQueries({queryKey:["group-member-counts"]}),s==null||s(),i(!1)}catch(g){console.error("Failed to update group:",g),ye.error("Failed to update group assignment")}finally{l(!1)}};return n.jsxs(gk,{open:a,onOpenChange:i,children:[n.jsx(xk,{asChild:!0,children:n.jsxs(H,{variant:"ghost",size:"sm",title:h?`Group: ${h.name}`:"Assign to group",className:"relative",children:[n.jsx(Vm,{className:"h-4 w-4"}),h&&n.jsx("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-primary rounded-full"})]})}),n.jsx(sj,{className:"w-64 p-2",align:"end",children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"px-2 py-1.5 text-sm font-medium text-muted-foreground",children:"Assign to Group"}),d?n.jsx("div",{className:"flex items-center justify-center py-4",children:n.jsx(mr,{className:"h-4 w-4 animate-spin"})}):c.length===0?n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:"No groups available"}):n.jsxs(n.Fragment,{children:[r&&n.jsxs(H,{variant:"ghost",size:"sm",className:"w-full justify-start text-destructive hover:text-destructive",onClick:()=>f(null),disabled:o,children:[n.jsx(vn,{className:"h-4 w-4 mr-2"}),"Remove from group"]}),c.map(m=>n.jsxs(H,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>f(m.id),disabled:o,children:[r===m.id?n.jsx(oi,{className:"h-4 w-4 mr-2 text-primary"}):n.jsx(Vm,{className:"h-4 w-4 mr-2 text-muted-foreground"}),n.jsx("span",{className:"truncate",children:m.name}),m.is_critical&&n.jsx(ve,{variant:"destructive",className:"ml-auto text-xs",children:"Critical"})]},m.id))]})]})})]})}var aj="Checkbox",[Gae,fRe]=Qr(aj),[Yae,vk]=Gae(aj);function Qae(e){const{__scopeCheckbox:t,checked:r,children:s,defaultChecked:a,disabled:i,form:o,name:l,onCheckedChange:c,required:d,value:u="on",internal_do_not_use_render:h}=e,[f,m]=Bs({prop:r,defaultProp:a??!1,onChange:c,caller:aj}),[g,p]=x.useState(null),[y,v]=x.useState(null),j=x.useRef(!1),b=g?!!o||!!g.closest("form"):!0,_={checked:f,disabled:i,setChecked:m,control:g,setControl:p,name:l,form:o,value:u,hasConsumerStoppedPropagationRef:j,required:d,defaultChecked:Kl(a)?!1:a,isFormControl:b,bubbleInput:y,setBubbleInput:v};return n.jsx(Yae,{scope:t,..._,children:Xae(h)?h(_):s})}var k6="CheckboxTrigger",P6=x.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:r,...s},a)=>{const{control:i,value:o,disabled:l,checked:c,required:d,setControl:u,setChecked:h,hasConsumerStoppedPropagationRef:f,isFormControl:m,bubbleInput:g}=vk(k6,e),p=nt(a,u),y=x.useRef(c);return x.useEffect(()=>{const v=i==null?void 0:i.form;if(v){const j=()=>h(y.current);return v.addEventListener("reset",j),()=>v.removeEventListener("reset",j)}},[i,h]),n.jsx(We.button,{type:"button",role:"checkbox","aria-checked":Kl(c)?"mixed":c,"aria-required":d,"data-state":M6(c),"data-disabled":l?"":void 0,disabled:l,value:o,...s,ref:p,onKeyDown:Te(t,v=>{v.key==="Enter"&&v.preventDefault()}),onClick:Te(r,v=>{h(j=>Kl(j)?!0:!j),g&&m&&(f.current=v.isPropagationStopped(),f.current||v.stopPropagation())})})});P6.displayName=k6;var yk=x.forwardRef((e,t)=>{const{__scopeCheckbox:r,name:s,checked:a,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:d,form:u,...h}=e;return n.jsx(Qae,{__scopeCheckbox:r,checked:a,defaultChecked:i,disabled:l,required:o,onCheckedChange:d,name:s,form:u,value:c,internal_do_not_use_render:({isFormControl:f})=>n.jsxs(n.Fragment,{children:[n.jsx(P6,{...h,ref:t,__scopeCheckbox:r}),f&&n.jsx(O6,{__scopeCheckbox:r})]})})});yk.displayName=aj;var T6="CheckboxIndicator",A6=x.forwardRef((e,t)=>{const{__scopeCheckbox:r,forceMount:s,...a}=e,i=vk(T6,r);return n.jsx(jn,{present:s||Kl(i.checked)||i.checked===!0,children:n.jsx(We.span,{"data-state":M6(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});A6.displayName=T6;var E6="CheckboxBubbleInput",O6=x.forwardRef(({__scopeCheckbox:e,...t},r)=>{const{control:s,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:l,disabled:c,name:d,value:u,form:h,bubbleInput:f,setBubbleInput:m}=vk(E6,e),g=nt(r,m),p=dg(i),y=Hh(s);x.useEffect(()=>{const j=f;if(!j)return;const b=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(b,"checked").set,N=!a.current;if(p!==i&&w){const S=new Event("click",{bubbles:N});j.indeterminate=Kl(i),w.call(j,Kl(i)?!1:i),j.dispatchEvent(S)}},[f,p,i,a]);
680const v=x.useRef(Kl(i)?!1:i);return n.jsx(We.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??v.current,required:l,disabled:c,name:d,value:u,form:h,...t,tabIndex:-1,ref:g,style:{...t.style,...y,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});O6.displayName=E6;function Xae(e){return typeof e=="function"}function Kl(e){return e==="indeterminate"}function M6(e){return Kl(e)?"indeterminate":e?"checked":"unchecked"}const ct=x.forwardRef(({className:e,...t},r)=>n.jsx(yk,{ref:r,className:we("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:n.jsx(A6,{className:we("flex items-center justify-center text-current"),children:n.jsx(oi,{className:"h-4 w-4"})})}));ct.displayName=yk.displayName;var D6="AlertDialog",[Zae,mRe]=Qr(D6,[j3]),Jo=j3(),R6=e=>{const{__scopeAlertDialog:t,...r}=e,s=Jo(t);return n.jsx(YC,{...s,...r,modal:!0})};R6.displayName=D6;var Jae="AlertDialogTrigger",$6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,a=Jo(r);return n.jsx($3,{...a,...s,ref:t})});$6.displayName=Jae;var eie="AlertDialogPortal",I6=e=>{const{__scopeAlertDialog:t,...r}=e,s=Jo(t);return n.jsx(QC,{...s,...r})};I6.displayName=eie;var tie="AlertDialogOverlay",L6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,a=Jo(r);return n.jsx(fg,{...a,...s,ref:t})});L6.displayName=tie;var Mu="AlertDialogContent",[rie,nie]=Zae(Mu),sie=U$("AlertDialogContent"),F6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:s,...a}=e,i=Jo(r),o=x.useRef(null),l=nt(t,o),c=x.useRef(null);return n.jsx(pne,{contentName:Mu,titleName:U6,docsSlug:"alert-dialog",children:n.jsx(rie,{scope:r,cancelRef:c,children:n.jsxs(mg,{role:"alertdialog",...i,...a,ref:l,onOpenAutoFocus:Te(a.onOpenAutoFocus,d=>{var u;d.preventDefault(),(u=c.current)==null||u.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[n.jsx(sie,{children:s}),n.jsx(iie,{contentRef:o})]})})})});F6.displayName=Mu;var U6="AlertDialogTitle",z6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,a=Jo(r);return n.jsx(pg,{...a,...s,ref:t})});z6.displayName=U6;var B6="AlertDialogDescription",q6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,a=Jo(r);return n.jsx(gg,{...a,...s,ref:t})});q6.displayName=B6;var aie="AlertDialogAction",W6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,a=Jo(r);return n.jsx(G0,{...a,...s,ref:t})});W6.displayName=aie;var H6="AlertDialogCancel",V6=x.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,{cancelRef:a}=nie(H6,r),i=Jo(r),o=nt(t,a);return n.jsx(G0,{...i,...s,ref:o})});V6.displayName=H6;var iie=({contentRef:e})=>{const t=`\`${Mu}\` requires a description for the component to be accessible for screen reader users.
681
682You can add a description to the \`${Mu}\` by passing a \`${B6}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
683
684Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Mu}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
685
686For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return x.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},oie=R6,lie=$6,cie=I6,K6=L6,G6=F6,Y6=W6,Q6=V6,X6=z6,Z6=q6;const os=oie,lh=lie,die=cie,J6=x.forwardRef(({className:e,...t},r)=>n.jsx(K6,{className:we("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:r}));J6.displayName=K6.displayName;const Ln=x.forwardRef(({className:e,...t},r)=>n.jsxs(die,{children:[n.jsx(J6,{}),n.jsx(G6,{ref:r,className:we("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rou
686nded-lg",e),...t})]}));Ln.displayName=G6.displayName;const Fn=({className:e,...t})=>n.jsx("div",{className:we("flex flex-col space-y-2 text-center sm:text-left",e),...t});Fn.displayName="AlertDialogHeader";const Un=({className:e,...t})=>n.jsx("div",{className:we("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Un.displayName="AlertDialogFooter";const zn=x.forwardRef(({className:e,...t},r)=>n.jsx(X6,{ref:r,className:we("text-lg font-semibold",e),...t}));zn.displayName=X6.displayName;const Bn=x.forwardRef(({className:e,...t},r)=>n.jsx(Z6,{ref:r,className:we("text-sm text-muted-foreground",e),...t}));Bn.displayName=Z6.displayName;const qn=x.forwardRef(({className:e,...t},r)=>n.jsx(Y6,{ref:r,className:we(U0(),e),...t}));qn.displayName=Y6.displayName;const Wn=x.forwardRef(({className:e,...t},r)=>n.jsx(Q6,{ref:r,className:we(U0({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Wn.displayName=Q6.displayName;function jg({open:e,onOpenChange:t,count:r,onConfirm:s}){return n.jsx(os,{open:e,onOpenChange:t,children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsxs(zn,{children:["Delete ",r," Monitor",r>1?"s":"","?"]}),n.jsxs(Bn,{className:"space-y-2",children:[n.jsxs("p",{children:["Are you sure you want to delete ",n.jsxs("strong",{children:[r," monitor",r>1?"s":""]}),"?"]}),n.jsx("p",{className:"text-destructive font-medium",children:"This will permanently delete for all selected monitors:"}),n.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1",children:[n.jsx("li",{children:"All monitor check history"}),n.jsx("li",{children:"Associated alerts and incidents"}),n.jsx("li",{children:"Configuration settings"})]}),n.jsx("p",{className:"font-medium",children:"This action cannot be undone."})]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsxs(qn,{onClick:s,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:["Delete ",r," Monitor",r>1?"s":""]})]})]})})}function mc(e,t=30){const{data:r=[],isLoading:s,error:a}=Ve({queryKey:["monitor-checks",e,t],queryFn:async()=>{if(!e)return[];const{data:i,error:o}=await B.from("monitors").select("id").eq("monitoring_agent_id",e);if(o)throw o;if(!i||i.length===0)return[];const l=i.map(u=>u.id),{data:c,error:d}=await B.from("monitor_checks").select("*").in("monitor_id",l).order("timestamp",{ascending:!1}).limit(t);if(d)throw d;return c||[]},enabled:!!e});return{checks:r,isLoading:s,error:(a==null?void 0:a.message)||null}}function $A(e){const t=new Date,r=new Date(e),s=t.getTime()-r.getTime(),a=Math.floor(s/(1e3*60*60*24)),i=Math.floor(s%(1e3*60*60*24)/(1e3*60*60)),o=Math.floor(s%(1e3*60*60)/(1e3*60));return a>0?`${a}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function Ki({monitoringAgentId:e,createdAt:t,checkInterval:r=300,className:s,refreshTrigger:a}){const i=Et(),{checks:o,isLoading:l}=mc(e,36),[c,d]=x.useState($A(t));if(x.useEffect(()=>{const h=setInterval(()=>{d($A(t))},6e4);return()=>clearInterval(h)},[t]),x.useEffect(()=>{a&&i.invalidateQueries({queryKey:["monitor-checks",e]})},[a,e,i]),l)return n.jsxs("div",{className:"flex items-center gap-5",children:[n.jsx("div",{className:we("grid grid-flow-col auto-cols-[6px] gap-[2px] items-center shrink-0 ml-[5px]",s),children:Array.from({length:36}).map((h,f)=>n.jsx("div",{className:"w-1.5 h-8 bg-muted/40 rounded-sm animate-pulse flex-none"},f))}),n.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[n.jsx("span",{className:"whitespace-nowrap",children:"Loading..."}),n.jsx("span",{className:"whitespace-nowrap",children:"History: 3h"})]})]});if(o.length===0)return n.jsxs("div",{className:"flex items-center gap-5",children:[n.jsx("div",{className:we("flex items-center gap-0.5 shrink-0 ml-[5px]",s),children:Array.from({length:36}).map((h,f)=>n.jsx("div",{className:"w-1.5 h-8 bg-muted/40 rounded-sm flex-none"},f))}),n.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[n.jsx("span",{className:"whitespace-nowrap",children:"No data"}),n.jsx("span",{className:"whitespace-nowrap",children:"History: 3h"})]})]});const u=[...o.slice(0,36),...Array.from({length:Math.max(0,36-o.length)},()=>null)];return n.jsxs("div",{className:"flex items-center gap-5",children:[n.jsx("div",{className:we("flex items-center gap-0.5 shrink-0 ml-[5px]",s),children:u.map((h,f)=>{if(!h)return n.jsx("div",{className:"w-1.5 h-8 bg-muted/40 rounded-sm flex-none"},`empty-${f}`);const m=h.status==="success",g=h.status==="failure",p=h.status==="error",y=m&&h.http_status_code&&[401,403,404].includes(h.http_status_code);return n.jsx("div",{className:we("w-1.5 h-8 rounded-sm transition-colors duration-200 cursor-pointer flex-none",m&&!y&&"bg-emerald-500 hover:bg-emerald-400 shadow-sm",m&&y&&"bg-amber-500 hover:bg-amber-400 shadow-sm",(g||p)&&"bg-destructive hover:bg-destructive/80 shadow-sm",!m&&!g&&!p&&"bg-muted-foreground hover:bg-muted-foreground
686/80 shadow-sm"),title:`${h.status.toUpperCase()}${y?" (RESTRICTED)":""} - ${new Date(h.timestamp).toLocaleString()}${h.http_status_code?` - HTTP ${h.http_status_code}`:""}${h.response_time_ms?` (${h.response_time_ms}ms)`:""}${h.error_message?` - ${h.error_message}`:""}`},h.id)})}),n.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[n.jsxs("span",{className:"whitespace-nowrap",children:["Up: ",c]}),n.jsx("span",{className:"whitespace-nowrap",children:"History: 3h"})]})]})}function eU(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["monitor-status",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitors").select("id").eq("monitoring_agent_id",e);if(i)throw i;if(!a||a.length===0)return null;const o=a.map(u=>u.id),{data:l,error:c}=await B.from("monitor_checks").select("status, timestamp, error_message").in("monitor_id",o).order("timestamp",{ascending:!1}).limit(1);if(c)throw c;if(!l||l.length===0)return null;const d=l[0];return{status:d.status==="success"?"up":"down",errorMessage:d.error_message}},enabled:!!e,refetchInterval:3e4});return{status:(t==null?void 0:t.status)||null,errorMessage:(t==null?void 0:t.errorMessage)||null,isLoading:r,error:(s==null?void 0:s.message)||null}}function uie({monitoringAgentId:e,assetType:t}){const{status:r,isLoading:s}=eU(e);return["website","saas","ssl","ping","keyword","tcp","tcp_udp"].includes(t)?s?n.jsx(ve,{variant:"outline",className:"text-xs",children:"Checking..."}):r===null?n.jsx(ve,{variant:"outline",className:"text-xs",children:"No Data"}):n.jsx(ve,{variant:r==="up"?"default":"destructive",className:`text-xs ${r==="up"?"bg-success text-success-foreground hover:bg-success/90":"bg-destructive text-destructive-foreground hover:bg-destructive/90"}`,children:r==="up"?"Online":"Offline"}):null}function hie({monitoringAgentId:e,onTestComplete:t}={}){const{runSingleMonitorCheck:r,isSingleCheckRunning:s}=Ra(),a=async()=>{e&&(console.log("Manual status check triggered for agent:",e),await r(e),t&&t(e))};return n.jsx(H,{onClick:a,disabled:s||!e,variant:"ghost",size:"sm",className:"flex items-center gap-1",title:"Recycle status check - Test this monitor only",children:s?n.jsx(mr,{className:"h-4 w-4 animate-spin"}):n.jsx(Ym,{className:"h-4 w-4"})})}var bg=e=>e.type==="checkbox",Bc=e=>e instanceof Date,vs=e=>e==null;const tU=e=>typeof e=="object";var rn=e=>!vs(e)&&!Array.isArray(e)&&tU(e)&&!Bc(e),rU=e=>rn(e)&&e.target?bg(e.target)?e.target.checked:e.target.value:e,fie=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,nU=(e,t)=>e.has(fie(t)),mie=e=>{const t=e.constructor&&e.constructor.prototype;return rn(t)&&t.hasOwnProperty("isPrototypeOf")},jk=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function fn(e){let t;const r=Array.isArray(e),s=typeof FileList<"u"?e instanceof FileList:!1;if(e instanceof Date)t=new Date(e);else if(!(jk&&(e instanceof Blob||s))&&(r||rn(e)))if(t=r?[]:{},!r&&!mie(e))t=e;else for(const a in e)e.hasOwnProperty(a)&&(t[a]=fn(e[a]));else return e;return t}var ij=e=>/^\w*$/.test(e),Xr=e=>e===void 0,bk=e=>Array.isArray(e)?e.filter(Boolean):[],wk=e=>bk(e.replace(/["|']|\]/g,"").split(/\.|\[/)),He=(e,t,r)=>{if(!t||!rn(e))return r;const s=(ij(t)?[t]:wk(t)).reduce((a,i)=>vs(a)?a:a[i],e);return Xr(s)||s===e?Xr(e[t])?r:e[t]:s},Qs=e=>typeof e=="boolean",ar=(e,t,r)=>{let s=-1;const a=ij(t)?[t]:wk(t),i=a.length,o=i-1;for(;++s<i;){const l=a[s];let c=r;if(s!==o){const d=e[l];c=rn(d)||Array.isArray(d)?d:isNaN(+a[s+1])?{}:[]}if(l==="__proto__"||l==="constructor"||l==="prototype")return;e[l]=c,e=e[l]}};const Kv={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ja={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},ro={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},_k=G.createContext(null);_k.displayName="HookFormContext";const oj=()=>G.useContext(_k),pie=e=>{const{children:t,...r}=e;return G.createElement(_k.Provider,{value:r},t)};var sU=(e,t,r,s=!0)=>{const a={defaultValues:t._defaultValues};for(const i in e)Object.defineProperty(a,i,{get:()=>{const o=i;return t._proxyFormState[o]!==Ja.all&&(t._proxyFormState[o]=!s||Ja.all),r&&(r[o]=!0),e[o]}});return a};const Nk=typeof window<"u"?G.useLayoutEffect:G.useEffect;function gie(e){const t=oj(),{control:r=t.control,disabled:s,name:a,exact:i}=e||{},[o,l]=G.useState(r._formState),c=G.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Nk(()=>r._subscribe({name:a,formState:c.current,exact:i,callback:d=>{!s&&l({...r._formState,...d})}}),[a,s,i]),G.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),G.useMemo(()=>sU(o,r,c.current,!1),[o,r])}var Ti=e=>typeof e=="string",aU=(e,t,r,s,a)=>Ti(e)?(s&&t.watch.add(e),He(r,e,a)):Array.isArray(e)?e.map(i=>(s&&t.watch.add(i),He(r,i))):(s&&(t.watchAll=!0),r),RN=e=>vs(e)||!tU(e);function mo(e,t,r=new WeakSet){if(RN(e)||RN(t))return e===t;if(Bc(e)&&Bc(t))return e.getTime()===t.getTime();const s=Object.keys(e),a=Object.keys(t);if(s.length!==a.length)return!1;if(r.has(e)||r.has(t))return!0;r.add(e),r.add(t);for(const i of s){const o=e[i];if(!a.includes(i))return!1;if(i!=="ref"){const l=t[i];if(Bc(o)&&Bc(l)||rn(o)&&rn(l)||Array.isArray(o)&&Array.isArray(l)?!mo(o,l,r):o!==l)return!1}}return!0}function xie(e){const t=oj(),{control:r=t.control,name:s,defaultValue:a,disabled:i,exact:o,c
686ompute:l}=e||{},c=G.useRef(a),d=G.useRef(l),u=G.useRef(void 0);d.current=l;const h=G.useMemo(()=>r._getWatch(s,c.current),[r,s]),[f,m]=G.useState(d.current?d.current(h):h);return Nk(()=>r._subscribe({name:s,formState:{values:!0},exact:o,callback:g=>{if(!i){const p=aU(s,r._names,g.values||r._formValues,!1,c.current);if(d.current){const y=d.current(p);mo(y,u.current)||(m(y),u.current=y)}else m(p)}}}),[r,i,s,o]),G.useEffect(()=>r._removeUnmounted()),f}function vie(e){const t=oj(),{name:r,disabled:s,control:a=t.control,shouldUnregister:i,defaultValue:o}=e,l=nU(a._names.array,r),c=G.useMemo(()=>He(a._formValues,r,He(a._defaultValues,r,o)),[a,r,o]),d=xie({control:a,name:r,defaultValue:c,exact:!0}),u=gie({control:a,name:r,exact:!0}),h=G.useRef(e),f=G.useRef(a.register(r,{...e.rules,value:d,...Qs(e.disabled)?{disabled:e.disabled}:{}}));h.current=e;const m=G.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!He(u.errors,r)},isDirty:{enumerable:!0,get:()=>!!He(u.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!He(u.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!He(u.validatingFields,r)},error:{enumerable:!0,get:()=>He(u.errors,r)}}),[u,r]),g=G.useCallback(j=>f.current.onChange({target:{value:rU(j),name:r},type:Kv.CHANGE}),[r]),p=G.useCallback(()=>f.current.onBlur({target:{value:He(a._formValues,r),name:r},type:Kv.BLUR}),[r,a._formValues]),y=G.useCallback(j=>{const b=He(a._fields,r);b&&j&&(b._f.ref={focus:()=>j.focus&&j.focus(),select:()=>j.select&&j.select(),setCustomValidity:_=>j.setCustomValidity(_),reportValidity:()=>j.reportValidity()})},[a._fields,r]),v=G.useMemo(()=>({name:r,value:d,...Qs(s)||u.disabled?{disabled:u.disabled||s}:{},onChange:g,onBlur:p,ref:y}),[r,s,u.disabled,g,p,y,d]);return G.useEffect(()=>{const j=a._options.shouldUnregister||i;a.register(r,{...h.current.rules,...Qs(h.current.disabled)?{disabled:h.current.disabled}:{}});const b=(_,w)=>{const N=He(a._fields,_);N&&N._f&&(N._f.mount=w)};if(b(r,!0),j){const _=fn(He(a._options.defaultValues,r));ar(a._defaultValues,r,_),Xr(He(a._formValues,r))&&ar(a._formValues,r,_)}return!l&&a.register(r),()=>{(l?j&&!a._state.action:j)?a.unregister(r):b(r,!1)}},[r,a,l,i]),G.useEffect(()=>{a._setDisabledField({disabled:s,name:r})},[s,r,a]),G.useMemo(()=>({field:v,formState:u,fieldState:m}),[v,u,m])}const yie=e=>e.render(vie(e));var iU=(e,t,r,s,a)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[s]:a||!0}}:{},bm=e=>Array.isArray(e)?e:[e],IA=()=>{let e=[];return{get observers(){return e},next:a=>{for(const i of e)i.next&&i.next(a)},subscribe:a=>(e.push(a),{unsubscribe:()=>{e=e.filter(i=>i!==a)}}),unsubscribe:()=>{e=[]}}},Es=e=>rn(e)&&!Object.keys(e).length,Sk=e=>e.type==="file",ei=e=>typeof e=="function",Gv=e=>{if(!jk)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},oU=e=>e.type==="select-multiple",Ck=e=>e.type==="radio",jie=e=>Ck(e)||bg(e),uw=e=>Gv(e)&&e.isConnected;function bie(e,t){const r=t.slice(0,-1).length;let s=0;for(;s<r;)e=Xr(e)?s++:e[t[s++]];return e}function wie(e){for(const t in e)if(e.hasOwnProperty(t)&&!Xr(e[t]))return!1;return!0}function sn(e,t){const r=Array.isArray(t)?t:ij(t)?[t]:wk(t),s=r.length===1?e:bie(e,r),a=r.length-1,i=r[a];return s&&delete s[i],a!==0&&(rn(s)&&Es(s)||Array.isArray(s)&&wie(s))&&sn(e,r.slice(0,-1)),e}var lU=e=>{for(const t in e)if(ei(e[t]))return!0;return!1};function Yv(e,t={}){const r=Array.isArray(e);if(rn(e)||r)for(const s in e)Array.isArray(e[s])||rn(e[s])&&!lU(e[s])?(t[s]=Array.isArray(e[s])?[]:{},Yv(e[s],t[s])):vs(e[s])||(t[s]=!0);return t}function cU(e,t,r){const s=Array.isArray(e);if(rn(e)||s)for(const a in e)Array.isArray(e[a])||rn(e[a])&&!lU(e[a])?Xr(t)||RN(r[a])?r[a]=Array.isArray(e[a])?Yv(e[a],[]):{...Yv(e[a])}:cU(e[a],vs(t)?{}:t[a],r[a]):r[a]=!mo(e[a],t[a]);return r}var Of=(e,t)=>cU(e,t,Yv(t));const LA={value:!1,isValid:!1},FA={value:!0,isValid:!0};var dU=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Xr(e[0].attributes.value)?Xr(e[0].value)||e[0].value===""?FA:{value:e[0].value,isValid:!0}:FA:LA}return LA},uU=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:s})=>Xr(e)?e:t?e===""?NaN:e&&+e:r&&Ti(e)?new Date(e):s?s(e):e;const UA={isValid:!1,value:null};var hU=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,UA):UA;function zA(e){const t=e.ref;return Sk(t)?t.files:Ck(t)?hU(e.refs).value:oU(t)?[...t.selectedOptions].map(({value:r})=>r):bg(t)?dU(e.refs).value:uU(Xr(t.value)?e.ref.value:t.value,e)}var _ie=(e,t,r,s)=>{const a={};for(const i of e){const o=He(t,i);o&&ar(a,i,o._f)}return{criteriaMode:r,names:[...e],fields:a,shouldUseNativeValidation:s}},Qv=e=>e instanceof RegExp,Mf=e=>Xr(e)?e:Qv(e)?e.source:rn(e)?Qv(e.value)?e.value.source:e.value:e,BA=e=>({isOnSubmit:!e||e===Ja.onSubmit,isOnBlur:e===Ja.onBlur,isOnChange:e===Ja.onChange,isOnAll:e===Ja.all,isOnTouch:e===Ja.onTouched});const qA="AsyncFunction";var Nie=e=>!!e&&!!e.validate&&!!(ei(e.validate)&&e.validate.constructor.name===qA||rn(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===qA)),Sie=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),WA=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(s=>e.startsWith(s)&&/^\.\w+/.test(e.slice(s.length))));const wm=(e,t,r,s)=>{for(const a of r||Object.keys(e)){const i=He(e,a);if(i){const{_f:o,...l}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],a)&&!s)return!0;
vendor: 4,297 bytes, line 686
686if(o.ref&&t(o.ref,o.name)&&!s)return!0;if(wm(l,t))break}else if(rn(l)&&wm(l,t))break}}};function HA(e,t,r){const s=He(e,r);if(s||ij(r))return{error:s,name:r};const a=r.split(".");for(;a.length;){const i=a.join("."),o=He(t,i),l=He(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(l&&l.type)return{name:i,error:l};if(l&&l.root&&l.root.type)return{name:`${i}.root`,error:l.root};a.pop()}return{name:r}}var Cie=(e,t,r,s)=>{r(e);const{name:a,...i}=e;return Es(i)||Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!s||Ja.all))},kie=(e,t,r)=>!e||!t||e===t||bm(e).some(s=>s&&(r?s===t:s.startsWith(t)||t.startsWith(s))),Pie=(e,t,r,s,a)=>a.isOnAll?!1:!r&&a.isOnTouch?!(t||e):(r?s.isOnBlur:a.isOnBlur)?!e:(r?s.isOnChange:a.isOnChange)?e:!0,Tie=(e,t)=>!bk(He(e,t)).length&&sn(e,t),Aie=(e,t,r)=>{const s=bm(He(e,r));return ar(s,"root",t[r]),ar(e,r,s),e},ev=e=>Ti(e);function VA(e,t,r="validate"){if(ev(e)||Array.isArray(e)&&e.every(ev)||Qs(e)&&!e)return{type:r,message:ev(e)?e:"",ref:t}}var Zd=e=>rn(e)&&!Qv(e)?e:{value:e,message:""},KA=async(e,t,r,s,a,i)=>{const{ref:o,refs:l,required:c,maxLength:d,minLength:u,min:h,max:f,pattern:m,validate:g,name:p,valueAsNumber:y,mount:v}=e._f,j=He(r,p);if(!v||t.has(p))return{};const b=l?l[0]:o,_=A=>{a&&b.reportValidity&&(b.setCustomValidity(Qs(A)?"":A||""),b.reportValidity())},w={},N=Ck(o),S=bg(o),C=N||S,P=(y||Sk(o))&&Xr(o.value)&&Xr(j)||Gv(o)&&o.value===""||j===""||Array.isArray(j)&&!j.length,M=iU.bind(null,p,s,w),D=(A,U,F,L=ro.maxLength,$=ro.minLength)=>{const R=A?U:F;w[p]={type:A?L:$,message:R,ref:o,...M(A?L:$,R)}};if(i?!Array.isArray(j)||!j.length:c&&(!C&&(P||vs(j))||Qs(j)&&!j||S&&!dU(l).isValid||N&&!hU(l).isValid)){const{value:A,message:U}=ev(c)?{value:!!c,message:c}:Zd(c);if(A&&(w[p]={type:ro.required,message:U,ref:b,...M(ro.required,U)},!s))return _(U),w}if(!P&&(!vs(h)||!vs(f))){let A,U;const F=Zd(f),L=Zd(h);if(!vs(j)&&!isNaN(j)){const $=o.valueAsNumber||j&&+j;vs(F.value)||(A=$>F.value),vs(L.value)||(U=$<L.value)}else{const $=o.valueAsDate||new Date(j),R=W=>new Date(new Date().toDateString()+" "+W),T=o.type=="time",k=o.type=="week";Ti(F.value)&&j&&(A=T?R(j)>R(F.value):k?j>F.value:$>new Date(F.value)),Ti(L.value)&&j&&(U=T?R(j)<R(L.value):k?j<L.value:$<new Date(L.value))}if((A||U)&&(D(!!A,F.message,L.message,ro.max,ro.min),!s))return _(w[p].message),w}if((d||u)&&!P&&(Ti(j)||i&&Array.isArray(j))){const A=Zd(d),U=Zd(u),F=!vs(A.value)&&j.length>+A.value,L=!vs(U.value)&&j.length<+U.value;if((F||L)&&(D(F,A.message,U.message),!s))return _(w[p].message),w}if(m&&!P&&Ti(j)){const{value:A,message:U}=Zd(m);if(Qv(A)&&!j.match(A)&&(w[p]={type:ro.pattern,message:U,ref:o,...M(ro.pattern,U)},!s))return _(U),w}if(g){if(ei(g)){const A=await g(j,r),U=VA(A,b);if(U&&(w[p]={...U,...M(ro.validate,U.message)},!s))return _(U.message),w}else if(rn(g)){let A={};for(const U in g){if(!Es(A)&&!s)break;const F=VA(await g[U](j,r),b,U);F&&(A={...F,...M(U,F.message)},_(F.message),s&&(w[p]=A))}if(!Es(A)&&(w[p]={ref:b,...A},!s))return w}}return _(!0),w};const Eie={mode:Ja.onSubmit,reValidateMode:Ja.onChange,shouldFocusError:!0};function Oie(e={}){let t={...Eie,...e},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:ei(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:t.errors||{},disabled:t.disabled||!1},s={},a=rn(t.defaultValues)||rn(t.values)?fn(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:fn(a),o={action:!1,mount:!1,watch:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set},c,d=0;const u={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1};let h={...u};const f={array:IA(),state:IA()},m=t.criteriaMode===Ja.all,g=E=>O=>{clearTimeout(d),d=setTimeout(E,O)},p=async E=>{if(!t.disabled&&(u.isValid||h.isValid||E)){const O=t.resolver?Es((await S()).errors):await P(s,!0);O!==r.isValid&&f.state.next({isValid:O})}},y=(E,O)=>{!t.disabled&&(u.isValidating||u.validatingFields||h.isValidating||h.validatingFields)&&((E||Array.from(l.mount)).forEach(I=>{I&&(O?ar(r.validatingFields,I,O):sn(r.validatingFields,I))}),f.state.next({validatingFields:r.validatingFields,isValidating:!Es(r.validatingFields)}))},v=(E,O=[],I,Y,te=!0,K=!0)=>
vendor: 4,101 bytes, line 686
686{if(Y&&I&&!t.disabled){if(o.action=!0,K&&Array.isArray(He(s,E))){const Z=I(He(s,E),Y.argA,Y.argB);te&&ar(s,E,Z)}if(K&&Array.isArray(He(r.errors,E))){const Z=I(He(r.errors,E),Y.argA,Y.argB);te&&ar(r.errors,E,Z),Tie(r.errors,E)}if((u.touchedFields||h.touchedFields)&&K&&Array.isArray(He(r.touchedFields,E))){const Z=I(He(r.touchedFields,E),Y.argA,Y.argB);te&&ar(r.touchedFields,E,Z)}(u.dirtyFields||h.dirtyFields)&&(r.dirtyFields=Of(a,i)),f.state.next({name:E,isDirty:D(E,O),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ar(i,E,O)},j=(E,O)=>{ar(r.errors,E,O),f.state.next({errors:r.errors})},b=E=>{r.errors=E,f.state.next({errors:r.errors,isValid:!1})},_=(E,O,I,Y)=>{const te=He(s,E);if(te){const K=He(i,E,Xr(I)?He(a,E):I);Xr(K)||Y&&Y.defaultChecked||O?ar(i,E,O?K:zA(te._f)):F(E,K),o.mount&&p()}},w=(E,O,I,Y,te)=>{let K=!1,Z=!1;const je={name:E};if(!t.disabled){if(!I||Y){(u.isDirty||h.isDirty)&&(Z=r.isDirty,r.isDirty=je.isDirty=D(),K=Z!==je.isDirty);const _e=mo(He(a,E),O);Z=!!He(r.dirtyFields,E),_e?sn(r.dirtyFields,E):ar(r.dirtyFields,E,!0),je.dirtyFields=r.dirtyFields,K=K||(u.dirtyFields||h.dirtyFields)&&Z!==!_e}if(I){const _e=He(r.touchedFields,E);_e||(ar(r.touchedFields,E,I),je.touchedFields=r.touchedFields,K=K||(u.touchedFields||h.touchedFields)&&_e!==I)}K&&te&&f.state.next(je)}return K?je:{}},N=(E,O,I,Y)=>{const te=He(r.errors,E),K=(u.isValid||h.isValid)&&Qs(O)&&r.isValid!==O;if(t.delayError&&I?(c=g(()=>j(E,I)),c(t.delayError)):(clearTimeout(d),c=null,I?ar(r.errors,E,I):sn(r.errors,E)),(I?!mo(te,I):te)||!Es(Y)||K){const Z={...Y,...K&&Qs(O)?{isValid:O}:{},errors:r.errors,name:E};r={...r,...Z},f.state.next(Z)}},S=async E=>{y(E,!0);const O=await t.resolver(i,t.context,_ie(E||l.mount,s,t.criteriaMode,t.shouldUseNativeValidation));return y(E),O},C=async E=>{const{errors:O}=await S(E);if(E)for(const I of E){const Y=He(O,I);Y?ar(r.errors,I,Y):sn(r.errors,I)}else r.errors=O;return O},P=async(E,O,I={valid:!0})=>{for(const Y in E){const te=E[Y];if(te){const{_f:K,...Z}=te;if(K){const je=l.array.has(K.name),_e=te._f&&Nie(te._f);_e&&u.validatingFields&&y([Y],!0);const Ee=await KA(te,l.disabled,i,m,t.shouldUseNativeValidation&&!O,je);if(_e&&u.validatingFields&&y([Y]),Ee[K.name]&&(I.valid=!1,O))break;!O&&(He(Ee,K.name)?je?Aie(r.errors,Ee,K.name):ar(r.errors,K.name,Ee[K.name]):sn(r.errors,K.name))}!Es(Z)&&await P(Z,O,I)}}return I.valid},M=()=>{for(const E of l.unMount){const O=He(s,E);O&&(O._f.refs?O._f.refs.every(I=>!uw(I)):!uw(O._f.ref))&&ce(E)}l.unMount=new Set},D=(E,O)=>!t.disabled&&(E&&O&&ar(i,E,O),!mo(W(),a)),A=(E,O,I)=>aU(E,l,{...o.mount?i:Xr(O)?a:Ti(E)?{[E]:O}:O},I,O),U=E=>bk(He(o.mount?i:a,E,t.shouldUnregister?He(a,E,[]):[])),F=(E,O,I={})=>{const Y=He(s,E);let te=O;if(Y){const K=Y._f;K&&(!K.disabled&&ar(i,E,uU(O,K)),te=Gv(K.ref)&&vs(O)?"":O,oU(K.ref)?[...K.ref.options].forEach(Z=>Z.selected=te.includes(Z.value)):K.refs?bg(K.ref)?K.refs.forEach(Z=>{(!Z.defaultChecked||!Z.disabled)&&(Array.isArray(te)?Z.checked=!!te.find(je=>je===Z.value):Z.checked=te===Z.value||!!te)}):K.refs.forEach(Z=>Z.checked=Z.value===te):Sk(K.ref)?K.ref.value="":(K.ref.value=te,K.ref.type||f.state.next({name:E,values:fn(i)})))}(I.shouldDirty||I.shouldTouch)&&w(E,te,I.shouldTouch,I.shouldDirty,!0),I.shouldValidate&&k(E)},L=(E,O,I)=>{for(const Y in O){if(!O.hasOwnProperty(Y))return;const te=O[Y],K=E+"."+Y,Z=He(s,K);(l.array.has(E)||rn(te)||Z&&!Z._f)&&!Bc(te)?L(K,te,I):F(K,te,I)}},$=(E,O,I={})=>{const Y=He(s,E),te=l.array.has(E),K=fn(O);ar(i,E,K),te?(f.array.next({name:E,values:fn(i)}),(u.isDirty||u.dirtyFields||h.isDirty||h.dirtyFields)&&I.shouldDirty&&f.state.next({name:E,dirtyFields:Of(a,i),isDirty:D(E,K)})):Y&&!Y._f&&!vs(K)?L(E,K,I):F(E,K,I),WA(E,l)&&f.state.next({...r,name:E}),f.state.next({name:o.mount?E:void 0,values:fn(i)})},R=async E=>{o.mount=!0;const O=E.target;let I=O.name,Y=!0;const te=He(s,I),K=_e=>{Y=Number.isNaN(_e)||Bc(_e)&&isNaN(_e.getTime())||mo(_e,He(i,I,_e))},Z=BA(t.mode),je=BA(t.reValidateMode);if(te){let _e,Ee;const Ze=O.type?zA(te._f):rU(E),st=E.type===Kv.BLUR||E.type===Kv.FOCUS_OUT,xt=!Sie(te._f)&&!t.resolver&&!He(r.errors,I)&&
vendor: 4,854 bytes, line 686
686!te._f.deps||Pie(st,He(r.touchedFields,I),r.isSubmitted,je,Z),Dt=WA(I,l,st);ar(i,I,Ze),st?(te._f.onBlur&&te._f.onBlur(E),c&&c(0)):te._f.onChange&&te._f.onChange(E);const xe=w(I,Ze,st),qe=!Es(xe)||Dt;if(!st&&f.state.next({name:I,type:E.type,values:fn(i)}),xt)return(u.isValid||h.isValid)&&(t.mode==="onBlur"?st&&p():st||p()),qe&&f.state.next({name:I,...Dt?{}:xe});if(!st&&Dt&&f.state.next({...r}),t.resolver){const{errors:St}=await S([I]);if(K(Ze),Y){const Pr=HA(r.errors,s,I),wn=HA(St,s,Pr.name||I);_e=wn.error,I=wn.name,Ee=Es(St)}}else y([I],!0),_e=(await KA(te,l.disabled,i,m,t.shouldUseNativeValidation))[I],y([I]),K(Ze),Y&&(_e?Ee=!1:(u.isValid||h.isValid)&&(Ee=await P(s,!0)));Y&&(te._f.deps&&k(te._f.deps),N(I,Ee,_e,xe))}},T=(E,O)=>{if(He(r.errors,O)&&E.focus)return E.focus(),1},k=async(E,O={})=>{let I,Y;const te=bm(E);if(t.resolver){const K=await C(Xr(E)?E:te);I=Es(K),Y=E?!te.some(Z=>He(K,Z)):I}else E?(Y=(await Promise.all(te.map(async K=>{const Z=He(s,K);return await P(Z&&Z._f?{[K]:Z}:Z)}))).every(Boolean),!(!Y&&!r.isValid)&&p()):Y=I=await P(s);return f.state.next({...!Ti(E)||(u.isValid||h.isValid)&&I!==r.isValid?{}:{name:E},...t.resolver||!E?{isValid:I}:{},errors:r.errors}),O.shouldFocus&&!Y&&wm(s,T,E?te:l.mount),Y},W=E=>{const O={...o.mount?i:a};return Xr(E)?O:Ti(E)?He(O,E):E.map(I=>He(O,I))},q=(E,O)=>({invalid:!!He((O||r).errors,E),isDirty:!!He((O||r).dirtyFields,E),error:He((O||r).errors,E),isValidating:!!He(r.validatingFields,E),isTouched:!!He((O||r).touchedFields,E)}),Q=E=>{E&&bm(E).forEach(O=>sn(r.errors,O)),f.state.next({errors:E?r.errors:{}})},ue=(E,O,I)=>{const Y=(He(s,E,{_f:{}})._f||{}).ref,te=He(r.errors,E)||{},{ref:K,message:Z,type:je,..._e}=te;ar(r.errors,E,{..._e,...O,ref:Y}),f.state.next({name:E,errors:r.errors,isValid:!1}),I&&I.shouldFocus&&Y&&Y.focus&&Y.focus()},X=(E,O)=>ei(E)?f.state.subscribe({next:I=>"values"in I&&E(A(void 0,O),I)}):A(E,O,!0),le=E=>f.state.subscribe({next:O=>{kie(E.name,O.name,E.exact)&&Cie(O,E.formState||u,Me,E.reRenderRoot)&&E.callback({values:{...i},...r,...O,defaultValues:a})}}).unsubscribe,pe=E=>(o.mount=!0,h={...h,...E.formState},le({...E,formState:h})),ce=(E,O={})=>{for(const I of E?bm(E):l.mount)l.mount.delete(I),l.array.delete(I),O.keepValue||(sn(s,I),sn(i,I)),!O.keepError&&sn(r.errors,I),!O.keepDirty&&sn(r.dirtyFields,I),!O.keepTouched&&sn(r.touchedFields,I),!O.keepIsValidating&&sn(r.validatingFields,I),!t.shouldUnregister&&!O.keepDefaultValue&&sn(a,I);f.state.next({values:fn(i)}),f.state.next({...r,...O.keepDirty?{isDirty:D()}:{}}),!O.keepIsValid&&p()},se=({disabled:E,name:O})=>{(Qs(E)&&o.mount||E||l.disabled.has(O))&&(E?l.disabled.add(O):l.disabled.delete(O))},oe=(E,O={})=>{let I=He(s,E);const Y=Qs(O.disabled)||Qs(t.disabled);return ar(s,E,{...I||{},_f:{...I&&I._f?I._f:{ref:{name:E}},name:E,mount:!0,...O}}),l.mount.add(E),I?se({disabled:Qs(O.disabled)?O.disabled:t.disabled,name:E}):_(E,!0,O.value),{...Y?{disabled:O.disabled||t.disabled}:{},...t.progressive?{required:!!O.required,min:Mf(O.min),max:Mf(O.max),minLength:Mf(O.minLength),maxLength:Mf(O.maxLength),pattern:Mf(O.pattern)}:{},name:E,onChange:R,onBlur:R,ref:te=>{if(te){oe(E,O),I=He(s,E);const K=Xr(te.value)&&te.querySelectorAll&&te.querySelectorAll("input,select,textarea")[0]||te,Z=jie(K),je=I._f.refs||[];if(Z?je.find(_e=>_e===K):K===I._f.ref)return;ar(s,E,{_f:{...I._f,...Z?{refs:[...je.filter(uw),K,...Array.isArray(He(a,E))?[{}]:[]],ref:{type:K.type,name:E}}:{ref:K}}}),_(E,!1,void 0,K)}else I=He(s,E,{}),I._f&&(I._f.mount=!1),(t.shouldUnregister||O.shouldUnregister)&&!(nU(l.array,E)&&o.action)&&l.unMount.add(E)}}},V=()=>t.shouldFocusError&&wm(s,T,l.mount),fe=E=>{Qs(E)&&(f.state.next({disabled:E}),wm(s,(O,I)=>{const Y=He(s,I);Y&&(O.disabled=Y._f.disabled||E,Array.isArray(Y._f.refs)&&Y._f.refs.forEach(te=>{te.disabled=Y._f.disabled||E}))},0,!1))},ne=(E,O)=>async I=>{let Y;I&&(I.preventDefault&&I.preventDefault(),I.persist&&I.persist());let te=fn(i);if(f.state.next({isSubmitting:!0}),t.resolver){const{errors:K,values:Z}=await S();r.errors=K,te=fn(Z)}else await P(s);if(l.disabled.size)for(const K of l.disabled)sn(te,K);if(sn(r.errors,"root"),Es(r.errors)){f.state.next({errors:{}});try{await E(te,I)}catch(K){Y=K}}else O&&await O({...r.errors},I),V(),setTimeout(V);if(f.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:Es(r.errors)&&!Y,submitCount:r.submitCount+1,errors:r.errors}),Y)throw Y},Ce=(E,O={})=>{He(s,E)&&(Xr(O.defaultValue)?$(E,fn(He(a,E))):($(E,O.defaultValue),ar(a,E,fn(O.defaultValue))),O.keepTouched||sn(r.touchedFields,E),O.keepDirty||(sn(r.dirtyFields,E),r.isDirty=O.defaultValue?D(E,fn(He(a,E))):D()),O.keepError||(sn(r.errors,E),u.isValid&&p()),f.state.next({...r}))},Pe=(E,O={})=>{const I=E?fn(E):a,Y=fn(I),te=Es(E),K=te?a:Y;if(O.keepDefaultValues||(a=I),!O.keepValues){if(O.keepDirtyValues){const Z=new Set([...l.mount,...Object.keys(Of(a,i))]);
686for(const je of Array.from(Z))He(r.dirtyFields,je)?ar(K,je,He(i,je)):$(je,He(K,je))}else{if(jk&&Xr(E))for(const Z of l.mount){const je=He(s,Z);if(je&&je._f){const _e=Array.isArray(je._f.refs)?je._f.refs[0]:je._f.ref;if(Gv(_e)){const Ee=_e.closest("form");if(Ee){Ee.reset();break}}}}if(O.keepFieldsRef)for(const Z of l.mount)$(Z,He(K,Z));else s={}}i=t.shouldUnregister?O.keepDefaultValues?fn(a):{}:fn(K),f.array.next({values:{...K}}),f.state.next({values:{...K}})}l={mount:O.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!u.isValid||!!O.keepIsValid||!!O.keepDirtyValues,o.watch=!!t.shouldUnregister,f.state.next({submitCount:O.keepSubmitCount?r.submitCount:0,isDirty:te?!1:O.keepDirty?r.isDirty:!!(O.keepDefaultValues&&!mo(E,a)),isSubmitted:O.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:te?{}:O.keepDirtyValues?O.keepDefaultValues&&i?Of(a,i):r.dirtyFields:O.keepDefaultValues&&E?Of(a,E):O.keepDirty?r.dirtyFields:{},touchedFields:O.keepTouched?r.touchedFields:{},errors:O.keepErrors?r.errors:{},isSubmitSuccessful:O.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},he=(E,O)=>Pe(ei(E)?E(i):E,O),ke=(E,O={})=>{const I=He(s,E),Y=I&&I._f;if(Y){const te=Y.refs?Y.refs[0]:Y.ref;te.focus&&(te.focus(),O.shouldSelect&&ei(te.select)&&te.select())}},Me=E=>{r={...r,...E}},Ke={control:{register:oe,unregister:ce,getFieldState:q,handleSubmit:ne,setError:ue,_subscribe:le,_runSchema:S,_focusError:V,_getWatch:A,_getDirty:D,_setValid:p,_setFieldArray:v,_setDisabledField:se,_setErrors:b,_getFieldArray:U,_reset:Pe,_resetDefaultValues:()=>ei(t.defaultValues)&&t.defaultValues().then(E=>{he(E,t.resetOptions),f.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:fe,_subjects:f,_proxyFormState:u,get _fields(){return s},get _formValues(){return i},get _state(){return o},set _state(E){o=E},get _defaultValues(){return a},get _names(){return l},set _names(E){l=E},get _formState(){return r},get _options(){return t},set _options(E){t={...t,...E}}},subscribe:pe,trigger:k,register:oe,handleSubmit:ne,watch:X,setValue:$,getValues:W,reset:he,resetField:Ce,clearErrors:Q,unregister:ce,setError:ue,setFocus:ke,getFieldState:q};return{...Ke,formControl:Ke}}function Mie(e={}){const t=G.useRef(void 0),r=G.useRef(void 0),[s,a]=G.useState({isDirty:!1,isValidating:!1,isLoading:ei(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},validatingFields:{},errors:e.errors||{},disabled:e.disabled||!1,isReady:!1,defaultValues:ei(e.defaultValues)?void 0:e.defaultValues});if(!t.current)if(e.formControl)t.current={...e.formControl,formState:s},e.defaultValues&&!ei(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:o,...l}=Oie(e);t.current={...l,formState:s}}const i=t.current.control;return i._options=e,Nk(()=>{const o=i._subscribe({formState:i._proxyFormState,callback:()=>a({...i._formState}),reRenderRoot:!0});return a(l=>({...l,isReady:!0})),i._formState.isReady=!0,o},[i]),G.useEffect(()=>i._disableForm(e.disabled),[i,e.disabled]),G.useEffect(()=>{e.mode&&(i._options.mode=e.mode),e.reValidateMode&&(i._options.reValidateMode=e.reValidateMode)},[i,e.mode,e.reValidateMode]),G.useEffect(()=>{e.errors&&(i._setErrors(e.errors),i._focusError())},[i,e.errors]),G.useEffect(()=>{e.shouldUnregister&&i._subjects.state.next({values:i._getWatch()})},[i,e.shouldUnregister]),G.useEffect(()=>{if(i._proxyFormState.isDirty){const o=i._getDirty();o!==s.isDirty&&i._subjects.state.next({isDirty:o})}},[i,s.isDirty]),G.useEffect(()=>{e.values&&!mo(e.values,r.current)?(i._reset(e.values,{keepFieldsRef:!0,...i._options.resetOptions}),r.current=e.values,a(o=>({...o}))):i._resetDefaultValues()},[i,e.values]),G.useEffect(()=>{i._state.mount||(i._setValid(),i._state.mount=!0),i._state.watch&&(i._state.watch=!1,i._subjects.state.next({...i._formState})),i._removeUnmounted()}),t.current.formState=sU(s,i),t.current}const GA=(e,t,r)=>{if(e&&"reportValidity"in e){const s=He(r,t);e.setCustomValidity(s&&s.message||""),e.reportValidity()}},fU=(e,t)=>{for(const r in t.fields){const s=t.fields[r];s&&s.ref&&"reportValidity"in s.ref?GA(s.ref,r,e):s.refs&&s.refs.forEac
vendor: 3,053 bytes, line 686
686h(a=>GA(a,r,e))}},Die=(e,t)=>{t.shouldUseNativeValidation&&fU(e,t);const r={};for(const s in e){const a=He(t.fields,s),i=Object.assign(e[s]||{},{ref:a&&a.ref});if(Rie(t.names||Object.keys(e),s)){const o=Object.assign({},He(r,s));ar(o,"root",i),ar(r,s,o)}else ar(r,s,i)}return r},Rie=(e,t)=>e.some(r=>r.startsWith(t+"."));var $ie=function(e,t){for(var r={};e.length;){var s=e[0],a=s.code,i=s.message,o=s.path.join(".");if(!r[o])if("unionErrors"in s){var l=s.unionErrors[0].errors[0];r[o]={message:l.message,type:l.code}}else r[o]={message:i,type:a};if("unionErrors"in s&&s.unionErrors.forEach(function(u){return u.errors.forEach(function(h){return e.push(h)})}),t){var c=r[o].types,d=c&&c[s.code];r[o]=iU(o,t,r,a,d?[].concat(d,s.message):s.message)}e.shift()}return r},Iie=function(e,t,r){return r===void 0&&(r={}),function(s,a,i){try{return Promise.resolve(function(o,l){try{var c=Promise.resolve(e[r.mode==="sync"?"parse":"parseAsync"](s,t)).then(function(d){return i.shouldUseNativeValidation&&fU({},i),{errors:{},values:r.raw?s:d}})}catch(d){return l(d)}return c&&c.then?c.then(void 0,l):c}(0,function(o){if(function(l){return Array.isArray(l==null?void 0:l.errors)}(o))return{values:{},errors:Die($ie(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}}},Ht;(function(e){e.assertEqual=a=>{};function t(a){}e.assertIs=t;function r(a){throw new Error}e.assertNever=r,e.arrayToEnum=a=>{const i={};for(const o of a)i[o]=o;return i},e.getValidEnumValues=a=>{const i=e.objectKeys(a).filter(l=>typeof a[a[l]]!="number"),o={};for(const l of i)o[l]=a[l];return e.objectValues(o)},e.objectValues=a=>e.objectKeys(a).map(function(i){return a[i]}),e.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const o in a)Object.prototype.hasOwnProperty.call(a,o)&&i.push(o);return i},e.find=(a,i)=>{for(const o of a)if(i(o))return o},e.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,i=" | "){return a.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}e.joinValues=s,e.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(Ht||(Ht={}));var YA;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(YA||(YA={}));const et=Ht.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),gl=e=>{switch(typeof e){case"undefined":return et.undefined;case"string":return et.string;case"number":return Number.isNaN(e)?et.nan:et.number;case"boolean":return et.boolean;case"function":return et.function;case"bigint":return et.bigint;case"symbol":return et.symbol;case"object":return Array.isArray(e)?et.array:e===null?et.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?et.promise:typeof Map<"u"&&e instanceof Map?et.map:typeof Set<"u"&&e instanceof Set?et.set:typeof Date<"u"&&e instanceof Date?et.date:et.object;default:return et.unknown}}
vendor: 4,379 bytes, line 686
686,$e=Ht.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Bo extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},s={_errors:[]},a=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(a);else if(o.code==="invalid_return_type")a(o.returnTypeError);else if(o.code==="invalid_arguments")a(o.argumentsError);else if(o.path.length===0)s._errors.push(r(o));else{let l=s,c=0;for(;c<o.path.length;){const d=o.path[c];c===o.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(r(o))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}};return a(this),s}static assert(t){if(!(t instanceof Bo))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ht.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r={},s=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(t(a))}else s.push(t(a));return{formErrors:s,fieldErrors:r}}get formErrors(){return this.flatten()}}Bo.create=e=>new Bo(e);const $N=(e,t)=>{let r;switch(e.code){case $e.invalid_type:e.received===et.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case $e.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ht.jsonStringifyReplacer)}`;break;case $e.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ht.joinValues(e.keys,", ")}`;break;case $e.invalid_union:r="Invalid input";break;case $e.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ht.joinValues(e.options)}`;break;case $e.invalid_enum_value:r=`Invalid enum value. Expected ${Ht.joinValues(e.options)}, received '${e.received}'`;break;case $e.invalid_arguments:r="Invalid function arguments";break;case $e.invalid_return_type:r="Invalid function return type";break;case $e.invalid_date:r="Invalid date";break;case $e.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Ht.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case $e.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case $e.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case $e.custom:r="Invalid input";break;
vendor: 5,030 bytes, line 686
686case $e.invalid_intersection_types:r="Intersection results could not be merged";break;case $e.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case $e.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ht.assertNever(e)}return{message:r}};let Lie=$N;function Fie(){return Lie}const Uie=e=>{const{data:t,path:r,errorMaps:s,issueData:a}=e,i=[...r,...a.path||[]],o={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let l="";const c=s.filter(d=>!!d).slice().reverse();for(const d of c)l=d(o,{data:t,defaultError:l}).message;return{...a,path:i,message:l}};function Ye(e,t){const r=Fie(),s=Uie({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===$N?void 0:$N].filter(a=>!!a)});e.common.issues.push(s)}class oa{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){const s=[];for(const a of r){if(a.status==="aborted")return ft;a.status==="dirty"&&t.dirty(),s.push(a.value)}return{status:t.value,value:s}}static async mergeObjectAsync(t,r){const s=[];for(const a of r){const i=await a.key,o=await a.value;s.push({key:i,value:o})}return oa.mergeObjectSync(t,s)}static mergeObjectSync(t,r){const s={};for(const a of r){const{key:i,value:o}=a;if(i.status==="aborted"||o.status==="aborted")return ft;i.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||a.alwaysSet)&&(s[i.value]=o.value)}return{status:t.value,value:s}}}const ft=Object.freeze({status:"aborted"}),sm=e=>({status:"dirty",value:e}),$a=e=>({status:"valid",value:e}),QA=e=>e.status==="aborted",XA=e=>e.status==="dirty",ch=e=>e.status==="valid",Xv=e=>typeof Promise<"u"&&e instanceof Promise;var rt;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(rt||(rt={}));class rc{constructor(t,r,s,a){this._cachedPath=[],this.parent=t,this.data=r,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ZA=(e,t)=>{if(ch(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Bo(e.common.issues);return this._error=r,this._error}}};function Nt(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:s,description:a}=e;if(t&&(r||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:a}:{errorMap:(o,l)=>{const{message:c}=e;return o.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??s??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:c??r??l.defaultError}},description:a}}class Wt{get description(){return this._def.description}_getType(t){return gl(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:gl(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new oa,ctx:{common:t.parent.common,data:t.data,parsedType:gl(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const r=this._parse(t);if(Xv(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){const r=this._parse(t);return Promise.resolve(r)}parse(t,r){const s=this.safeParse(t,r);if(s.success)return s.data;throw s.error}safeParse(t,r){const s={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:gl(t)},a=this._parseSync({data:t,path:s.path,parent:s});return ZA(s,a)}"~validate"(t){var s,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:gl(t)};if(!this["~standard"].async)try{const i=this._parseSync({data:t,path:[],parent:r});return ch(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(a=(s=i==null?void 0:i.message)==null?void 0:s.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:r}).then(i=>ch(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(t,r){const s=await this.safeParseAsync(t,r);if(s.success)return s.data;throw s.error}async safeParseAsync(t,r){const s={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:gl(t)},a=this._parse({data:t,path:s.path,parent:s}),i=await(Xv(a)?a:Promise.resolve(a));return ZA(s,i)}refine(t,r){const s=a=>typeof r=="string"||typeof r>"u"?{message:r}
vendor: 6,231 bytes, line 686
686:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const o=t(a),l=()=>i.addIssue({code:$e.custom,...s(a)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(t,r){return this._refinement((s,a)=>t(s)?!0:(a.addIssue(typeof r=="function"?r(s,a):r),!1))}_refinement(t){return new hh({schema:this,typeName:pt.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return Gl.create(this,this._def)}nullable(){return fh.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Di.create(this)}promise(){return ty.create(this,this._def)}or(t){return Jv.create([this,t],this._def)}and(t){return ey.create(this,t,this._def)}transform(t){return new hh({...Nt(this._def),schema:this,typeName:pt.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const r=typeof t=="function"?t:()=>t;return new LN({...Nt(this._def),innerType:this,defaultValue:r,typeName:pt.ZodDefault})}brand(){return new coe({typeName:pt.ZodBranded,type:this,...Nt(this._def)})}catch(t){const r=typeof t=="function"?t:()=>t;return new FN({...Nt(this._def),innerType:this,catchValue:r,typeName:pt.ZodCatch})}describe(t){const r=this.constructor;return new r({...this._def,description:t})}pipe(t){return kk.create(this,t)}readonly(){return UN.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const zie=/^c[^\s-]{8,}$/i,Bie=/^[0-9a-z]+$/,qie=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Wie=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Hie=/^[a-z0-9_-]{21}$/i,Vie=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Kie=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Gie=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yie="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let hw;const Qie=/^(?:(?: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])$/,Xie=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Zie=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Jie=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,eoe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,toe=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mU="((\\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])))",roe=new RegExp(`^${mU}$`);function pU(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const r=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function noe(e){return new RegExp(`^${pU(e)}$`)}function soe(e){let t=`${mU}T${pU(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function aoe(e,t){return!!((t==="v4"||!t)&&Qie.test(e)||(t==="v6"||!t)&&Zie.test(e))}function ioe(e,t){if(!Vie.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const s=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||t&&a.alg!==t)}catch{return!1}}function ooe(e,t){return!!((t==="v4"||!t)&&Xie.test(e)||(t==="v6"||!t)&&Jie.test(e))}class jo extends Wt{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==et.string){const i=this._getOrReturnCtx(t);
vendor: 19,335 bytes, line 686
686return Ye(i,{code:$e.invalid_type,expected:et.string,received:i.parsedType}),ft}const s=new oa;let a;for(const i of this._def.checks)if(i.kind==="min")t.data.length<i.value&&(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="max")t.data.length>i.value&&(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),s.dirty());else if(i.kind==="length"){const o=t.data.length>i.value,l=t.data.length<i.value;(o||l)&&(a=this._getOrReturnCtx(t,a),o?Ye(a,{code:$e.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):l&&Ye(a,{code:$e.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),s.dirty())}else if(i.kind==="email")Gie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"email",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="emoji")hw||(hw=new RegExp(Yie,"u")),hw.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"emoji",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="uuid")Wie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"uuid",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="nanoid")Hie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"nanoid",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid")zie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"cuid",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="cuid2")Bie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"cuid2",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="ulid")qie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"ulid",code:$e.invalid_string,message:i.message}),s.dirty());else if(i.kind==="url")try{new URL(t.data)}catch{a=this._getOrReturnCtx(t,a),Ye(a,{validation:"url",code:$e.invalid_string,message:i.message}),s.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"regex",code:$e.invalid_string,message:i.message}),s.dirty())):i.kind==="trim"?t.data=t.data.trim():i.kind==="includes"?t.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),s.dirty()):i.kind==="toLowerCase"?t.data=t.data.toLowerCase():i.kind==="toUpperCase"?t.data=t.data.toUpperCase():i.kind==="startsWith"?t.data.startsWith(i.value)||(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.invalid_string,validation:{startsWith:i.value},message:i.message}),s.dirty()):i.kind==="endsWith"?t.data.endsWith(i.value)||(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.invalid_string,validation:{endsWith:i.value},message:i.message}),s.dirty()):i.kind==="datetime"?soe(i).test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.invalid_string,validation:"datetime",message:i.message}),s.dirty()):i.kind==="date"?roe.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.invalid_string,validation:"date",message:i.message}),s.dirty()):i.kind==="time"?noe(i).test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.invalid_string,validation:"time",message:i.message}),s.dirty()):i.kind==="duration"?Kie.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"duration",code:$e.invalid_string,message:i.message}),s.dirty()):i.kind==="ip"?aoe(t.data,i.version)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"ip",code:$e.invalid_string,message:i.message}),s.dirty()):i.kind==="jwt"?ioe(t.data,i.alg)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"jwt",code:$e.invalid_string,message:i.message}),s.dirty()):i.kind==="cidr"?ooe(t.data,i.version)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"cidr",code:$e.invalid_string,message:i.message}),s.dirty()):i.kind==="base64"?eoe.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"base64",code:$e.invalid_string,message:i.message}),s.dirty()):i.kind==="base64url"?toe.test(t.data)||(a=this._getOrReturnCtx(t,a),Ye(a,{validation:"base64url",code:$e.invalid_string,message:i.message}),s.dirty()):Ht.assertNever(i);return{status:s.value,value:t.data}}_regex(t,r,s){return this.refinement(a=>t.test(a),{validation:r,code:$e.invalid_string,...rt.errToObj(s)})}_addCheck(t){return new jo({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...rt.errToObj(t)})}url(t){return this._addCheck({kind:"url",...rt.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...rt.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...rt.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...rt.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...rt.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...rt.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...rt.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...rt.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...rt.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...rt.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...rt.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...rt.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...rt.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...rt.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...rt.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...rt.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r==null?void 0:r.position,...rt.errToObj(r==null?void 0:r.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...rt.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...rt.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...rt.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...rt.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...rt.errToObj(r)})}nonempty(t){return this.min(1,rt.errToObj(t))}trim(){return new jo({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jo({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jo({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}jo.create=e=>new jo({checks:[],typeName:pt.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Nt(e)});function loe(e,t){const r=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,a=r>s?r:s,i=Number.parseInt(e.toFixed(a).replace(".","")),o=Number.parseInt(t.toFixed(a).replace(".",""));return i%o/10**a}class jd extends Wt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==et.number){const i=this._getOrReturnCtx(t);return Ye(i,{code:$e.invalid_type,expected:et.number,received:i.parsedType}),ft}let s;const a=new oa;for(const i of this._def.checks)i.kind==="int"?Ht.isInteger(t.data)||(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?loe(t.data,i.value)!==0&&(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(t.data)||(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.not_finite,message:i.message}),a.dirty()):Ht.assertNever(i);return{status:a.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,rt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,rt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,rt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,rt.toString(r))}setLimit(t,r,s,a){return new jd({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:s,message:rt.toString(a)}]})}_addCheck(t){return new jd({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:rt.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:rt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:rt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:rt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:rt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:rt.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:rt.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:rt.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:rt.toString(t)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ht.isInteger(t.value))}get isFinite(){let t=null,r=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(r===null||s.value>r)&&(r=s.value):s.kind==="max"&&(t===null||s.value<t)&&(t=s.value)}return Number.isFinite(r)&&Number.isFinite(t)}}jd.create=e=>new jd({checks:[],typeName:pt.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Nt(e)});class bd extends Wt{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==et.bigint)return this._getInvalidInput(t);let s;const a=new oa;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?t.data<i.value:t.data<=i.value)&&(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?t.data>i.value:t.data>=i.value)&&(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?t.data%i.value!==BigInt(0)&&(s=this._getOrReturnCtx(t,s),Ye(s,{code:$e.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):Ht.assertNever(i);return{status:a.value,value:t.data}}_getInvalidInput(t){const r=this._getOrReturnCtx(t);return Ye(r,{code:$e.invalid_type,expected:et.bigint,received:r.parsedType}),ft}gte(t,r){return this.setLimit("min",t,!0,rt.toString(r))}gt(t,r){return this.setLimit("min",t,!1,rt.toString(r))}lte(t,r){return this.setLimit("max",t,!0,rt.toString(r))}lt(t,r){return this.setLimit("max",t,!1,rt.toString(r))}setLimit(t,r,s,a){return new bd({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:s,message:rt.toString(a)}]})}_addCheck(t){return new bd({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:rt.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:rt.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:rt.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:rt.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:rt.toString(r)})}get minValue(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}}bd.create=e=>new bd({checks:[],typeName:pt.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Nt(e)});class Zv extends Wt{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==et.boolean){const s=this._getOrReturnCtx(t);return Ye(s,{code:$e.invalid_type,expected:et.boolean,received:s.parsedType}),ft}return $a(t.data)}}Zv.create=e=>new Zv({typeName:pt.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Nt(e)});class dh extends Wt{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==et.date){const i=this._getOrReturnCtx(t);return Ye(i,{code:$e.invalid_type,expected:et.date,received:i.parsedType}),ft}if(Number.isNaN(t.data.getTime())){const i=this._getOrReturnCtx(t);return Ye(i,{code:$e.invalid_date}),ft}const s=new oa;let a;for(const i of this._def.checks)i.kind==="min"?t.data.getTime()<i.value&&(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),s.dirty()):i.kind==="max"?t.data.getTime()>i.value&&(a=this._getOrReturnCtx(t,a),Ye(a,{code:$e.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),s.dirty()):Ht.assertNever(i);return{status:s.value,value:new Date(t.data.getTime())}}_addCheck(t){return new dh({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:rt.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:rt.toString(r)})}get minDate(){let t=null;for(const r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}}dh.create=e=>new dh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:pt.ZodDate,...Nt(e)});class JA extends Wt{_parse(t){if(this._getType(t)!==et.symbol){const s=this._getOrReturnCtx(t);return Ye(s,{code:$e.invalid_type,expected:et.symbol,received:s.parsedType}),ft}return $a(t.data)}}JA.create=e=>new JA({typeName:pt.ZodSymbol,...Nt(e)});class eE extends Wt{_parse(t){if(this._getType(t)!==et.undefined){const s=this._getOrReturnCtx(t);return Ye(s,{code:$e.invalid_type,expected:et.undefined,received:s.parsedType}),ft}return $a(t.data)}}eE.create=e=>new eE({typeName:pt.ZodUndefined,...Nt(e)});class tE extends Wt{_parse(t){if(this._getType(t)!==et.null){const s=this._getOrReturnCtx(t);return Ye(s,{code:$e.invalid_type,expected:et.null,received:s.parsedType}),ft}return $a(t.data)}}tE.create=e=>new tE({typeName:pt.ZodNull,...Nt(e)});class rE extends Wt{constructor(){super(...arguments),this._any=!0}_parse(t){return $a(t.data)}}rE.create=e=>new rE({typeName:pt.ZodAny,...Nt(e)});class nE extends Wt{constructor(){super(...arguments),this._unknown=!0}_parse(t){return $a(t.data)}}nE.create=e=>new nE({typeName:pt.ZodUnknown,...Nt(e)});class nc extends Wt{_parse(t){const r=this._getOrReturnCtx(t);return Ye(r,{code:$e.invalid_type,expected:et.never,received:r.parsedType}),ft}}nc.create=e=>new nc({typeName:pt.ZodNever,...Nt(e)});class sE extends Wt{_parse(t){if(this._getType(t)!==et.undefined){const s=this._getOrReturnCtx(t);return Ye(s,{code:$e.invalid_type,expected:et.void,received:s.parsedType}),ft}return $a(t.data)}}sE.create=e=>new sE({typeName:pt.ZodVoid,...Nt(e)});class Di extends Wt{_parse(t){const{ctx:r,status:s}=this._processInputParams(t),a=this._def;if(r.parsedType!==et.array)return Ye(r,{code:$e.invalid_type,expected:et.array,received:r.parsedType}),ft;if(a.exactLength!==null){const o=r.data.length>a.exactLength.value,l=r.data.length<a.exactLength.value;(o||l)&&(Ye(r,{code:o?$e.too_big:$e.too_small,minimum:l?a.exactLength.value:void 0,maximum:o?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(Ye(r,{code:$e.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(Ye(r,{code:$e.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),r.common.async)return Promise.all([...r.data].map((o,l)=>a.type._parseAsync(new rc(r,o,r.path,l)))).then(o=>oa.mergeArray(s,o));const i=[...r.data].map((o,l)=>a.type._parseSync(new rc(r,o,r.path,l)));return oa.mergeArray(s,i)}get element(){return this._def.type}min(t,r){return new Di({...this._def,minLength:{value:t,message:rt.toString(r)}})}max(t,r){return new Di({...this._def,maxLength:{value:t,message:rt.toString(r)}})}length(t,r){return new Di({...this._def,exactLength:{value:t,message:rt.toString(r)}})}nonempty(t){return this.min(1,t)}}Di.create=(e,t)=>new Di({type:e,minLength:null,maxLength:null,exactLength:null,typeName:pt.ZodArray,...Nt(t)});function au(e){if(e instanceof Vr){const t={};for(const r in e.shape){const s=e.shape[r];t[r]=Gl.create(au(s))}return new Vr({...e._def,shape:()=>t})}else return e instanceof Di?new Di({...e._def,type:au(e.element)}):e instanceof Gl?Gl.create(au(e.unwrap())):e instanceof fh?fh.create(au(e.unwrap())):e instanceof wd?wd.create(e.items.map(t=>au(t))):e}class Vr extends Wt{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;
vendor: 4,147 bytes, line 686
686const t=this._def.shape(),r=Ht.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==et.object){const d=this._getOrReturnCtx(t);return Ye(d,{code:$e.invalid_type,expected:et.object,received:d.parsedType}),ft}const{status:s,ctx:a}=this._processInputParams(t),{shape:i,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof nc&&this._def.unknownKeys==="strip"))for(const d in a.data)o.includes(d)||l.push(d);const c=[];for(const d of o){const u=i[d],h=a.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new rc(a,h,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof nc){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of l)c.push({key:{status:"valid",value:u},value:{status:"valid",value:a.data[u]}});else if(d==="strict")l.length>0&&(Ye(a,{code:$e.unrecognized_keys,keys:l}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of l){const h=a.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new rc(a,h,a.path,u)),alwaysSet:u in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const h=await u.key,f=await u.value;d.push({key:h,value:f,alwaysSet:u.alwaysSet})}return d}).then(d=>oa.mergeObjectSync(s,d)):oa.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(t){return rt.errToObj,new Vr({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,s)=>{var i,o;const a=((o=(i=this._def).errorMap)==null?void 0:o.call(i,r,s).message)??s.defaultError;return r.code==="unrecognized_keys"?{message:rt.errToObj(t).message??a}:{message:a}}}:{}})}strip(){return new Vr({...this._def,unknownKeys:"strip"})}passthrough(){return new Vr({...this._def,unknownKeys:"passthrough"})}extend(t){return new Vr({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Vr({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:pt.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Vr({...this._def,catchall:t})}pick(t){const r={};for(const s of Ht.objectKeys(t))t[s]&&this.shape[s]&&(r[s]=this.shape[s]);return new Vr({...this._def,shape:()=>r})}omit(t){const r={};for(const s of Ht.objectKeys(this.shape))t[s]||(r[s]=this.shape[s]);return new Vr({...this._def,shape:()=>r})}deepPartial(){return au(this)}partial(t){const r={};for(const s of Ht.objectKeys(this.shape)){const a=this.shape[s];t&&!t[s]?r[s]=a:r[s]=a.optional()}return new Vr({...this._def,shape:()=>r})}required(t){const r={};for(const s of Ht.objectKeys(this.shape))if(t&&!t[s])r[s]=this.shape[s];else{let i=this.shape[s];for(;i instanceof Gl;)i=i._def.innerType;r[s]=i}return new Vr({...this._def,shape:()=>r})}keyof(){return gU(Ht.objectKeys(this.shape))}}Vr.create=(e,t)=>new Vr({shape:()=>e,unknownKeys:"strip",catchall:nc.create(),typeName:pt.ZodObject,...Nt(t)});Vr.strictCreate=(e,t)=>new Vr({shape:()=>e,unknownKeys:"strict",catchall:nc.create(),typeName:pt.ZodObject,...Nt(t)});Vr.lazycreate=(e,t)=>new Vr({shape:e,unknownKeys:"strip",catchall:nc.create(),typeName:pt.ZodObject,...Nt(t)});class Jv extends Wt{_parse(t){const{ctx:r}=this._processInputParams(t),s=this._def.options;function a(i){for(const l of i)if(l.result.status==="valid")return l.result;for(const l of i)if(l.result.status==="dirty")return r.common.issues.push(...l.ctx.common.issues),l.result;const o=i.map(l=>new Bo(l.ctx.common.issues));return Ye(r,{code:$e.invalid_union,unionErrors:o}),ft}if(r.common.async)return Promise.all(s.map(async i=>{const o={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(a);{let i;const o=[];for(const c of s){const d={...r,common:{...r.common,issues:[]},parent:null},u=c._parseSync({data:r.data,path:r.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!i&&(i={result:u,ctx:d}),d.common.issues.length&&o.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const l=o.map(c=>new Bo(c));
vendor: 4,521 bytes, line 686
686return Ye(r,{code:$e.invalid_union,unionErrors:l}),ft}}get options(){return this._def.options}}Jv.create=(e,t)=>new Jv({options:e,typeName:pt.ZodUnion,...Nt(t)});function IN(e,t){const r=gl(e),s=gl(t);if(e===t)return{valid:!0,data:e};if(r===et.object&&s===et.object){const a=Ht.objectKeys(t),i=Ht.objectKeys(e).filter(l=>a.indexOf(l)!==-1),o={...e,...t};for(const l of i){const c=IN(e[l],t[l]);if(!c.valid)return{valid:!1};o[l]=c.data}return{valid:!0,data:o}}else if(r===et.array&&s===et.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const o=e[i],l=t[i],c=IN(o,l);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return r===et.date&&s===et.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class ey extends Wt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t),a=(i,o)=>{if(QA(i)||QA(o))return ft;const l=IN(i.value,o.value);return l.valid?((XA(i)||XA(o))&&r.dirty(),{status:r.value,value:l.data}):(Ye(s,{code:$e.invalid_intersection_types}),ft)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([i,o])=>a(i,o)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ey.create=(e,t,r)=>new ey({left:e,right:t,typeName:pt.ZodIntersection,...Nt(r)});class wd extends Wt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==et.array)return Ye(s,{code:$e.invalid_type,expected:et.array,received:s.parsedType}),ft;if(s.data.length<this._def.items.length)return Ye(s,{code:$e.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ft;!this._def.rest&&s.data.length>this._def.items.length&&(Ye(s,{code:$e.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...s.data].map((o,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new rc(s,o,s.path,l)):null}).filter(o=>!!o);return s.common.async?Promise.all(i).then(o=>oa.mergeArray(r,o)):oa.mergeArray(r,i)}get items(){return this._def.items}rest(t){return new wd({...this._def,rest:t})}}wd.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new wd({items:e,typeName:pt.ZodTuple,rest:null,...Nt(t)})};class aE extends Wt{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==et.map)return Ye(s,{code:$e.invalid_type,expected:et.map,received:s.parsedType}),ft;const a=this._def.keyType,i=this._def.valueType,o=[...s.data.entries()].map(([l,c],d)=>({key:a._parse(new rc(s,l,s.path,[d,"key"])),value:i._parse(new rc(s,c,s.path,[d,"value"]))}));if(s.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of o){const d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return ft;(d.status==="dirty"||u.status==="dirty")&&r.dirty(),l.set(d.value,u.value)}return{status:r.value,value:l}})}else{const l=new Map;for(const c of o){const d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return ft;(d.status==="dirty"||u.status==="dirty")&&r.dirty(),l.set(d.value,u.value)}return{status:r.value,value:l}}}}aE.create=(e,t,r)=>new aE({valueType:t,keyType:e,typeName:pt.ZodMap,...Nt(r)});class ip extends Wt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.parsedType!==et.set)return Ye(s,{code:$e.invalid_type,expected:et.set,received:s.parsedType}),ft;const a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(Ye(s,{code:$e.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(Ye(s,{code:$e.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function o(c){const d=new Set;for(const u of c){if(u.status==="aborted")return ft;u.status==="dirty"&&r.dirty(),d.add(u.value)}return{status:r.value,value:d}}const l=[...s.data.values()].map((c,d)=>i._parse(new rc(s,c,s.path,d)));return s.common.async?Promise.all(l).then(c=>o(c)):o(l)}min(t,r){return new ip({...this._def,minSize:{value:t,message:rt.toString(r)}})}max(t,r){return new ip({...this._def,maxSize:{value:t,message:rt.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}}ip.create=(e,t)=>
vendor: 5,021 bytes, line 686
686new ip({valueType:e,minSize:null,maxSize:null,typeName:pt.ZodSet,...Nt(t)});class iE extends Wt{get schema(){return this._def.getter()}_parse(t){const{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}iE.create=(e,t)=>new iE({getter:e,typeName:pt.ZodLazy,...Nt(t)});class oE extends Wt{_parse(t){if(t.data!==this._def.value){const r=this._getOrReturnCtx(t);return Ye(r,{received:r.data,code:$e.invalid_literal,expected:this._def.value}),ft}return{status:"valid",value:t.data}}get value(){return this._def.value}}oE.create=(e,t)=>new oE({value:e,typeName:pt.ZodLiteral,...Nt(t)});function gU(e,t){return new uh({values:e,typeName:pt.ZodEnum,...Nt(t)})}class uh extends Wt{_parse(t){if(typeof t.data!="string"){const r=this._getOrReturnCtx(t),s=this._def.values;return Ye(r,{expected:Ht.joinValues(s),received:r.parsedType,code:$e.invalid_type}),ft}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const r=this._getOrReturnCtx(t),s=this._def.values;return Ye(r,{received:r.data,code:$e.invalid_enum_value,options:s}),ft}return $a(t.data)}get options(){return this._def.values}get enum(){const t={};for(const r of this._def.values)t[r]=r;return t}get Values(){const t={};for(const r of this._def.values)t[r]=r;return t}get Enum(){const t={};for(const r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return uh.create(t,{...this._def,...r})}exclude(t,r=this._def){return uh.create(this.options.filter(s=>!t.includes(s)),{...this._def,...r})}}uh.create=gU;class lE extends Wt{_parse(t){const r=Ht.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(t);if(s.parsedType!==et.string&&s.parsedType!==et.number){const a=Ht.objectValues(r);return Ye(s,{expected:Ht.joinValues(a),received:s.parsedType,code:$e.invalid_type}),ft}if(this._cache||(this._cache=new Set(Ht.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const a=Ht.objectValues(r);return Ye(s,{received:s.data,code:$e.invalid_enum_value,options:a}),ft}return $a(t.data)}get enum(){return this._def.values}}lE.create=(e,t)=>new lE({values:e,typeName:pt.ZodNativeEnum,...Nt(t)});class ty extends Wt{unwrap(){return this._def.type}_parse(t){const{ctx:r}=this._processInputParams(t);if(r.parsedType!==et.promise&&r.common.async===!1)return Ye(r,{code:$e.invalid_type,expected:et.promise,received:r.parsedType}),ft;const s=r.parsedType===et.promise?r.data:Promise.resolve(r.data);return $a(s.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ty.create=(e,t)=>new ty({type:e,typeName:pt.ZodPromise,...Nt(t)});class hh extends Wt{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===pt.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:r,ctx:s}=this._processInputParams(t),a=this._def.effect||null,i={addIssue:o=>{Ye(s,o),o.fatal?r.abort():r.dirty()},get path(){return s.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const o=a.transform(s.data,i);if(s.common.async)return Promise.resolve(o).then(async l=>{if(r.value==="aborted")return ft;const c=await this._def.schema._parseAsync({data:l,path:s.path,parent:s});return c.status==="aborted"?ft:c.status==="dirty"||r.value==="dirty"?sm(c.value):c});{if(r.value==="aborted")return ft;const l=this._def.schema._parseSync({data:o,path:s.path,parent:s});return l.status==="aborted"?ft:l.status==="dirty"||r.value==="dirty"?sm(l.value):l}}if(a.type==="refinement"){const o=l=>{const c=a.refinement(l,i);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(s.common.async===!1){const l=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return l.status==="aborted"?ft:(l.status==="dirty"&&r.dirty(),o(l.value),{status:r.value,value:l.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(l=>l.status==="aborted"?ft:(l.status==="dirty"&&r.dirty(),o(l.value).then(()=>({status:r.value,value:l.value}))))}if(a.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ch(o))return ft;const l=a.transform(o.value,i);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:l}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>ch(o)?Promise.resolve(a.transform(o.value,i)).then(l=>({status:r.value,value:l})):ft);Ht.assertNever(a)}}hh.create=(e,t,r)=>new hh({schema:e,typeName:pt.ZodEffects,effect:t,...Nt(r)});hh.createWithPreprocess=(e,t,r)=>new hh({schema:t,effect:{type:"preprocess",transform:e},typeName:pt.ZodEffects,...Nt(r)});class Gl extends Wt{_parse(t){return this._getType(t)===et.undefined?$a(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Gl.create=(e,t)=>
686new Gl({innerType:e,typeName:pt.ZodOptional,...Nt(t)});class fh extends Wt{_parse(t){return this._getType(t)===et.null?$a(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}fh.create=(e,t)=>new fh({innerType:e,typeName:pt.ZodNullable,...Nt(t)});class LN extends Wt{_parse(t){const{ctx:r}=this._processInputParams(t);let s=r.data;return r.parsedType===et.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}LN.create=(e,t)=>new LN({innerType:e,typeName:pt.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Nt(t)});class FN extends Wt{_parse(t){const{ctx:r}=this._processInputParams(t),s={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Xv(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Bo(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Bo(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}FN.create=(e,t)=>new FN({innerType:e,typeName:pt.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Nt(t)});class cE extends Wt{_parse(t){if(this._getType(t)!==et.nan){const s=this._getOrReturnCtx(t);return Ye(s,{code:$e.invalid_type,expected:et.nan,received:s.parsedType}),ft}return{status:"valid",value:t.data}}}cE.create=e=>new cE({typeName:pt.ZodNaN,...Nt(e)});class coe extends Wt{_parse(t){const{ctx:r}=this._processInputParams(t),s=r.data;return this._def.type._parse({data:s,path:r.path,parent:r})}unwrap(){return this._def.type}}class kk extends Wt{_parse(t){const{status:r,ctx:s}=this._processInputParams(t);if(s.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?ft:i.status==="dirty"?(r.dirty(),sm(i.value)):this._def.out._parseAsync({data:i.value,path:s.path,parent:s})})();{const a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?ft:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(t,r){return new kk({in:t,out:r,typeName:pt.ZodPipeline})}}class UN extends Wt{_parse(t){const r=this._def.innerType._parse(t),s=a=>(ch(a)&&(a.value=Object.freeze(a.value)),a);return Xv(r)?r.then(a=>s(a)):s(r)}unwrap(){return this._def.innerType}}UN.create=(e,t)=>new UN({innerType:e,typeName:pt.ZodReadonly,...Nt(t)});Vr.lazycreate;var pt;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(pt||(pt={}));const Df=jo.create;jd.create;bd.create;Zv.create;dh.create;nc.create;Di.create;const doe=Vr.create;Vr.strictCreate;Jv.create;ey.create;wd.create;const uoe=uh.create;ty.create;Gl.create;fh.create;const fw={string:e=>jo.create({...e,coerce:!0}),number:e=>jd.create({...e,coerce:!0}),boolean:e=>Zv.create({...e,coerce:!0}),bigint:e=>bd.create({...e,coerce:!0}),date:e=>dh.create({...e,coerce:!0})},hoe=pie,xU=x.createContext({}),no=({...e})=>n.jsx(xU.Provider,{value:{name:e.name},children:n.jsx(yie,{...e})}),lj=()=>{const e=x.useContext(xU),t=x.useContext(vU),{getFieldState:r,formState:s}=oj(),a=r(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:i}=t;return{id:i,name:e.name,formItemId:`${i}-form-item`,formDescriptionId:`${i}-form-item-description`,formMessageId:`${i}-form-item-message`,...a}},vU=x.createContext({}),gi=x.forwardRef(({className:e,...t},r)=>{const s=x.useId();return n.jsx(vU.Provider,{value:{id:s},children:n.jsx("div",{ref:r,className:we("space-y-2",e),...t})})});gi.displayName="FormItem";const xi=x.forwardRef(({className:e,...t},r)=>{const{error:s,formItemId:a}=lj();return n.jsx(z,{ref:r,className:we(s&&"text-destructive",e),htmlFor:a,...t})});xi.displayName="FormLabel";const vi=x.forwardRef(({...e},t)=>{const{error:r,formItemId:s,formDescriptionId:a,formMessageId:i}=lj();return n.jsx(oc,{ref:t,id:s,"aria-describedby":r?`${a} ${i}`:`${a}`,"aria-invalid":!!r,...e})});vi.displayName="FormControl";const fl=x.forwardRef(({className:e,...t},r)=>{const{formDescriptionId:s}=lj();return n.jsx("p",{ref:r,id:s,className:we("text-sm text-muted-foreground",e),...t})});fl.displayName="FormDescription";const yi=x.forwardRef(({className:e,children:t,...r},s)=>{const{error:a,formMessageId:i}=lj(),o=a?String(a==null?void 0:a.message):t;return o?n.jsx("p",{ref:s,id:i,className:we("text-sm font-medium text-destructive",e),...r,children:o}):null});yi.displayName="FormMessage";const foe=doe({name:Df().trim().min(1,"Name is required").max(100,"Name must be less than 100 characters"),description:Df().trim().max(500,"Description must be less than 500 characters").optional(),hostname_or_url:Df().trim().min(1,"URL/Hostname is required").max(255,"URL must be less than 255 characters"),port:fw.number().int().min(1).max(65535).optional().nullable(),protocol:uoe(["http","https"]),check_interval:fw.number().int().min(60,"Minimum 60 seconds").max(3600,"Maximum 3600 seconds"),timeout_seconds:fw.number().int().min(5,"Minimum 5 seconds").max(300,"Maximum 300 seconds"),expected_status_codes:Df().trim().regex(/^[0-9]+(,[0-9]+)*$/,"Must be comma-separated status codes (e.g., 200,301)").max(100),group_id:Df().nullable().optional()});function moe({monitor:e,open:t,onOpenChange:r}){const{updateAgent:s,isUpdating:a}=Lt(e.client_id),{groups:i,isLoading:o}=Vi(e.client_id),[l,c]=x.useState(!1),d=e.monitoring_config||{},u=d.check_interval||300,h=d.timeout_seconds||30,f=d.expected_status_codes||"200",m=Mie({resolver:Iie(foe),defaultValues:{name:e.name,description:e.description||"",hostname_or_url:e.hostname_or_url||"",port:e.port||null,protocol:e.protocol,check_interval:u,timeout_seconds:h,expected_status_codes:f,group_id:e.group_id||null}}),g=async p=>{c(!0);try{const y={...d,check_interval:p.check_interval,timeout_seconds:p.timeout_seconds,expected_status_codes:p.expected_status_codes},v=`${p.protocol}://${p.hostname_or_url}${p.port&&p.port!==80&&p.port!==443?`:${p.port}`:""}`;await s({id:e.id,name:p.name,description:p.description||null,hostname_or_url:p.hostname_or_url,port:p.port||null,protocol:p.protocol,monitoring_config:y,group_id:p.group_id==="none"?null:p.group_id||null});const{data:j}=await B.from("monitors").select("id").eq("monitoring_agent_id",e.id).single();j&&await B.from("monitors").update({url:v}).eq("id",j.id),ye.success("Monitor updated successfully"),r(!1)}catch(y){ye.error("Failed to update monitor"),console.error("Error updating monitor:",y)}finally{c(!1)}};return n.jsx(er,{open:t,onOpenChange:r,children:n.jsxs(Kt,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Edit HTTP Monitor"}),n.jsx(_s,{children:"Update the configuration for this HTTP/HTTPS monitor"})]}),n.jsx(hoe,{...m,children:n.jsxs("form",{onSubmit:m.handleSubmit(g),className:"space-y-6",children:[n.jsx(no,{control:m.control,name:"name",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Monitor Name *"}),n.jsx(vi,{children:n.jsx(ie,{placeholder:"My Website Monitor",...p})}),n.jsx(fl,{children:"A descriptive name for this monitor"}),n.jsx(yi,{})]})}),n.jsx(no,{control:m.control,name:"description",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Description"}),n.jsx(vi,{children:n.jsx(kr,{placeholder:"Additional details about this monitor...",className:"resize-none",...p})}),n.jsx(yi,{})]})}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsx(no,{control:m.control,name:"protocol",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Protocol *"}),n.jsxs(Fe,{onValueChange:p.onChange,defaultValue:p.value,children:[n.jsx(vi,{children:n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select protocol"})})}),n.jsxs(Le,{children:[n.jsx(J,{value:"http",children:"HTTP"}),n.jsx(J,{value:"https",children:"HTTPS"})]})]}),n.jsx(yi,{})]})}),n.jsx(no,{control:m.control,name:"hostname_or_url",render:({field:p})=>n.jsxs(gi,{className:"md:col-span-2",children:[n.jsx(xi,{children:"Hostname/URL *"}),n.jsx(vi,{children:n.jsx(ie,{placeholder:"example.com",...p})}),n.jsx(fl,{children:"Enter full Domain or IP address (with http:// or https://)"}),n.jsx(yi,{})]})})]}),n.jsx(no,{control:m.control,name:"port",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Port"}),n.jsx(vi,{children:n.jsx(ie,{type:"number",placeholder:"80 or 443 (default)",...p,value:p.value||""})}),n.jsx(fl,{children:"Leave empty for default (80 for HTTP, 443 for HTTPS)"}),n.jsx(yi,{})]})}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(no,{control:m.control,name:"check_interval",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Check Interval (seconds) *"}),n.jsx(vi,{children:n.jsx(ie,{type:"number",...p})}),n.jsx(fl,{children:"How often to check (60-3600)"}),n.jsx(yi,{})]})}),n.jsx(no,{control:m.control,name:"timeout_seconds",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Timeout (seconds) *"}),n.jsx(vi,{children:n.jsx(ie,{type:"number",...p})}),n.jsx(fl,{children:"Request timeout (5-300)"}),n.jsx(yi,{})]})})]}),n.jsx(no,{control:m.control,name:"expected_status_codes",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Expected Status Codes *"}),n.jsx(vi,{children:n.jsx(ie,{placeholder:"200,301,302",...p})}),n.jsx(fl,{children:"Comma-separated HTTP status codes that indicate success"}),n.jsx(yi,{})]})}),n.jsx(no,{control:m.control,name:"group_id",render:({field:p})=>n.jsxs(gi,{children:[n.jsx(xi,{children:"Group"}),n.jsxs(Fe,{onValueChange:p.onChange,defaultValue:p.value||"none",disabled:o,children:[n.jsx(vi,{children:n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"No group assigned"})})}),n.jsxs(Le,{children:[n.jsx(J,{value:"none",children:"No Group"}),i.map(y=>n.jsx(J,{value:y.id,children:n.jsxs("div",{className:"flex items-center gap-2",children:[y.name,y.is_critical&&n.jsx(ve,{variant:"destructive",className:"text-xs",children:"Critical"})]})},y.id))]})]}),n.jsx(fl,{children:"Assign this monitor to a group for organization"}),n.jsx(yi,{})]})}),n.jsxs(xg,{children:[n.jsx(H,{type:"button",variant:"outline",onClick:()=>r(!1),disabled:l,children:"Cancel"}),n.jsx(H,{type:"submit",disabled:l||a,children:l?"Saving...":"Save Changes"})]})]})})]})})}function Gi({monitor:e,open:t,onOpenChange:r}){const{deleteAgent:s,isDeleting:a}=Lt(e==null?void 0:e.client_id),[i,o]=x.useState(!1);if(!e)return null;const l=async()=>
686{if(e){o(!0);try{await s(e.id),ye.success(`Monitor "${e.name}" deleted successfully`),r(!1)}catch(c){ye.error("Failed to delete monitor"),console.error("Error deleting monitor:",c)}finally{o(!1)}}};return n.jsx(os,{open:t,onOpenChange:r,children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete HTTP Monitor"}),n.jsxs(Bn,{className:"space-y-2",children:[n.jsxs("p",{children:["Are you sure you want to delete the monitor ",n.jsxs("strong",{children:['"',e.name,'"']}),"?"]}),n.jsx("p",{className:"text-destructive font-medium",children:"This will permanently delete:"}),n.jsxs("ul",{className:"list-disc list-inside text-sm space-y-1",children:[n.jsx("li",{children:"All monitor check history"}),n.jsx("li",{children:"Associated alerts and incidents"}),n.jsx("li",{children:"Configuration settings"})]}),n.jsx("p",{className:"font-medium",children:"This action cannot be undone."})]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:i,children:"Cancel"}),n.jsx(qn,{onClick:l,disabled:i||a,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:i?"Deleting...":"Delete Monitor"})]})]})})}const Yi=({className:e,...t})=>n.jsx("nav",{role:"navigation","aria-label":"pagination",className:we("mx-auto flex w-full justify-center",e),...t});Yi.displayName="Pagination";const Qi=x.forwardRef(({className:e,...t},r)=>n.jsx("ul",{ref:r,className:we("flex flex-row items-center gap-1",e),...t}));Qi.displayName="PaginationContent";const wt=x.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,className:we("",e),...t}));wt.displayName="PaginationItem";const ss=({className:e,isActive:t,size:r="icon",...s})=>n.jsx("a",{"aria-current":t?"page":void 0,className:we(U0({variant:t?"outline":"ghost",size:r}),e),...s});ss.displayName="PaginationLink";const Xi=({className:e,...t})=>n.jsxs(ss,{"aria-label":"Go to previous page",size:"default",className:we("gap-1 pl-2.5",e),...t,children:[n.jsx(zh,{className:"h-4 w-4"}),n.jsx("span",{children:"Previous"})]});Xi.displayName="PaginationPrevious";const Zi=({className:e,...t})=>n.jsxs(ss,{"aria-label":"Go to next page",size:"default",className:we("gap-1 pr-2.5",e),...t,children:[n.jsx("span",{children:"Next"}),n.jsx(Yo,{className:"h-4 w-4"})]});Zi.displayName="PaginationNext";const qo=({className:e,...t})=>n.jsxs("span",{"aria-hidden":!0,className:we("flex h-9 w-9 items-center justify-center",e),...t,children:[n.jsx(xI,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"More pages"})]});qo.displayName="PaginationEllipsis";const poe=["website","saas","server","database"];function goe({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const{agents:i,isLoading:o,toggleAgentStatus:l,deleteAgent:c}=Lt(e),{metrics:d}=Dae(e),{groups:u}=Vi(e),[h,f]=x.useState(""),[m,g]=x.useState("all"),[p,y]=x.useState("all"),[v,j]=x.useState("all"),[b,_]=x.useState("all"),[w,N]=x.useState("name-asc"),[S,C]=x.useState(!1),[P,M]=x.useState(null),[D,A]=x.useState(null),[U,F]=x.useState(null),[L,$]=x.useState(new Set),[R,T]=x.useState(!1),[k,W]=x.useState(1),q=5,Q=t??U,ue=K=>{r?r(K):F(K)},X=s??L,le=K=>{a?a(K):$(K)},pe=(i==null?void 0:i.filter(K=>poe.includes(K.asset_type)))||[],ce=x.useMemo(()=>{const K=new Set;return pe.forEach(Z=>{var je;(je=Z.tags)==null||je.forEach(_e=>K.add(_e))}),Array.from(K).sort()},[pe]),se=x.useMemo(()=>pe.filter(K=>{var xt,Dt,xe;const Z=K.name.toLowerCase().includes(h.toLowerCase())||((xt=K.hostname_or_url)==null?void 0:xt.toLowerCase().includes(h.toLowerCase()))||((Dt=K.description)==null?void 0:Dt.toLowerCase().includes(h.toLowerCase())),je=m==="all"||K.status===m,_e=b==="all"||((xe=K.tags)==null?void 0:xe.includes(b)),Ee=d.find(qe=>qe.agentId===K.id);let Ze=!0;if(p!=="all"&&Ee){const qe=Ee.avgResponseTime;switch(p){case"fast":Ze=qe<100;break;case"medium":Ze=qe>=100&&qe<500;break;case"slow":Ze=qe>=500&&qe<1e3;break;case"very-slow":Ze=qe>=1e3;break}}let st=!0;if(v!=="all"&&Ee){const qe=Ee.uptime24h;switch(v){case"excellent":st=qe>=99;break;case"good":st=qe>=95&&qe<99;break;case"poor":st=qe<95;break}}return Z&&je&&_e&&Ze&&st}),[pe,h,m,b,p,v,d]),oe=x.useMemo(()=>{const K=[...se];switch(w){case"name-asc":K.sort((Z,je)=>Z.name.localeCompare(je.name));break;case"name-desc":K.sort((Z,je)=>je.name.localeCompare(Z.name));break;case"response-time-asc":K.sort((Z,je)=>{const _e=d.find(Ze=>Ze.agentId===Z.id),Ee=d.find(Ze=>Ze.agentId===je.id);return((_e==null?void 0:_e.avgResponseTime)||0)-((Ee==null?void 0:Ee.avgResponseTime)||0)});break;case"response-time-desc":K.sort((Z,je)=>{const _e=d.find(Ze=>Ze.agentId===Z.id),Ee=d.find(Ze=>Ze.agentId===je.id);return((Ee==null?void 0:Ee.avgResponseTime)||0)-((_e==null?void 0:_e.avgResponseTime)||0)});break;case"uptime-asc":K.sort((Z,je)=>{const _e=d.find(Ze=>Ze.agentId===Z.id),Ee=d.find(Ze=>Ze.agentId===je.id);return((_e==null?void 0:_e.uptime24h)||0)-((Ee==null?void 0:Ee.uptime24h)||0)});break;case"uptime-desc":K.sort((Z,je)=>{const _e=d.find(Ze=>Ze.agentId===Z.id),Ee=d.find(Ze=>Ze.agentId===je.id);return((Ee==null?void 0:Ee.uptime24h)||0)-((_e==null?void 0:_e.uptime24h)||0)});break;case"last-check-desc":K.sort((Z,je)=>{const _e=d.find(xt=>xt.agentId===Z.id),Ee=d.find(xt=>xt.agentId===je.id),Ze=_e!=null&&_e.lastCheckTime?new Date(_e.lastCheckTime).getTime():0;return(Ee!=null&&Ee.lastCheckTime?new Date(Ee.lastCheckTime).getTime():0)-Ze});break;case"last-check-asc":K.sort((Z,je)=>{const _e=d.find(xt=>xt.agentId===Z.id),Ee=d.find(xt=>xt.agentId===je.id),Ze=_e!=null&&_e.lastCheckTime?new Date(_e.lastCheckTime).getTime():0,st=Ee!=null&&Ee.lastCheckTime?new Date(Ee.lastCheckTime).getTime():0;return Ze-st});break}return K},[se,w,d]),V=Math.ceil(oe.length/q),fe=(k-1)*q,ne=fe+q,Ce=oe.slice(fe,
686ne);x.useEffect(()=>{W(1)},[h,m,p,v,b,w]),x.useEffect(()=>{k>V&&V>0&&W(V)},[k,V]);const Pe=m!=="all"||p!=="all"||v!=="all"||b!=="all",he=()=>{g("all"),y("all"),j("all"),_("all"),f("")},ke=K=>{ue(K),Me(K)},Me=K=>{const Z=new Set(X);Z.has(K)?Z.delete(K):Z.add(K),le(Z)},Je=()=>{if(X.size===Ce.length&&Ce.every(K=>X.has(K.id))){const K=new Set(X);Ce.forEach(Z=>K.delete(Z.id)),le(K)}else{const K=new Set(X);Ce.forEach(Z=>K.add(Z.id)),le(K)}},Ke=()=>{let K=0;for(const Z of Array.from(X)){const je=i==null?void 0:i.find(_e=>_e.id===Z);(je==null?void 0:je.status)==="active"&&(l(je),K++)}K>0&&ye.success(`Pausing ${K} monitor(s)`)},E=()=>{let K=0;for(const Z of Array.from(X)){const je=i==null?void 0:i.find(_e=>_e.id===Z);(je==null?void 0:je.status)==="suspended"&&(l(je),K++)}K>0&&ye.success(`Resuming ${K} monitor(s)`)},O=()=>{const K=(i==null?void 0:i.filter(_e=>X.has(_e.id)))||[],Z=K.filter(_e=>_e.status==="active").length,je=K.filter(_e=>_e.status==="suspended").length;Z>=je?Ke():(E(),le(new Set))},I=x.useMemo(()=>{const K=(i==null?void 0:i.filter(_e=>X.has(_e.id)))||[],Z=K.filter(_e=>_e.status==="active").length,je=K.filter(_e=>_e.status==="suspended").length;return Z>=je},[X,i]),Y=()=>{for(const K of Array.from(X))c(K);ye.success(`Deleting ${X.size} monitor(s)`),le(new Set),T(!1)},te=()=>{T(!0)};return o?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((K,Z)=>n.jsx(tt,{className:"h-16 w-full"},Z))})})]}):n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[X.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:O,disabled:X.size===0,children:I?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:te,disabled:X.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[n.jsxs(me,{children:["HTTP/HTTPS Monitors",oe.length>0&&n.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-2",children:["Showing ",fe+1,"-",Math.min(ne,oe.length)," of ",oe.length]})]}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full sm:w-auto",children:[n.jsxs("div",{className:"relative flex-1 sm:flex-initial",children:[n.jsx(qt,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:h,onChange:K=>f(K.target.value),className:"pl-8 w-full sm:w-[250px]"})]}),n.jsxs(H,{variant:Pe?"default":"outline",size:"default",onClick:()=>C(!S),className:"w-full sm:w-auto",children:[n.jsx(Ui,{className:"h-4 w-4 mr-2"}),"Filters",Pe&&n.jsx(ve,{variant:"secondary",className:"ml-2",children:[m!=="all",p!=="all",v!=="all",b!=="all"].filter(Boolean).length})]})]})]}),n.jsx(ur,{open:S,children:n.jsxs(Er,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 p-4 border rounded-lg bg-muted/50",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Status"}),n.jsxs(Fe,{value:m,onValueChange:g,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Status"}),n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"suspended",children:"Suspended"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Response Time"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Speeds"}),n.jsx(J,{value:"fast",children:"< 100ms (Fast)"}),n.jsx(J,{value:"medium",children:"100-500ms (Medium)"}),n.jsx(J,{value:"slow",children:"500-1000ms (Slow)"}),n.jsx(J,{value:"very-slow",children:"> 1000ms (Very Slow)"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Uptime (24h)"}),n.jsxs(Fe,{value:v,onValueChange:j,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Uptime"}),n.jsx(J,{value:"excellent",children:"> 99% (Excellent)"}),n.jsx(J,{value:"good",children:"95-99% (Good)"}),n.jsx(J,{value:"poor",children:"< 95% (Poor)"})]})]})]}),ce.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Tags"}),n.jsxs(Fe,{value:b,onValueChange:_,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),ce.map(K=>n.jsx(J,{value:K,children:K},K))]})]})]}),n.jsx("div",{className:"flex items-end",children:Pe&&n.jsxs(H,{variant:"ghost",size:"sm",onClick:he,className:"w-full",children:[n.jsx(vn,{className:"h-4 w-4 mr-2"}),"Clear Filters"]})})]}),n.jsxs("div",{className:"flex items-center gap-2 px-4",children:[n.jsx(ns,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("label",{className:"text-sm font-medium",children:"Sort by:"}),n.jsxs(Fe,{value:w,onValueChange:N,children:[n.jsx(Ie,{className:"w-[200px]",children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"name-asc",children:"Name (A-Z)"}),n.jsx(J,{value:"name-desc",children:"Name (Z-A)"}),n.jsx(J,{value:"response-time-asc",children:"Response Time (Fastest)"}),n.jsx(J,{value:"response-time-desc",children:"Response Time (Slowest)"}),n.jsx(J,{value:"uptime-desc",children:"Uptime (Highest)"}),n.jsx(J,{value:"uptime-asc",children:"Uptime (Lowest)"}),n.jsx(J,{value:"last-check-desc",children:"Last Check (Newest)"}),n.jsx(J,{value:"last-check-asc",children:"Last Check (Oldest)"})]})]})]})]})})]})}),n.jsxs(re,{children:[oe.length===0?n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:pe.length===0?n.jsx("p",{children:"No HTTP/HTTPS monitors configured yet."}):n.jsxs("div",{children:[n.jsx("p",{className:"mb-3",children:"No monitors match your filters."}),Pe&&n.jsxs(H,{variant:"outline",size:"sm",onClick:he,children:[n.jsx(vn,{className:"h-4 w-4 mr-2"}),"Clear All Filters"]})]})}):n.jsx("div",{className:"rounded-md border",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-[50px]",children:n.jsx(ct,{checked:Ce.length>0&&Ce.every(K=>
686X.has(K.id)),onCheckedChange:Je})}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:"Name"}),n.jsx(Se,{children:"URL"}),n.jsx(Se,{className:"hidden md:table-cell",children:"Uptime (24h)"}),n.jsx(Se,{className:"hidden lg:table-cell",children:"History"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:Ce.map(K=>{var Ee,Ze,st;const Z=d.find(xt=>xt.agentId===K.id),je=Q===K.id,_e=X.has(K.id);return n.jsxs(gt,{className:`cursor-pointer hover:bg-muted/50 ${_e?"bg-muted/30":""} ${je?"border-l-4 border-l-primary":""}`,onClick:()=>ke(K.id),children:[n.jsx(be,{onClick:xt=>xt.stopPropagation(),children:n.jsx(ct,{checked:_e,onCheckedChange:()=>Me(K.id)})}),n.jsx(be,{children:n.jsx(uie,{monitoringAgentId:K.id,assetType:K.asset_type})}),n.jsx(be,{children:n.jsxs("div",{children:[n.jsxs("div",{className:"font-medium flex items-center gap-2",children:[K.name,K.group_id&&n.jsx(ve,{variant:"outline",className:"text-xs font-normal",children:((Ee=u.find(xt=>xt.id===K.group_id))==null?void 0:Ee.name)||"Unknown"})]}),K.description&&n.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:K.description})]})}),n.jsx(be,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("span",{className:"text-sm truncate max-w-[200px]",children:[(Ze=K.hostname_or_url)!=null&&Ze.includes("://")?K.hostname_or_url:`${K.protocol}://${K.hostname_or_url}`,K.port&&K.port!==80&&K.port!==443?`:${K.port}`:""]}),K.hostname_or_url&&n.jsx("a",{href:(st=K.hostname_or_url)!=null&&st.includes("://")?`${K.hostname_or_url}${K.port&&K.port!==80&&K.port!==443?`:${K.port}`:""}`:`${K.protocol}://${K.hostname_or_url}${K.port&&K.port!==80&&K.port!==443?`:${K.port}`:""}`,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground hover:text-foreground",children:n.jsx(_0,{className:"h-3 w-3"})})]})}),n.jsx(be,{className:"hidden md:table-cell",children:Z?`${Z.uptime24h.toFixed(2)}%`:"N/A"}),n.jsx(be,{className:"hidden lg:table-cell",children:n.jsx(Ki,{monitoringAgentId:K.id,createdAt:K.created_at})}),n.jsx(be,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:xt=>xt.stopPropagation(),children:[n.jsx(hie,{monitoringAgentId:K.id}),n.jsx(C6,{monitorId:K.id,clientId:e,currentGroupId:K.group_id}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>M(K),title:"Edit monitor",children:n.jsx(Qo,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>A(K),title:"Delete monitor",className:"text-destructive hover:text-destructive",children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},K.id)})})]})}),oe.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>W(K=>Math.max(1,K-1)),className:k===1?"pointer-events-none opacity-50":"cursor-pointer"})}),n.jsx(wt,{children:n.jsx(ss,{onClick:()=>W(1),isActive:k===1,className:"cursor-pointer",children:"1"})}),k>3&&V>4&&n.jsx(wt,{children:n.jsx(qo,{})}),Array.from({length:V},(K,Z)=>Z+1).filter(K=>K===1||K===V?!1:Math.abs(K-k)<=1).map(K=>n.jsx(wt,{children:n.jsx(ss,{onClick:()=>W(K),isActive:k===K,className:"cursor-pointer",children:K})},K)),k<V-2&&V>4&&n.jsx(wt,{children:n.jsx(qo,{})}),V>1&&n.jsx(wt,{children:n.jsx(ss,{onClick:()=>W(V),isActive:k===V,className:"cursor-pointer",children:V})}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>W(K=>Math.min(V,K+1)),className:k===V?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]}),P&&n.jsx(moe,{monitor:P,open:!!P,onOpenChange:K=>!K&&M(null)}),D&&n.jsx(Gi,{monitor:D,open:!!D,onOpenChange:K=>!K&&A(null)}),n.jsx(jg,{open:R,onOpenChange:T,count:X.size,onConfirm:Y})]})}var xoe=Array.isArray,Hs=xoe,voe=typeof rs=="object"&&rs&&rs.Object===Object&&rs,yU=voe,yoe=yU,joe=typeof self=="object"&&self&&self.Object===Object&&self,boe=yoe||joe||Function("return this")(),Ji=boe,woe=Ji,_oe=woe.Symbol,wg=_oe,dE=wg,jU=Object.prototype,Noe=jU.hasOwnProperty,Soe=jU.toString,Rf=dE?dE.toStringTag:void 0;function Coe(e){var t=Noe.call(e,Rf),r=e[Rf];try{e[Rf]=void 0;var s=!0}catch{}var a=Soe.call(e);return s&&(t?e[Rf]=r:delete e[Rf]),a}var koe=Coe,Poe=Object.prototype,Toe=Poe.toString;function Aoe(e){return Toe.call(e)}var Eoe=Aoe,uE=wg,Ooe=koe,Moe=Eoe,Doe="[object Null]",Roe="[object Undef
686ined]",hE=uE?uE.toStringTag:void 0;function $oe(e){return e==null?e===void 0?Roe:Doe:hE&&hE in Object(e)?Ooe(e):Moe(e)}var el=$oe;function Ioe(e){return e!=null&&typeof e=="object"}var tl=Ioe,Loe=el,Foe=tl,Uoe="[object Symbol]";function zoe(e){return typeof e=="symbol"||Foe(e)&&Loe(e)==Uoe}var nf=zoe,Boe=Hs,qoe=nf,Woe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Hoe=/^\w*$/;function Voe(e,t){if(Boe(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||qoe(e)?!0:Hoe.test(e)||!Woe.test(e)||t!=null&&e in Object(t)}var Pk=Voe;function Koe(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var pc=Koe;const sf=fr(pc);var Goe=el,Yoe=pc,Qoe="[object AsyncFunction]",Xoe="[object Function]",Zoe="[object GeneratorFunction]",Joe="[object Proxy]";function ele(e){if(!Yoe(e))return!1;var t=Goe(e);return t==Xoe||t==Zoe||t==Qoe||t==Joe}var Tk=ele;const _t=fr(Tk);var tle=Ji,rle=tle["__core-js_shared__"],nle=rle,mw=nle,fE=function(){var e=/[^.]+$/.exec(mw&&mw.keys&&mw.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function sle(e){return!!fE&&fE in e}var ale=sle,ile=Function.prototype,ole=ile.toString;function lle(e){if(e!=null){try{return ole.call(e)}catch{}try{return e+""}catch{}}return""}var bU=lle,cle=Tk,dle=ale,ule=pc,hle=bU,fle=/[\\^$.*+?()[\]{}|]/g,mle=/^\[object .+?Constructor\]$/,ple=Function.prototype,gle=Object.prototype,xle=ple.toString,vle=gle.hasOwnProperty,yle=RegExp("^"+xle.call(vle).replace(fle,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function jle(e){if(!ule(e)||dle(e))return!1;var t=cle(e)?yle:mle;return t.test(hle(e))}var ble=jle;function wle(e,t){return e==null?void 0:e[t]}var _le=wle,Nle=ble,Sle=_le;function Cle(e,t){var r=Sle(e,t);return Nle(r)?r:void 0}var Dd=Cle,kle=Dd,Ple=kle(Object,"create"),cj=Ple,mE=cj;function Tle(){this.__data__=mE?mE(null):{},this.size=0}var Ale=Tle;function Ele(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var Ole=Ele,Mle=cj,Dle="__lodash_hash_undefined__",Rle=Object.prototype,$le=Rle.hasOwnProperty;function Ile(e){var t=this.__data__;if(Mle){var r=t[e];return r===Dle?void 0:r}return $le.call(t,e)?t[e]:void 0}var Lle=Ile,Fle=cj,Ule=Object.prototype,zle=Ule.hasOwnProperty;function Ble(e){var t=this.__data__;return Fle?t[e]!==void 0:zle.call(t,e)}var qle=Ble,Wle=cj,Hle="__lodash_hash_undefined__";function Vle(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Wle&&t===void 0?Hle:t,this}var Kle=Vle,Gle=Ale,Yle=Ole,Qle=Lle,Xle=qle,Zle=Kle;function af(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}af.prototype.clear=Gle;af.prototype.delete=Yle;af.prototype.get=Qle;af.prototype.has=Xle;af.prototype.set=Zle;var Jle=af;function ece(){this.__data__=[],this.size=0}var tce=ece;function rce(e,t){return e===t||e!==e&&t!==t}var Ak=rce,nce=Ak;function sce(e,t){for(var r=e.length;r--;)if(nce(e[r][0],t))return r;return-1}var dj=sce,ace=dj,ice=Array.prototype,oce=ice.splice;function lce(e){var t=this.__data__,r=ace(t,e);if(r<0)return!1;var s=t.length-1;return r==s?t.pop():oce.call(t,r,1),--this.size,!0}var cce=lce,dce=dj;function uce(e){var t=this.__data__,r=dce(t,e);return r<0?void 0:t[r][1]}var hce=uce,fce=dj;function mce(e){return fce(this.__data__,e)>-1}var pce=mce,gce=dj;function xce(e,t){var r=this.__data__,s=gce(r,e);return s<0?(++this.size,r.push([e,t])):r[s][1]=t,this}var vce=xce,yce=tce,jce=cce,bce=hce,wce=pce,_ce=vce;function of(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}of.prototype.clear=yce;of.prototype.delete=jce;of.prototype.get=bce;of.prototype.has=wce;of.prototype.set=_ce;var uj=of,Nce=Dd,Sce=Ji,Cce=Nce(Sce,"Map"),Ek=Cce,pE=Jle,kce=uj,Pce=Ek;function Tce(){this.size=0,this.__data__={hash:new pE,map:new(Pce||kce),string:new pE}}var Ace=Tce;function Ece(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Oce=Ece,Mce=Oce;function Dce(e,t){var r=e.__data__;return Mce(t)?r[typeof t=="string"?"string":"hash"]:r.map}var hj=Dce,Rce=hj;function $ce(e){var t=Rce(this,e).delete(e);return this.size-=t?1:0,t}var Ice=$ce,Lce=hj;function Fce(e){return Lce(this,e).get(e)}var Uce=Fce,zce=hj;function Bce(e){return zce(this,e).has(e)}var qce=Bce,Wce=hj;function Hce(e,t){var r=Wce(this,e),s=r.size;return r.set(e,t),this.size+=r.size==s?0:1,this}var Vce=Hce,Kce=Ace,Gce=Ice,Yce=Uce,Qce=qce,Xce=Vce;function lf(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var s=e[t];this.set(s[0],s[1])}}lf.prototype.clear=Kce;lf.prototype.delete=Gce;lf.prototype.get=Yce;lf.prototype.has=Qce;lf.prototype.set=Xce;var Ok=lf,wU=Ok,Zce="Expected a function";function Mk(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(Zce);var r=function(){var s=arguments,a=t?t.apply(this,s):s[0],i=r.cache;if(i.has(a))return i.get(a);var o=e.apply(this,s);return r.cache=i.set(a,o)||i,o};return r.cache=new(Mk.Cache||wU),r}Mk.Cache=wU;var _U=Mk;const Jce=fr(_U);var ede=_U,tde=500;function rde(e){var t=ede(e,function(s){return r.size===tde&&r.clear(),s}
vendor: 6,750 bytes, lines 686-694
686),r=t.cache;return t}var nde=rde,sde=nde,ade=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ide=/\\(\\)?/g,ode=sde(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(ade,function(r,s,a,i){t.push(a?i.replace(ide,"$1"):s||r)}),t}),lde=ode;function cde(e,t){for(var r=-1,s=e==null?0:e.length,a=Array(s);++r<s;)a[r]=t(e[r],r,e);return a}var Dk=cde,gE=wg,dde=Dk,ude=Hs,hde=nf,fde=1/0,xE=gE?gE.prototype:void 0,vE=xE?xE.toString:void 0;function NU(e){if(typeof e=="string")return e;if(ude(e))return dde(e,NU)+"";if(hde(e))return vE?vE.call(e):"";var t=e+"";return t=="0"&&1/e==-fde?"-0":t}var mde=NU,pde=mde;function gde(e){return e==null?"":pde(e)}var SU=gde,xde=Hs,vde=Pk,yde=lde,jde=SU;function bde(e,t){return xde(e)?e:vde(e,t)?[e]:yde(jde(e))}var CU=bde,wde=nf,_de=1/0;function Nde(e){if(typeof e=="string"||wde(e))return e;var t=e+"";return t=="0"&&1/e==-_de?"-0":t}var fj=Nde,Sde=CU,Cde=fj;function kde(e,t){t=Sde(t,e);for(var r=0,s=t.length;e!=null&&r<s;)e=e[Cde(t[r++])];return r&&r==s?e:void 0}var Rk=kde,Pde=Rk;function Tde(e,t,r){var s=e==null?void 0:Pde(e,t);return s===void 0?r:s}var kU=Tde;const Ca=fr(kU);function Ade(e){return e==null}var Ede=Ade;const Pt=fr(Ede);var Ode=el,Mde=Hs,Dde=tl,Rde="[object String]";function $de(e){return typeof e=="string"||!Mde(e)&&Dde(e)&&Ode(e)==Rde}var Ide=$de;const _d=fr(Ide);var PU={exports:{}},lr={};/**
687 * @license React
688 * react-is.production.min.js
689 *
690 * Copyright (c) Facebook, Inc. and its affiliates.
691 *
692 * This source code is licensed under the MIT license found in the
693 * LICENSE file in the root directory of this source tree.
694 */var $k=Symbol.for("react.element"),Ik=Symbol.for("react.portal"),mj=Symbol.for("react.fragment"),pj=Symbol.for("react.strict_mode"),gj=Symbol.for("react.profiler"),xj=Symbol.for("react.provider"),vj=Symbol.for("react.context"),Lde=Symbol.for("react.server_context"),yj=Symbol.for("react.forward_ref"),jj=Symbol.for("react.suspense"),bj=Symbol.for("react.suspense_list"),wj=Symbol.for("react.memo"),_j=Symbol.for("react.lazy"),Fde=Symbol.for("react.offscreen"),TU;TU=Symbol.for("react.module.reference");function Ia(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case $k:switch(e=e.type,e){case mj:case gj:case pj:case jj:case bj:return e;default:switch(e=e&&e.$$typeof,e){case Lde:case vj:case yj:case _j:case wj:case xj:return e;default:return t}}case Ik:return t}}}lr.ContextConsumer=vj;lr.ContextProvider=xj;lr.Element=$k;lr.ForwardRef=yj;lr.Fragment=mj;lr.Lazy=_j;lr.Memo=wj;lr.Portal=Ik;lr.Profiler=gj;lr.StrictMode=pj;lr.Suspense=jj;lr.SuspenseList=bj;lr.isAsyncMode=function(){return!1};lr.isConcurrentMode=function(){return!1};lr.isContextConsumer=function(e){return Ia(e)===vj};lr.isContextProvider=function(e){return Ia(e)===xj};lr.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===$k};lr.isForwardRef=function(e){return Ia(e)===yj};lr.isFragment=function(e){return Ia(e)===mj};lr.isLazy=function(e){return Ia(e)===_j};lr.isMemo=function(e){return Ia(e)===wj};lr.isPortal=function(e){return Ia(e)===Ik};lr.isProfiler=function(e){return Ia(e)===gj};lr.isStrictMode=function(e){return Ia(e)===pj};lr.isSuspense=function(e){return Ia(e)===jj};lr.isSuspenseList=function(e){return Ia(e)===bj};lr.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===mj||e===gj||e===pj||e===jj||e===bj||e===Fde||typeof e=="object"&&e!==null&&(e.$$typeof===_j||e.$$typeof===wj||e.$$typeof===xj||e.$$typeof===vj||e.$$typeof===yj||e.$$typeof===TU||e.getModuleId!==void 0)};lr.typeOf=Ia;PU.exports=lr;var Ude=PU.exports,zde=el,Bde=tl,qde="[object Number]";function Wde(e){return typeof e=="number"||Bde(e)&&zde(e)==qde}var AU=Wde;const Hde=fr(AU);var Vde=AU;function Kde(e){return Vde(e)&&e!=+e}var Gde=Kde;const _g=fr(Gde);var ri=function(t){return t===0?0:t>0?1:-1},qc=function(t){return _d(t)&&t.indexOf("%")===t.length-1},Be=function(t){return Hde(t)&&!_g(t)},Yde=function(t){return Pt(t)},yn=function(t){return Be(t)||_d(t)},Qde=0,Ng=function(t){var r=++Qde;return"".concat(t||"").concat(r)},Nd=function(t,r){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Be(t)&&!_d(t))return s;var i;if(qc(t)){var o=t.indexOf("%");i=r*parseFloat(t.slice(0,o))/100}else i=+t;return _g(i)&&(i=s),a&&i>r&&(i=r),i},bl=function(t){if(!t)return null;var r=Object.keys(t);return r&&r.length?t[r[0]]:null},Xde=function(t){if(!Array.isArray(t))return!1;for(var r=t.length,s={},a=0;a<r;a++)if(!s[t[a]])s[t[a]]=!0;else return!0;return!1},Za=function(t,r){return Be(t)&&Be(r)?function(s){return t+s*(r-t)}:function(){return r}};function ry(e,t,r){return!e||!e.length?null:e.find(function(s){return s&&(typeof t=="function"?t(s):Ca(s,t))===r})}var Zde=function(t,r){return Be(t)&&Be(r)?t-r:_d(t)&&_d(r)?t.localeCompare(r):t instanceof Date&&r instanceof Date?t.getTime()-r.getTime():String(t).localeCompare(String(r))};function Du(e,t){for(var r in e)if({}.hasOwnProperty.call(e,r)&&(!{}.hasOwnProperty.call(t,r)||e[r]!==t[r]))return!1;for(var s in t)if({}.hasOwnProperty.call(t,s)&&!{}.hasOwnProperty.call(e,s))return!1;return!0}function zN(e){"@babel/helpers - typeof";return zN=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zN(e)}var Jde=["viewBox","children"],eue=["aria-activedescendant","aria-atomic","aria-autocomplete","aria-busy","aria-checked","aria-colcount","aria-colindex","aria-colspan","aria-controls","aria-current","aria-describedby","aria-details","aria-disabled","aria-errormessage","aria-expanded","aria-flowto","aria-haspopup","aria-hidden","aria-invalid","aria-keyshortcuts","aria-label","aria-labelledby","aria-level","aria-live","aria-modal","aria-multiline","aria-multiselectable","aria-orientation","aria-owns","aria-placeholder","aria-posinset","aria-pressed","aria-readonly","aria-relevant","aria-required","aria-roledescription","aria-rowcount","aria-rowindex","aria-rowspan","aria-selected","aria-setsize","aria-sort","aria-valuemax","aria-valuemin","aria-valuenow","aria-valuetext","className","color","height","id","lang","max","media","method","min","name","style","target","width","role","tabIndex","accentHeight","accumulate","additive","alignmentBaseline","allowReorder","alphabetic","amplitude","arabicForm","ascent","attributeName","attributeType","autoReverse","azimuth","baseFrequency","baselineShift","baseProfile","bbox","begin","bias","by","calcMode","capHeight","clip","clipPath","clipPathUnits","clipRule","colorInterpolation","colorInterpolationFilters","colorProfile","colorRen
694dering","contentScriptType","contentStyleType","cursor","cx","cy","d","decelerate","descent","diffuseConstant","direction","display","divisor","dominantBaseline","dur","dx","dy","edgeMode","elevation","enableBackground","end","exponent","externalResourcesRequired","fill","fillOpacity","fillRule","filter","filterRes","filterUnits","floodColor","floodOpacity","focusable","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontStyle","fontVariant","fontWeight","format","from","fx","fy","g1","g2","glyphName","glyphOrientationHorizontal","glyphOrientationVertical","glyphRef","gradientTransform","gradientUnits","hanging","horizAdvX","horizOriginX","href","ideographic","imageRendering","in2","in","intercept","k1","k2","k3","k4","k","kernelMatrix","kernelUnitLength","kerning","keyPoints","keySplines","keyTimes","lengthAdjust","letterSpacing","lightingColor","limitingConeAngle","local","markerEnd","markerHeight","markerMid","markerStart","markerUnits","markerWidth","mask","maskContentUnits","maskUnits","mathematical","mode","numOctaves","offset","opacity","operator","order","orient","orientation","origin","overflow","overlinePosition","overlineThickness","paintOrder","panose1","pathLength","patternContentUnits","patternTransform","patternUnits","pointerEvents","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","r","radius","refX","refY","renderingIntent","repeatCount","repeatDur","requiredExtensions","requiredFeatures","restart","result","rotate","rx","ry","seed","shapeRendering","slope","spacing","specularConstant","specularExponent","speed","spreadMethod","startOffset","stdDeviation","stemh","stemv","stitchTiles","stopColor","stopOpacity","strikethroughPosition","strikethroughThickness","string","stroke","strokeDasharray","strokeDashoffset","strokeLinecap","strokeLinejoin","strokeMiterlimit","strokeOpacity","strokeWidth","surfaceScale","systemLanguage","tableValues","targetX","targetY","textAnchor","textDecoration","textLength","textRendering","to","transform","u1","u2","underlinePosition","underlineThickness","unicode","unicodeBidi","unicodeRange","unitsPerEm","vAlphabetic","values","vectorEffect","version","vertAdvY","vertOriginX","vertOriginY","vHanging","vIdeographic","viewTarget","visibility","vMathematical","widths","wordSpacing","writingMode","x1","x2","x","xChannelSelector","xHeight","xlinkActuate","xlinkArcrole","xlinkHref","xlinkRole","xlinkShow","xlinkTitle","xlinkType","xmlBase","xmlLang","xmlns","xmlnsXlink","xmlSpace","y1","y2","y","yChannelSelector","z","zoomAndPan","ref","key","angle"],yE=["points","pathLength"],pw={svg:Jde,polygon:yE,polyline:yE},Lk=["dangerouslySetInnerHTML","onCopy","onCopyCapture","onCut","onCutCapture","onPaste","onPasteCapture","onCompositionEnd","onCompositionEndCapture","onCompositionStart","onCompositionStartCapture","onCompositionUpdate","onCompositionUpdateCapture","onFocus","onFocusCapture","onBlur","onBlurCapture","onChange","onChangeCapture","onBeforeInput","onBeforeInputCapture","onInput","onInputCapture","onReset","onResetCapture","onSubmit","onSubmitCapture","onInvalid","onInvalidCapture","onLoad","onLoadCapture","onError","onErrorCapture","onKeyDown","onKeyDownCapture","onKeyPress","onKeyPressCapture","onKeyUp","onKeyUpCapture","onAbort","onAbortCapture","onCanPlay","onCanPlayCapture","onCanPlayThrough","onCanPlayThroughCapture","onDurationChange","onDurationChangeCapture","onEmptied","onEmptiedCapture","onEncrypted","onEncryptedCapture","onEnded","onEndedCapture","onLoadedData","onLoadedDataCapture","onLoadedMetadata","onLoadedMetadataCapture","onLoadStart","onLoadStartCapture","onPause","onPauseCapture","onPlay","onPlayCapture","onPlaying","onPlayingCapture","onProgress","onProgressCapture","onRateChange","onRateChangeCapture","onSeeked","onSeekedCapture","onSeeking","onSeekingCapture","onStalled","onStalledCapture","onSuspend","onSuspendCapture","onTimeUpdate","onTimeUpdateCapture","onVolumeChange","onVolumeChangeCapture","onWaiting","onWaitingCapture","onAuxClick","onAuxClickCapture","onClick","onClickCapture","onContextMenu","onContextMenuCapture","onDoubleClick","onDoubleClickCapture","onDrag","onDrag
694Capture","onDragEnd","onDragEndCapture","onDragEnter","onDragEnterCapture","onDragExit","onDragExitCapture","onDragLeave","onDragLeaveCapture","onDragOver","onDragOverCapture","onDragStart","onDragStartCapture","onDrop","onDropCapture","onMouseDown","onMouseDownCapture","onMouseEnter","onMouseLeave","onMouseMove","onMouseMoveCapture","onMouseOut","onMouseOutCapture","onMouseOver","onMouseOverCapture","onMouseUp","onMouseUpCapture","onSelect","onSelectCapture","onTouchCancel","onTouchCancelCapture","onTouchEnd","onTouchEndCapture","onTouchMove","onTouchMoveCapture","onTouchStart","onTouchStartCapture","onPointerDown","onPointerDownCapture","onPointerMove","onPointerMoveCapture","onPointerUp","onPointerUpCapture","onPointerCancel","onPointerCancelCapture","onPointerEnter","onPointerEnterCapture","onPointerLeave","onPointerLeaveCapture","onPointerOver","onPointerOverCapture","onPointerOut","onPointerOutCapture","onGotPointerCapture","onGotPointerCaptureCapture","onLostPointerCapture","onLostPointerCaptureCapture","onScroll","onScrollCapture","onWheel","onWheelCapture","onAnimationStart","onAnimationStartCapture","onAnimationEnd","onAnimationEndCapture","onAnimationIteration","onAnimationIterationCapture","onTransitionEnd","onTransitionEndCapture"],ny=function(t,r){if(!t||typeof t=="function"||typeof t=="boolean")return null;var s=t;if(x.isValidElement(t)&&(s=t.props),!sf(s))return null;var a={};return Object.keys(s).forEach(function(i){Lk.includes(i)&&(a[i]=r||function(o){return s[i](s,o)})}),a},tue=function(t,r,s){return function(a){return t(r,s,a),null}},sy=function(t,r,s){if(!sf(t)||zN(t)!=="object")return null;var a=null;return Object.keys(t).forEach(function(i){var o=t[i];Lk.includes(i)&&typeof o=="function"&&(a||(a={}),a[i]=tue(o,r,s))}),a},rue=["children"],nue=["children"];function jE(e,t){if(e==null)return{};var r=sue(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function sue(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function BN(e){"@babel/helpers - typeof";return BN=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},BN(e)}var bE={click:"onClick",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",mouseout:"onMouseOut",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",touchcancel:"onTouchCancel",touchend:"onTouchEnd",touchmove:"onTouchMove",touchstart:"onTouchStart",contextmenu:"onContextMenu",dblclick:"onDoubleClick"},So=function(t){return typeof t=="string"?t:t?t.displayName||t.name||"Component":""},wE=null,gw=null,Fk=function e(t){if(t===wE&&Array.isArray(gw))return gw;var r=[];return x.Children.forEach(t,function(s){Pt(s)||(Ude.isFragment(s)?r=r.concat(e(s.props.children)):r.push(s))}),gw=r,wE=t,r};function ka(e,t){var r=[],s=[];return Array.isArray(t)?s=t.map(function(a){return So(a)}):s=[So(t)],Fk(e).forEach(function(a){var i=Ca(a,"type.displayName")||Ca(a,"type.name");s.indexOf(i)!==-1&&r.push(a)}),r}function Ys(e,t){var r=ka(e,t);return r&&r[0]}var _E=function(t){if(!t||!t.props)return!1;var r=t.props,s=r.width,a=r.height;return!(!Be(s)||s<=0||!Be(a)||a<=0)},aue=["a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColormatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-url","foreignObject","g","glyph","glyphRef","hkern","image","line","lineGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern"],iue=function(t){return t&&t.type&&_d(t.type)&&aue.indexOf(t.type)>=0},oue=function(t){return t&&BN(t)==="object"&&"clipDot"in t},lue=function(t,r,s,a){var i,o=(i=pw==null?void 0:pw[a])!==null&&i!==void 0?i:[];return r.startsWith("data-")||!_t(t)&&(a&&o.includes(r)||eue.includes(r))||s&&Lk.includes(r)},$t=function(t,r,s){if(!t||typeof t=="function"||typeof t=="boolean")return null;var a=t;if(x.isValidElement(t)&&(a=t.props),!sf(a))return null;var i={};
vendor: 2,229 bytes, line 694
694return Object.keys(a).forEach(function(o){var l;lue((l=a)===null||l===void 0?void 0:l[o],o,r,s)&&(i[o]=a[o])}),i},qN=function e(t,r){if(t===r)return!0;var s=x.Children.count(t);if(s!==x.Children.count(r))return!1;if(s===0)return!0;if(s===1)return NE(Array.isArray(t)?t[0]:t,Array.isArray(r)?r[0]:r);for(var a=0;a<s;a++){var i=t[a],o=r[a];if(Array.isArray(i)||Array.isArray(o)){if(!e(i,o))return!1}else if(!NE(i,o))return!1}return!0},NE=function(t,r){if(Pt(t)&&Pt(r))return!0;if(!Pt(t)&&!Pt(r)){var s=t.props||{},a=s.children,i=jE(s,rue),o=r.props||{},l=o.children,c=jE(o,nue);return a&&l?Du(i,c)&&qN(a,l):!a&&!l?Du(i,c):!1}return!1},SE=function(t,r){var s=[],a={};return Fk(t).forEach(function(i,o){if(iue(i))s.push(i);else if(i){var l=So(i.type),c=r[l]||{},d=c.handler,u=c.once;if(d&&(!u||!a[l])){var h=d(i,l,o);s.push(h),a[l]=!0}}}),s},cue=function(t){var r=t&&t.type;return r&&bE[r]?bE[r]:null},due=function(t,r){return Fk(r).indexOf(t)},uue=["children","width","height","viewBox","className","style","title","desc"];function WN(){return WN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},WN.apply(this,arguments)}function hue(e,t){if(e==null)return{};var r=fue(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function fue(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function HN(e){var t=e.children,r=e.width,s=e.height,a=e.viewBox,i=e.className,o=e.style,l=e.title,c=e.desc,d=hue(e,uue),u=a||{width:r,height:s,x:0,y:0},h=It("recharts-surface",i);return G.createElement("svg",WN({},$t(d,!0,"svg"),{className:h,width:r,height:s,style:o,viewBox:"".concat(u.x," ").concat(u.y," ").concat(u.width," ").concat(u.height)}),G.createElement("title",null,l),G.createElement("desc",null,c),t)}var mue=["children","className"];function VN(){return VN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];
694for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},VN.apply(this,arguments)}function pue(e,t){if(e==null)return{};var r=gue(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function gue(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var en=G.forwardRef(function(e,t){var r=e.children,s=e.className,a=pue(e,mue),i=It("recharts-layer",s);return G.createElement("g",VN({className:i},$t(a,!0),{ref:t}),r)}),Co=function(t,r){for(var s=arguments.length,a=new Array(s>2?s-2:0),i=2;i<s;i++)a[i-2]=arguments[i]};function xue(e,t,r){var s=-1,a=e.length;t<0&&(t=-t>a?0:a+t),r=r>a?a:r,r<0&&(r+=a),a=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(a);++s<a;)i[s]=e[s+t];return i}var vue=xue,yue=vue;function jue(e,t,r){var s=e.length;return r=r===void 0?s:r,!t&&r>=s?e:yue(e,t,r)}var bue=jue,wue="\\ud800-\\udfff",_ue="\\u0300-\\u036f",Nue="\\ufe20-\\ufe2f",Sue="\\u20d0-\\u20ff",Cue=_ue+Nue+Sue,kue="\\ufe0e\\ufe0f",Pue="\\u200d",Tue=RegExp("["+Pue+wue+Cue+kue+"]");function Aue(e){return Tue.test(e)}var EU=Aue;function Eue(e){return e.split("")}var Oue=Eue,OU="\\ud800-\\udfff",Mue="\\u0300-\\u036f",Due="\\ufe20-\\ufe2f",Rue="\\u20d0-\\u20ff",$ue=Mue+Due+Rue,Iue="\\ufe0e\\ufe0f",Lue="["+OU+"]",KN="["+$ue+"]",GN="\\ud83c[\\udffb-\\udfff]",Fue="(?:"+KN+"|"+GN+")",MU="[^"+OU+"]",DU="(?:\\ud83c[\\udde6-\\uddff]){2}",RU="[\\ud800-\\udbff][\\udc00-\\udfff]",Uue="\\u200d",$U=Fue+"?",IU="["+Iue+"]?",zue="(?:"+Uue+"(?:"+[MU,DU,RU].join("|")+")"+IU+$U+")*",Bue=IU+$U+zue,que="(?:"+[MU+KN+"?",KN,DU,RU,Lue].join("|")+")",Wue=RegExp(GN+"(?="+GN+")|"+que+Bue,"g");function Hue(e){return e.match(Wue)||[]}var Vue=Hue,Kue=Oue,Gue=EU,Yue=Vue;function Que(e){return Gue(e)?Yue(e):Kue(e)}var Xue=Que,Zue=bue,Jue=EU,ehe=Xue,the=SU;function rhe(e){return function(t){t=the(t);var r=Jue(t)?ehe(t):void 0,s=r?r[0]:t.charAt(0),a=r?Zue(r,1).join(""):t.slice(1);return s[e]()+a}}var nhe=rhe,she=nhe,ahe=she("toUpperCase"),ihe=ahe;const Nj=fr(ihe);function vr(e){return function(){return e}}const LU=Math.cos,ay=Math.sin,hi=Math.sqrt,iy=Math.PI,Sj=2*iy,YN=Math.PI,QN=2*YN,Rc=1e-6,ohe=QN-Rc;function FU(e){this._+=e[0];for(let t=1,r=e.length;t<r;++t)this._+=arguments[t]+e[t]}function lhe(e){let t=Math.floor(e);if(!(t>=0))throw new Error(`invalid digits: ${e}`);if(t>15)return FU;const r=10**t;return function(s){this._+=s[0];for(let a=1,i=s.length;a<i;++a)this._+=Math.round(arguments[a]*r)/r+s[a]}}class che{constructor(t){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=t==null?FU:lhe(t)}moveTo(t,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(t,r){this._append`L${this._x1=+t},${this._y1=+r}`}quadraticCurveTo(t,r,s,a){this._append`Q${+t},${+r},${this._x1=+s},${this._y1=+a}`}bezierCurveTo(t,r,s,a,i,o){this._append`C${+t},${+r},${+s},${+a},${this._x1=+i},${this._y1=+o}`}arcTo(t,r,s,a,i){if(t=+t,r=+r,s=+s,a=+a,i=+i,i<0)throw new Error(`negative radius: ${i}`);let o=this._x1,l=this._y1,c=s-t,d=a-r,u=o-t,h=l-r,f=u*u+h*h;if(this._x1===null)this._append`M${this._x1=t},${this._y1=r}`;else if(f>Rc)if(!(Math.abs(h*c-d*u)>Rc)||!i)this._append`L${this._x1=t},${this._y1=r}`;else{let m=s-o,g=a-l,p=c*c+d*d,y=m*m+g*g,v=Math.sqrt(p),j=Math.sqrt(f),b=i*Math.tan((YN-Math.acos((p+f-y)/(2*v*j)))/2),_=b/j,w=b/v;Math.abs(_-1)>Rc&&this._append`L${t+_*u},${r+_*h}`,this._append`A${i},${i},0,0,${+(h*m>u*g)},${this._x1=t+w*c},${this._y1=r+w*d}`}}arc(t,r,s,a,i,o){if(t=+t,r=+r,s=+s,o=!!o,s<0)throw new Error(`negative radius: ${s}`);let l=s*Math.cos(a),c=s*Math.sin(a),d=t+l,u=r+c,h=1^o,f=o?a-i:i-a;this._x1===null?this._append`M${d},${u}`:(Math.abs(this._x1-d)>Rc||Math.abs(this._y1-u)>Rc)&&this._append`L${d},${u}`,s&&(f<0&&(f=f%QN+QN),f>ohe?this._append`A${s},${s},0,1,${h},${t-l},${r-c}A${s},${s},0,1,${h},${this._x1=d},${this._y1=u}`:f>Rc&&this._append`A${s},${s},0,${+(f>=YN)},${h},${this._x1=t+s*Math.cos(i)},${this._y1=r+s*Math.sin(i)}`)}rect(t,r,s,a){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+r}h${s=+s}v${+a}h${-s}Z`}toString(){return this._}}function Uk(e){let t=3;return e.digits=function(r){if(!arguments.length)return t;if(r==null)t=null;else{const s=Math.floor(r);if(!(s>=0))throw new RangeError(`invalid digits: ${r}`);t=s}return e},()=>new che(t)}function zk(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function UU(e){this._context=e}UU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function Cj(e){return new UU(e)}function zU(e){return e[0]}function BU(e){return e[1]}function qU(e,t){var r=vr(!0),s=null,a=Cj,i=null,o=Uk(l);e=typeof e=="function"?e:e===void 0?zU:vr(e),t=typeof t=="function"?t:t===void 0?BU:vr(t);function l(c){var d,u=(c=zk(c)).length,h,f=!1,m;
vendor: 10,797 bytes, line 694
694for(s==null&&(i=a(m=o())),d=0;d<=u;++d)!(d<u&&r(h=c[d],d,c))===f&&((f=!f)?i.lineStart():i.lineEnd()),f&&i.point(+e(h,d,c),+t(h,d,c));if(m)return i=null,m+""||null}return l.x=function(c){return arguments.length?(e=typeof c=="function"?c:vr(+c),l):e},l.y=function(c){return arguments.length?(t=typeof c=="function"?c:vr(+c),l):t},l.defined=function(c){return arguments.length?(r=typeof c=="function"?c:vr(!!c),l):r},l.curve=function(c){return arguments.length?(a=c,s!=null&&(i=a(s)),l):a},l.context=function(c){return arguments.length?(c==null?s=i=null:i=a(s=c),l):s},l}function fx(e,t,r){var s=null,a=vr(!0),i=null,o=Cj,l=null,c=Uk(d);e=typeof e=="function"?e:e===void 0?zU:vr(+e),t=typeof t=="function"?t:vr(t===void 0?0:+t),r=typeof r=="function"?r:r===void 0?BU:vr(+r);function d(h){var f,m,g,p=(h=zk(h)).length,y,v=!1,j,b=new Array(p),_=new Array(p);for(i==null&&(l=o(j=c())),f=0;f<=p;++f){if(!(f<p&&a(y=h[f],f,h))===v)if(v=!v)m=f,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),g=f-1;g>=m;--g)l.point(b[g],_[g]);l.lineEnd(),l.areaEnd()}v&&(b[f]=+e(y,f,h),_[f]=+t(y,f,h),l.point(s?+s(y,f,h):b[f],r?+r(y,f,h):_[f]))}if(j)return l=null,j+""||null}function u(){return qU().defined(a).curve(o).context(i)}return d.x=function(h){return arguments.length?(e=typeof h=="function"?h:vr(+h),s=null,d):e},d.x0=function(h){return arguments.length?(e=typeof h=="function"?h:vr(+h),d):e},d.x1=function(h){return arguments.length?(s=h==null?null:typeof h=="function"?h:vr(+h),d):s},d.y=function(h){return arguments.length?(t=typeof h=="function"?h:vr(+h),r=null,d):t},d.y0=function(h){return arguments.length?(t=typeof h=="function"?h:vr(+h),d):t},d.y1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:vr(+h),d):r},d.lineX0=d.lineY0=function(){return u().x(e).y(t)},d.lineY1=function(){return u().x(e).y(r)},d.lineX1=function(){return u().x(s).y(t)},d.defined=function(h){return arguments.length?(a=typeof h=="function"?h:vr(!!h),d):a},d.curve=function(h){return arguments.length?(o=h,i!=null&&(l=o(i)),d):o},d.context=function(h){return arguments.length?(h==null?i=l=null:l=o(i=h),d):i},d}class WU{constructor(t,r){this._context=t,this._x=r}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(t,r){switch(t=+t,r=+r,this._point){case 0:{this._point=1,this._line?this._context.lineTo(t,r):this._context.moveTo(t,r);break}case 1:this._point=2;default:{this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,r,t,r):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+r)/2,t,this._y0,t,r);break}}this._x0=t,this._y0=r}}function dhe(e){return new WU(e,!0)}function uhe(e){return new WU(e,!1)}const Bk={draw(e,t){const r=hi(t/iy);e.moveTo(r,0),e.arc(0,0,r,0,Sj)}},hhe={draw(e,t){const r=hi(t/5)/2;e.moveTo(-3*r,-r),e.lineTo(-r,-r),e.lineTo(-r,-3*r),e.lineTo(r,-3*r),e.lineTo(r,-r),e.lineTo(3*r,-r),e.lineTo(3*r,r),e.lineTo(r,r),e.lineTo(r,3*r),e.lineTo(-r,3*r),e.lineTo(-r,r),e.lineTo(-3*r,r),e.closePath()}},HU=hi(1/3),fhe=HU*2,mhe={draw(e,t){const r=hi(t/fhe),s=r*HU;e.moveTo(0,-r),e.lineTo(s,0),e.lineTo(0,r),e.lineTo(-s,0),e.closePath()}},phe={draw(e,t){const r=hi(t),s=-r/2;e.rect(s,s,r,r)}},ghe=.8908130915292852,VU=ay(iy/10)/ay(7*iy/10),xhe=ay(Sj/10)*VU,vhe=-LU(Sj/10)*VU,yhe={draw(e,t){const r=hi(t*ghe),s=xhe*r,a=vhe*r;e.moveTo(0,-r),e.lineTo(s,a);for(let i=1;i<5;++i){const o=Sj*i/5,l=LU(o),c=ay(o);e.lineTo(c*r,-l*r),e.lineTo(l*s-c*a,c*s+l*a)}e.closePath()}},xw=hi(3),jhe={draw(e,t){const r=-hi(t/(xw*3));e.moveTo(0,r*2),e.lineTo(-xw*r,-r),e.lineTo(xw*r,-r),e.closePath()}},fa=-.5,ma=hi(3)/2,XN=1/hi(12),bhe=(XN/2+1)*3,whe={draw(e,t){const r=hi(t/bhe),s=r/2,a=r*XN,i=s,o=r*XN+r,l=-i,c=o;e.moveTo(s,a),e.lineTo(i,o),e.lineTo(l,c),e.lineTo(fa*s-ma*a,ma*s+fa*a),e.lineTo(fa*i-ma*o,ma*i+fa*o),e.lineTo(fa*l-ma*c,ma*l+fa*c),e.lineTo(fa*s+ma*a,fa*a-ma*s),e.lineTo(fa*i+ma*o,fa*o-ma*i),e.lineTo(fa*l+ma*c,fa*c-ma*l),e.closePath()}};function _he(e,t){let r=null,s=Uk(a);e=typeof e=="function"?e:vr(e||Bk),t=typeof t=="function"?t:vr(t===void 0?64:+t);function a(){let i;if(r||(r=i=s()),e.apply(this,arguments).draw(r,+t.apply(this,arguments)),i)return r=null,i+""||null}return a.type=function(i){return arguments.length?(e=typeof i=="function"?i:vr(i),a):e},a.size=function(i){return arguments.length?(t=typeof i=="function"?i:vr(+i),a):t},a.context=function(i){return arguments.length?(r=i??null,a):r},a}function oy(){}function ly(e,t,r){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+r)/6)}function KU(e){this._context=e}KU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:ly(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1);break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:ly(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Nhe(e){return new KU(e)}function GU(e){this._context=e}GU.prototype={areaStart:oy,areaEnd:oy,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:{this._context.moveTo(this._x2,this._y2),this._context.closePath();break}case 2:{this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break}case 3:{this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4);break}}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:ly(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function She(e){return new GU(e)}function YU(e){this._context=e}YU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var r=(this._x0+4*this._x1+e)/6,s=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(r,s):this._context.moveTo(r,s);break;case 3:this._point=4;default:ly(this,e,t);break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function Che(e){return new YU(e)}function QU(e){this._context=e}QU.prototype={areaStart:oy,areaEnd:oy,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function khe(e){return new QU(e)}function CE(e){return e<0?-1:1}function kE(e,t,r){var s=e._x1-e._x0,a=t-e._x1,i=(e._y1-e._y0)/(s||a<0&&-0),o=(r-e._y1)/(a||s<0&&-0),l=(i*a+o*s)/(s+a);return(CE(i)+CE(o))*Math.min(Math.abs(i),Math.abs(o),.5*Math.abs(l))||0}function PE(e,t){var r=e._x1-e._x0;return r?(3*(e._y1-e._y0)/r-t)/2:t}function vw(e,t,r){var s=e._x0,a=e._y0,i=e._x1,o=e._y1,l=(i-s)/3;e._context.bezierCurveTo(s+l,a+l*t,i-l,o-l*r,i,o)}function cy(e){this._context=e}cy.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:vw(this,this._t0,PE(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var r=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,vw(this,PE(this,r=kE(this,e,t)),r);break;default:vw(this,this._t0,r=kE(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=r}}};function XU(e){this._context=new ZU(e)}(XU.prototype=Object.create(cy.prototype)).point=function(e,t){cy.prototype.point.call(this,t,e)};function ZU(e){this._context=e}ZU.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,r,s,a,i){this._context.bezierCurveTo(t,e,s,r,i,a)}};function Phe(e){return new cy(e)}function The(e){return new XU(e)}function JU(e){this._context=e}JU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,r=e.length;if(r)if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),r===2)this._context.lineTo(e[1],t[1]);else for(var s=TE(e),a=TE(t),i=0,o=1;o<r;++i,++o)this._context.bezierCurveTo(s[0][i],a[0][i],s[1][i],a[1][i],e[o],t[o]);(this._line||this._line!==0&&r===1)&&this._context.closePath(),this._line=1-this._line,this._x=this._y=null},point:function(e,t){this._x.push(+e),this._y.push(+t)}};function TE(e){var t,r=e.length-1,s,a=new Array(r),i=new Array(r),o=new Array(r);for(a[0]=0,i[0]=2,o[0]=e[0]+2*e[1],t=1;t<r-1;++t)a[t]=1,i[t]=4,o[t]=4*e[t]+2*e[t+1];for(a[r-1]=2,i[r-1]=7,o[r-1]=8*e[r-1]+e[r],t=1;t<r;++t)s=a[t]/i[t-1],i[t]-=s,o[t]-=s*o[t-1];for(a[r-1]=o[r-1]/i[r-1],t=r-2;t>=0;--t)a[t]=(o[t]-a[t+1])/i[t];for(i[r-1]=(e[r]+a[r-1])/2,t=0;t<r-1;++t)i[t]=2*e[t+1]-a[t+1];return[a,i]}function Ahe(e){return new JU(e)}function kj(e,t){this._context=e,this._t=t}kj.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=this._y=NaN,this._point=0},lineEnd:function(){0<this._t&&this._t<1&&this._point===2&&this._context.lineTo(this._x,this._y),(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line>=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;
vendor: 9,187 bytes, lines 694-697
694default:{if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var r=this._x*(1-this._t)+e*this._t;this._context.lineTo(r,this._y),this._context.lineTo(r,t)}break}}this._x=e,this._y=t}};function Ehe(e){return new kj(e,.5)}function Ohe(e){return new kj(e,0)}function Mhe(e){return new kj(e,1)}function mh(e,t){if((o=e.length)>1)for(var r=1,s,a,i=e[t[0]],o,l=i.length;r<o;++r)for(a=i,i=e[t[r]],s=0;s<l;++s)i[s][1]+=i[s][0]=isNaN(a[s][1])?a[s][0]:a[s][1]}function ZN(e){for(var t=e.length,r=new Array(t);--t>=0;)r[t]=t;return r}function Dhe(e,t){return e[t]}function Rhe(e){const t=[];return t.key=e,t}function $he(){var e=vr([]),t=ZN,r=mh,s=Dhe;function a(i){var o=Array.from(e.apply(this,arguments),Rhe),l,c=o.length,d=-1,u;for(const h of i)for(l=0,++d;l<c;++l)(o[l][d]=[0,+s(h,o[l].key,d,i)]).data=h;for(l=0,u=zk(t(o));l<c;++l)o[u[l]].index=l;return r(o,u),o}return a.keys=function(i){return arguments.length?(e=typeof i=="function"?i:vr(Array.from(i)),a):e},a.value=function(i){return arguments.length?(s=typeof i=="function"?i:vr(+i),a):s},a.order=function(i){return arguments.length?(t=i==null?ZN:typeof i=="function"?i:vr(Array.from(i)),a):t},a.offset=function(i){return arguments.length?(r=i??mh,a):r},a}function Ihe(e,t){if((s=e.length)>0){for(var r,s,a=0,i=e[0].length,o;a<i;++a){for(o=r=0;r<s;++r)o+=e[r][a][1]||0;if(o)for(r=0;r<s;++r)e[r][a][1]/=o}mh(e,t)}}function Lhe(e,t){if((a=e.length)>0){for(var r=0,s=e[t[0]],a,i=s.length;r<i;++r){for(var o=0,l=0;o<a;++o)l+=e[o][r][1]||0;s[r][1]+=s[r][0]=-l/2}mh(e,t)}}function Fhe(e,t){if(!(!((o=e.length)>0)||!((i=(a=e[t[0]]).length)>0))){for(var r=0,s=1,a,i,o;s<i;++s){for(var l=0,c=0,d=0;l<o;++l){for(var u=e[t[l]],h=u[s][1]||0,f=u[s-1][1]||0,m=(h-f)/2,g=0;g<l;++g){var p=e[t[g]],y=p[s][1]||0,v=p[s-1][1]||0;m+=y-v}c+=h,d+=m*h}a[s-1][1]+=a[s-1][0]=r,c&&(r-=d/c)}a[s-1][1]+=a[s-1][0]=r,mh(e,t)}}function op(e){"@babel/helpers - typeof";return op=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},op(e)}var Uhe=["type","size","sizeType"];function JN(){return JN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},JN.apply(this,arguments)}function AE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function EE(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?AE(Object(r),!0).forEach(function(s){zhe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):AE(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function zhe(e,t,r){return t=Bhe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Bhe(e){var t=qhe(e,"string");return op(t)=="symbol"?t:t+""}function qhe(e,t){if(op(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(op(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Whe(e,t){if(e==null)return{};var r=Hhe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Hhe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var ez={symbolCircle:Bk,symbolCross:hhe,symbolDiamond:mhe,symbolSquare:phe,symbolStar:yhe,symbolTriangle:jhe,symbolWye:whe},Vhe=Math.PI/180,Khe=function(t){var r="symbol".concat(Nj(t));return ez[r]||Bk},Ghe=function(t,r,s){if(r==="area")return t;switch(s){case"cross":return 5*t*t/9;case"diamond":return .5*t*t/Math.sqrt(3);case"square":return t*t;case"star":{var a=18*Vhe;return 1.25*t*t*(Math.tan(a)-Math.tan(a*2)*Math.pow(Math.tan(a),2))}case"triangle":return Math.sqrt(3)*t*t/4;case"wye":return(21-10*Math.sqrt(3))*t*t/8;default:return Math.PI*t*t/4}},Yhe=function(t,r){ez["symbol".concat(Nj(t))]=r},qk=function(t){var r=t.type,s=r===void 0?"circle":r,a=t.size,i=a===void 0?64:a,o=t.sizeType,l=o===void 0?"area":o,c=Whe(t,Uhe),d=EE(EE({},c),{},{type:s,size:i,sizeType:l}),u=function(){var y=Khe(s),v=_he().type(y).size(Ghe(i,l,s));return v()},h=d.className,f=d.cx,m=d.cy,g=$t(d,!0);return f===+f&&m===+m&&i===+i?G.createElement("path",JN({},g,{className:It("recharts-symbols",h),transform:"translate(".concat(f,", ").concat(m,")"),d:u()})):null};qk.registerSymbol=Yhe;function ph(e){"@babel/helpers - typeof";return ph=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ph(e)}function e1(){return e1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},e1.apply(this,arguments)}function OE(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Qhe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?OE(Object(r),!0).forEach(function(s){lp(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):OE(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Xhe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Zhe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,rz(s.key),s)}}function Jhe(e,t,r){return t&&Zhe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function efe(e,t,r){return t=dy(t),tfe(e,tz()?Reflect.construct(t,r||[],dy(e).constructor):t.apply(e,r))}function tfe(e,t){if(t&&(ph(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return rfe(e)}function rfe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function tz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(tz=function(){return!!e})()}function dy(e){return dy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},dy(e)}function nfe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&t1(e,t)}function t1(e,t){return t1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},t1(e,t)}function lp(e,t,r){return t=rz(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function rz(e){var t=sfe(e,"string");return ph(t)=="symbol"?t:t+""}function sfe(e,t){if(ph(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(ph(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var pa=32,Wk=function(e){function t(){return Xhe(this,t),efe(this,t,arguments)}return nfe(t,e),Jhe(t,[{key:"renderIcon",value:function(s){var a=this.props.inactiveColor,i=pa/2,o=pa/6,l=pa/3,c=s.inactive?a:s.color;if(s.type==="plainline")return G.createElement("line",{strokeWidth:4,fill:"none",stroke:c,strokeDasharray:s.payload.strokeDasharray,x1:0,y1:i,x2:pa,y2:i,className:"recharts-legend-icon"});if(s.type==="line")return G.createElement("path",{strokeWidth:4,fill:"none",stroke:c,d:"M0,".concat(i,"h").concat(l,`
695            A`).concat(o,",").concat(o,",0,1,1,").concat(2*l,",").concat(i,`
696            H`).concat(pa,"M").concat(2*l,",").concat(i,`
697            A`).concat(o,",").concat(o,",0,1,1,").concat(l,",").concat(i),className:"recharts-legend-icon"});if(s.type==="rect")return G.createElement("path",{stroke:"none",fill:c,d:"M0,".concat(pa/8,"h").concat(pa,"v").concat(pa*3/4,"h").concat(-pa,"z"),className:"recharts-legend-icon"});if(G.isValidElement(s.legendIcon)){var d=Qhe({},s);return delete d.legendIcon,G.cloneElement(s.legendIcon,d)}return G.createElement(qk,{fill:c,cx:i,cy:i,size:pa,sizeType:"diameter",type:s.type})}},{key:"renderItems",value:function(){var s=this,a=this.props,i=a.payload,o=a.iconSize,l=a.layout,c=a.formatter,d=a.inactiveColor,u={x:0,y:0,width:pa,height:pa}
697,h={display:l==="horizontal"?"inline-block":"block",marginRight:10},f={display:"inline-block",verticalAlign:"middle",marginRight:4};return i.map(function(m,g){var p=m.formatter||c,y=It(lp(lp({"recharts-legend-item":!0},"legend-item-".concat(g),!0),"inactive",m.inactive));if(m.type==="none")return null;var v=_t(m.value)?null:m.value;Co(!_t(m.value),`The name property is also required when using a function for the dataKey of a chart's cartesian components. Ex: <Bar name="Name of my Data"/>`);var j=m.inactive?d:m.color;return G.createElement("li",e1({className:y,style:h,key:"legend-item-".concat(g)},sy(s.props,m,g)),G.createElement(HN,{width:o,height:o,viewBox:u,style:f},s.renderIcon(m)),G.createElement("span",{className:"recharts-legend-item-text",style:{color:j}},p?p(v,m,g):v))})}},{key:"render",value:function(){var s=this.props,a=s.payload,i=s.layout,o=s.align;if(!a||!a.length)return null;var l={padding:0,margin:0,textAlign:i==="horizontal"?o:"left"};return G.createElement("ul",{className:"recharts-default-legend",style:l},this.renderItems())}}])}(x.PureComponent);lp(Wk,"displayName","Legend");lp(Wk,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var afe=uj;function ife(){this.__data__=new afe,this.size=0}var ofe=ife;function lfe(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}var cfe=lfe;function dfe(e){return this.__data__.get(e)}var ufe=dfe;function hfe(e){return this.__data__.has(e)}var ffe=hfe,mfe=uj,pfe=Ek,gfe=Ok,xfe=200;function vfe(e,t){var r=this.__data__;if(r instanceof mfe){var s=r.__data__;if(!pfe||s.length<xfe-1)return s.push([e,t]),this.size=++r.size,this;r=this.__data__=new gfe(s)}return r.set(e,t),this.size=r.size,this}var yfe=vfe,jfe=uj,bfe=ofe,wfe=cfe,_fe=ufe,Nfe=ffe,Sfe=yfe;function cf(e){var t=this.__data__=new jfe(e);this.size=t.size}cf.prototype.clear=bfe;cf.prototype.delete=wfe;cf.prototype.get=_fe;cf.prototype.has=Nfe;cf.prototype.set=Sfe;var nz=cf,Cfe="__lodash_hash_undefined__";function kfe(e){return this.__data__.set(e,Cfe),this}var Pfe=kfe;function Tfe(e){return this.__data__.has(e)}var Afe=Tfe,Efe=Ok,Ofe=Pfe,Mfe=Afe;function uy(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Efe;++t<r;)this.add(e[t])}uy.prototype.add=uy.prototype.push=Ofe;uy.prototype.has=Mfe;var sz=uy;function Dfe(e,t){for(var r=-1,s=e==null?0:e.length;++r<s;)if(t(e[r],r,e))return!0;return!1}var az=Dfe;function Rfe(e,t){return e.has(t)}var iz=Rfe,$fe=sz,Ife=az,Lfe=iz,Ffe=1,Ufe=2;function zfe(e,t,r,s,a,i){var o=r&Ffe,l=e.length,c=t.length;if(l!=c&&!(o&&c>l))return!1;var d=i.get(e),u=i.get(t);if(d&&u)return d==t&&u==e;var h=-1,f=!0,m=r&Ufe?new $fe:void 0;for(i.set(e,t),i.set(t,e);++h<l;){var g=e[h],p=t[h];if(s)var y=o?s(p,g,h,t,e,i):s(g,p,h,e,t,i);if(y!==void 0){if(y)continue;f=!1;break}if(m){if(!Ife(t,function(v,j){if(!Lfe(m,j)&&(g===v||a(g,v,r,s,i)))return m.push(j)})){f=!1;break}}else if(!(g===p||a(g,p,r,s,i))){f=!1;break}}return i.delete(e),i.delete(t),f}var oz=zfe,Bfe=Ji,qfe=Bfe.Uint8Array,Wfe=qfe;function Hfe(e){var t=-1,r=Array(e.size);return e.forEach(function(s,a){r[++t]=[a,s]}),r}var Vfe=Hfe;function Kfe(e){var t=-1,r=Array(e.size);return e.forEach(function(s){r[++t]=s}),r}var Hk=Kfe,ME=wg,DE=Wfe,Gfe=Ak,Yfe=oz,Qfe=Vfe,Xfe=Hk,Zfe=1,Jfe=2,eme="[object Boolean]",tme="[object Date]",rme="[object Error]",nme="[object Map]",sme="[object Number]",ame="[object RegExp]",ime="[object Set]",ome="[object String]",lme="[object Symbol]",cme="[object ArrayBuffer]",dme="[object DataView]",RE=ME?ME.prototype:void 0,yw=RE?RE.valueOf:void 0;function ume(e,t,r,s,a,i,o){switch(r){case dme:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case cme:return!(e.byteLength!=t.byteLength||!i(new DE(e),new DE(t)));case eme:case tme:case sme:return Gfe(+e,+t);case rme:return e.name==t.name&&e.message==t.message;case ame:case ome:return e==t+"";case nme:var l=Qfe;case ime:var c=s&Zfe;if(l||(l=Xfe),e.size!=t.size&&!c)return!1;var d=o.get(e);if(d)return d==t;s|=Jfe,o.set(e,t);var u=Yfe(l(e),l(t),s,a,i,o);return o.delete(e),u;case lme:if(yw)return yw.call(e)==yw.call(t)}return!1}var hme=ume;function fme(e,t){for(var r=-1,s=t.length,a=e.length;++r<s;)e[a+r]=t[r];return e}var lz=fme,mme=lz,pme=Hs;function gme(e,t,r){var s=t(e);return pme(e)?s:mme(s,r(e))}var xme=gme;function vme(e,t){for(var r=-1,s=e==null?0:e.length,a=0,i=[];++r<s;){var o=e[r];t(o,r,e)&&(i[a++]=o)}return i}var yme=vme;function jme(){return[]}var bme=jme,wme=yme,_me=bme,Nme=Object.prototype,Sme=Nme.propertyIsEnumerable,$E=Object.getOwnPropertySymbols,Cme=$E?function(e){return e==null?[]:(e=Object(e),wme($E(e),function(t){return Sme.call(e,t)}))}:_me,kme=Cme;function Pme(e,t){for(var r=-1,s=Array(e);++r<e;)s[r]=t(r);return s}var Tme=Pme,Ame=el,Eme=tl,Ome="[object Arguments]";function Mme(e){return Eme(e)&&Ame(e)==Ome}var Dme=Mme,IE=Dme,Rme=tl,cz=Object.prototype,$me=cz.hasOwnProperty,Ime=cz.propertyIsEnumerable,Lme=IE(function(){return arguments}())?IE:function(e){return Rme(e)&&$me.call(e,"callee")&&!Ime.call(e,"callee")},Vk=Lme,hy={exports:{}};function Fme(){return!1}var Ume=Fme;hy.exports;(function(e,t){var r=Ji,s=Ume,a=t&&!t.nodeType&&t,i=a&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===a,l=o?r.Buffer:void 0,c=l?l.isBuffer:void 0,d=c||s;e.exports=d}
vendor: 4,423 bytes, line 697
697)(hy,hy.exports);var dz=hy.exports,zme=9007199254740991,Bme=/^(?:0|[1-9]\d*)$/;function qme(e,t){var r=typeof e;return t=t??zme,!!t&&(r=="number"||r!="symbol"&&Bme.test(e))&&e>-1&&e%1==0&&e<t}var Kk=qme,Wme=9007199254740991;function Hme(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Wme}var Gk=Hme,Vme=el,Kme=Gk,Gme=tl,Yme="[object Arguments]",Qme="[object Array]",Xme="[object Boolean]",Zme="[object Date]",Jme="[object Error]",epe="[object Function]",tpe="[object Map]",rpe="[object Number]",npe="[object Object]",spe="[object RegExp]",ape="[object Set]",ipe="[object String]",ope="[object WeakMap]",lpe="[object ArrayBuffer]",cpe="[object DataView]",dpe="[object Float32Array]",upe="[object Float64Array]",hpe="[object Int8Array]",fpe="[object Int16Array]",mpe="[object Int32Array]",ppe="[object Uint8Array]",gpe="[object Uint8ClampedArray]",xpe="[object Uint16Array]",vpe="[object Uint32Array]",_r={};_r[dpe]=_r[upe]=_r[hpe]=_r[fpe]=_r[mpe]=_r[ppe]=_r[gpe]=_r[xpe]=_r[vpe]=!0;_r[Yme]=_r[Qme]=_r[lpe]=_r[Xme]=_r[cpe]=_r[Zme]=_r[Jme]=_r[epe]=_r[tpe]=_r[rpe]=_r[npe]=_r[spe]=_r[ape]=_r[ipe]=_r[ope]=!1;function ype(e){return Gme(e)&&Kme(e.length)&&!!_r[Vme(e)]}var jpe=ype;function bpe(e){return function(t){return e(t)}}var uz=bpe,fy={exports:{}};fy.exports;(function(e,t){var r=yU,s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===s,o=i&&r.process,l=function(){try{var c=a&&a.require&&a.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();e.exports=l})(fy,fy.exports);var wpe=fy.exports,_pe=jpe,Npe=uz,LE=wpe,FE=LE&&LE.isTypedArray,Spe=FE?Npe(FE):_pe,hz=Spe,Cpe=Tme,kpe=Vk,Ppe=Hs,Tpe=dz,Ape=Kk,Epe=hz,Ope=Object.prototype,Mpe=Ope.hasOwnProperty;function Dpe(e,t){var r=Ppe(e),s=!r&&kpe(e),a=!r&&!s&&Tpe(e),i=!r&&!s&&!a&&Epe(e),o=r||s||a||i,l=o?Cpe(e.length,String):[],c=l.length;for(var d in e)(t||Mpe.call(e,d))&&!(o&&(d=="length"||a&&(d=="offset"||d=="parent")||i&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||Ape(d,c)))&&l.push(d);return l}var Rpe=Dpe,$pe=Object.prototype;function Ipe(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||$pe;return e===r}var Lpe=Ipe;function Fpe(e,t){return function(r){return e(t(r))}}var fz=Fpe,Upe=fz,zpe=Upe(Object.keys,Object),Bpe=zpe,qpe=Lpe,Wpe=Bpe,Hpe=Object.prototype,Vpe=Hpe.hasOwnProperty;function Kpe(e){if(!qpe(e))return Wpe(e);var t=[];for(var r in Object(e))Vpe.call(e,r)&&r!="constructor"&&t.push(r);return t}var Gpe=Kpe,Ype=Tk,Qpe=Gk;function Xpe(e){return e!=null&&Qpe(e.length)&&!Ype(e)}var Sg=Xpe,Zpe=Rpe,Jpe=Gpe,ege=Sg;function tge(e){return ege(e)?Zpe(e):Jpe(e)}var Pj=tge,rge=xme,nge=kme,sge=Pj;function age(e){return rge(e,sge,nge)}var ige=age,UE=ige,oge=1,lge=Object.prototype,cge=lge.hasOwnProperty;function dge(e,t,r,s,a,i){var o=r&oge,l=UE(e),c=l.length,d=UE(t),u=d.length;if(c!=u&&!o)return!1;for(var h=c;h--;){var f=l[h];if(!(o?f in t:cge.call(t,f)))return!1}var m=i.get(e),g=i.get(t);if(m&&g)return m==t&&g==e;var p=!0;i.set(e,t),i.set(t,e);for(var y=o;++h<c;){f=l[h];var v=e[f],j=t[f];if(s)var b=o?s(j,v,f,t,e,i):s(v,j,f,e,t,i);if(!(b===void 0?v===j||a(v,j,r,s,i):b)){p=!1;break}y||(y=f=="constructor")}if(p&&!y){var _=e.constructor,w=t.constructor;_!=w&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof w=="function"&&w instanceof w)&&(p=!1)}return i.delete(e),i.delete(t),p}var uge=dge,hge=Dd,fge=Ji,mge=hge(fge,"DataView"),pge=mge,gge=Dd,xge=Ji,vge=gge(xge,"Promise"),yge=vge,jge=Dd,bge=Ji,wge=jge(bge,"Set"),mz=wge,_ge=Dd,Nge=Ji,Sge=_ge(Nge,"WeakMap"),Cge=Sge,r1=pge,n1=Ek,s1=yge,a1=mz,i1=Cge,pz=el,df=bU,zE="[object Map]",kge="[object Object]",BE="[object Promise]",qE="[object Set]",WE="[object WeakMap]",HE="[object DataView]",Pge=df(r1),Tge=df(n1),Age=df(s1),Ege=df(a1),Oge=df(i1),$c=pz;(r1&&$c(new r1(new ArrayBuffer(1)))!=HE||n1&&$c(new n1)!=zE||s1&&$c(s1.resolve())!=BE||a1&&$c(new a1)!=qE||i1&&$c(new i1)!=WE)&&($c=function(e){var t=pz(e),r=t==kge?e.constructor:void 0,s=r?df(r):"";if(s)switch(s){case Pge:return HE;case Tge:return zE;case Age:return BE;case Ege:return qE;case Oge:return WE}return t});var Mge=$c,jw=nz,Dge=oz,Rge=hme,$ge=uge,VE=Mge,KE=Hs,GE=dz,Ige=hz,Lge=1,YE="[object Arguments]",QE="[object Array]",mx="[object Object]",Fge=Object.prototype,XE=Fge.hasOwnProperty;function Uge(e,t,r,s,a,i){var o=KE(e),l=KE(t),c=o?QE:VE(e),d=l?QE:VE(t);c=c==YE?mx:c,d=d==YE?mx:d;var u=c==mx,h=d==mx,f=c==d;if(f&&GE(e)){if(!GE(t))return!1;o=!0,u=!1}
vendor: 4,093 bytes, line 697
697if(f&&!u)return i||(i=new jw),o||Ige(e)?Dge(e,t,r,s,a,i):Rge(e,t,c,r,s,a,i);if(!(r&Lge)){var m=u&&XE.call(e,"__wrapped__"),g=h&&XE.call(t,"__wrapped__");if(m||g){var p=m?e.value():e,y=g?t.value():t;return i||(i=new jw),a(p,y,r,s,i)}}return f?(i||(i=new jw),$ge(e,t,r,s,a,i)):!1}var zge=Uge,Bge=zge,ZE=tl;function gz(e,t,r,s,a){return e===t?!0:e==null||t==null||!ZE(e)&&!ZE(t)?e!==e&&t!==t:Bge(e,t,r,s,gz,a)}var Yk=gz,qge=nz,Wge=Yk,Hge=1,Vge=2;function Kge(e,t,r,s){var a=r.length,i=a,o=!s;if(e==null)return!i;for(e=Object(e);a--;){var l=r[a];if(o&&l[2]?l[1]!==e[l[0]]:!(l[0]in e))return!1}for(;++a<i;){l=r[a];var c=l[0],d=e[c],u=l[1];if(o&&l[2]){if(d===void 0&&!(c in e))return!1}else{var h=new qge;if(s)var f=s(d,u,c,e,t,h);if(!(f===void 0?Wge(u,d,Hge|Vge,s,h):f))return!1}}return!0}var Gge=Kge,Yge=pc;function Qge(e){return e===e&&!Yge(e)}var xz=Qge,Xge=xz,Zge=Pj;function Jge(e){for(var t=Zge(e),r=t.length;r--;){var s=t[r],a=e[s];t[r]=[s,a,Xge(a)]}return t}var exe=Jge;function txe(e,t){return function(r){return r==null?!1:r[e]===t&&(t!==void 0||e in Object(r))}}var vz=txe,rxe=Gge,nxe=exe,sxe=vz;function axe(e){var t=nxe(e);return t.length==1&&t[0][2]?sxe(t[0][0],t[0][1]):function(r){return r===e||rxe(r,e,t)}}var ixe=axe;function oxe(e,t){return e!=null&&t in Object(e)}var lxe=oxe,cxe=CU,dxe=Vk,uxe=Hs,hxe=Kk,fxe=Gk,mxe=fj;function pxe(e,t,r){t=cxe(t,e);for(var s=-1,a=t.length,i=!1;++s<a;){var o=mxe(t[s]);if(!(i=e!=null&&r(e,o)))break;e=e[o]}return i||++s!=a?i:(a=e==null?0:e.length,!!a&&fxe(a)&&hxe(o,a)&&(uxe(e)||dxe(e)))}var gxe=pxe,xxe=lxe,vxe=gxe;function yxe(e,t){return e!=null&&vxe(e,t,xxe)}var jxe=yxe,bxe=Yk,wxe=kU,_xe=jxe,Nxe=Pk,Sxe=xz,Cxe=vz,kxe=fj,Pxe=1,Txe=2;function Axe(e,t){return Nxe(e)&&Sxe(t)?Cxe(kxe(e),t):function(r){var s=wxe(r,e);return s===void 0&&s===t?_xe(r,e):bxe(t,s,Pxe|Txe)}}var Exe=Axe;function Oxe(e){return e}var uf=Oxe;function Mxe(e){return function(t){return t==null?void 0:t[e]}}var Dxe=Mxe,Rxe=Rk;function $xe(e){return function(t){return Rxe(t,e)}}var Ixe=$xe,Lxe=Dxe,Fxe=Ixe,Uxe=Pk,zxe=fj;function Bxe(e){return Uxe(e)?Lxe(zxe(e)):Fxe(e)}var qxe=Bxe,Wxe=ixe,Hxe=Exe,Vxe=uf,Kxe=Hs,Gxe=qxe;function Yxe(e){return typeof e=="function"?e:e==null?Vxe:typeof e=="object"?Kxe(e)?Hxe(e[0],e[1]):Wxe(e):Gxe(e)}var gc=Yxe;function Qxe(e,t,r,s){for(var a=e.length,i=r+(s?1:-1);s?i--:++i<a;)if(t(e[i],i,e))return i;return-1}var yz=Qxe;function Xxe(e){return e!==e}var Zxe=Xxe;function Jxe(e,t,r){for(var s=r-1,a=e.length;++s<a;)if(e[s]===t)return s;return-1}var eve=Jxe,tve=yz,rve=Zxe,nve=eve;function sve(e,t,r){return t===t?nve(e,t,r):tve(e,rve,r)}var ave=sve,ive=ave;function ove(e,t){var r=e==null?0:e.length;return!!r&&ive(e,t,0)>-1}var lve=ove;function cve(e,t,r){for(var s=-1,a=e==null?0:e.length;++s<a;)if(r(t,e[s]))return!0;return!1}var dve=cve;function uve(){}var hve=uve,bw=mz,fve=hve,mve=Hk,pve=1/0,gve=bw&&1/mve(new bw([,-0]))[1]==pve?function(e){return new bw(e)}:fve,xve=gve,vve=sz,yve=lve,jve=dve,bve=iz,wve=xve,_ve=Hk,Nve=200;function Sve(e,t,r){var s=-1,a=yve,i=e.length,o=!0,l=[],c=l;if(r)o=!1,a=jve;else if(i>=Nve){var d=t?null:wve(e);if(d)return _ve(d);o=!1,a=bve,c=new vve}else c=t?[]:l;e:for(;++s<i;){var u=e[s],h=t?t(u):u;if(u=r||u!==0?u:0,o&&h===h){for(var f=c.length;f--;)if(c[f]===h)continue e;t&&c.push(h),l.push(u)}else a(c,h,r)||(c!==l&&c.push(h),l.push(u))}return l}var Cve=Sve,kve=gc,Pve=Cve;function Tve(e,t){return e&&e.length?Pve(e,kve(t)):[]}var Ave=Tve;const JE=fr(Ave);function jz(e,t,r){return t===!0?JE(e,r):_t(t)?JE(e,t):e}function gh(e){"@babel/helpers - typeof";return gh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gh(e)}var Eve=["ref"];function eO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function so(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};
vendor: 4,101 bytes, line 697
697t%2?eO(Object(r),!0).forEach(function(s){Tj(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):eO(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Ove(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tO(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,wz(s.key),s)}}function Mve(e,t,r){return t&&tO(e.prototype,t),r&&tO(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Dve(e,t,r){return t=my(t),Rve(e,bz()?Reflect.construct(t,r||[],my(e).constructor):t.apply(e,r))}function Rve(e,t){if(t&&(gh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return $ve(e)}function $ve(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(bz=function(){return!!e})()}function my(e){return my=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},my(e)}function Ive(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o1(e,t)}function o1(e,t){return o1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},o1(e,t)}function Tj(e,t,r){return t=wz(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function wz(e){var t=Lve(e,"string");return gh(t)=="symbol"?t:t+""}function Lve(e,t){if(gh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(gh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Fve(e,t){if(e==null)return{};var r=Uve(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Uve(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function zve(e){return e.value}function Bve(e,t){if(G.isValidElement(e))return G.cloneElement(e,t);if(typeof e=="function")return G.createElement(e,t);t.ref;var r=Fve(t,Eve);return G.createElement(Wk,r)}var rO=1,ko=function(e){function t(){var r;Ove(this,t);for(var s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];return r=Dve(this,t,[].concat(a)),Tj(r,"lastBoundingBox",{width:-1,height:-1}),r}return Ive(t,e),Mve(t,[{key:"componentDidMount",value:function(){this.updateBBox()}},{key:"componentDidUpdate",value:function(){this.updateBBox()}},{key:"getBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var s=this.wrapperNode.getBoundingClientRect();return s.height=this.wrapperNode.offsetHeight,s.width=this.wrapperNode.offsetWidth,s}return null}},{key:"updateBBox",value:function(){var s=this.props.onBBoxUpdate,a=this.getBBox();a?(Math.abs(a.width-this.lastBoundingBox.width)>rO||Math.abs(a.height-this.lastBoundingBox.height)>rO)&&(this.lastBoundingBox.width=a.width,this.lastBoundingBox.height=a.height,s&&s(a)):(this.lastBoundingBox.width!==-1||this.lastBoundingBox.height!==-1)&&(this.lastBoundingBox.width=-1,this.lastBoundingBox.height=-1,s&&s(null))}},{key:"getBBoxSnapshot",value:function(){return this.lastBoundingBox.width>=0&&this.lastBoundingBox.height>=0?so({},this.lastBoundingBox):{width:0,height:0}}},{key:"getDefaultPosition",value:function(s){var a=this.props,i=a.layout,o=a.align,l=a.verticalAlign,c=a.margin,d=a.chartWidth,u=a.chartHe
697ight,h,f;if(!s||(s.left===void 0||s.left===null)&&(s.right===void 0||s.right===null))if(o==="center"&&i==="vertical"){var m=this.getBBoxSnapshot();h={left:((d||0)-m.width)/2}}else h=o==="right"?{right:c&&c.right||0}:{left:c&&c.left||0};if(!s||(s.top===void 0||s.top===null)&&(s.bottom===void 0||s.bottom===null))if(l==="middle"){var g=this.getBBoxSnapshot();f={top:((u||0)-g.height)/2}}else f=l==="bottom"?{bottom:c&&c.bottom||0}:{top:c&&c.top||0};return so(so({},h),f)}},{key:"render",value:function(){var s=this,a=this.props,i=a.content,o=a.width,l=a.height,c=a.wrapperStyle,d=a.payloadUniqBy,u=a.payload,h=so(so({position:"absolute",width:o||"auto",height:l||"auto"},this.getDefaultPosition(c)),c);return G.createElement("div",{className:"recharts-legend-wrapper",style:h,ref:function(m){s.wrapperNode=m}},Bve(i,so(so({},this.props),{},{payload:jz(u,d,zve)})))}}],[{key:"getWithHeight",value:function(s,a){var i=so(so({},this.defaultProps),s.props),o=i.layout;return o==="vertical"&&Be(s.props.height)?{height:s.props.height}:o==="horizontal"?{width:s.props.width||a}:null}}])}(x.PureComponent);Tj(ko,"displayName","Legend");Tj(ko,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var nO=wg,qve=Vk,Wve=Hs,sO=nO?nO.isConcatSpreadable:void 0;function Hve(e){return Wve(e)||qve(e)||!!(sO&&e&&e[sO])}var Vve=Hve,Kve=lz,Gve=Vve;function _z(e,t,r,s,a){var i=-1,o=e.length;for(r||(r=Gve),a||(a=[]);++i<o;){var l=e[i];t>0&&r(l)?t>1?_z(l,t-1,r,s,a):Kve(a,l):s||(a[a.length]=l)}return a}var Nz=_z;function Yve(e){return function(t,r,s){for(var a=-1,i=Object(t),o=s(t),l=o.length;l--;){var c=o[e?l:++a];if(r(i[c],c,i)===!1)break}return t}}var Qve=Yve,Xve=Qve,Zve=Xve(),Jve=Zve,eye=Jve,tye=Pj;function rye(e,t){return e&&eye(e,t,tye)}var Sz=rye,nye=Sg;function sye(e,t){return function(r,s){if(r==null)return r;if(!nye(r))return e(r,s);for(var a=r.length,i=t?a:-1,o=Object(r);(t?i--:++i<a)&&s(o[i],i,o)!==!1;);return r}}var aye=sye,iye=Sz,oye=aye,lye=oye(iye),Qk=lye,cye=Qk,dye=Sg;function uye(e,t){var r=-1,s=dye(e)?Array(e.length):[];return cye(e,function(a,i,o){s[++r]=t(a,i,o)}),s}var Cz=uye;function hye(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}var fye=hye,aO=nf;function mye(e,t){if(e!==t){var r=e!==void 0,s=e===null,a=e===e,i=aO(e),o=t!==void 0,l=t===null,c=t===t,d=aO(t);if(!l&&!d&&!i&&e>t||i&&o&&c&&!l&&!d||s&&o&&c||!r&&c||!a)return 1;if(!s&&!i&&!d&&e<t||d&&r&&a&&!s&&!i||l&&r&&a||!o&&a||!c)return-1}return 0}var pye=mye,gye=pye;function xye(e,t,r){for(var s=-1,a=e.criteria,i=t.criteria,o=a.length,l=r.length;++s<o;){var c=gye(a[s],i[s]);if(c){if(s>=l)return c;var d=r[s];return c*(d=="desc"?-1:1)}}return e.index-t.index}var vye=xye,ww=Dk,yye=Rk,jye=gc,bye=Cz,wye=fye,_ye=uz,Nye=vye,Sye=uf,Cye=Hs;function kye(e,t,r){t.length?t=ww(t,function(i){return Cye(i)?function(o){return yye(o,i.length===1?i[0]:i)}:i}):t=[Sye];var s=-1;t=ww(t,_ye(jye));var a=bye(e,function(i,o,l){var c=ww(t,function(d){return d(i)});return{criteria:c,index:++s,value:i}});return wye(a,function(i,o){return Nye(i,o,r)})}var Pye=kye;function Tye(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}var Aye=Tye,Eye=Aye,iO=Math.max;function Oye(e,t,r){return t=iO(t===void 0?e.length-1:t,0),function(){for(var s=arguments,a=-1,i=iO(s.length-t,0),o=Array(i);++a<i;)o[a]=s[t+a];a=-1;for(var l=Array(t+1);++a<t;)l[a]=s[a];return l[t]=r(o),Eye(e,this,l)}}var Mye=Oye;function Dye(e){return function(){return e}}var Rye=Dye,$ye=Dd,Iye=function(){try{var e=$ye(Object,"defineProperty");return e({},"",{}),e}catch{}}(),kz=Iye,Lye=Rye,oO=kz,Fye=uf,Uye=oO?function(e,t){return oO(e,"toString",{configurable:!0,enumerable:!1,value:Lye(t),writable:!0})}:Fye,zye=Uye,Bye=800,qye=16,Wye=Date.now;function Hye(e){var t=0,r=0;return function(){var s=Wye(),a=qye-(s-r);if(r=s,a>0){if(++t>=Bye)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}var Vye=Hye,Kye=zye,Gye=Vye,Yye=Gye(Kye),Qye=Yye,Xye=uf,Zye=Mye,Jye=Qye;function e0e(e,t){return Jye(Zye(e,t,Xye),e+"")}var t0e=e0e,r0e=Ak,n0e=Sg,s0e=Kk,a0e=pc;function i0e(e,t,r){if(!a0e(r))return!1;var s=typeof t;return(s=="number"?n0e(r)&&s0e(t,r.length):s=="string"&&t in r)?r0e(r[t],e):!1}var Aj=i0e,o0e=Nz,l0e=Pye,c0e=t0e,lO=Aj,d0e=c0e(function(e,t){if(e==null)return[];var r=t.length;return r>1&&lO(e,t[0],t[1])?t=[]:r>2&&lO(t[0],t[1],t[2])&&(t=[t[0]]),l0e(e,o0e(t,1),[])}),u0e=d0e;const Xk=fr(u0e);function cp(e){"@babel/helpers - typeof";return cp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cp(e)}function l1(){return l1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];
vendor: 29,157 bytes, lines 697-704
697for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},l1.apply(this,arguments)}function h0e(e,t){return g0e(e)||p0e(e,t)||m0e(e,t)||f0e()}function f0e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
698In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function m0e(e,t){if(e){if(typeof e=="string")return cO(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return cO(e,t)}}function cO(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function p0e(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function g0e(e){if(Array.isArray(e))return e}function dO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function _w(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?dO(Object(r),!0).forEach(function(s){x0e(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):dO(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function x0e(e,t,r){return t=v0e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function v0e(e){var t=y0e(e,"string");return cp(t)=="symbol"?t:t+""}function y0e(e,t){if(cp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(cp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function j0e(e){return Array.isArray(e)&&yn(e[0])&&yn(e[1])?e.join(" ~ "):e}var b0e=function(t){var r=t.separator,s=r===void 0?" : ":r,a=t.contentStyle,i=a===void 0?{}:a,o=t.itemStyle,l=o===void 0?{}:o,c=t.labelStyle,d=c===void 0?{}:c,u=t.payload,h=t.formatter,f=t.itemSorter,m=t.wrapperClassName,g=t.labelClassName,p=t.label,y=t.labelFormatter,v=t.accessibilityLayer,j=v===void 0?!1:v,b=function(){if(u&&u.length){var A={padding:0,margin:0},U=(f?Xk(u,f):u).map(function(F,L){if(F.type==="none")return null;var $=_w({display:"block",paddingTop:4,paddingBottom:4,color:F.color||"#000"},l),R=F.formatter||h||j0e,T=F.value,k=F.name,W=T,q=k;if(R&&W!=null&&q!=null){var Q=R(T,k,F,L,u);if(Array.isArray(Q)){var ue=h0e(Q,2);W=ue[0],q=ue[1]}else W=Q}return G.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(L),style:$},yn(q)?G.createElement("span",{className:"recharts-tooltip-item-name"},q):null,yn(q)?G.createElement("span",{className:"recharts-tooltip-item-separator"},s):null,G.createElement("span",{className:"recharts-tooltip-item-value"},W),G.createElement("span",{className:"recharts-tooltip-item-unit"},F.unit||""))});return G.createElement("ul",{className:"recharts-tooltip-item-list",style:A},U)}return null},_=_w({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},i),w=_w({margin:0},d),N=!Pt(p),S=N?p:"",C=It("recharts-default-tooltip",m),P=It("recharts-tooltip-label",g);N&&y&&u!==void 0&&u!==null&&(S=y(p,u));var M=j?{role:"status","aria-live":"assertive"}:{};return G.createElement("div",l1({className:C,style:_},M),G.createElement("p",{className:P,style:w},G.isValidElement(S)?S:"".concat(S)),b())};function dp(e){"@babel/helpers - typeof";return dp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dp(e)}function px(e,t,r){return t=w0e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function w0e(e){var t=_0e(e,"string");return dp(t)=="symbol"?t:t+""}function _0e(e,t){if(dp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(dp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var $f="recharts-tooltip-wrapper",N0e={visibility:"hidden"};function S0e(e){var t=e.coordinate,r=e.translateX,s=e.translateY;return It($f,px(px(px(px({},"".concat($f,"-right"),Be(r)&&t&&Be(t.x)&&r>=t.x),"".concat($f,"-left"),Be(r)&&t&&Be(t.x)&&r<t.x),"".concat($f,"-bottom"),Be(s)&&t&&Be(t.y)&&s>=t.y),"".concat($f,"-top"),Be(s)&&t&&Be(t.y)&&s<t.y))}function uO(e){var t=e.allowEscapeViewBox,r=e.coordinate,s=e.key,a=e.offsetTopLeft,i=e.position,o=e.reverseDirection,l=e.tooltipDimension,c=e.viewBox,d=e.viewBoxDimension;if(i&&Be(i[s]))return i[s];var u=r[s]-l-a,h=r[s]+a;if(t[s])return o[s]?u:h;if(o[s]){var f=u,m=c[s];return f<m?Math.max(h,c[s]):Math.max(u,c[s])}var g=h+l,p=c[s]+d;return g>p?Math.max(u,c[s]):Math.max(h,c[s])}function C0e(e){var t=e.translateX,r=e.translateY,s=e.useTranslate3d;return{transform:s?"translate3d(".concat(t,"px, ").concat(r,"px, 0)"):"translate(".concat(t,"px, ").concat(r,"px)")}}function k0e(e){var t=e.allowEscapeViewBox,r=e.coordinate,s=e.offsetTopLeft,a=e.position,i=e.reverseDirection,o=e.tooltipBox,l=e.useTranslate3d,c=e.viewBox,d,u,h;return o.height>0&&o.width>0&&r?(u=uO({allowEscapeViewBox:t,coordinate:r,key:"x",offsetTopLeft:s,position:a,reverseDirection:i,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),h=uO({allowEscapeViewBox:t,coordinate:r,key:"y",offsetTopLeft:s,position:a,reverseDirection:i,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),d=C0e({translateX:u,translateY:h,useTranslate3d:l})):d=N0e,{cssProperties:d,cssClasses:S0e({translateX:u,translateY:h,coordinate:r})}}function xh(e){"@babel/helpers - typeof";return xh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xh(e)}function hO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function fO(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?hO(Object(r),!0).forEach(function(s){d1(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hO(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function P0e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function T0e(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Tz(s.key),s)}}function A0e(e,t,r){return t&&T0e(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function E0e(e,t,r){return t=py(t),O0e(e,Pz()?Reflect.construct(t,r||[],py(e).constructor):t.apply(e,r))}function O0e(e,t){if(t&&(xh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return M0e(e)}function M0e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Pz=function(){return!!e})()}function py(e){return py=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},py(e)}function D0e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&c1(e,t)}function c1(e,t){return c1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},c1(e,t)}function d1(e,t,r){return t=Tz(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Tz(e){var t=R0e(e,"string");return xh(t)=="symbol"?t:t+""}function R0e(e,t){if(xh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(xh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var mO=1,$0e=function(e){function t(){var r;P0e(this,t);for(var s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];return r=E0e(this,t,[].concat(a)),d1(r,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0},lastBoundingBox:{width:-1,height:-1}}),d1(r,"handleKeyDown",function(o){if(o.key==="Escape"){var l,c,d,u;r.setState({dismissed:!0,dismissedAtCoordinate:{x:(l=(c=r.props.coordinate)===null||c===void 0?void 0:c.x)!==null&&l!==void 0?l:0,y:(d=(u=r.props.coordinate)===null||u===void 0?void 0:u.y)!==null&&d!==void 0?d:0}})}}),r}return D0e(t,e),A0e(t,[{key:"updateBBox",value:function(){if(this.wrapperNode&&this.wrapperNode.getBoundingClientRect){var s=this.wrapperNode.getBoundingClientRect();(Math.abs(s.width-this.state.lastBoundingBox.width)>mO||Math.abs(s.height-this.state.lastBoundingBox.height)>mO)&&this.setState({lastBoundingBox:{width:s.width,height:s.height}})}else(this.state.lastBoundingBox.width!==-1||this.state.lastBoundingBox.height!==-1)&&this.setState({lastBoundingBox:{width:-1,height:-1}})}},{key:"componentDidMount",value:function(){document.addEventListener("keydown",this.handleKeyDown),this.updateBBox()}},{key:"componentWillUnmount",value:function(){document.removeEventListener("keydown",this.handleKeyDown)}},{key:"componentDidUpdate",value:function(){var s,a;this.props.active&&this.updateBBox(),this.state.dismissed&&(((s=this.props.coordinate)===null||s===void 0?void 0:s.x)!==this.state.dismissedAtCoordinate.x||((a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}},{key:"render",value:function(){var s=this,a=this.props,i=a.active,o=a.allowEscapeViewBox,l=a.animationDuration,c=a.animationEasing,d=a.children,u=a.coordinate,h=a.hasPayload,f=a.isAnimationActive,m=a.offset,g=a.position,p=a.reverseDirection,y=a.useTranslate3d,v=a.viewBox,j=a.wrapperStyle,b=k0e({allowEscapeViewBox:o,coordinate:u,offsetTopLeft:m,position:g,reverseDirection:p,tooltipBox:this.state.lastBoundingBox,useTranslate3d:y,viewBox:v}),_=b.cssClasses,w=b.cssProperties,N=fO(fO({transition:f&&i?"transform ".concat(l,"ms ").concat(c):void 0},w),{},{pointerEvents:"none",visibility:!this.state.dismissed&&i&&h?"visible":"hidden",position:"absolute",top:0,left:0},j);return G.createElement("div",{tabIndex:-1,className:_,style:N,ref:function(C){s.wrapperNode=C}},d)}}])}(x.PureComponent),I0e=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},Po={isSsr:I0e(),get:function(t){return Po[t]},set:function(t,r){if(typeof t=="string")Po[t]=r;else{var s=Object.keys(t);s&&s.length&&s.forEach(function(a){Po[a]=t[a]})}}};function vh(e){"@babel/helpers - typeof";return vh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vh(e)}function pO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function gO(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pO(Object(r),!0).forEach(function(s){Zk(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pO(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function L0e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F0e(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Ez(s.key),s)}}function U0e(e,t,r){return t&&F0e(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function z0e(e,t,r){return t=gy(t),B0e(e,Az()?Reflect.construct(t,r||[],gy(e).constructor):t.apply(e,r))}function B0e(e,t){if(t&&(vh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return q0e(e)}function q0e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Az(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Az=function(){return!!e})()}function gy(e){return gy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},gy(e)}function W0e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u1(e,t)}function u1(e,t){return u1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},u1(e,t)}function Zk(e,t,r){return t=Ez(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ez(e){var t=H0e(e,"string");return vh(t)=="symbol"?t:t+""}function H0e(e,t){if(vh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(vh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function V0e(e){return e.dataKey}function K0e(e,t){return G.isValidElement(e)?G.cloneElement(e,t):typeof e=="function"?G.createElement(e,t):G.createElement(b0e,t)}var Ot=function(e){function t(){return L0e(this,t),z0e(this,t,arguments)}return W0e(t,e),U0e(t,[{key:"render",value:function(){var s=this,a=this.props,i=a.active,o=a.allowEscapeViewBox,l=a.animationDuration,c=a.animationEasing,d=a.content,u=a.coordinate,h=a.filterNull,f=a.isAnimationActive,m=a.offset,g=a.payload,p=a.payloadUniqBy,y=a.position,v=a.reverseDirection,j=a.useTranslate3d,b=a.viewBox,_=a.wrapperStyle,w=g??[];h&&w.length&&(w=jz(g.filter(function(S){return S.value!=null&&(S.hide!==!0||s.props.includeHidden)}),p,V0e));var N=w.length>0;return G.createElement($0e,{allowEscapeViewBox:o,animationDuration:l,animationEasing:c,isAnimationActive:f,active:i,coordinate:u,hasPayload:N,offset:m,position:y,reverseDirection:v,useTranslate3d:j,viewBox:b,wrapperStyle:_},K0e(d,gO(gO({},this.props),{},{payload:w})))}}])}(x.PureComponent);Zk(Ot,"displayName","Tooltip");Zk(Ot,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!Po.isSsr,itemStyle:{},labelStyle:{},offset:10,reverseDirection:{x:!1,y:!1},separator:" : ",trigger:"hover",useTranslate3d:!1,viewBox:{x:0,y:0,height:0,width:0},wrapperStyle:{}});var G0e=Ji,Y0e=function(){return G0e.Date.now()},Q0e=Y0e,X0e=/\s/;function Z0e(e){for(var t=e.length;t--&&X0e.test(e.charAt(t)););return t}var J0e=Z0e,eje=J0e,tje=/^\s+/;function rje(e){return e&&e.slice(0,eje(e)+1).replace(tje,"")}var nje=rje,sje=nje,xO=pc,aje=nf,vO=NaN,ije=/^[-+]0x[0-9a-f]+$/i,oje=/^0b[01]+$/i,lje=/^0o[0-7]+$/i,cje=parseInt;function dje(e){if(typeof e=="number")return e;if(aje(e))return vO;if(xO(e)){var t=typeof e.valueOf=="function"?e.valueOf():e;e=xO(t)?t+"":t}if(typeof e!="string")return e===0?e:+e;e=sje(e);var r=oje.test(e);return r||lje.test(e)?cje(e.slice(2),r?2:8):ije.test(e)?vO:+e}var Oz=dje,uje=pc,Nw=Q0e,yO=Oz,hje="Expected a function",fje=Math.max,mje=Math.min;function pje(e,t,r){var s,a,i,o,l,c,d=0,u=!1,h=!1,f=!0;if(typeof e!="function")throw new TypeError(hje);t=yO(t)||0,uje(r)&&(u=!!r.leading,h="maxWait"in r,i=h?fje(yO(r.maxWait)||0,t):i,f="trailing"in r?!!r.trailing:f);function m(N){var S=s,C=a;return s=a=void 0,d=N,o=e.apply(C,S),o}function g(N){return d=N,l=setTimeout(v,t),u?m(N):o}function p(N){var S=N-c,C=N-d,P=t-S;return h?mje(P,i-C):P}function y(N){var S=N-c,C=N-d;return c===void 0||S>=t||S<0||h&&C>=i}function v(){var N=Nw();if(y(N))return j(N);l=setTimeout(v,p(N))}function j(N){return l=void 0,f&&s?m(N):(s=a=void 0,o)}function b(){l!==void 0&&clearTimeout(l),d=0,s=c=a=l=void 0}function _(){return l===void 0?o:j(Nw())}function w(){var N=Nw(),S=y(N);if(s=arguments,a=this,c=N,S){if(l===void 0)return g(c);if(h)return clearTimeout(l),l=setTimeout(v,t),m(c)}return l===void 0&&(l=setTimeout(v,t)),o}return w.cancel=b,w.flush=_,w}var gje=pje,xje=gje,vje=pc,yje="Expected a function";function jje(e,t,r){var s=!0,a=!0;if(typeof e!="function")throw new TypeError(yje);return vje(r)&&(s="leading"in r?!!r.leading:s,a="trailing"in r?!!r.trailing:a),xje(e,t,{leading:s,maxWait:t,trailing:a})}var bje=jje;const Mz=fr(bje);function up(e){"@babel/helpers - typeof";return up=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},up(e)}function jO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function gx(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?jO(Object(r),!0).forEach(function(s){wje(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):jO(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function wje(e,t,r){return t=_je(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _je(e){var t=Nje(e,"string");return up(t)=="symbol"?t:t+""}function Nje(e,t){if(up(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(up(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Sje(e,t){return Tje(e)||Pje(e,t)||kje(e,t)||Cje()}function Cje(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
699In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kje(e,t){if(e){if(typeof e=="string")return bO(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return bO(e,t)}}function bO(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function Pje(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function Tje(e){if(Array.isArray(e))return e}var gr=x.forwardRef(function(e,t){var r=e.aspect,s=e.initialDimension,a=s===void 0?{width:-1,height:-1}:s,i=e.width,o=i===void 0?"100%":i,l=e.height,c=l===void 0?"100%":l,d=e.minWidth,u=d===void 0?0:d,h=e.minHeight,f=e.maxHeight,m=e.children,g=e.debounce,p=g===void 0?0:g,y=e.id,v=e.className,j=e.onResize,b=e.style,_=b===void 0?{}:b,w=x.useRef(null),N=x.useRef();N.current=j,x.useImperativeHandle(t,function(){return Object.defineProperty(w.current,"current",{get:function(){return console.warn("The usage of ref.current.current is deprecated and will no longer be supported."),w.current},configurable:!0})});var S=x.useState({containerWidth:a.width,containerHeight:a.height}),C=Sje(S,2),P=C[0],M=C[1],D=x.useCallback(function(U,F){M(function(L){var $=Math.round(U),R=Math.round(F);return L.containerWidth===$&&L.containerHeight===R?L:{containerWidth:$,containerHeight:R}})},[]);x.useEffect(function(){var U=function(k){var W,q=k[0].contentRect,Q=q.width,ue=q.height;D(Q,ue),(W=N.current)===null||W===void 0||W.call(N,Q,ue)};p>0&&(U=Mz(U,p,{trailing:!0,leading:!1}));var F=new ResizeObserver(U),L=w.current.getBoundingClientRect(),$=L.width,R=L.height;return D($,R),F.observe(w.current),function(){F.disconnect()}},[D,p]);var A=x.useMemo(function(){var U=P.containerWidth,F=P.containerHeight;if(U<0||F<0)return null;Co(qc(o)||qc(c),`The width(%s) and height(%s) are both fixed numbers,
700       maybe you don't need to use a ResponsiveContainer.`,o,c),Co(!r||r>0,"The aspect(%s) must be greater than zero.",r);var L=qc(o)?U:o,$=qc(c)?F:c;r&&r>0&&(L?$=L/r:$&&(L=$*r),f&&$>f&&($=f)),Co(L>0||$>0,`The width(%s) and height(%s) of chart should be greater than 0,
701       please check the style of container, or the props width(%s) and height(%s),
702       or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
703       height and width.`,L,$,o,c,u,h,r);var R=!Array.isArray(m)&&So(m.type).endsWith("Chart");return G.Children.map(m,function(T){return G.isValidElement(T)?x.cloneElement(T,gx({width:L,height:$},R?{style:gx({height:"100%",width:"100%",maxHeight:$,maxWidth:L},T.props.style)}:{})):T})},[r,m,c,f,h,u,P,o]);return G.createElement("div",{id:y?"".concat(y):void 0,className:It("recharts-responsive-container",v),style:gx(gx({},_),{},{width:o,height:c,minWidth:u,minHeight:h,maxHeight:f}),ref:w},A)}),Dz=function(t){return null};Dz.displayName="Cell";function hp(e){"@babel/helpers - typeof";return hp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hp(e)}function wO(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function h1(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wO(Object(r),!0).forEach(function(s){Aje(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wO(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Aje(e,t,r){return t=Eje(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Eje(e){var t=Oje(e,"string");return hp(t)=="symbol"?t:t+""}function Oje(e,t){if(hp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(hp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Jd={widthCache:{},cacheCount:0},Mje=2e3,Dje={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},_O="recharts_measurement_span";function Rje(e){var t=h1({},e);return Object.keys(t).forEach(function(r){t[r]||delete t[r]}),t}var _m=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(t==null||Po.isSsr)return{width:0,height:0};var s=Rje(r),a=JSON.stringify({text:t,copyStyle:s});if(Jd.widthCache[a])return Jd.widthCache[a];try{var i=document.getElementById(_O);i||(i=document.createElement("span"),i.setAttribute("id",_O),i.setAttribute("aria-hidden","true"),document.body.appendChild(i));var o=h1(h1({},Dje),s);Object.assign(i.style,o),i.textContent="".concat(t);var l=i.getBoundingClientRect(),c={width:l.width,height:l.height};return Jd.widthCache[a]=c,++Jd.cacheCount>Mje&&(Jd.cacheCount=0,Jd.widthCache={}),c}catch{return{width:0,height:0}}},$je=function(t){return{top:t.top+window.scrollY-document.documentElement.clientTop,left:t.left+window.scrollX-document.documentElement.clientLeft}};function fp(e){"@babel/helpers - typeof";return fp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fp(e)}function xy(e,t){return Uje(e)||Fje(e,t)||Lje(e,t)||Ije()}function Ije(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
704In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lje(e,t){if(e){if(typeof e=="string")return NO(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return NO(e,t)}}function NO(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function Fje(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function Uje(e){if(Array.isArray(e))return e}function zje(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function SO(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,qje(s.key),s)}}function Bje(e,t,r){return t&&SO(e.prototype,t),r&&SO(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function qje(e){var t=Wje(e,"string");return fp(t)=="symbol"?t:t+""}function Wje(e,t){if(fp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(fp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var CO=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,kO=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,Hje=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,Vje=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,Rz={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},Kje=Object.keys(Rz),vu="NaN";function Gje(e,t){return e*Rz[t]}var xx=function(){function e(t,r){zje(this,e),this.num=t,this.unit=r,this.num=t,this.unit=r,Number.isNaN(t)&&(this.unit=""),r!==""&&!Hje.test(r)&&(this.num=NaN,this.unit=""),Kje.includes(r)&&(this.num=Gje(t,r),this.unit="px")}return Bje(e,[{key:"add",value:function(r){return this.unit!==r.unit?new e(NaN,""):new e(this.num+r.num,this.unit)}},{key:"subtract",value:function(r){return this.unit!==r.unit?new e(NaN,""):new e(this.num-r.num,this.unit)}},{key:"multiply",value:function(r){return this.unit!==""&&r.unit!==""&&this.unit!==r.unit?new e(NaN,""):new e(this.num*r.num,this.unit||r.unit)}},{key:"divide",value:function(r){return this.unit!==""&&r.unit!==""&&this.unit!==r.unit?new e(NaN,""):new e(this.num/r.num,this.unit||r.unit)}},{key:"toString",value:function(){return"".concat(this.num).concat(this.unit)}},{key:"isNaN",value:function(){return Number.isNaN(this.num)}}],[{key:"parse",value:function(r){var s,a=(s=Vje.exec(r))!==null&&s!==void 0?s:[],i=xy(a,3),o=i[1],l=i[2];return new e(parseFloat(o),l??"")}}])}();function $z(e){if(e.includes(vu))return vu;for(var t=e;t.includes("*")||t.includes("/");){var r,s=(r=CO.exec(t))!==null&&r!==void 0?r:[],a=xy(s,4),i=a[1],o=a[2],l=a[3],c=xx.parse(i??""),d=xx.parse(l??""),u=o==="*"?c.multiply(d):c.divide(d);if(u.isNaN())return vu;t=t.replace(CO,u.toString())}for(;t.includes("+")||/.-\d+(?:\.\d+)?/.test(t);){var h,f=(h=kO.exec(t))!==null&&h!==void 0?h:[],m=xy(f,4),g=m[1],p=m[2],y=m[3],v=xx.parse(g??""),j=xx.parse(y??""),b=p==="+"?v.add(j):v.subtract(j);if(b.isNaN())return vu;t=t.replace(kO,b.toString())}return t}var PO=/\(([^()]*)\)/;function Yje(e){for(var t=e;t.includes("(");){var r=PO.exec(t),s=xy(r,2),a=s[1];t=t.replace(PO,$z(a))}return t}function Qje(e){var t=e.replace(/\s+/g,"");return t=Yje(t),t=$z(t),t}function Xje(e){try{return Qje(e)}catch{return vu}}function Sw(e){var t=Xje(e.slice(5,-1));return t===vu?"":t}var Zje=["x","y","lineHeight","capHeight","scaleToFit","textAnchor","verticalAnchor","fill"],Jje=["dx","dy","angle","className","breakAll"];function f1(){return f1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];
704for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},f1.apply(this,arguments)}function TO(e,t){if(e==null)return{};var r=ebe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function ebe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function AO(e,t){return sbe(e)||nbe(e,t)||rbe(e,t)||tbe()}function tbe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
705In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function rbe(e,t){if(e){if(typeof e=="string")return EO(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return EO(e,t)}}function EO(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function nbe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;c=!1}else for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function sbe(e){if(Array.isArray(e))return e}var Iz=/[ \f\n\r\t\v\u2028\u2029]+/,Lz=function(t){var r=t.children,s=t.breakAll,a=t.style;try{var i=[];Pt(r)||(s?i=r.toString().split(""):i=r.toString().split(Iz));var o=i.map(function(c){return{word:c,width:_m(c,a).width}}),l=s?0:_m(" ",a).width;return{wordsWithComputedWidth:o,spaceWidth:l}}catch{return null}},abe=function(t,r,s,a,i){var o=t.maxLines,l=t.children,c=t.style,d=t.breakAll,u=Be(o),h=l,f=function(){var L=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return L.reduce(function($,R){var T=R.word,k=R.width,W=$[$.length-1];if(W&&(a==null||i||W.width+k+s<Number(a)))W.words.push(T),W.width+=k+s;else{var q={words:[T],width:k};$.push(q)}return $},[])},m=f(r),g=function(L){return L.reduce(function($,R){return $.width>R.width?$:R})};if(!u)return m;for(var p="…",y=function(L){var $=h.slice(0,L),R=Lz({breakAll:d,style:c,children:$+p}).wordsWithComputedWidth,T=f(R),k=T.length>o||g(T).width>Number(a);return[k,T]},v=0,j=h.length-1,b=0,_;v<=j&&b<=h.length-1;){var w=Math.floor((v+j)/2),N=w-1,S=y(N),C=AO(S,2),P=C[0],M=C[1],D=y(w),A=AO(D,1),U=A[0];if(!P&&!U&&(v=w+1),P&&U&&(j=w-1),!P&&U){_=M;break}b++}return _||m},OO=function(t){var r=Pt(t)?[]:t.toString().split(Iz);return[{words:r}]},ibe=function(t){var r=t.width,s=t.scaleToFit,a=t.children,i=t.style,o=t.breakAll,l=t.maxLines;if((r||s)&&!Po.isSsr){var c,d,u=Lz({breakAll:o,children:a,style:i});if(u){var h=u.wordsWithComputedWidth,f=u.spaceWidth;c=h,d=f}else return OO(a);return abe({breakAll:o,children:a,maxLines:l,style:i},c,d,r,s)}return OO(a)},MO="#808080",vy=function(t){var r=t.x,s=r===void 0?0:r,a=t.y,i=a===void 0?0:a,o=t.lineHeight,l=o===void 0?"1em":o,c=t.capHeight,d=c===void 0?"0.71em":c,u=t.scaleToFit,h=u===void 0?!1:u,f=t.textAnchor,m=f===void 0?"start":f,g=t.verticalAnchor,p=g===void 0?"end":g,y=t.fill,v=y===void 0?MO:y,j=TO(t,Zje),b=x.useMemo(function(){return ibe({breakAll:j.breakAll,children:j.children,maxLines:j.maxLines,scaleToFit:h,style:j.style,width:j.width})},[j.breakAll,j.children,j.maxLines,h,j.style,j.width]),_=j.dx,w=j.dy,N=j.angle,S=j.className,C=j.breakAll,P=TO(j,Jje);if(!yn(s)||!yn(i))return null;var M=s+(Be(_)?_:0),D=i+(Be(w)?w:0),A;switch(p){case"start":A=Sw("calc(".concat(d,")"));break;case"middle":A=Sw("calc(".concat((b.length-1)/2," * -").concat(l," + (").concat(d," / 2))"));break;default:A=Sw("calc(".concat(b.length-1," * -").concat(l,")"));break}var U=[];if(h){var F=b[0].width,L=j.width;U.push("scale(".concat((Be(L)?L/F:1)/F,")"))}return N&&U.push("rotate(".concat(N,", ").concat(M,", ").concat(D,")")),U.length&&(P.transform=U.join(" ")),G.createElement("text",f1({},$t(P,!0),{x:M,y:D,className:It("recharts-text",S),textAnchor:m,fill:v.includes("url")?MO:v}),b.map(function($,R){var T=$.words.join(C?"":" ");return G.createElement("tspan",{x:M,dy:R===0?A:l,key:"".concat(T,"-").concat(R)},T)}))};function Yl(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function obe(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Jk(e){let t,r,s;e.length!==2?(t=Yl,r=(l,c)=>Yl(e(l),c),s=(l,c)=>e(l)-c):(t=e===Yl||e===obe?e:lbe,r=e,s=e);function a(l,c,d=0,u=l.length){if(d<u){if(t(c,c)!==0)return u;do{const h=d+u>>>1;r(l[h],c)<0?d=h+1:u=h}while(d<u)}return d}function i(l,c,d=0,u=l.length){if(d<u){if(t(c,c)!==0)return u;do{const h=d+u>>>1;r(l[h],c)<=0?d=h+1:u=h}while(d<u)}return d}function o(l,c,d=0,u=l.length){const h=a(l,c,d,u-1);return h>d&&s(l[h-1],c)>-s(l[h],c)?h-1:h}return{left:a,center:o,right:i}}function lbe(){return 0}function Fz(e){return e===null?NaN:+e}function*cbe(e,t){for(let r of e)r!=null&&(r=+r)>=r&&(yield r)}const dbe=Jk(Yl),Cg=dbe.right;Jk(Fz).center;class DO extends Map{constructor(t,r=fbe){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:r}}),t!=null)for(const[s,a]of t)this.set(s,a)}get(t){return super.get(RO(this,t))}has(t){return super.has(RO(this,t))}set(t,r){return super.set(ube(this,t),r)}delete(t){return super.delete(hbe(this,t))}}function RO({_intern:e,_key:t},r){const s=t(r);return e.has(s)?e.get(s):r}function ube({_intern:e,_key:t},r){const s=t(r);return e.has(s)?e.get(s):(e.set(s,r),r)}function hbe({_intern:e,_key:t},r){const s=t(r);return e.has(s)&&(r=e.get(s),e.delete(s)),r}function fbe(e){return e!==null&&typeof e=="object"?e.valueOf():e}function mbe(e=Yl){if(e===Yl)return Uz;if(typeof e!="function")throw new TypeError("compare is not a function");return(t,r)=>{const s=e(t,r);return s||s===0?s:(e(r,r)===0)-(e(t,t)===0)}}function Uz(e,t){return(e==null||!(e>=e))-(t==null||!(t>=t))||(e<t?-1:e>t?1:0)}const pbe=Math.sqrt(50),gbe=Math.sqrt(10),xbe=Math.sqrt(2);function yy(e,t,r){const s=(t-e)/Math.max(0,r),a=Math.floor(Math.log10(s)),i=s/Math.pow(10,a),o=i>=pbe?10:i>=gbe?5:i>=xbe?2:1;let l,c,d;return a<0?(d=Math.pow(10,-a)/o,l=Math.round(e*d),c=Math.round(t*d),l/d<e&&++l,c/d>t&&--c,d=-d):(d=Math.pow(10,a)*o,l=Math.round(e/d),c=Math.round(t/d),l*d<e&&++l,c*d>t&&--c),c<l&&.5<=r&&r<2?yy(e,t,r*2):[l,c,d]}function m1(e,t,r){if(t=+t,e=+e,r=+r,!(r>0))return[];if(e===t)return[e];const s=t<e,[a,i,o]=s?yy(t,e,r):yy(e,t,r);if(!(i>=a))return[];const l=i-a+1,c=new Array(l);if(s)if(o<0)for(let d=0;d<l;++d)c[d]=(i-d)/-o;else for(let d=0;d<l;++d)c[d]=(i-d)*o;else if(o<0)for(let d=0;d<l;++d)c[d]=(a+d)/-o;else for(let d=0;d<l;++d)c[d]=(a+d)*o;return c}function p1(e,t,r){return t=+t,e=+e,r=+r,yy(e,t,r)[2]}function g1(e,t,r){t=+t,e=+e,r=+r;const s=t<e,a=s?p1(t,e,r):p1(e,t,r);return(s?-1:1)*(a<0?1/-a:a)}function $O(e,t){let r;for(const s of e)s!=null&&(r<s||r===void 0&&s>=s)&&(r=s);return r}function IO(e,t){let r;for(const s of e)s!=null&&(r>s||r===void 0&&s>=s)&&(r=s);return r}function zz(e,t,r=0,s=1/0,a){if(t=Math.floor(t),r=Math.floor(Math.max(0,r)),s=Math.floor(Math.min(e.length-1,s)),!(r<=t&&t<=s))return e;for(a=a===void 0?Uz:mbe(a);s>r;){if(s-r>600){const c=s-r+1,d=t-r+1,u=Math.log(c),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(c-h)/c)*(d-c/2<0?-1:1),m=Math.max(r,Math.floor(t-d*h/c+f)),g=Math.min(s,Math.floor(t+(c-d)*h/c+f));zz(e,t,m,g,a)}const i=e[t];let o=r,l=s;for(If(e,r,t),a(e[s],i)>0&&If(e,r,s);o<l;){for(If(e,o,l),++o,--l;a(e[o],i)<0;)++o;for(;a(e[l],i)>0;)--l}a(e[r],i)===0?If(e,r,l):(++l,If(e,l,s)),l<=t&&(r=l+1),t<=l&&(s=l-1)}return e}function If(e,t,r){const s=e[t];e[t]=e[r],e[r]=s}function vbe(e,t,r){if(e=Float64Array.from(cbe(e)),!(!(s=e.length)||isNaN(t=+t))){if(t<=0||s<2)return IO(e);
vendor: 8,761 bytes, line 705
705if(t>=1)return $O(e);var s,a=(s-1)*t,i=Math.floor(a),o=$O(zz(e,i).subarray(0,i+1)),l=IO(e.subarray(i+1));return o+(l-o)*(a-i)}}function ybe(e,t,r=Fz){if(!(!(s=e.length)||isNaN(t=+t))){if(t<=0||s<2)return+r(e[0],0,e);if(t>=1)return+r(e[s-1],s-1,e);var s,a=(s-1)*t,i=Math.floor(a),o=+r(e[i],i,e),l=+r(e[i+1],i+1,e);return o+(l-o)*(a-i)}}function jbe(e,t,r){e=+e,t=+t,r=(a=arguments.length)<2?(t=e,e=0,1):a<3?1:+r;for(var s=-1,a=Math.max(0,Math.ceil((t-e)/r))|0,i=new Array(a);++s<a;)i[s]=e+s*r;return i}function La(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function rl(e,t){switch(arguments.length){case 0:break;case 1:{typeof e=="function"?this.interpolator(e):this.range(e);break}default:{this.domain(e),typeof t=="function"?this.interpolator(t):this.range(t);break}}return this}const x1=Symbol("implicit");function e2(){var e=new DO,t=[],r=[],s=x1;function a(i){let o=e.get(i);if(o===void 0){if(s!==x1)return s;e.set(i,o=t.push(i)-1)}return r[o%r.length]}return a.domain=function(i){if(!arguments.length)return t.slice();t=[],e=new DO;for(const o of i)e.has(o)||e.set(o,t.push(o)-1);return a},a.range=function(i){return arguments.length?(r=Array.from(i),a):r.slice()},a.unknown=function(i){return arguments.length?(s=i,a):s},a.copy=function(){return e2(t,r).unknown(s)},La.apply(a,arguments),a}function mp(){var e=e2().unknown(void 0),t=e.domain,r=e.range,s=0,a=1,i,o,l=!1,c=0,d=0,u=.5;delete e.unknown;function h(){var f=t().length,m=a<s,g=m?a:s,p=m?s:a;i=(p-g)/Math.max(1,f-c+d*2),l&&(i=Math.floor(i)),g+=(p-g-i*(f-c))*u,o=i*(1-c),l&&(g=Math.round(g),o=Math.round(o));var y=jbe(f).map(function(v){return g+i*v});return r(m?y.reverse():y)}return e.domain=function(f){return arguments.length?(t(f),h()):t()},e.range=function(f){return arguments.length?([s,a]=f,s=+s,a=+a,h()):[s,a]},e.rangeRound=function(f){return[s,a]=f,s=+s,a=+a,l=!0,h()},e.bandwidth=function(){return o},e.step=function(){return i},e.round=function(f){return arguments.length?(l=!!f,h()):l},e.padding=function(f){return arguments.length?(c=Math.min(1,d=+f),h()):c},e.paddingInner=function(f){return arguments.length?(c=Math.min(1,f),h()):c},e.paddingOuter=function(f){return arguments.length?(d=+f,h()):d},e.align=function(f){return arguments.length?(u=Math.max(0,Math.min(1,f)),h()):u},e.copy=function(){return mp(t(),[s,a]).round(l).paddingInner(c).paddingOuter(d).align(u)},La.apply(h(),arguments)}function Bz(e){var t=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,delete e.paddingOuter,e.copy=function(){return Bz(t())},e}function Nm(){return Bz(mp.apply(null,arguments).paddingInner(1))}function t2(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function qz(e,t){var r=Object.create(e.prototype);for(var s in t)r[s]=t[s];return r}function kg(){}var pp=.7,jy=1/pp,Ru="\\s*([+-]?\\d+)\\s*",gp="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ri="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bbe=/^#([0-9a-f]{3,8})$/,wbe=new RegExp(`^rgb\\(${Ru},${Ru},${Ru}\\)$`),_be=new RegExp(`^rgb\\(${Ri},${Ri},${Ri}\\)$`),Nbe=new RegExp(`^rgba\\(${Ru},${Ru},${Ru},${gp}\\)$`),Sbe=new RegExp(`^rgba\\(${Ri},${Ri},${Ri},${gp}\\)$`),Cbe=new RegExp(`^hsl\\(${gp},${Ri},${Ri}\\)$`),kbe=new RegExp(`^hsla\\(${gp},${Ri},${Ri},${gp}\\)$`),LO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};t2(kg,xp,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:FO,formatHex:FO,formatHex8:Pbe,formatHsl:Tbe,formatRgb:UO,toString:UO});function FO(){return this.rgb().formatHex()}function Pbe(){return this.rgb().formatHex8()}function Tbe(){return Wz(this).formatHsl()}function UO(){return this.rgb().formatRgb()}function xp(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=bbe.exec(e))?(r=t[1].length,t=parseInt(t[1],16),r===6?zO(t):r===3?new Is(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):r===8?vx(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):r===4?vx(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=wbe.exec(e))?new Is(t[1],t[2],t[3],1):(t=_be.exec(e))?new Is(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Nbe.exec(e))?vx(t[1],t[2],t[3],t[4]):(t=Sbe.exec(e))?vx(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Cbe.exec(e))?WO(t[1],t[2]/100,t[3]/100,1):(t=kbe.exec(e))?WO(t[1],t[2]/100,t[3]/100,t[4]):LO.hasOwnProperty(e)?zO(LO[e]):e==="transparent"?new Is(NaN,NaN,NaN,0):null}function zO(e){return new Is(e>>16&255,e>>8&255,e&255,1)}function vx(e,t,r,s){return s<=0&&(e=t=r=NaN),new Is(e,t,r,s)}function Abe(e){return e instanceof kg||(e=xp(e)),e?(e=e.rgb(),new Is(e.r,e.g,e.b,e.opacity)):new Is}function v1(e,t,r,s){return arguments.length===1?Abe(e):new Is(e,t,r,s??1)}function Is(e,t,r,s){this.r=+e,this.g=+t,this.b=+r,this.opacity=+s}t2(Is,v1,qz(kg,{brighter(e){return e=e==null?jy:Math.pow(jy,e),new Is(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?pp:Math.pow(pp,e),new Is(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Is(ad(this.r),ad(this.g),ad(this.b),by(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:BO,formatHex:BO,formatHex8:Ebe,formatRgb:qO,toString:qO}));function BO(){return`#${Wc(this.r)}${Wc(this.g)}${Wc(this.b)}`}function Ebe(){return`#${Wc(this.r)}${Wc(this.g)}${Wc(this.b)}${Wc((isNaN(this.opacity)?1:this.opacity)*255)}`}function qO(){const e=by(this.opacity);return`${e===1?"rgb(":"rgba("}${ad(this.r)}, ${ad(this.g)}, ${ad(this.b)}${e===1?")":`, ${e})`}`}function by(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ad(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wc(e){return e=ad(e),(e<16?"0":"")+e.toString(16)}function WO(e,t,r,s){return s<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new ti(e,t,r,s)}function Wz(e){if(e instanceof ti)return new ti(e.h,e.s,e.l,e.opacity);if(e instanceof kg||(e=xp(e)),!e)return new ti;if(e instanceof ti)return e;e=e.rgb();var t=e.r/255,r=e.g/255,s=e.b/255,a=Math.min(t,r,s),i=Math.max(t,r,s),o=NaN,l=i-a,c=(i+a)/2;
vendor: 4,919 bytes, line 705
705return l?(t===i?o=(r-s)/l+(r<s)*6:r===i?o=(s-t)/l+2:o=(t-r)/l+4,l/=c<.5?i+a:2-i-a,o*=60):l=c>0&&c<1?0:o,new ti(o,l,c,e.opacity)}function Obe(e,t,r,s){return arguments.length===1?Wz(e):new ti(e,t,r,s??1)}function ti(e,t,r,s){this.h=+e,this.s=+t,this.l=+r,this.opacity=+s}t2(ti,Obe,qz(kg,{brighter(e){return e=e==null?jy:Math.pow(jy,e),new ti(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?pp:Math.pow(pp,e),new ti(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,s=r+(r<.5?r:1-r)*t,a=2*r-s;return new Is(Cw(e>=240?e-240:e+120,a,s),Cw(e,a,s),Cw(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new ti(HO(this.h),yx(this.s),yx(this.l),by(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=by(this.opacity);return`${e===1?"hsl(":"hsla("}${HO(this.h)}, ${yx(this.s)*100}%, ${yx(this.l)*100}%${e===1?")":`, ${e})`}`}}));function HO(e){return e=(e||0)%360,e<0?e+360:e}function yx(e){return Math.max(0,Math.min(1,e||0))}function Cw(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}const r2=e=>()=>e;function Mbe(e,t){return function(r){return e+r*t}}function Dbe(e,t,r){return e=Math.pow(e,r),t=Math.pow(t,r)-e,r=1/r,function(s){return Math.pow(e+s*t,r)}}function Rbe(e){return(e=+e)==1?Hz:function(t,r){return r-t?Dbe(t,r,e):r2(isNaN(t)?r:t)}}function Hz(e,t){var r=t-e;return r?Mbe(e,r):r2(isNaN(e)?t:e)}const VO=function e(t){var r=Rbe(t);function s(a,i){var o=r((a=v1(a)).r,(i=v1(i)).r),l=r(a.g,i.g),c=r(a.b,i.b),d=Hz(a.opacity,i.opacity);return function(u){return a.r=o(u),a.g=l(u),a.b=c(u),a.opacity=d(u),a+""}}return s.gamma=e,s}(1);function $be(e,t){t||(t=[]);var r=e?Math.min(t.length,e.length):0,s=t.slice(),a;return function(i){for(a=0;a<r;++a)s[a]=e[a]*(1-i)+t[a]*i;return s}}function Ibe(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Lbe(e,t){var r=t?t.length:0,s=e?Math.min(r,e.length):0,a=new Array(s),i=new Array(r),o;for(o=0;o<s;++o)a[o]=hf(e[o],t[o]);for(;o<r;++o)i[o]=t[o];return function(l){for(o=0;o<s;++o)i[o]=a[o](l);return i}}function Fbe(e,t){var r=new Date;return e=+e,t=+t,function(s){return r.setTime(e*(1-s)+t*s),r}}function wy(e,t){return e=+e,t=+t,function(r){return e*(1-r)+t*r}}function Ube(e,t){var r={},s={},a;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(a in t)a in e?r[a]=hf(e[a],t[a]):s[a]=t[a];return function(i){for(a in r)s[a]=r[a](i);return s}}var y1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,kw=new RegExp(y1.source,"g");function zbe(e){return function(){return e}}function Bbe(e){return function(t){return e(t)+""}}function qbe(e,t){var r=y1.lastIndex=kw.lastIndex=0,s,a,i,o=-1,l=[],c=[];for(e=e+"",t=t+"";(s=y1.exec(e))&&(a=kw.exec(t));)(i=a.index)>r&&(i=t.slice(r,i),l[o]?l[o]+=i:l[++o]=i),(s=s[0])===(a=a[0])?l[o]?l[o]+=a:l[++o]=a:(l[++o]=null,c.push({i:o,x:wy(s,a)})),r=kw.lastIndex;return r<t.length&&(i=t.slice(r),l[o]?l[o]+=i:l[++o]=i),l.length<2?c[0]?Bbe(c[0].x):zbe(t):(t=c.length,function(d){for(var u=0,h;u<t;++u)l[(h=c[u]).i]=h.x(d);return l.join("")})}function hf(e,t){var r=typeof t,s;return t==null||r==="boolean"?r2(t):(r==="number"?wy:r==="string"?(s=xp(t))?(t=s,VO):qbe:t instanceof xp?VO:t instanceof Date?Fbe:Ibe(t)?$be:Array.isArray(t)?Lbe:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ube:wy)(e,t)}function n2(e,t){return e=+e,t=+t,function(r){return Math.round(e*(1-r)+t*r)}}function Wbe(e,t){t===void 0&&(t=e,e=hf);for(var r=0,s=t.length-1,a=t[0],i=new Array(s<0?0:s);r<s;)i[r]=e(a,a=t[++r]);return function(o){var l=Math.max(0,Math.min(s-1,Math.floor(o*=s)));return i[l](o-l)}}function Hbe(e){return function(){return e}}function _y(e){return+e}var KO=[0,1];function ys(e){return e}function j1(e,t){return(t-=e=+e)?function(r){return(r-e)/t}:Hbe(isNaN(t)?NaN:.5)}function Vbe(e,t){var r;return e>t&&(r=e,e=t,t=r),function(s){return Math.max(e,Math.min(t,s))}}function Kbe(e,t,r){var s=e[0],a=e[1],i=t[0],o=t[1];return a<s?(s=j1(a,s),i=r(o,i)):(s=j1(s,a),i=r(i,o)),function(l){return i(s(l))}}function Gbe(e,t,r){var s=Math.min(e.length,t.length)-1,a=new Array(s),i=new Array(s),o=-1;for(e[s]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++o<s;)a[o]=j1(e[o],e[o+1]),i[o]=r(t[o],t[o+1]);return function(l){var c=Cg(e,l,1,s)-1;return i[c](a[c](l))}}function Pg(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function Ej(){var e=KO,t=KO,r=hf,s,a,i,o=ys,l,c,d;function u(){var f=Math.min(e.length,t.length);return o!==ys&&(o=Vbe(e[0],e[f-1])),l=f>2?Gbe:Kbe,c=d=null,h}function h(f){return f==null||isNaN(f=+f)?i:(c||(c=l(e.map(s),t,r)))(s(o(f)))}return h.invert=function(f){return o(a((d||(d=l(t,e.map(s),wy)))(f)))},h.domain=function(f){return arguments.length?(e=Array.from(f,_y),u(
vendor: 4,227 bytes, line 705
705)):e.slice()},h.range=function(f){return arguments.length?(t=Array.from(f),u()):t.slice()},h.rangeRound=function(f){return t=Array.from(f),r=n2,u()},h.clamp=function(f){return arguments.length?(o=f?!0:ys,u()):o!==ys},h.interpolate=function(f){return arguments.length?(r=f,u()):r},h.unknown=function(f){return arguments.length?(i=f,h):i},function(f,m){return s=f,a=m,u()}}function s2(){return Ej()(ys,ys)}function Ybe(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function Ny(e,t){if((r=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"))<0)return null;var r,s=e.slice(0,r);return[s.length>1?s[0]+s.slice(2):s,+e.slice(r+1)]}function yh(e){return e=Ny(Math.abs(e)),e?e[1]:NaN}function Qbe(e,t){return function(r,s){for(var a=r.length,i=[],o=0,l=e[0],c=0;a>0&&l>0&&(c+l+1>s&&(l=Math.max(1,s-c)),i.push(r.substring(a-=l,a+l)),!((c+=l+1)>s));)l=e[o=(o+1)%e.length];return i.reverse().join(t)}}function Xbe(e){return function(t){return t.replace(/[0-9]/g,function(r){return e[+r]})}}var Zbe=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function vp(e){if(!(t=Zbe.exec(e)))throw new Error("invalid format: "+e);var t;return new a2({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}vp.prototype=a2.prototype;function a2(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}a2.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function Jbe(e){e:for(var t=e.length,r=1,s=-1,a;r<t;++r)switch(e[r]){case".":s=a=r;break;case"0":s===0&&(s=r),a=r;break;default:if(!+e[r])break e;s>0&&(s=0);break}return s>0?e.slice(0,s)+e.slice(a+1):e}var Vz;function ewe(e,t){var r=Ny(e,t);if(!r)return e+"";var s=r[0],a=r[1],i=a-(Vz=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,o=s.length;return i===o?s:i>o?s+new Array(i-o+1).join("0"):i>0?s.slice(0,i)+"."+s.slice(i):"0."+new Array(1-i).join("0")+Ny(e,Math.max(0,t+i-1))[0]}function GO(e,t){var r=Ny(e,t);if(!r)return e+"";var s=r[0],a=r[1];return a<0?"0."+new Array(-a).join("0")+s:s.length>a+1?s.slice(0,a+1)+"."+s.slice(a+1):s+new Array(a-s.length+2).join("0")}const YO={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:Ybe,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>GO(e*100,t),r:GO,s:ewe,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function QO(e){return e}var XO=Array.prototype.map,ZO=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function twe(e){var t=e.grouping===void 0||e.thousands===void 0?QO:Qbe(XO.call(e.grouping,Number),e.thousands+""),r=e.currency===void 0?"":e.currency[0]+"",s=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",i=e.numerals===void 0?QO:Xbe(XO.call(e.numerals,String)),o=e.percent===void 0?"%":e.percent+"",l=e.minus===void 0?"−":e.minus+"",c=e.nan===void 0?"NaN":e.nan+"";function d(h){h=vp(h);var f=h.fill,m=h.align,g=h.sign,p=h.symbol,y=h.zero,v=h.width,j=h.comma,b=h.precision,_=h.trim,w=h.type;w==="n"?(j=!0,w="g"):YO[w]||(b===void 0&&(b=12),_=!0,w="g"),(y||f==="0"&&m==="=")&&(y=!0,f="0",m="=");var N=p==="$"?r:p==="#"&&/[boxX]/.test(w)?"0"+w.toLowerCase():"",S=p==="$"?s:/[%p]/.test(w)?o:"",C=YO[w],P=/[defgprs%]/.test(w);b=b===void 0?6:/[gprs]/.test(w)?Math.max(1,Math.min(21,b)):Math.max(0,Math.min(20,b));function M(D){var A=N,U=S,F,L,$;if(w==="c")U=C(D)+U,D="";else{D=+D;var R=D<0||1/D<0;if(D=isNaN(D)?c:C(Math.abs(D),b),_&&(D=Jbe(D)),R&&+D==0&&g!=="+"&&(R=!1),A=(R?g==="("?g:l:g==="-"||g==="("?"":g)+A,U=(w==="s"?ZO[8+Vz/3]:"")+U+(R&&g==="("?")":""),P){for(F=-1,L=D.length;++F<L;
vendor: 4,083 bytes, line 705
705)if($=D.charCodeAt(F),48>$||$>57){U=($===46?a+D.slice(F+1):D.slice(F))+U,D=D.slice(0,F);break}}}j&&!y&&(D=t(D,1/0));var T=A.length+D.length+U.length,k=T<v?new Array(v-T+1).join(f):"";switch(j&&y&&(D=t(k+D,k.length?v-U.length:1/0),k=""),m){case"<":D=A+D+U+k;break;case"=":D=A+k+D+U;break;case"^":D=k.slice(0,T=k.length>>1)+A+D+U+k.slice(T);break;default:D=k+A+D+U;break}return i(D)}return M.toString=function(){return h+""},M}function u(h,f){var m=d((h=vp(h),h.type="f",h)),g=Math.max(-8,Math.min(8,Math.floor(yh(f)/3)))*3,p=Math.pow(10,-g),y=ZO[8+g/3];return function(v){return m(p*v)+y}}return{format:d,formatPrefix:u}}var jx,i2,Kz;rwe({thousands:",",grouping:[3],currency:["$",""]});function rwe(e){return jx=twe(e),i2=jx.format,Kz=jx.formatPrefix,jx}function nwe(e){return Math.max(0,-yh(Math.abs(e)))}function swe(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(yh(t)/3)))*3-yh(Math.abs(e)))}function awe(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,yh(t)-yh(e))+1}function Gz(e,t,r,s){var a=g1(e,t,r),i;switch(s=vp(s??",f"),s.type){case"s":{var o=Math.max(Math.abs(e),Math.abs(t));return s.precision==null&&!isNaN(i=swe(a,o))&&(s.precision=i),Kz(s,o)}case"":case"e":case"g":case"p":case"r":{s.precision==null&&!isNaN(i=awe(a,Math.max(Math.abs(e),Math.abs(t))))&&(s.precision=i-(s.type==="e"));break}case"f":case"%":{s.precision==null&&!isNaN(i=nwe(a))&&(s.precision=i-(s.type==="%")*2);break}}return i2(s)}function xc(e){var t=e.domain;return e.ticks=function(r){var s=t();return m1(s[0],s[s.length-1],r??10)},e.tickFormat=function(r,s){var a=t();return Gz(a[0],a[a.length-1],r??10,s)},e.nice=function(r){r==null&&(r=10);var s=t(),a=0,i=s.length-1,o=s[a],l=s[i],c,d,u=10;for(l<o&&(d=o,o=l,l=d,d=a,a=i,i=d);u-- >0;){if(d=p1(o,l,r),d===c)return s[a]=o,s[i]=l,t(s);if(d>0)o=Math.floor(o/d)*d,l=Math.ceil(l/d)*d;else if(d<0)o=Math.ceil(o*d)/d,l=Math.floor(l*d)/d;else break;c=d}return e},e}function Sy(){var e=s2();return e.copy=function(){return Pg(e,Sy())},La.apply(e,arguments),xc(e)}function Yz(e){var t;function r(s){return s==null||isNaN(s=+s)?t:s}return r.invert=r,r.domain=r.range=function(s){return arguments.length?(e=Array.from(s,_y),r):e.slice()},r.unknown=function(s){return arguments.length?(t=s,r):t},r.copy=function(){return Yz(e).unknown(t)},e=arguments.length?Array.from(e,_y):[0,1],xc(r)}function Qz(e,t){e=e.slice();var r=0,s=e.length-1,a=e[r],i=e[s],o;return i<a&&(o=r,r=s,s=o,o=a,a=i,i=o),e[r]=t.floor(a),e[s]=t.ceil(i),e}function JO(e){return Math.log(e)}function eM(e){return Math.exp(e)}function iwe(e){return-Math.log(-e)}function owe(e){return-Math.exp(-e)}function lwe(e){return isFinite(e)?+("1e"+e):e<0?0:e}function cwe(e){return e===10?lwe:e===Math.E?Math.exp:t=>Math.pow(e,t)}function dwe(e){return e===Math.E?Math.log:e===10&&Math.log10||e===2&&Math.log2||(e=Math.log(e),t=>Math.log(t)/e)}function tM(e){return(t,r)=>-e(-t,r)}function o2(e){const t=e(JO,eM),r=t.domain;let s=10,a,i;function o(){return a=dwe(s),i=cwe(s),r()[0]<0?(a=tM(a),i=tM(i),e(iwe,owe)):e(JO,eM),t}return t.base=function(l){return arguments.length?(s=+l,o()):s},t.domain=function(l){return arguments.length?(r(l),o()):r()},t.ticks=l=>{const c=r();let d=c[0],u=c[c.length-1];const h=u<d;h&&([d,u]=[u,d]);let f=a(d),m=a(u),g,p;const y=l==null?10:+l;let v=[];if(!(s%1)&&m-f<y){if(f=Math.floor(f),m=Math.ceil(m),d>0){for(;f<=m;++f)for(g=1;g<s;++g)if(p=f<0?g/i(-f):g*i(f),!(p<d)){if(p>u)break;v.push(p)}}else for(;f<=m;++f)for(g=s-1;g>=1;--g)if(p=f>0?g/i(-f):g*i(f),!(p<d)){if(p>u)break;v.push(p)}v.length*2<y&&(v=m1(d,u,y))}else v=m1(f,m,Math.min(m-f,y)).map(i);return h?v.reverse():v},t.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=s===10?"s":","),typeof c!="function"&&(!(s%1)&&(c=vp(c)).precision==null&&(c.trim=!0),c=i2(c)),l===1/0)return c;const d=Math.max(1,s*l/t.ticks().length);return u=>{let h=u/i(Math.round(a(u)));return h*s<s-.5&&(h*=s),h<=d?c(u):""}},t.nice=()=>r(Qz(r(),{floor:l=>i(Math.floor(a(l))),ceil:l=>i(Math.ceil(a(l)))})),t}function Xz(){const e=o2(Ej()).domain([1,10]);return e.copy=()=>Pg(e,Xz()).base(e.base()),La.apply(e,arguments),e}
705function rM(e){return function(t){return Math.sign(t)*Math.log1p(Math.abs(t/e))}}function nM(e){return function(t){return Math.sign(t)*Math.expm1(Math.abs(t))*e}}function l2(e){var t=1,r=e(rM(t),nM(t));return r.constant=function(s){return arguments.length?e(rM(t=+s),nM(t)):t},xc(r)}function Zz(){var e=l2(Ej());return e.copy=function(){return Pg(e,Zz()).constant(e.constant())},La.apply(e,arguments)}function sM(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function uwe(e){return e<0?-Math.sqrt(-e):Math.sqrt(e)}function hwe(e){return e<0?-e*e:e*e}function c2(e){var t=e(ys,ys),r=1;function s(){return r===1?e(ys,ys):r===.5?e(uwe,hwe):e(sM(r),sM(1/r))}return t.exponent=function(a){return arguments.length?(r=+a,s()):r},xc(t)}function d2(){var e=c2(Ej());return e.copy=function(){return Pg(e,d2()).exponent(e.exponent())},La.apply(e,arguments),e}function fwe(){return d2.apply(null,arguments).exponent(.5)}function aM(e){return Math.sign(e)*e*e}function mwe(e){return Math.sign(e)*Math.sqrt(Math.abs(e))}function Jz(){var e=s2(),t=[0,1],r=!1,s;function a(i){var o=mwe(e(i));return isNaN(o)?s:r?Math.round(o):o}return a.invert=function(i){return e.invert(aM(i))},a.domain=function(i){return arguments.length?(e.domain(i),a):e.domain()},a.range=function(i){return arguments.length?(e.range((t=Array.from(i,_y)).map(aM)),a):t.slice()},a.rangeRound=function(i){return a.range(i).round(!0)},a.round=function(i){return arguments.length?(r=!!i,a):r},a.clamp=function(i){return arguments.length?(e.clamp(i),a):e.clamp()},a.unknown=function(i){return arguments.length?(s=i,a):s},a.copy=function(){return Jz(e.domain(),t).round(r).clamp(e.clamp()).unknown(s)},La.apply(a,arguments),xc(a)}function eB(){var e=[],t=[],r=[],s;function a(){var o=0,l=Math.max(1,t.length);for(r=new Array(l-1);++o<l;)r[o-1]=ybe(e,o/l);return i}function i(o){return o==null||isNaN(o=+o)?s:t[Cg(r,o)]}return i.invertExtent=function(o){var l=t.indexOf(o);return l<0?[NaN,NaN]:[l>0?r[l-1]:e[0],l<r.length?r[l]:e[e.length-1]]},i.domain=function(o){if(!arguments.length)return e.slice();e=[];for(let l of o)l!=null&&!isNaN(l=+l)&&e.push(l);return e.sort(Yl),a()},i.range=function(o){return arguments.length?(t=Array.from(o),a()):t.slice()},i.unknown=function(o){return arguments.length?(s=o,i):s},i.quantiles=function(){return r.slice()},i.copy=function(){return eB().domain(e).range(t).unknown(s)},La.apply(i,arguments)}function tB(){var e=0,t=1,r=1,s=[.5],a=[0,1],i;function o(c){return c!=null&&c<=c?a[Cg(s,c,0,r)]:i}function l(){var c=-1;for(s=new Array(r);++c<r;)s[c]=((c+1)*t-(c-r)*e)/(r+1);return o}return o.domain=function(c){return arguments.length?([e,t]=c,e=+e,t=+t,l()):[e,t]},o.range=function(c){return arguments.length?(r=(a=Array.from(c)).length-1,l()):a.slice()},o.invertExtent=function(c){var d=a.indexOf(c);return d<0?[NaN,NaN]:d<1?[e,s[0]]:d>=r?[s[r-1],t]:[s[d-1],s[d]]},o.unknown=function(c){return arguments.length&&(i=c),o},o.thresholds=function(){return s.slice()},o.copy=function(){return tB().domain([e,t]).range(a).unknown(i)},La.apply(xc(o),arguments)}function rB(){var e=[.5],t=[0,1],r,s=1;function a(i){return i!=null&&i<=i?t[Cg(e,i,0,s)]:r}return a.domain=function(i){return arguments.length?(e=Array.from(i),s=Math.min(e.length,t.length-1),a):e.slice()},a.range=function(i){return arguments.length?(t=Array.from(i),s=Math.min(e.length,t.length-1),a):t.slice()},a.invertExtent=function(i){var o=t.indexOf(i);return[e[o-1],e[o]]},a.unknown=function(i){return arguments.length?(r=i,a):r},a.copy=function(){return rB().domain(e).range(t).unknown(r)},La.apply(a,arguments)}const Pw=new Date,Tw=new Date;function bn(e,t,r,s){function a(i){return e(i=arguments.length===0?new Date:new Date(+i)),i}return a.floor=i=>(e(i=new Date(+i)),i),a.ceil=i=>(e(i=new Date(i-1)),t(i,1),e(i),i),a.round=i=>{const o=a(i),l=a.ceil(i);return i-o<l-i?o:l},a.offset=(i,o)=>(t(i=new Date(+i),o==null?1:Math.floor(o)),i),a.range=(i,o,l)=>{const c=[];if(i=a.ceil(i),l=l==null?1:Math.floor(l),!(i<o)||!(l>0))return c;let d;do c.push(d=new Date(+i)),t(i,l),e(i);while(d<i&&i<o);return c},a.filter=i=>bn(o=>{if(o>=o)for(;e(o),!i(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;t(o,-1),!i(o););else for(;--l>=0;)for(;t(o,1),!i(o););}),r&&(a.count=(i,o)=>(Pw.setTime(+i),Tw.setTime(+o),e(Pw),e(Tw),Math.floor(r(Pw,Tw))),a.every=i=>(i=Math.floor(i),!isFinite(i)||!(i>0)?null:i>1?a.filter(s?o=>s(o)%i===0:o=>a.count(0,o)%i===0):a)),a}const Cy=bn(()=>{},(e,t)=>{e.setTime(+e+t)},(e,t)=>t-e);Cy.every=e=>(e=Math.floor(e),!isFinite(e)||!(e>0)?null:e>1?bn(t=>{t.setTime(Math.floor(t/e)*e)},(t,r)=>{t.setTime(+t+r*e)},(t,r)=>(r-t)/e):Cy);Cy.range;const bo=1e3,Na=bo*60,wo=Na*60,Wo=wo*24,u2=Wo*7,iM=Wo*30,Aw=Wo*365,Hc=bn(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*bo)},(e,t)=>(t-e)/bo,e=>e.getUTCSeconds());Hc.range;const h2=bn(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*bo)},(e,t)=>{e.setTime(+e+t*Na)},(e,t)=>(t-e)/Na,e=>e.getMinutes());h2.range;const f2=bn(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Na)},(e,t)=>(t-e)/Na,e=>e.getUTCMinutes());f2.range;const m2=bn(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*bo-e.getMinutes()*Na)},(e,t)=>{e.setTime(+e+t*wo)},(e,t)=>(t-e)/wo,e=>e.getHours());m2.range;const p2=bn(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*wo)},(e,t)=>(t-e)/wo,e=>e.getUTCHours());p2.range;const Tg=bn(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Na)/Wo,e=>e.getDate()-1);Tg.range;const Oj=bn(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Wo,e=>e.getUTCDate()-1);Oj.range;const nB=bn(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/Wo,e=>Math.floor(e/Wo));nB.range;function Rd(e){return bn(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,r)=>{t.setDate(t.getDate()+r*7)},(t,r)=>(r-t-(r.getTimezoneOffset()-t.getTimezoneOffset())*Na)/u2)}const Mj=Rd(0),ky=Rd(1),pwe=Rd(2),gwe=Rd(3),jh=Rd(4),xwe=Rd(5),vwe=Rd(6);Mj.range;ky.range;pwe.range;gwe.range;jh.range;xwe.range;vwe.range;function $d(e){return bn(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCDate(t.getUTCDate()+r*7)},(t,r)=>(r-t)/u2)}const Dj=$d(0),Py=$d(1),ywe=$d(2),jwe=$d(3),bh=$d(4),bwe=$d(5),wwe=$d(6);Dj.range;Py.range;ywe.range;jwe.range;bh.range;bwe.range;wwe.range;const g2=bn(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());g2.range;const x2=bn(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());x2.range;const Ho=bn(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());Ho.every=e=>
vendor: 4,688 bytes, line 705
705!isFinite(e=Math.floor(e))||!(e>0)?null:bn(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,r)=>{t.setFullYear(t.getFullYear()+r*e)});Ho.range;const Vo=bn(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());Vo.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:bn(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,r)=>{t.setUTCFullYear(t.getUTCFullYear()+r*e)});Vo.range;function sB(e,t,r,s,a,i){const o=[[Hc,1,bo],[Hc,5,5*bo],[Hc,15,15*bo],[Hc,30,30*bo],[i,1,Na],[i,5,5*Na],[i,15,15*Na],[i,30,30*Na],[a,1,wo],[a,3,3*wo],[a,6,6*wo],[a,12,12*wo],[s,1,Wo],[s,2,2*Wo],[r,1,u2],[t,1,iM],[t,3,3*iM],[e,1,Aw]];function l(d,u,h){const f=u<d;f&&([d,u]=[u,d]);const m=h&&typeof h.range=="function"?h:c(d,u,h),g=m?m.range(d,+u+1):[];return f?g.reverse():g}function c(d,u,h){const f=Math.abs(u-d)/h,m=Jk(([,,y])=>y).right(o,f);if(m===o.length)return e.every(g1(d/Aw,u/Aw,h));if(m===0)return Cy.every(Math.max(g1(d,u,h),1));const[g,p]=o[f/o[m-1][2]<o[m][2]/f?m-1:m];return g.every(p)}return[l,c]}const[_we,Nwe]=sB(Vo,x2,Dj,nB,p2,f2),[Swe,Cwe]=sB(Ho,g2,Mj,Tg,m2,h2);function Ew(e){if(0<=e.y&&e.y<100){var t=new Date(-1,e.m,e.d,e.H,e.M,e.S,e.L);return t.setFullYear(e.y),t}return new Date(e.y,e.m,e.d,e.H,e.M,e.S,e.L)}function Ow(e){if(0<=e.y&&e.y<100){var t=new Date(Date.UTC(-1,e.m,e.d,e.H,e.M,e.S,e.L));return t.setUTCFullYear(e.y),t}return new Date(Date.UTC(e.y,e.m,e.d,e.H,e.M,e.S,e.L))}function Lf(e,t,r){return{y:e,m:t,d:r,H:0,M:0,S:0,L:0}}function kwe(e){var t=e.dateTime,r=e.date,s=e.time,a=e.periods,i=e.days,o=e.shortDays,l=e.months,c=e.shortMonths,d=Ff(a),u=Uf(a),h=Ff(i),f=Uf(i),m=Ff(o),g=Uf(o),p=Ff(l),y=Uf(l),v=Ff(c),j=Uf(c),b={a:R,A:T,b:k,B:W,c:null,d:hM,e:hM,f:Qwe,g:i_e,G:l_e,H:Kwe,I:Gwe,j:Ywe,L:aB,m:Xwe,M:Zwe,p:q,q:Q,Q:pM,s:gM,S:Jwe,u:e_e,U:t_e,V:r_e,w:n_e,W:s_e,x:null,X:null,y:a_e,Y:o_e,Z:c_e,"%":mM},_={a:ue,A:X,b:le,B:pe,c:null,d:fM,e:fM,f:f_e,g:__e,G:S_e,H:d_e,I:u_e,j:h_e,L:oB,m:m_e,M:p_e,p:ce,q:se,Q:pM,s:gM,S:g_e,u:x_e,U:v_e,V:y_e,w:j_e,W:b_e,x:null,X:null,y:w_e,Y:N_e,Z:C_e,"%":mM},w={a:M,A:D,b:A,B:U,c:F,d:dM,e:dM,f:qwe,g:cM,G:lM,H:uM,I:uM,j:Fwe,L:Bwe,m:Lwe,M:Uwe,p:P,q:Iwe,Q:Hwe,s:Vwe,S:zwe,u:Owe,U:Mwe,V:Dwe,w:Ewe,W:Rwe,x:L,X:$,y:cM,Y:lM,Z:$we,"%":Wwe};b.x=N(r,b),b.X=N(s,b),b.c=N(t,b),_.x=N(r,_),_.X=N(s,_),_.c=N(t,_);function N(oe,V){return function(fe){var ne=[],Ce=-1,Pe=0,he=oe.length,ke,Me,Je;for(fe instanceof Date||(fe=new Date(+fe));++Ce<he;)oe.charCodeAt(Ce)===37&&(ne.push(oe.slice(Pe,Ce)),(Me=oM[ke=oe.charAt(++Ce)])!=null?ke=oe.charAt(++Ce):Me=ke==="e"?" ":"0",(Je=V[ke])&&(ke=Je(fe,Me)),ne.push(ke),Pe=Ce+1);return ne.push(oe.slice(Pe,Ce)),ne.join("")}}function S(oe,V){return function(fe){var ne=Lf(1900,void 0,1),Ce=C(ne,oe,fe+="",0),Pe,he;if(Ce!=fe.length)return null;if("Q"in ne)return new Date(ne.Q);if("s"in ne)return new Date(ne.s*1e3+("L"in ne?ne.L:0));if(V&&!("Z"in ne)&&(ne.Z=0),"p"in ne&&(ne.H=ne.H%12+ne.p*12),ne.m===void 0&&(ne.m="q"in ne?ne.q:0),"V"in ne){if(ne.V<1||ne.V>53)return null;"w"in ne||(ne.w=1),"Z"in ne?(Pe=Ow(Lf(ne.y,0,1)),he=Pe.getUTCDay(),Pe=he>4||he===0?Py.ceil(Pe):Py(Pe),Pe=Oj.offset(Pe,(ne.V-1)*7),ne.y=Pe.getUTCFullYear(),ne.m=Pe.getUTCMonth(),ne.d=Pe.getUTCDate()+(ne.w+6)%7):(Pe=Ew(Lf(ne.y,0,1)),he=Pe.getDay(),Pe=he>4||he===0?ky.ceil(Pe):ky(Pe),Pe=Tg.offset(Pe,(ne.V-1)*7),ne.y=Pe.getFullYear(),ne.m=Pe.getMonth(),ne.d=Pe.getDate()+(ne.w+6)%7)}else("W"in ne||"U"in ne)&&("w"in ne||(ne.w="u"in ne?ne.u%7:"W"in ne?1:0),he="Z"in ne?Ow(Lf(ne.y,0,1)).getUTCDay():Ew(Lf(ne.y,0,1)).getDay(),ne.m=0,ne.d="W"in ne?(ne.w+6)%7+ne.W*7-(he+5)%7:ne.w+ne.U*7-(he+6)%7);return"Z"in ne?(ne.H+=ne.Z/100|0,ne.M+=ne.Z%100,Ow(ne)):Ew(ne)}}function C(oe,V,fe,ne){for(var Ce=0,Pe=V.length,he=fe.length,ke,Me;Ce<Pe;){if(ne>=he)return-1;if(ke=V.charCodeAt(Ce++),ke===37){if(ke=V.charAt(Ce++),Me=w[ke in oM?V.charAt(Ce++):ke],!Me||(ne=Me(oe,fe,ne))<0)return-1}else if(ke!=fe.charCodeAt(ne++))return-1}return ne}function P(oe,V,fe){var ne=d.exec(V.slice(fe));return ne?(oe.p=u.get(ne[0].toLowerCase()),fe+ne[0].length):-1}function M(oe,V,fe){var ne=m.exec(V.slice(fe));return ne?(oe.w=g.get(ne[0].toLowerCase()),fe+ne[0].length):-1}function D(oe,V,fe){var ne=h.exec(V.slice(fe));return ne?(oe.w=f.get(ne[0].toLowerCase()),fe+ne[0].length):-1}function A(oe,V,fe){var ne=v.exec(V.slice(fe));return ne?(oe.m=j.get(ne[0].toLowerCase()),fe+ne[0].length):-1}function U(oe,V,fe){var ne=p.exec(V.slice(fe));return ne?(oe.m=y.get(ne[0].toLowerCase()),fe+ne[0].length):-1}function F(oe,V,fe){return C(oe,t,V,fe)}function L(oe,V,fe){return C(oe,r,V,fe)}
vendor: 4,266 bytes, line 705
705function $(oe,V,fe){return C(oe,s,V,fe)}function R(oe){return o[oe.getDay()]}function T(oe){return i[oe.getDay()]}function k(oe){return c[oe.getMonth()]}function W(oe){return l[oe.getMonth()]}function q(oe){return a[+(oe.getHours()>=12)]}function Q(oe){return 1+~~(oe.getMonth()/3)}function ue(oe){return o[oe.getUTCDay()]}function X(oe){return i[oe.getUTCDay()]}function le(oe){return c[oe.getUTCMonth()]}function pe(oe){return l[oe.getUTCMonth()]}function ce(oe){return a[+(oe.getUTCHours()>=12)]}function se(oe){return 1+~~(oe.getUTCMonth()/3)}return{format:function(oe){var V=N(oe+="",b);return V.toString=function(){return oe},V},parse:function(oe){var V=S(oe+="",!1);return V.toString=function(){return oe},V},utcFormat:function(oe){var V=N(oe+="",_);return V.toString=function(){return oe},V},utcParse:function(oe){var V=S(oe+="",!0);return V.toString=function(){return oe},V}}}var oM={"-":"",_:" ",0:"0"},Tn=/^\s*\d+/,Pwe=/^%/,Twe=/[\\^$*+?|[\]().{}]/g;function Gt(e,t,r){var s=e<0?"-":"",a=(s?-e:e)+"",i=a.length;return s+(i<r?new Array(r-i+1).join(t)+a:a)}function Awe(e){return e.replace(Twe,"\\$&")}function Ff(e){return new RegExp("^(?:"+e.map(Awe).join("|")+")","i")}function Uf(e){return new Map(e.map((t,r)=>[t.toLowerCase(),r]))}function Ewe(e,t,r){var s=Tn.exec(t.slice(r,r+1));return s?(e.w=+s[0],r+s[0].length):-1}function Owe(e,t,r){var s=Tn.exec(t.slice(r,r+1));return s?(e.u=+s[0],r+s[0].length):-1}function Mwe(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.U=+s[0],r+s[0].length):-1}function Dwe(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.V=+s[0],r+s[0].length):-1}function Rwe(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.W=+s[0],r+s[0].length):-1}function lM(e,t,r){var s=Tn.exec(t.slice(r,r+4));return s?(e.y=+s[0],r+s[0].length):-1}function cM(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.y=+s[0]+(+s[0]>68?1900:2e3),r+s[0].length):-1}function $we(e,t,r){var s=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(t.slice(r,r+6));return s?(e.Z=s[1]?0:-(s[2]+(s[3]||"00")),r+s[0].length):-1}function Iwe(e,t,r){var s=Tn.exec(t.slice(r,r+1));return s?(e.q=s[0]*3-3,r+s[0].length):-1}function Lwe(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.m=s[0]-1,r+s[0].length):-1}function dM(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.d=+s[0],r+s[0].length):-1}function Fwe(e,t,r){var s=Tn.exec(t.slice(r,r+3));return s?(e.m=0,e.d=+s[0],r+s[0].length):-1}function uM(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.H=+s[0],r+s[0].length):-1}function Uwe(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.M=+s[0],r+s[0].length):-1}function zwe(e,t,r){var s=Tn.exec(t.slice(r,r+2));return s?(e.S=+s[0],r+s[0].length):-1}function Bwe(e,t,r){var s=Tn.exec(t.slice(r,r+3));return s?(e.L=+s[0],r+s[0].length):-1}function qwe(e,t,r){var s=Tn.exec(t.slice(r,r+6));return s?(e.L=Math.floor(s[0]/1e3),r+s[0].length):-1}function Wwe(e,t,r){var s=Pwe.exec(t.slice(r,r+1));return s?r+s[0].length:-1}function Hwe(e,t,r){var s=Tn.exec(t.slice(r));return s?(e.Q=+s[0],r+s[0].length):-1}function Vwe(e,t,r){var s=Tn.exec(t.slice(r));return s?(e.s=+s[0],r+s[0].length):-1}function hM(e,t){return Gt(e.getDate(),t,2)}function Kwe(e,t){return Gt(e.getHours(),t,2)}function Gwe(e,t){return Gt(e.getHours()%12||12,t,2)}function Ywe(e,t){return Gt(1+Tg.count(Ho(e),e),t,3)}function aB(e,t){return Gt(e.getMilliseconds(),t,3)}function Qwe(e,t){return aB(e,t)+"000"}function Xwe(e,t){return Gt(e.getMonth()+1,t,2)}function Zwe(e,t){return Gt(e.getMinutes(),t,2)}function Jwe(e,t){return Gt(e.getSeconds(),t,2)}function e_e(e){var t=e.getDay();return t===0?7:t}function t_e(e,t){return Gt(Mj.count(Ho(e)-1,e),t,2)}function iB(e){var t=e.getDay();return t>=4||t===0?jh(e):jh.ceil(e)}function r_e(e,t){return e=iB(e),Gt(jh.count(Ho(e),e)+(Ho(e).getDay()===4),t,2)}function n_e(e){return e.getDay()}function s_e(e,t){return Gt(ky.count(Ho(e)-1,e),t,2)}function a_e(e,t){return Gt(e.getFullYear()%100,t,2)}function i_e(e,t){return e=iB(e),Gt(e.getFullYear()%100,t,2)}function o_e(e,t){return Gt(e.getFullYear()%1e4,t,4)}function l_e(e,t){var r=e.getDay();return e=r>=4||r===0?jh(e):jh.ceil(e),Gt(e.getFullYear()%1e4,t,4)}function c_e(e){var t=e.getTimezoneOffset();return(t>0?"-":(t*=-1,"+"))+Gt(t/60|0,"0",2)+Gt(t%60,"0",2)}function fM(e,t){return Gt(e.getUTCDate(),t,2)}
705function d_e(e,t){return Gt(e.getUTCHours(),t,2)}function u_e(e,t){return Gt(e.getUTCHours()%12||12,t,2)}function h_e(e,t){return Gt(1+Oj.count(Vo(e),e),t,3)}function oB(e,t){return Gt(e.getUTCMilliseconds(),t,3)}function f_e(e,t){return oB(e,t)+"000"}function m_e(e,t){return Gt(e.getUTCMonth()+1,t,2)}function p_e(e,t){return Gt(e.getUTCMinutes(),t,2)}function g_e(e,t){return Gt(e.getUTCSeconds(),t,2)}function x_e(e){var t=e.getUTCDay();return t===0?7:t}function v_e(e,t){return Gt(Dj.count(Vo(e)-1,e),t,2)}function lB(e){var t=e.getUTCDay();return t>=4||t===0?bh(e):bh.ceil(e)}function y_e(e,t){return e=lB(e),Gt(bh.count(Vo(e),e)+(Vo(e).getUTCDay()===4),t,2)}function j_e(e){return e.getUTCDay()}function b_e(e,t){return Gt(Py.count(Vo(e)-1,e),t,2)}function w_e(e,t){return Gt(e.getUTCFullYear()%100,t,2)}function __e(e,t){return e=lB(e),Gt(e.getUTCFullYear()%100,t,2)}function N_e(e,t){return Gt(e.getUTCFullYear()%1e4,t,4)}function S_e(e,t){var r=e.getUTCDay();return e=r>=4||r===0?bh(e):bh.ceil(e),Gt(e.getUTCFullYear()%1e4,t,4)}function C_e(){return"+0000"}function mM(){return"%"}function pM(e){return+e}function gM(e){return Math.floor(+e/1e3)}var eu,cB,dB;k_e({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});function k_e(e){return eu=kwe(e),cB=eu.format,eu.parse,dB=eu.utcFormat,eu.utcParse,eu}function P_e(e){return new Date(e)}function T_e(e){return e instanceof Date?+e:+new Date(+e)}function v2(e,t,r,s,a,i,o,l,c,d){var u=s2(),h=u.invert,f=u.domain,m=d(".%L"),g=d(":%S"),p=d("%I:%M"),y=d("%I %p"),v=d("%a %d"),j=d("%b %d"),b=d("%B"),_=d("%Y");function w(N){return(c(N)<N?m:l(N)<N?g:o(N)<N?p:i(N)<N?y:s(N)<N?a(N)<N?v:j:r(N)<N?b:_)(N)}return u.invert=function(N){return new Date(h(N))},u.domain=function(N){return arguments.length?f(Array.from(N,T_e)):f().map(P_e)},u.ticks=function(N){var S=f();return e(S[0],S[S.length-1],N??10)},u.tickFormat=function(N,S){return S==null?w:d(S)},u.nice=function(N){var S=f();return(!N||typeof N.range!="function")&&(N=t(S[0],S[S.length-1],N??10)),N?f(Qz(S,N)):u},u.copy=function(){return Pg(u,v2(e,t,r,s,a,i,o,l,c,d))},u}function A_e(){return La.apply(v2(Swe,Cwe,Ho,g2,Mj,Tg,m2,h2,Hc,cB).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function E_e(){return La.apply(v2(_we,Nwe,Vo,x2,Dj,Oj,p2,f2,Hc,dB).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function Rj(){var e=0,t=1,r,s,a,i,o=ys,l=!1,c;function d(h){return h==null||isNaN(h=+h)?c:o(a===0?.5:(h=(i(h)-r)*a,l?Math.max(0,Math.min(1,h)):h))}d.domain=function(h){return arguments.length?([e,t]=h,r=i(e=+e),s=i(t=+t),a=r===s?0:1/(s-r),d):[e,t]},d.clamp=function(h){return arguments.length?(l=!!h,d):l},d.interpolator=function(h){return arguments.length?(o=h,d):o};function u(h){return function(f){var m,g;return arguments.length?([m,g]=f,o=h(m,g),d):[o(0),o(1)]}}return d.range=u(hf),d.rangeRound=u(n2),d.unknown=function(h){return arguments.length?(c=h,d):c},function(h){return i=h,r=h(e),s=h(t),a=r===s?0:1/(s-r),d}}function vc(e,t){return t.domain(e.domain()).interpolator(e.interpolator()).clamp(e.clamp()).unknown(e.unknown())}function uB(){var e=xc(Rj()(ys));return e.copy=function(){return vc(e,uB())},rl.apply(e,arguments)}function hB(){var e=o2(Rj()).domain([1,10]);return e.copy=function(){return vc(e,hB()).base(e.base())},rl.apply(e,arguments)}function fB(){var e=l2(Rj());return e.copy=function(){return vc(e,fB()).constant(e.constant())},rl.apply(e,arguments)}function y2(){var e=c2(Rj());return e.copy=function(){return vc(e,y2()).exponent(e.exponent())},rl.apply(e,arguments)}function O_e(){return y2.apply(null,arguments).exponent(.5)}function mB(){var e=[],t=ys;function r(s){if(s!=null&&!isNaN(s=+s))return t((Cg(e,s,1)-1)/(e.length-1))}return r.domain=function(s){if(!arguments.length)return e.slice();e=[];for(let a of s)a!=null&&!isNaN(a=+a)&&e.push(a);return e.sort(Yl),r},r.interpolator=function(s){return arguments.length?(t=s,r):t},r.range=function(){return e.map((s,a)=>t(a/(e.length-1)))},r.quantiles=function(s){return Array.from({length:s+1},(a,i)=>vbe(e,i/s))},r.copy=function(){return mB(t).domain(e)},rl.apply(r,arguments)}function $j(){var e=0,t=.5,r=1,s=1,a,i,o,l,c,d=ys,u,h=!1,f;function m(p){return isNaN(p=+p)?f:(p=.5+((p=+u(p))-i)*(s*p<s*i?l:c),d(h?Math.max(0,Math.min(1,p)):p))}m.domain=function(p){return arguments.length?([e,t,r]=p,a=u(e=+e),i=u(t=+t),o=u(r=+r),l=a===i?0:.5/(i-a),c=i===o?0:.5/(o-i),s=i<a?-1:1,m):[e,t,r]},m.clamp=function(p){return arguments.length?(h=!!p,m):h},m.interpolator=function(p){return arguments.length?(d=p,m):d};function g(p){return function(y){var v,j,b;return arguments.length?([v,j,b]=y,d=Wbe(p,[v,j,b]),m):[d(0),d(.5),d(1)]}}return m.range=g(hf),m.rangeRound=g(n2),m.unknown=function(p){return arguments.length?(f=p,m):f},function(p){return u=p,a=p(e),i=p(t),o=p(r),l=a===i?0:.5/(i-a),c=i===o?0:.5/(o-i),s=i<a?-1:1,m}}function pB(){var e=xc($j()(ys));
vendor: 68,034 bytes, lines 705-731
705return e.copy=function(){return vc(e,pB())},rl.apply(e,arguments)}function gB(){var e=o2($j()).domain([.1,1,10]);return e.copy=function(){return vc(e,gB()).base(e.base())},rl.apply(e,arguments)}function xB(){var e=l2($j());return e.copy=function(){return vc(e,xB()).constant(e.constant())},rl.apply(e,arguments)}function j2(){var e=c2($j());return e.copy=function(){return vc(e,j2()).exponent(e.exponent())},rl.apply(e,arguments)}function M_e(){return j2.apply(null,arguments).exponent(.5)}const xM=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:mp,scaleDiverging:pB,scaleDivergingLog:gB,scaleDivergingPow:j2,scaleDivergingSqrt:M_e,scaleDivergingSymlog:xB,scaleIdentity:Yz,scaleImplicit:x1,scaleLinear:Sy,scaleLog:Xz,scaleOrdinal:e2,scalePoint:Nm,scalePow:d2,scaleQuantile:eB,scaleQuantize:tB,scaleRadial:Jz,scaleSequential:uB,scaleSequentialLog:hB,scaleSequentialPow:y2,scaleSequentialQuantile:mB,scaleSequentialSqrt:O_e,scaleSequentialSymlog:fB,scaleSqrt:fwe,scaleSymlog:Zz,scaleThreshold:rB,scaleTime:A_e,scaleUtc:E_e,tickFormat:Gz},Symbol.toStringTag,{value:"Module"}));var D_e=nf;function R_e(e,t,r){for(var s=-1,a=e.length;++s<a;){var i=e[s],o=t(i);if(o!=null&&(l===void 0?o===o&&!D_e(o):r(o,l)))var l=o,c=i}return c}var vB=R_e;function $_e(e,t){return e>t}var I_e=$_e,L_e=vB,F_e=I_e,U_e=uf;function z_e(e){return e&&e.length?L_e(e,U_e,F_e):void 0}var B_e=z_e;const Ij=fr(B_e);function q_e(e,t){return e<t}var W_e=q_e,H_e=vB,V_e=W_e,K_e=uf;function G_e(e){return e&&e.length?H_e(e,K_e,V_e):void 0}var Y_e=G_e;const Lj=fr(Y_e);var Q_e=Dk,X_e=gc,Z_e=Cz,J_e=Hs;function eNe(e,t){var r=J_e(e)?Q_e:Z_e;return r(e,X_e(t))}var tNe=eNe,rNe=Nz,nNe=tNe;function sNe(e,t){return rNe(nNe(e,t),1)}var aNe=sNe;const iNe=fr(aNe);var oNe=Yk;function lNe(e,t){return oNe(e,t)}var cNe=lNe;const Fj=fr(cNe);var ff=1e9,dNe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},w2,Or=!0,Oa="[DecimalError] ",id=Oa+"Invalid argument: ",b2=Oa+"Exponent out of range: ",mf=Math.floor,Ic=Math.pow,uNe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Zs,_n=1e7,Nr=7,yB=9007199254740991,Ty=mf(yB/Nr),Xe={};Xe.absoluteValue=Xe.abs=function(){var e=new this.constructor(this);return e.s&&(e.s=1),e};Xe.comparedTo=Xe.cmp=function(e){var t,r,s,a,i=this;if(e=new i.constructor(e),i.s!==e.s)return i.s||-e.s;if(i.e!==e.e)return i.e>e.e^i.s<0?1:-1;for(s=i.d.length,a=e.d.length,t=0,r=s<a?s:a;t<r;++t)if(i.d[t]!==e.d[t])return i.d[t]>e.d[t]^i.s<0?1:-1;return s===a?0:s>a^i.s<0?1:-1};Xe.decimalPlaces=Xe.dp=function(){var e=this,t=e.d.length-1,r=(t-e.e)*Nr;if(t=e.d[t],t)for(;t%10==0;t/=10)r--;return r<0?0:r};Xe.dividedBy=Xe.div=function(e){return To(this,new this.constructor(e))};Xe.dividedToIntegerBy=Xe.idiv=function(e){var t=this,r=t.constructor;return pr(To(t,new r(e),0,1),r.precision)};Xe.equals=Xe.eq=function(e){return!this.cmp(e)};Xe.exponent=function(){return ln(this)};Xe.greaterThan=Xe.gt=function(e){return this.cmp(e)>0};Xe.greaterThanOrEqualTo=Xe.gte=function(e){return this.cmp(e)>=0};Xe.isInteger=Xe.isint=function(){return this.e>this.d.length-2};Xe.isNegative=Xe.isneg=function(){return this.s<0};Xe.isPositive=Xe.ispos=function(){return this.s>0};Xe.isZero=function(){return this.s===0};Xe.lessThan=Xe.lt=function(e){return this.cmp(e)<0};Xe.lessThanOrEqualTo=Xe.lte=function(e){return this.cmp(e)<1};Xe.logarithm=Xe.log=function(e){var t,r=this,s=r.constructor,a=s.precision,i=a+5;if(e===void 0)e=new s(10);else if(e=new s(e),e.s<1||e.eq(Zs))throw Error(Oa+"NaN");if(r.s<1)throw Error(Oa+(r.s?"NaN":"-Infinity"));return r.eq(Zs)?new s(0):(Or=!1,t=To(yp(r,i),yp(e,i),i),Or=!0,pr(t,a))};Xe.minus=Xe.sub=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?wB(t,e):jB(t,(e.s=-e.s,e))};Xe.modulo=Xe.mod=function(e){var t,r=this,s=r.constructor,a=s.precision;if(e=new s(e),!e.s)throw Error(Oa+"NaN");return r.s?(Or=!1,t=To(r,e,0,1).times(e),Or=!0,r.minus(t)):pr(new s(r),a)};Xe.naturalExponential=Xe.exp=function(){return bB(this)};Xe.naturalLogarithm=Xe.ln=function(){return yp(this)};Xe.negated=Xe.neg=function(){var e=new this.constructor(this);return e.s=-e.s||0,e};Xe.plus=Xe.add=function(e){var t=this;return e=new t.constructor(e),t.s==e.s?jB(t,e):wB(t,(e.s=-e.s,e))};Xe.precision=Xe.sd=function(e){var t,r,s,a=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(id+e);if(t=ln(a)+1,s=a.d.length-1,r=s*Nr+1,s=a.d[s],s){for(;s%10==0;s/=10)r--;for(s=a.d[0];s>=10;s/=10)r++}return e&&t>r?t:r};Xe.squareRoot=Xe.sqrt=function(){var e,t,r,s,a,i,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(Oa+"NaN")}for(e=ln(l),Or=!1,a=Math.sqrt(+l),a==0||a==1/0?(t=Ai(l.d),(t.length+e)%2==0&&(t+="0"),a=Math.sqrt(t),e=mf((e+1)/2)-(e<0||e%2),a==1/0?t="5e"+e:(t=a.toExponential(),t=t.slice(0,t.indexOf("e")+1)+e),s=new c(t)):s=new c(a.toString()),r=c.precision,a=o=r+3;;)if(i=s,s=i.plus(To(l,i,o+2)).times(.5),Ai(i.d).slice(0,o)===(t=Ai(s.d)).slice(0,o)){if(t=t.slice(o-3,o+1),a==o&&t=="4999"){if(pr(i,r+1,0),i.times(i).eq(l)){s=i;break}}else if(t!="9999")break;o+=4}return Or=!0,pr(s,r)};Xe.times=Xe.mul=function(e){var t,r,s,a,i,o,l,c,d,u=this,h=u.constructor,f=u.d,m=(e=new h(e)).d;if(!u.s||!e.s)return new h(0);for(e.s*=u.s,r=u.e+e.e,c=f.length,d=m.length,c<d&&(i=f,f=m,m=i,o=c,c=d,d=o),i=[],o=c+d,s=o;s--;)i.push(0);for(s=d;--s>=0;){for(t=0,a=c+s;a>s;)l=i[a]+m[s]*f[a-s-1]+t,i[a--]=l%_n|0,t=l/_n|0;i[a]=(i[a]+t)%_n|0}for(;!i[--o];)i.pop();return t?++r:i.shift(),e.d=i,e.e=r,Or?pr(e,h.precision):e};Xe.toDecimalPlaces=Xe.todp=function(e,t){var r=this,s=r.constructor;return r=new s(r),e===void 0?r:(Fi(e,0,ff),t===void 0?t=s.rounding:Fi(t,0,8),pr(r,e+ln(r)+1,t))};Xe.toExponential=function(e,t){var r,s=this,a=s.constructor;return e===void 0?r=Sd(s,!0):(Fi(e,0,ff),t===void 0?t=a.rounding:Fi(t,0,8),s=pr(new a(s),e+1,t),r=Sd(s,!0,e+1)),r};Xe.toFixed=function(e,t){var r,s,a=this,i=a.constructor;return e===void 0?Sd(a):(Fi(e,0,ff),t===void 0?t=i.rounding:Fi(t,0,8),s=pr(new i(a),e+ln(a)+1,t),r=Sd(s.abs(),!1,e+ln(s)+1),a.isneg()&&!a.isZero()?"-"+r:r)};Xe.toInteger=Xe.toint=function(){var e=this,t=e.constructor;return pr(new t(e),ln(e)+1,t.rounding)};Xe.toNumber=function(){return+this};Xe.toPower=Xe.pow=function(e){var t,r,s,a,i,o,l=this,c=l.constructor,d=12,u=+(e=new c(e));if(!e.s)return new c(Zs);if(l=new c(l),!l.s){if(e.s<1)throw Error(Oa+"Infinity");return l}if(l.eq(Zs))return l;if(s=c.precision,e.eq(Zs))return pr(l,s);if(t=e.e,r=e.d.length-1,o=t>=r,i=l.s,o){if((r=u<0?-u:u)<=yB){for(a=new c(Zs),t=Math.ceil(s/Nr+4),Or=!1;r%2&&(a=a.times(l),yM(a.d,t)),r=mf(r/2),r!==0;)l=l.times(l),yM(l.d,t);return Or=!0,e.s<0?new c(Zs).div(a):pr(a,s)}}else if(i<0)throw Error(Oa+"NaN");return i=i<0&&e.d[Math.max(t,r)]&1?-1:1,l.s=1,Or=!1,a=e.times(yp(l,s+d)),Or=!0,a=bB(a),a.s=i,a};Xe.toPrecision=function(e,t){var r,s,a=this,i=a.constructor;return e===void 0?(r=ln(a),s=Sd(a,r<=i.toExpNeg||r>=i.toExpPos)):(Fi(e,1,ff),t===void 0?t=i.rounding:Fi(t,0,8),a=pr(new i(a),e,t),r=ln(a),s=Sd(a,e<=r||r<=i.toExpNeg,e)),s};Xe.toSignificantDigits=Xe.tosd=function(e,t){var r=this,s=r.constructor;return e===void 0?(e=s.precision,t=s.rounding):(Fi(e,1,ff),t===void 0?t=s.rounding:Fi(t,0,8)),pr(new s(r),e,t)};Xe.toString=Xe.valueOf=Xe.val=Xe.toJSON=Xe[Symbol.for("nodejs.util.inspect.custom")]=function(){var e=this,t=ln(e),r=e.constructor;return Sd(e,t<=r.toExpNeg||t>=r.toExpPos)};function jB(e,t){var r,s,a,i,o,l,c,d,u=e.constructor,h=u.precision;if(!e.s||!t.s)return t.s||(t=new u(e)),Or?pr(t,h):t;if(c=e.d,d=t.d,o=e.e,a=t.e,c=c.slice(),i=o-a,i){for(i<0?(s=c,i=-i,l=d.length):(s=d,a=o,l=c.length),o=Math.ceil(h/Nr),l=o>l?o+1:l+1,i>l&&(i=l,s.length=1),s.reverse();i--;)s.push(0);s.reverse()}for(l=c.length,i=d.length,l-i<0&&(i=l,s=d,d=c,c=s),r=0;i;)r=(c[--i]=c[i]+d[i]+r)/_n|0,c[i]%=_n;for(r&&(c.unshift(r),++a),l=c.length;c[--l]==0;)c.pop();return t.d=c,t.e=a,Or?pr(t,h):t}function Fi(e,t,r){if(e!==~~e||e<t||e>r)throw Error(id+e)}function Ai(e){var t,r,s,a=e.length-1,i="",o=e[0];if(a>0){for(i+=o,t=1;t<a;t++)s=e[t]+"",r=Nr-s.length,r&&(i+=xl(r)),i+=s;o=e[t],s=o+"",r=Nr-s.length,r&&(i+=xl(r))}else if(o===0)return"0";for(;o%10===0;)o/=10;return i+o}var To=function(){function e(s,a){var i,o=0,l=s.length;for(s=s.slice();l--;)i=s[l]*a+o,s[l]=i%_n|0,o=i/_n|0;return o&&s.unshift(o),s}function t(s,a,i,o){var l,c;if(i!=o)c=i>o?1:-1;else for(l=c=0;l<i;l++)if(s[l]!=a[l]){c=s[l]>a[l]?1:-1;break}return c}function r(s,a,i){for(var o=0;i--;)s[i]-=o,o=s[i]<a[i]?1:0,s[i]=o*_n+s[i]-a[i];for(;!s[0]&&s.length>1;)s.shift()}return function(s,a,i,o){var l,c,d,u,h,f,m,g,p,y,v,j,b,_,w,N,S,C,P=s.constructor,M=s.s==a.s?1:-1,D=s.d,A=a.d;if(!s.s)return new P(s);if(!a.s)throw Error(Oa+"Division by zero");for(c=s.e-a.e,S=A.length,w=D.length,m=new P(M),g=m.d=[],d=0;A[d]==(D[d]||0);)++d;if(A[d]>(D[d]||0)&&--c,i==null?j=i=P.precision:o?j=i+(ln(s)-ln(a))+1:j=i,j<0)return new P(0);if(j=j/Nr+2|0,d=0,S==1)for(u=0,A=A[0],j++;(d<w||u)&&j--;d++)b=u*_n+(D[d]||0),g[d]=b/A|0,u=b%A|0;else{for(u=_n/(A[0]+1)|0,u>1&&(A=e(A,u),D=e(D,u),S=A.length,w=D.length),_=S,p=D.slice(0,S),y=p.length;y<S;)p[y++]=0;C=A.slice(),C.unshift(0),N=A[0],A[1]>=_n/2&&++N;do u=0,l=t(A,p,S,y),l<0?(v=p[0],S!=y&&(v=v*_n+(p[1]||0)),u=v/N|0,u>1?(u>=_n&&(u=_n-1),h=e(A,u),f=h.length,y=p.length,l=t(h,p,f,y),l==1&&(u--,r(h,S<f?C:A,f))):(u==0&&(l=u=1),h=A.slice()),f=h.length,f<y&&h.unshift(0),r(p,h,y),l==-1&&(y=p.length,l=t(A,p,S,y),l<1&&(u++,r(p,S<y?C:A,y))),y=p.length):l===0&&(u++,p=[0]),g[d++]=u,l&&p[0]?p[y++]=D[_]||0:(p=[D[_]],y=1);while((_++<w||p[0]!==void 0)&&j--)}return g[0]||g.shift(),m.e=c,pr(m,o?i+ln(m)+1:i)}}();function bB(e,t){var r,s,a,i,o,l,c=0,d=0,u=e.constructor,h=u.precision;if(ln(e)>16)throw Error(b2+ln(e));if(!e.s)return new u(Zs);for(t==null?(Or=!1,l=h):l=t,o=new u(.03125);e.abs().gte(.1);)e=e.times(o),d+=5;for(s=Math.log(Ic(2,d))/Math.LN10*2+5|0,l+=s,r=a=i=new u(Zs),u.precision=l;;){if(a=pr(a.times(e),l),r=r.times(++c),o=i.plus(To(a,r,l)),Ai(o.d).slice(0,l)===Ai(i.d).slice(0,l)){for(;d--;)i=pr(i.times(i),l);return u.precision=h,t==null?(Or=!0,pr(i,h)):i}i=o}}function ln(e){for(var t=e.e*Nr,r=e.d[0];r>=10;r/=10)t++;return t}function Mw(e,t,r){if(t>e.LN10.sd())throw Or=!0,r&&(e.precision=r),Error(Oa+"LN10 precision limit exceeded");return pr(new e(e.LN10),t)}function xl(e){for(var t="";e--;)t+="0";return t}function yp(e,t){var r,s,a,i,o,l,c,d,u,h=1,f=10,m=e,g=m.d,p=m.constructor,y=p.precision;if(m.s<1)throw Error(Oa+(m.s?"NaN":"-Infinity"));if(m.eq(Zs))return new p(0);if(t==null?(Or=!1,d=y):d=t,m.eq(10))return t==null&&(Or=!0),Mw(p,d);if(d+=f,p.precision=d,r=Ai(g),s=r.charAt(0),i=ln(m),Math.abs(i)<15e14){for(;s<7&&s!=1||s==1&&r.charAt(1)>3;)m=m.times(e),r=Ai(m.d),s=r.charAt(0),h++;i=ln(m),s>1?(m=new p("0."+r),i++):m=new p(s+"."+r.slice(1))}else return c=Mw(p,d+2,y).times(i+""),m=yp(new p(s+"."+r.slice(1)),d-f).plus(c),p.precision=y,t==null?(Or=!0,pr(m,y)):m;for(l=o=m=To(m.minus(Zs),m.plus(Zs),d),u=pr(m.times(m),d),a=3;;){if(o=pr(o.times(u),d),c=l.plus(To(o,new p(a),d)),Ai(c.d).slice(0,d)===Ai(l.d).slice(0,d))return l=l.times(2),i!==0&&(l=l.plus(Mw(p,d+2,y).times(i+""))),l=To(l,new p(h),d),p.precision=y,t==null?(Or=!0,pr(l,y)):l;l=c,a+=2}}function vM(e,t){var r,s,a;for((r=t.indexOf("."))>-1&&(t=t.replace(".","")),(s=t.search(/e/i))>0?(r<0&&(r=s),r+=+t.slice(s+1),t=t.substring(0,s)):r<0&&(r=t.length),s=0;t.charCodeAt(s)===48;)++s;for(a=t.length;t.charCodeAt(a-1)===48;)--a;if(t=t.slice(s,a),t){if(a-=s,r=r-s-1,e.e=mf(r/Nr),e.d=[],s=(r+1)%Nr,r<0&&(s+=Nr),s<a){for(s&&e.d.push(+t.slice(0,s)),a-=Nr;s<a;)e.d.push(+t.slice(s,s+=Nr));t=t.slice(s),s=Nr-t.length}else s-=a;for(;s--;)t+="0";if(e.d.push(+t),Or&&(e.e>Ty||e.e<-Ty))throw Error(b2+r)}else e.s=0,e.e=0,e.d=[0];return e}function pr(e,t,r){var s,a,i,o,l,c,d,u,h=e.d;for(o=1,i=h[0];i>=10;i/=10)o++;if(s=t-o,s<0)s+=Nr,a=t,d=h[u=0];else{if(u=Math.ceil((s+1)/Nr),i=h.length,u>=i)return e;for(d=i=h[u],o=1;i>=10;i/=10)o++;s%=Nr,a=s-Nr+o}if(r!==void 0&&(i=Ic(10,o-a-1),l=d/i%10|0,c=t<0||h[u+1]!==void 0||d%i,c=r<4?(l||c)&&(r==0||r==(e.s<0?3:2)):l>5||l==5&&(r==4||c||r==6&&(s>0?a>0?d/Ic(10,o-a):0:h[u-1])%10&1||r==(e.s<0?8:7))),t<1||!h[0])return c?(i=ln(e),h.length=1,t=t-i-1,h[0]=Ic(10,(Nr-t%Nr)%Nr),e.e=mf(-t/Nr)||0):(h.length=1,h[0]=e.e=e.s=0),e;if(s==0?(h.length=u,i=1,u--):(h.length=u+1,i=Ic(10,Nr-s),h[u]=a>0?(d/Ic(10,o-a)%Ic(10,a)|0)*i:0),c)for(;;)if(u==0){(h[0]+=i)==_n&&(h[0]=1,++e.e);break}else{if(h[u]+=i,h[u]!=_n)break;h[u--]=0,i=1}for(s=h.length;h[--s]===0;)h.pop();if(Or&&(e.e>Ty||e.e<-Ty))throw Error(b2+ln(e));return e}function wB(e,t){var r,s,a,i,o,l,c,d,u,h,f=e.constructor,m=f.precision;if(!e.s||!t.s)return t.s?t.s=-t.s:t=new f(e),Or?pr(t,m):t;if(c=e.d,h=t.d,s=t.e,d=e.e,c=c.slice(),o=d-s,o){for(u=o<0,u?(r=c,o=-o,l=h.length):(r=h,s=d,l=c.length),a=Math.max(Math.ceil(m/Nr),l)+2,o>a&&(o=a,r.length=1),r.reverse(),a=o;a--;)r.push(0);r.reverse()}else{for(a=c.length,l=h.length,u=a<l,u&&(l=a),a=0;a<l;a++)if(c[a]!=h[a]){u=c[a]<h[a];break}o=0}for(u&&(r=c,c=h,h=r,t.s=-t.s),l=c.length,a=h.length-l;a>0;--a)c[l++]=0;for(a=h.length;a>o;){if(c[--a]<h[a]){for(i=a;i&&c[--i]===0;)c[i]=_n-1;--c[i],c[a]+=_n}c[a]-=h[a]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--s;return c[0]?(t.d=c,t.e=s,Or?pr(t,m):t):new f(0)}function Sd(e,t,r){var s,a=ln(e),i=Ai(e.d),o=i.length;return t?(r&&(s=r-o)>0?i=i.charAt(0)+"."+i.slice(1)+xl(s):o>1&&(i=i.charAt(0)+"."+i.slice(1)),i=i+(a<0?"e":"e+")+a):a<0?(i="0."+xl(-a-1)+i,r&&(s=r-o)>0&&(i+=xl(s))):a>=o?(i+=xl(a+1-o),r&&(s=r-a-1)>0&&(i=i+"."+xl(s))):((s=a+1)<o&&(i=i.slice(0,s)+"."+i.slice(s)),r&&(s=r-o)>0&&(a+1===o&&(i+="."),i+=xl(s))),e.s<0?"-"+i:i}function yM(e,t){if(e.length>t)return e.length=t,!0}function _B(e){var t,r,s;function a(i){var o=this;if(!(o instanceof a))return new a(i);if(o.constructor=a,i instanceof a){o.s=i.s,o.e=i.e,o.d=(i=i.d)?i.slice():i;return}if(typeof i=="number"){if(i*0!==0)throw Error(id+i);if(i>0)o.s=1;else if(i<0)i=-i,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(i===~~i&&i<1e7){o.e=0,o.d=[i];return}return vM(o,i.toString())}else if(typeof i!="string")throw Error(id+i);if(i.charCodeAt(0)===45?(i=i.slice(1),o.s=-1):o.s=1,uNe.test(i))vM(o,i);else throw Error(id+i)}if(a.prototype=Xe,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.clone=_B,a.config=a.set=hNe,e===void 0&&(e={}),e)for(s=["precision","rounding","toExpNeg","toExpPos","LN10"],t=0;t<s.length;)e.hasOwnProperty(r=s[t++])||(e[r]=this[r]);return a.config(e),a}function hNe(e){if(!e||typeof e!="object")throw Error(Oa+"Object expected");var t,r,s,a=["precision",1,ff,"rounding",0,8,"toExpNeg",-1/0,0,"toExpPos",0,1/0];for(t=0;t<a.length;t+=3)if((s=e[r=a[t]])!==void 0)if(mf(s)===s&&s>=a[t+1]&&s<=a[t+2])this[r]=s;else throw Error(id+r+": "+s);if((s=e[r="LN10"])!==void 0)if(s==Math.LN10)this[r]=new this(s);else throw Error(id+r+": "+s);return this}var w2=_B(dNe);Zs=new w2(1);const cr=w2;function fNe(e){return xNe(e)||gNe(e)||pNe(e)||mNe()}function mNe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
706In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pNe(e,t){if(e){if(typeof e=="string")return b1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return b1(e,t)}}function gNe(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function xNe(e){if(Array.isArray(e))return b1(e)}function b1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}var vNe=function(t){return t},NB={"@@functional/placeholder":!0},SB=function(t){return t===NB},jM=function(t){return function r(){return arguments.length===0||arguments.length===1&&SB(arguments.length<=0?void 0:arguments[0])?r:t.apply(void 0,arguments)}},yNe=function e(t,r){return t===1?r:jM(function(){for(var s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];var o=a.filter(function(l){return l!==NB}).length;return o>=t?r.apply(void 0,a):e(t-o,jM(function(){for(var l=arguments.length,c=new Array(l),d=0;d<l;d++)c[d]=arguments[d];var u=a.map(function(h){return SB(h)?c.shift():h});return r.apply(void 0,fNe(u).concat(c))}))})},Uj=function(t){return yNe(t.length,t)},w1=function(t,r){for(var s=[],a=t;a<r;++a)s[a-t]=a;return s},jNe=Uj(function(e,t){return Array.isArray(t)?t.map(e):Object.keys(t).map(function(r){return t[r]}).map(e)}),bNe=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];if(!r.length)return vNe;var a=r.reverse(),i=a[0],o=a.slice(1);return function(){return o.reduce(function(l,c){return c(l)},i.apply(void 0,arguments))}},_1=function(t){return Array.isArray(t)?t.reverse():t.split("").reverse.join("")},CB=function(t){var r=null,s=null;return function(){for(var a=arguments.length,i=new Array(a),o=0;o<a;o++)i[o]=arguments[o];return r&&i.every(function(l,c){return l===r[c]})||(r=i,s=t.apply(void 0,i)),s}};function wNe(e){var t;return e===0?t=1:t=Math.floor(new cr(e).abs().log(10).toNumber())+1,t}function _Ne(e,t,r){for(var s=new cr(e),a=0,i=[];s.lt(t)&&a<1e5;)i.push(s.toNumber()),s=s.add(r),a++;return i}var NNe=Uj(function(e,t,r){var s=+e,a=+t;return s+r*(a-s)}),SNe=Uj(function(e,t,r){var s=t-+e;return s=s||1/0,(r-e)/s}),CNe=Uj(function(e,t,r){var s=t-+e;return s=s||1/0,Math.max(0,Math.min(1,(r-e)/s))});const zj={rangeStep:_Ne,getDigitCount:wNe,interpolateNumber:NNe,uninterpolateNumber:SNe,uninterpolateTruncation:CNe};function N1(e){return TNe(e)||PNe(e)||kB(e)||kNe()}function kNe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
707In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function PNe(e){if(typeof Symbol<"u"&&Symbol.iterator in Object(e))return Array.from(e)}function TNe(e){if(Array.isArray(e))return S1(e)}function jp(e,t){return ONe(e)||ENe(e,t)||kB(e,t)||ANe()}function ANe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
708In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kB(e,t){if(e){if(typeof e=="string")return S1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return S1(e,t)}}function S1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function ENe(e,t){if(!(typeof Symbol>"u"||!(Symbol.iterator in Object(e)))){var r=[],s=!0,a=!1,i=void 0;try{for(var o=e[Symbol.iterator](),l;!(s=(l=o.next()).done)&&(r.push(l.value),!(t&&r.length===t));s=!0);}catch(c){a=!0,i=c}finally{try{!s&&o.return!=null&&o.return()}finally{if(a)throw i}}return r}}function ONe(e){if(Array.isArray(e))return e}function PB(e){var t=jp(e,2),r=t[0],s=t[1],a=r,i=s;return r>s&&(a=s,i=r),[a,i]}function TB(e,t,r){if(e.lte(0))return new cr(0);var s=zj.getDigitCount(e.toNumber()),a=new cr(10).pow(s),i=e.div(a),o=s!==1?.05:.1,l=new cr(Math.ceil(i.div(o).toNumber())).add(r).mul(o),c=l.mul(a);return t?c:new cr(Math.ceil(c))}function MNe(e,t,r){var s=1,a=new cr(e);if(!a.isint()&&r){var i=Math.abs(e);i<1?(s=new cr(10).pow(zj.getDigitCount(e)-1),a=new cr(Math.floor(a.div(s).toNumber())).mul(s)):i>1&&(a=new cr(Math.floor(e)))}else e===0?a=new cr(Math.floor((t-1)/2)):r||(a=new cr(Math.floor(e)));var o=Math.floor((t-1)/2),l=bNe(jNe(function(c){return a.add(new cr(c-o).mul(s)).toNumber()}),w1);return l(0,t)}function AB(e,t,r,s){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((t-e)/(r-1)))return{step:new cr(0),tickMin:new cr(0),tickMax:new cr(0)};var i=TB(new cr(t).sub(e).div(r-1),s,a),o;e<=0&&t>=0?o=new cr(0):(o=new cr(e).add(t).div(2),o=o.sub(new cr(o).mod(i)));var l=Math.ceil(o.sub(e).div(i).toNumber()),c=Math.ceil(new cr(t).sub(o).div(i).toNumber()),d=l+c+1;return d>r?AB(e,t,r,s,a+1):(d<r&&(c=t>0?c+(r-d):c,l=t>0?l:l+(r-d)),{step:i,tickMin:o.sub(new cr(l).mul(i)),tickMax:o.add(new cr(c).mul(i))})}function DNe(e){var t=jp(e,2),r=t[0],s=t[1],a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(a,2),l=PB([r,s]),c=jp(l,2),d=c[0],u=c[1];if(d===-1/0||u===1/0){var h=u===1/0?[d].concat(N1(w1(0,a-1).map(function(){return 1/0}))):[].concat(N1(w1(0,a-1).map(function(){return-1/0})),[u]);return r>s?_1(h):h}if(d===u)return MNe(d,a,i);var f=AB(d,u,o,i),m=f.step,g=f.tickMin,p=f.tickMax,y=zj.rangeStep(g,p.add(new cr(.1).mul(m)),m);return r>s?_1(y):y}function RNe(e,t){var r=jp(e,2),s=r[0],a=r[1],i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=PB([s,a]),l=jp(o,2),c=l[0],d=l[1];if(c===-1/0||d===1/0)return[s,a];if(c===d)return[c];var u=Math.max(t,2),h=TB(new cr(d).sub(c).div(u-1),i,0),f=[].concat(N1(zj.rangeStep(new cr(c),new cr(d).sub(new cr(.99).mul(h)),h)),[d]);return s>a?_1(f):f}var $Ne=CB(DNe),INe=CB(RNe),LNe="Invariant failed";function Cd(e,t){throw new Error(LNe)}var FNe=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function wh(e){"@babel/helpers - typeof";return wh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wh(e)}function Ay(){return Ay=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Ay.apply(this,arguments)}function UNe(e,t){return WNe(e)||qNe(e,t)||BNe(e,t)||zNe()}function zNe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
709In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BNe(e,t){if(e){if(typeof e=="string")return bM(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return bM(e,t)}}function bM(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function qNe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function WNe(e){if(Array.isArray(e))return e}function HNe(e,t){if(e==null)return{};var r=VNe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function VNe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function KNe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function GNe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,MB(s.key),s)}}function YNe(e,t,r){return t&&GNe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function QNe(e,t,r){return t=Ey(t),XNe(e,EB()?Reflect.construct(t,r||[],Ey(e).constructor):t.apply(e,r))}function XNe(e,t){if(t&&(wh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ZNe(e)}function ZNe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function EB(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(EB=function(){return!!e})()}function Ey(e){return Ey=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ey(e)}function JNe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&C1(e,t)}function C1(e,t){return C1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},C1(e,t)}function OB(e,t,r){return t=MB(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function MB(e){var t=e1e(e,"string");return wh(t)=="symbol"?t:t+""}function e1e(e,t){if(wh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(wh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Ag=function(e){function t(){return KNe(this,t),QNe(this,t,arguments)}return JNe(t,e),YNe(t,[{key:"render",value:function(){var s=this.props,a=s.offset,i=s.layout,o=s.width,l=s.dataKey,c=s.data,d=s.dataPointFormatter,u=s.xAxis,h=s.yAxis,f=HNe(s,FNe),m=$t(f,!1);this.props.direction==="x"&&u.type!=="number"&&Cd();var g=c.map(function(p){var y=d(p,l),v=y.x,j=y.y,b=y.value,_=y.errorVal;if(!_)return null;var w=[],N,S;if(Array.isArray(_)){var C=UNe(_,2);N=C[0],S=C[1]}else N=S=_;if(i==="vertical"){var P=u.scale,M=j+a,D=M+o,A=M-o,U=P(b-N),F=P(b+S);w.push({x1:F,y1:D,x2:F,y2:A}),w.push({x1:U,y1:M,x2:F,y2:M}),w.push({x1:U,y1:D,x2:U,y2:A})}else if(i==="horizontal"){var L=h.scale,$=v+a,R=$-o,T=$+o,k=L(b-N),W=L(b+S);w.push({x1:R,y1:W,x2:T,y2:W}),w.push({x1:$,y1:k,x2:$,y2:W}),w.push({x1:R,y1:k,x2:T,y2:k})}return G.createElement(en,Ay({className:"recharts-errorBar",key:"bar-".concat(w.map(function(q){return"".concat(q.x1,"-").concat(q.x2,"-").concat(q.y1,"-").concat(q.y2)}))},m),w.map(function(q){return G.createElement("line",Ay({},q,{key:"line-".concat(q.x1,"-").concat(q.x2,"-").concat(q.y1,"-").concat(q.y2)}))}))});return G.createElement(en,{className:"recharts-errorBars"},g)}}])}(G.Component);OB(Ag,"defaultProps",{stroke:"black",strokeWidth:1.5,width:5,offset:0,layout:"horizontal"});OB(Ag,"displayName","ErrorBar");function bp(e){"@babel/helpers - typeof";return bp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},bp(e)}function wM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function _c(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wM(Object(r),!0).forEach(function(s){t1e(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function t1e(e,t,r){return t=r1e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r1e(e){var t=n1e(e,"string");return bp(t)=="symbol"?t:t+""}function n1e(e,t){if(bp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(bp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var DB=function(t){var r=t.children,s=t.formattedGraphicalItems,a=t.legendWidth,i=t.legendContent,o=Ys(r,ko);if(!o)return null;var l=ko.defaultProps,c=l!==void 0?_c(_c({},l),o.props):{},d;return o.props&&o.props.payload?d=o.props&&o.props.payload:i==="children"?d=(s||[]).reduce(function(u,h){var f=h.item,m=h.props,g=m.sectors||m.data||[];return u.concat(g.map(function(p){return{type:o.props.iconType||f.props.legendType,value:p.name,color:p.fill,payload:p}}))},[]):d=(s||[]).map(function(u){var h=u.item,f=h.type.defaultProps,m=f!==void 0?_c(_c({},f),h.props):{},g=m.dataKey,p=m.name,y=m.legendType,v=m.hide;return{inactive:v,dataKey:g,type:c.iconType||y||"square",color:_2(h),value:p||g,payload:m}}),_c(_c(_c({},c),ko.getWithHeight(o,a)),{},{payload:d,item:o})};function wp(e){"@babel/helpers - typeof";return wp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wp(e)}function _M(e){return o1e(e)||i1e(e)||a1e(e)||s1e()}function s1e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
710In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function a1e(e,t){if(e){if(typeof e=="string")return k1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return k1(e,t)}}function i1e(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function o1e(e){if(Array.isArray(e))return k1(e)}function k1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function NM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Gr(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?NM(Object(r),!0).forEach(function(s){$u(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):NM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function $u(e,t,r){return t=l1e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function l1e(e){var t=c1e(e,"string");return wp(t)=="symbol"?t:t+""}function c1e(e,t){if(wp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(wp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function la(e,t,r){return Pt(e)||Pt(t)?r:yn(t)?Ca(e,t,r):_t(t)?t(e):r}function Sm(e,t,r,s){var a=iNe(e,function(l){return la(l,t)});if(r==="number"){var i=a.filter(function(l){return Be(l)||parseFloat(l)});return i.length?[Lj(i),Ij(i)]:[1/0,-1/0]}var o=s?a.filter(function(l){return!Pt(l)}):a;return o.map(function(l){return yn(l)||l instanceof Date?l:""})}var d1e=function(t){var r,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],a=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,o=-1,l=(r=s==null?void 0:s.length)!==null&&r!==void 0?r:0;if(l<=1)return 0;if(i&&i.axisType==="angleAxis"&&Math.abs(Math.abs(i.range[1]-i.range[0])-360)<=1e-6)for(var c=i.range,d=0;d<l;d++){var u=d>0?a[d-1].coordinate:a[l-1].coordinate,h=a[d].coordinate,f=d>=l-1?a[0].coordinate:a[d+1].coordinate,m=void 0;if(ri(h-u)!==ri(f-h)){var g=[];if(ri(f-h)===ri(c[1]-c[0])){m=f;var p=h+c[1]-c[0];g[0]=Math.min(p,(p+u)/2),g[1]=Math.max(p,(p+u)/2)}else{m=u;var y=f+c[1]-c[0];g[0]=Math.min(h,(y+h)/2),g[1]=Math.max(h,(y+h)/2)}var v=[Math.min(h,(m+h)/2),Math.max(h,(m+h)/2)];if(t>v[0]&&t<=v[1]||t>=g[0]&&t<=g[1]){o=a[d].index;break}}else{var j=Math.min(u,f),b=Math.max(u,f);if(t>(j+h)/2&&t<=(b+h)/2){o=a[d].index;break}}}else for(var _=0;_<l;_++)if(_===0&&t<=(s[_].coordinate+s[_+1].coordinate)/2||_>0&&_<l-1&&t>(s[_].coordinate+s[_-1].coordinate)/2&&t<=(s[_].coordinate+s[_+1].coordinate)/2||_===l-1&&t>(s[_].coordinate+s[_-1].coordinate)/2){o=s[_].index;break}return o},_2=function(t){var r,s=t,a=s.type.displayName,i=(r=t.type)!==null&&r!==void 0&&r.defaultProps?Gr(Gr({},t.type.defaultProps),t.props):t.props,o=i.stroke,l=i.fill,c;switch(a){case"Line":c=o;break;case"Area":case"Radar":c=o&&o!=="none"?o:l;break;default:c=l;break}return c},u1e=function(t){var r=t.barSize,s=t.totalSize,a=t.stackGroups,i=a===void 0?{}:a;if(!i)return{};for(var o={},l=Object.keys(i),c=0,d=l.length;c<d;c++)for(var u=i[l[c]].stackGroups,h=Object.keys(u),f=0,m=h.length;f<m;f++){var g=u[h[f]],p=g.items,y=g.cateAxisId,v=p.filter(function(S){return So(S.type).indexOf("Bar")>=0});if(v&&v.length){var j=v[0].type.defaultProps,b=j!==void 0?Gr(Gr({},j),v[0].props):v[0].props,_=b.barSize,w=b[y];o[w]||(o[w]=[]);var N=Pt(_)?r:_;o[w].push({item:v[0],stackList:v.slice(1),barSize:Pt(N)?void 0:Nd(N,s,0)})}}return o},h1e=function(t){var r=t.barGap,s=t.barCategoryGap,a=t.bandSize,i=t.sizeList,o=i===void 0?[]:i,l=t.maxBarSize,c=o.length;if(c<1)return null;var d=Nd(r,a,0,!0),u,h=[];if(o[0].barSize===+o[0].barSize){var f=!1,m=a/c,g=o.reduce(function(_,w){return _+w.barSize||0},0);g+=(c-1)*d,g>=a&&(g-=(c-1)*d,d=0),g>=a&&m>0&&(f=!0,m*=.9,g=c*m);var p=(a-g)/2>>0,y={offset:p-d,size:0};u=o.reduce(function(_,w){var N={item:w.item,position:{offset:y.offset+y.size+d,size:f?m:w.barSize}},S=[].concat(_M(_),[N]);return y=S[S.length-1].position,w.stackList&&w.stackList.length&&w.stackList.forEach(function(C){S.push({item:C,position:y})}),S},h)}else{var v=Nd(s,a,0,!0);a-2*v-(c-1)*d<=0&&(d=0);var j=(a-2*v-(c-1)*d)/c;j>1&&(j>>=0);var b=l===+l?Math.min(j,l):j;u=o.reduce(function(_,w,N){var S=[].concat(_M(_),[{item:w.item,position:{offset:v+(j+d)*N+(j-b)/2,size:b}}]);return w.stackList&&w.stackList.length&&w.stackList.forEach(function(C){S.push({item:C,position:S[S.length-1].position})}),S},h)}return u},f1e=function(t,r,s,a){var i=s.children,o=s.width,l=s.margin,c=o-(l.left||0)-(l.right||0),d=DB({children:i,legendWidth:c});if(d){var u=a||{},h=u.width,f=u.height,m=d.align,g=d.verticalAlign,p=d.layout;if((p==="vertical"||p==="horizontal"&&g==="middle")&&m!=="center"&&Be(t[m]))return Gr(Gr({},t),{},$u({},m,t[m]+(h||0)));if((p==="horizontal"||p==="vertical"&&m==="center")&&g!=="middle"&&Be(t[g]))return Gr(Gr({},t),{},$u({},g,t[g]+(f||0)))}return t},m1e=function(t,r,s){return Pt(r)?!0:t==="horizontal"?r==="yAxis":t==="vertical"||s==="x"?r==="xAxis":s==="y"?r==="yAxis":!0},RB=function(t,r,s,a,i){var o=r.props.children,l=ka(o,Ag).filter(function(d){return m1e(a,i,d.props.direction)});if(l&&l.length){var c=l.map(function(d){return d.props.dataKey});return t.reduce(function(d,u){var h=la(u,s);if(Pt(h))return d;var f=Array.isArray(h)?[Lj(h),Ij(h)]:[h,h],m=c.reduce(function(g,p){var y=la(u,p,0),v=f[0]-Math.abs(Array.isArray(y)?y[0]:y),j=f[1]+Math.abs(Array.isArray(y)?y[1]:y);return[Math.min(v,g[0]),Math.max(j,g[1])]},[1/0,-1/0]);return[Math.min(m[0],d[0]),Math.max(m[1],d[1])]},[1/0,-1/0])}return null},p1e=function(t,r,s,a,i){var o=r.map(function(l){return RB(t,l,s,i,a)}).filter(function(l){return!Pt(l)});return o&&o.length?o.reduce(function(l,c){return[Math.min(l[0],c[0]),Math.max(l[1],c[1])]},[1/0,-1/0]):null},$B=function(t,r,s,a,i){var o=r.map(function(c){var d=c.props.dataKey;return s==="number"&&d&&RB(t,c,d,a)||Sm(t,d,s,i)});if(s==="number")return o.reduce(function(c,d){return[Math.min(c[0],d[0]),Math.max(c[1],d[1])]},[1/0,-1/0]);var l={};return o.reduce(function(c,d){for(var u=0,h=d.length;u<h;u++)l[d[u]]||(l[d[u]]=!0,c.push(d[u]));return c},[])},IB=function(t,r){return t==="horizontal"&&r==="xAxis"||t==="vertical"&&r==="yAxis"||t==="centric"&&r==="angleAxis"||t==="radial"&&r==="radiusAxis"},LB=function(t,r,s,a){if(a)return t.map(function(c){return c.coordinate});var i,o,l=t.map(function(c){return c.coordinate===r&&(i=!0),c.coordinate===s&&(o=!0),c.coordinate});return i||l.push(r),o||l.push(s),l},_o=function(t,r,s){if(!t)return null;var a=t.scale,i=t.duplicateDomain,o=t.type,l=t.range,c=t.realScaleType==="scaleBand"?a.bandwidth()/2:2,d=(r||s)&&o==="category"&&a.bandwidth?a.bandwidth()/c:0;if(d=t.axisType==="angleAxis"&&(l==null?void 0:l.length)>=2?ri(l[0]-l[1])*2*d:d,r&&(t.ticks||t.niceTicks)){var u=(t.ticks||t.niceTicks).map(function(h){var f=i?i.indexOf(h):h;return{coordinate:a(f)+d,value:h,offset:d}});return u.filter(function(h){return!_g(h.coordinate)})}return t.isCategorical&&t.categoricalDomain?t.categoricalDomain.map(function(h,f){return{coordinate:a(h)+d,value:h,index:f,offset:d}}):a.ticks&&!s?a.ticks(t.tickCount).map(function(h){return{coordinate:a(h)+d,value:h,offset:d}}):a.domain().map(function(h,f){return{coordinate:a(h)+d,value:i?i[h]:h,index:f,offset:d}})},Dw=new WeakMap,bx=function(t,r){if(typeof r!="function")return t;Dw.has(t)||Dw.set(t,new WeakMap);var s=Dw.get(t);if(s.has(r))return s.get(r);var a=function(){t.apply(void 0,arguments),r.apply(void 0,arguments)};return s.set(r,a),a},g1e=function(t,r,s){var a=t.scale,i=t.type,o=t.layout,l=t.axisType;if(a==="auto")return o==="radial"&&l==="radiusAxis"?{scale:mp(),realScaleType:"band"}:o==="radial"&&l==="angleAxis"?{scale:Sy(),realScaleType:"linear"}:i==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!s)?{scale:Nm(),realScaleType:"point"}:i==="category"?{scale:mp(),realScaleType:"band"}:{scale:Sy(),realScaleType:"linear"};if(_d(a)){var c="scale".concat(Nj(a));return{scale:(xM[c]||Nm)(),realScaleType:xM[c]?c:"point"}}return _t(a)?{scale:a}:{scale:Nm(),realScaleType:"point"}},SM=1e-4,x1e=function(t){var r=t.domain();if(!(!r||r.length<=2)){var s=r.length,a=t.range(),i=Math.min(a[0],a[1])-SM,o=Math.max(a[0],a[1])+SM,l=t(r[0]),c=t(r[s-1]);(l<i||l>o||c<i||c>o)&&t.domain([r[0],r[s-1]])}},v1e=function(t,r){if(!t)return null;for(var s=0,a=t.length;s<a;s++)if(t[s].item===r)return t[s].position;return null},y1e=function(t,r){if(!r||r.length!==2||!Be(r[0])||!Be(r[1]))return t;var s=Math.min(r[0],r[1]),a=Math.max(r[0],r[1]),i=[t[0],t[1]];return(!Be(t[0])||t[0]<s)&&(i[0]=s),(!Be(t[1])||t[1]>a)&&(i[1]=a),i[0]>a&&(i[0]=a),i[1]<s&&(i[1]=s),i},j1e=function(t){var r=t.length;if(!(r<=0))for(var s=0,a=t[0].length;s<a;++s)for(var i=0,o=0,l=0;l<r;++l){var c=_g(t[l][s][1])?t[l][s][0]:t[l][s][1];c>=0?(t[l][s][0]=i,t[l][s][1]=i+c,i=t[l][s][1]):(t[l][s][0]=o,t[l][s][1]=o+c,o=t[l][s][1])}},b1e=function(t){var r=t.length;if(!(r<=0))for(var s=0,a=t[0].length;s<a;++s)for(var i=0,o=0;o<r;++o){var l=_g(t[o][s][1])?t[o][s][0]:t[o][s][1];l>=0?(t[o][s][0]=i,t[o][s][1]=i+l,i=t[o][s][1]):(t[o][s][0]=0,t[o][s][1]=0)}},w1e={sign:j1e,expand:Ihe,none:mh,silhouette:Lhe,wiggle:Fhe,positive:b1e},_1e=function(t,r,s){var a=r.map(function(l){return l.props.dataKey}),i=w1e[s],o=$he().keys(a).value(function(l,c){return+la(l,c,0)}).order(ZN).offset(i);return o(t)},N1e=function(t,r,s,a,i,o){if(!t)return null;var l=o?r.reverse():r,c={},d=l.reduce(function(h,f){var m,g=(m=f.type)!==null&&m!==void 0&&m.defaultProps?Gr(Gr({},f.type.defaultProps),f.props):f.props,p=g.stackId,y=g.hide;if(y)return h;var v=g[s],j=h[v]||{hasStack:!1,stackGroups:{}};if(yn(p)){var b=j.stackGroups[p]||{numericAxisId:s,cateAxisId:a,items:[]};b.items.push(f),j.hasStack=!0,j.stackGroups[p]=b}else j.stackGroups[Ng("_stackId_")]={numericAxisId:s,cateAxisId:a,items:[f]};return Gr(Gr({},h),{},$u({},v,j))},c),u={};return Object.keys(d).reduce(function(h,f){var m=d[f];if(m.hasStack){var g={};m.stackGroups=Object.keys(m.stackGroups).reduce(function(p,y){var v=m.stackGroups[y];return Gr(Gr({},p),{},$u({},y,{numericAxisId:s,cateAxisId:a,items:v.items,stackedData:_1e(t,v.items,i)}))},g)}return Gr(Gr({},h),{},$u({},f,m))},u)},S1e=function(t,r){var s=r.realScaleType,a=r.type,i=r.tickCount,o=r.originalDomain,l=r.allowDecimals,c=s||r.scale;if(c!=="auto"&&c!=="linear")return null;if(i&&a==="number"&&o&&(o[0]==="auto"||o[1]==="auto")){var d=t.domain();if(!d.length)return null;var u=$Ne(d,i,l);return t.domain([Lj(u),Ij(u)]),{niceTicks:u}}if(i&&a==="number"){var h=t.domain(),f=INe(h,i,l);return{niceTicks:f}}return null};function CM(e){var t=e.axis,r=e.ticks,s=e.bandSize,a=e.entry,i=e.index,o=e.dataKey;if(t.type==="category"){if(!t.allowDuplicatedCategory&&t.dataKey&&!Pt(a[t.dataKey])){var l=ry(r,"value",a[t.dataKey]);if(l)return l.coordinate+s/2}return r[i]?r[i].coordinate+s/2:null}var c=la(a,Pt(o)?t.dataKey:o);return Pt(c)?null:t.scale(c)}var kM=function(t){var r=t.axis,s=t.ticks,a=t.offset,i=t.bandSize,o=t.entry,l=t.index;if(r.type==="category")return s[l]?s[l].coordinate+a:null;var c=la(o,r.dataKey,r.domain[l]);return Pt(c)?null:r.scale(c)-i/2+a},C1e=function(t){var r=t.numericAxis,s=r.scale.domain();if(r.type==="number"){var a=Math.min(s[0],s[1]),i=Math.max(s[0],s[1]);return a<=0&&i>=0?0:i<0?i:a}return s[0]},k1e=function(t,r){var s,a=(s=t.type)!==null&&s!==void 0&&s.defaultProps?Gr(Gr({},t.type.defaultProps),t.props):t.props,i=a.stackId;if(yn(i)){var o=r[i];if(o){var l=o.items.indexOf(t);return l>=0?o.stackedData[l]:null}}return null},P1e=function(t){return t.reduce(function(r,s){return[Lj(s.concat([r[0]]).filter(Be)),Ij(s.concat([r[1]]).filter(Be))]},[1/0,-1/0])},FB=function(t,r,s){return Object.keys(t).reduce(function(a,i){var o=t[i],l=o.stackedData,c=l.reduce(function(d,u){var h=P1e(u.slice(r,s+1));return[Math.min(d[0],h[0]),Math.max(d[1],h[1])]},[1/0,-1/0]);return[Math.min(c[0],a[0]),Math.max(c[1],a[1])]},[1/0,-1/0]).map(function(a){return a===1/0||a===-1/0?0:a})},PM=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,TM=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,P1=function(t,r,s){if(_t(t))return t(r,s);if(!Array.isArray(t))return r;var a=[];if(Be(t[0]))a[0]=s?t[0]:Math.min(t[0],r[0]);else if(PM.test(t[0])){var i=+PM.exec(t[0])[1];a[0]=r[0]-i}else _t(t[0])?a[0]=t[0](r[0]):a[0]=r[0];if(Be(t[1]))a[1]=s?t[1]:Math.max(t[1],r[1]);else if(TM.test(t[1])){var o=+TM.exec(t[1])[1];a[1]=r[1]+o}else _t(t[1])?a[1]=t[1](r[1]):a[1]=r[1];return a},Oy=function(t,r,s){if(t&&t.scale&&t.scale.bandwidth){var a=t.scale.bandwidth();if(!s||a>0)return a}if(t&&r&&r.length>=2){for(var i=Xk(r,function(h){return h.coordinate}),o=1/0,l=1,c=i.length;l<c;l++){var d=i[l],u=i[l-1];o=Math.min((d.coordinate||0)-(u.coordinate||0),o)}return o===1/0?0:o}return s?void 0:0},AM=function(t,r,s){return!t||!t.length||Fj(t,Ca(s,"type.defaultProps.domain"))?r:t},UB=function(t,r){var s=t.type.defaultProps?Gr(Gr({},t.type.defaultProps),t.props):t.props,a=s.dataKey,i=s.name,o=s.unit,l=s.formatter,c=s.tooltipType,d=s.chartType,u=s.hide;return Gr(Gr({},$t(t,!1)),{},{dataKey:a,unit:o,formatter:l,name:i||a,color:_2(t),value:la(r,a),type:c,payload:r,chartType:d,hide:u})};function _p(e){"@babel/helpers - typeof";return _p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_p(e)}function EM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function OM(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?EM(Object(r),!0).forEach(function(s){T1e(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):EM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function T1e(e,t,r){return t=A1e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function A1e(e){var t=E1e(e,"string");return _p(t)=="symbol"?t:t+""}function E1e(e,t){if(_p(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(_p(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var My=Math.PI/180,O1e=function(t){return t*180/Math.PI},Rn=function(t,r,s,a){return{x:t+Math.cos(-My*a)*s,y:r+Math.sin(-My*a)*s}},M1e=function(t,r){var s=t.x,a=t.y,i=r.x,o=r.y;return Math.sqrt(Math.pow(s-i,2)+Math.pow(a-o,2))},D1e=function(t,r){var s=t.x,a=t.y,i=r.cx,o=r.cy,l=M1e({x:s,y:a},{x:i,y:o});if(l<=0)return{radius:l};var c=(s-i)/l,d=Math.acos(c);return a>o&&(d=2*Math.PI-d),{radius:l,angle:O1e(d),angleInRadian:d}},R1e=function(t){var r=t.startAngle,s=t.endAngle,a=Math.floor(r/360),i=Math.floor(s/360),o=Math.min(a,i);return{startAngle:r-o*360,endAngle:s-o*360}},$1e=function(t,r){var s=r.startAngle,a=r.endAngle,i=Math.floor(s/360),o=Math.floor(a/360),l=Math.min(i,o);return t+l*360},MM=function(t,r){var s=t.x,a=t.y,i=D1e({x:s,y:a},r),o=i.radius,l=i.angle,c=r.innerRadius,d=r.outerRadius;if(o<c||o>d)return!1;if(o===0)return!0;var u=R1e(r),h=u.startAngle,f=u.endAngle,m=l,g;if(h<=f){for(;m>f;)m-=360;for(;m<h;)m+=360;g=m>=h&&m<=f}else{for(;m>h;)m-=360;for(;m<f;)m+=360;g=m>=f&&m<=h}return g?OM(OM({},r),{},{radius:o,angle:$1e(m,r)}):null};function Np(e){"@babel/helpers - typeof";return Np=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Np(e)}var I1e=["offset"];function L1e(e){return B1e(e)||z1e(e)||U1e(e)||F1e()}function F1e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
711In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function U1e(e,t){if(e){if(typeof e=="string")return T1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return T1(e,t)}}function z1e(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function B1e(e){if(Array.isArray(e))return T1(e)}function T1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function q1e(e,t){if(e==null)return{};var r=W1e(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function W1e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function DM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function un(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?DM(Object(r),!0).forEach(function(s){H1e(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):DM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function H1e(e,t,r){return t=V1e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function V1e(e){var t=K1e(e,"string");return Np(t)=="symbol"?t:t+""}function K1e(e,t){if(Np(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Np(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Sp(){return Sp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Sp.apply(this,arguments)}var G1e=function(t){var r=t.value,s=t.formatter,a=Pt(t.children)?r:t.children;return _t(s)?s(a):a},Y1e=function(t,r){var s=ri(r-t),a=Math.min(Math.abs(r-t),360);return s*a},Q1e=function(t,r,s){var a=t.position,i=t.viewBox,o=t.offset,l=t.className,c=i,d=c.cx,u=c.cy,h=c.innerRadius,f=c.outerRadius,m=c.startAngle,g=c.endAngle,p=c.clockWise,y=(h+f)/2,v=Y1e(m,g),j=v>=0?1:-1,b,_;a==="insideStart"?(b=m+j*o,_=p):a==="insideEnd"?(b=g-j*o,_=!p):a==="end"&&(b=g+j*o,_=p),_=v<=0?_:!_;var w=Rn(d,u,y,b),N=Rn(d,u,y,b+(_?1:-1)*359),S="M".concat(w.x,",").concat(w.y,`
712    A`).concat(y,",").concat(y,",0,1,").concat(_?0:1,`,
713    `).concat(N.x,",").concat(N.y),C=Pt(t.id)?Ng("recharts-radial-line-"):t.id;return G.createElement("text",Sp({},s,{dominantBaseline:"central",className:It("recharts-radial-bar-label",l)}),G.createElement("defs",null,G.createElement("path",{id:C,d:S})),G.createElement("textPath",{xlinkHref:"#".concat(C)},r))},X1e=function(t){var r=t.viewBox,s=t.offset,a=t.position,i=r,o=i.cx,l=i.cy,c=i.innerRadius,d=i.outerRadius,u=i.startAngle,h=i.endAngle,f=(u+h)/2;if(a==="outside"){var m=Rn(o,l,d+s,f),g=m.x,p=m.y;return{x:g,y:p,textAnchor:g>=o?"start":"end",verticalAnchor:"middle"}}if(a==="center")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"middle"};if(a==="centerTop")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"start"};if(a==="centerBottom")return{x:o,y:l,textAnchor:"middle",verticalAnchor:"end"};var y=(c+d)/2,v=Rn(o,l,y,f),j=v.x,b=v.y;return{x:j,y:b,textAnchor:"middle",verticalAnchor:"middle"}},Z1e=function(t){var r=t.viewBox,s=t.parentViewBox,a=t.offset,i=t.position,o=r,l=o.x,c=o.y,d=o.width,u=o.height,h=u>=0?1:-1,f=h*a,m=h>0?"end":"start",g=h>0?"start":"end",p=d>=0?1:-1,y=p*a,v=p>0?"end":"start",j=p>0?"start":"end";if(i==="top"){var b={x:l+d/2,y:c-h*a,textAnchor:"middle",verticalAnchor:m};return un(un({},b),s?{height:Math.max(c-s.y,0),width:d}:{})}if(i==="bottom"){var _={x:l+d/2,y:c+u+f,textAnchor:"middle",verticalAnchor:g};return un(un({},_),s?{height:Math.max(s.y+s.height-(c+u),0),width:d}:{})}if(i==="left"){var w={x:l-y,y:c+u/2,textAnchor:v,verticalAnchor:"middle"};return un(un({},w),s?{width:Math.max(w.x-s.x,0),height:u}:{})}if(i==="right"){var N={x:l+d+y,y:c+u/2,textAnchor:j,verticalAnchor:"middle"};return un(un({},N),s?{width:Math.max(s.x+s.width-N.x,0),height:u}:{})}var S=s?{width:d,height:u}:{};return i==="insideLeft"?un({x:l+y,y:c+u/2,textAnchor:j,verticalAnchor:"middle"},S):i==="insideRight"?un({x:l+d-y,y:c+u/2,textAnchor:v,verticalAnchor:"middle"},S):i==="insideTop"?un({x:l+d/2,y:c+f,textAnchor:"middle",verticalAnchor:g},S):i==="insideBottom"?un({x:l+d/2,y:c+u-f,textAnchor:"middle",verticalAnchor:m},S):i==="insideTopLeft"?un({x:l+y,y:c+f,textAnchor:j,verticalAnchor:g},S):i==="insideTopRight"?un({x:l+d-y,y:c+f,textAnchor:v,verticalAnchor:g},S):i==="insideBottomLeft"?un({x:l+y,y:c+u-f,textAnchor:j,verticalAnchor:m},S):i==="insideBottomRight"?un({x:l+d-y,y:c+u-f,textAnchor:v,verticalAnchor:m},S):sf(i)&&(Be(i.x)||qc(i.x))&&(Be(i.y)||qc(i.y))?un({x:l+Nd(i.x,d),y:c+Nd(i.y,u),textAnchor:"end",verticalAnchor:"end"},S):un({x:l+d/2,y:c+u/2,textAnchor:"middle",verticalAnchor:"middle"},S)},J1e=function(t){return"cx"in t&&Be(t.cx)};function es(e){var t=e.offset,r=t===void 0?5:t,s=q1e(e,I1e),a=un({offset:r},s),i=a.viewBox,o=a.position,l=a.value,c=a.children,d=a.content,u=a.className,h=u===void 0?"":u,f=a.textBreakAll;if(!i||Pt(l)&&Pt(c)&&!x.isValidElement(d)&&!_t(d))return null;if(x.isValidElement(d))return x.cloneElement(d,a);var m;if(_t(d)){if(m=x.createElement(d,a),x.isValidElement(m))return m}else m=G1e(a);var g=J1e(i),p=$t(a,!0);if(g&&(o==="insideStart"||o==="insideEnd"||o==="end"))return Q1e(a,m,p);var y=g?X1e(a):Z1e(a);return G.createElement(vy,Sp({className:It("recharts-label",h)},p,y,{breakAll:f}),m)}es.displayName="Label";var zB=function(t){var r=t.cx,s=t.cy,a=t.angle,i=t.startAngle,o=t.endAngle,l=t.r,c=t.radius,d=t.innerRadius,u=t.outerRadius,h=t.x,f=t.y,m=t.top,g=t.left,p=t.width,y=t.height,v=t.clockWise,j=t.labelViewBox;if(j)return j;if(Be(p)&&Be(y)){if(Be(h)&&Be(f))return{x:h,y:f,width:p,height:y};if(Be(m)&&Be(g))return{x:m,y:g,width:p,height:y}}return Be(h)&&Be(f)?{x:h,y:f,width:0,height:0}:Be(r)&&Be(s)?{cx:r,cy:s,startAngle:i||a||0,endAngle:o||a||0,innerRadius:d||0,outerRadius:u||c||l||0,clockWise:v}:t.viewBox?t.viewBox:{}},eSe=function(t,r){return t?t===!0?G.createElement(es,{key:"label-implicit",viewBox:r}):yn(t)?G.createElement(es,{key:"label-implicit",viewBox:r,value:t}):x.isValidElement(t)?t.type===es?x.cloneElement(t,{key:"label-implicit",viewBox:r}):G.createElement(es,{key:"label-implicit",content:t,viewBox:r}):_t(t)?G.createElement(es,{key:"label-implicit",content:t,viewBox:r}):sf(t)?G.createElement(es,Sp({viewBox:r},t,{key:"label-implicit"})):null:null},tSe=function(t,r){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!t||!t.children&&s&&!t.label)return null;var a=t.children,i=zB(t),o=ka(a,es).map(function(c,d){return x.cloneElement(c,{viewBox:r||i,key:"label-".concat(d)})});if(!s)return o;var l=eSe(t.label,r||i);return[l].concat(L1e(o))};es.parseViewBox=zB;es.renderCallByParent=tSe;function rSe(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}var nSe=rSe;const sSe=fr(nSe);function Cp(e){"@babel/helpers - typeof";return Cp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Cp(e)}var aSe=["valueAccessor"],iSe=["data","dataKey","clockWise","id","textBreakAll"];function oSe(e){return uSe(e)||dSe(e)||cSe(e)||lSe()}function lSe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
714In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cSe(e,t){if(e){if(typeof e=="string")return A1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return A1(e,t)}}function dSe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function uSe(e){if(Array.isArray(e))return A1(e)}function A1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function Dy(){return Dy=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Dy.apply(this,arguments)}function RM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function $M(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?RM(Object(r),!0).forEach(function(s){hSe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):RM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function hSe(e,t,r){return t=fSe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function fSe(e){var t=mSe(e,"string");return Cp(t)=="symbol"?t:t+""}function mSe(e,t){if(Cp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Cp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function IM(e,t){if(e==null)return{};var r=pSe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function pSe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var gSe=function(t){return Array.isArray(t.value)?sSe(t.value):t.value};function Ql(e){var t=e.valueAccessor,r=t===void 0?gSe:t,s=IM(e,aSe),a=s.data,i=s.dataKey,o=s.clockWise,l=s.id,c=s.textBreakAll,d=IM(s,iSe);return!a||!a.length?null:G.createElement(en,{className:"recharts-label-list"},a.map(function(u,h){var f=Pt(i)?r(u,h):la(u&&u.payload,i),m=Pt(l)?{}:{id:"".concat(l,"-").concat(h)};return G.createElement(es,Dy({},$t(u,!0),d,m,{parentViewBox:u.parentViewBox,value:f,textBreakAll:c,viewBox:es.parseViewBox(Pt(o)?u:$M($M({},u),{},{clockWise:o})),key:"label-".concat(h),index:h}))}))}Ql.displayName="LabelList";function xSe(e,t){return e?e===!0?G.createElement(Ql,{key:"labelList-implicit",data:t}):G.isValidElement(e)||_t(e)?G.createElement(Ql,{key:"labelList-implicit",data:t,content:e}):sf(e)?G.createElement(Ql,Dy({data:t},e,{key:"labelList-implicit"})):null:null}function vSe(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(!e||!e.children&&r&&!e.label)return null;var s=e.children,a=ka(s,Ql).map(function(o,l){return x.cloneElement(o,{data:t,key:"labelList-".concat(l)})});if(!r)return a;var i=xSe(e.label,t);return[i].concat(oSe(a))}Ql.renderCallByParent=vSe;function kp(e){"@babel/helpers - typeof";return kp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kp(e)}function E1(){return E1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},E1.apply(this,arguments)}function LM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function FM(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?LM(Object(r),!0).forEach(function(s){ySe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):LM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function ySe(e,t,r){return t=jSe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function jSe(e){var t=bSe(e,"string");return kp(t)=="symbol"?t:t+""}function bSe(e,t){if(kp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(kp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var wSe=function(t,r){var s=ri(r-t),a=Math.min(Math.abs(r-t),359.999);return s*a},wx=function(t){var r=t.cx,s=t.cy,a=t.radius,i=t.angle,o=t.sign,l=t.isExternal,c=t.cornerRadius,d=t.cornerIsExternal,u=c*(l?1:-1)+a,h=Math.asin(c/u)/My,f=d?i:i+o*h,m=Rn(r,s,u,f),g=Rn(r,s,a,f),p=d?i-o*h:i,y=Rn(r,s,u*Math.cos(h*My),p);return{center:m,circleTangency:g,lineTangency:y,theta:h}},BB=function(t){var r=t.cx,s=t.cy,a=t.innerRadius,i=t.outerRadius,o=t.startAngle,l=t.endAngle,c=wSe(o,l),d=o+c,u=Rn(r,s,i,o),h=Rn(r,s,i,d),f="M ".concat(u.x,",").concat(u.y,`
715    A `).concat(i,",").concat(i,`,0,
716    `).concat(+(Math.abs(c)>180),",").concat(+(o>d),`,
717    `).concat(h.x,",").concat(h.y,`
718  `);if(a>0){var m=Rn(r,s,a,o),g=Rn(r,s,a,d);f+="L ".concat(g.x,",").concat(g.y,`
719            A `).concat(a,",").concat(a,`,0,
720            `).concat(+(Math.abs(c)>180),",").concat(+(o<=d),`,
721            `).concat(m.x,",").concat(m.y," Z")}else f+="L ".concat(r,",").concat(s," Z");return f},_Se=function(t){var r=t.cx,s=t.cy,a=t.innerRadius,i=t.outerRadius,o=t.cornerRadius,l=t.forceCornerRadius,c=t.cornerIsExternal,d=t.startAngle,u=t.endAngle,h=ri(u-d),f=wx({cx:r,cy:s,radius:i,angle:d,sign:h,cornerRadius:o,cornerIsExternal:c}),m=f.circleTangency,g=f.lineTangency,p=f.theta,y=wx({cx:r,cy:s,radius:i,angle:u,sign:-h,cornerRadius:o,cornerIsExternal:c}),v=y.circleTangency,j=y.lineTangency,b=y.theta,_=c?Math.abs(d-u):Math.abs(d-u)-p-b;if(_<0)return l?"M ".concat(g.x,",").concat(g.y,`
722        a`).concat(o,",").concat(o,",0,0,1,").concat(o*2,`,0
723        a`).concat(o,",").concat(o,",0,0,1,").concat(-o*2,`,0
724      `):BB({cx:r,cy:s,innerRadius:a,outerRadius:i,startAngle:d,endAngle:u});var w="M ".concat(g.x,",").concat(g.y,`
725    A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(m.x,",").concat(m.y,`
726    A`).concat(i,",").concat(i,",0,").concat(+(_>180),",").concat(+(h<0),",").concat(v.x,",").concat(v.y,`
727    A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(j.x,",").concat(j.y,`
728  `);if(a>0){var N=wx({cx:r,cy:s,radius:a,angle:d,sign:h,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),S=N.circleTangency,C=N.lineTangency,P=N.theta,M=wx({cx:r,cy:s,radius:a,angle:u,sign:-h,isExternal:!0,cornerRadius:o,cornerIsExternal:c}),D=M.circleTangency,A=M.lineTangency,U=M.theta,F=c?Math.abs(d-u):Math.abs(d-u)-P-U;if(F<0&&o===0)return"".concat(w,"L").concat(r,",").concat(s,"Z");w+="L".concat(A.x,",").concat(A.y,`
729      A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(D.x,",").concat(D.y,`
730      A`).concat(a,",").concat(a,",0,").concat(+(F>180),",").concat(+(h>0),",").concat(S.x,",").concat(S.y,`
731      A`).concat(o,",").concat(o,",0,0,").concat(+(h<0),",").concat(C.x,",").concat(C.y,"Z")}else w+="L".concat(r,",").concat(s,"Z");return w},NSe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},qB=function(t){var r=FM(FM({},NSe),t),s=r.cx,a=r.cy,i=r.innerRadius,o=r.outerRadius,l=r.cornerRadius,c=r.forceCornerRadius,d=r.cornerIsExternal,u=r.startAngle,h=r.endAngle,f=r.className;if(o<i||u===h)return null;var m=It("recharts-sector",f),g=o-i,p=Nd(l,g,0,!0),y;return p>0&&Math.abs(u-h)<360?y=_Se({cx:s,cy:a,innerRadius:i,outerRadius:o,cornerRadius:Math.min(p,g/2),forceCornerRadius:c,cornerIsExternal:d,startAngle:u,endAngle:h}):y=BB({cx:s,cy:a,innerRadius:i,outerRadius:o,startAngle:u,endAngle:h}),G.createElement("path",E1({},$t(r,!0),{className:m,d:y,role:"img"}))};function Pp(e){"@babel/helpers - typeof";return Pp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Pp(e)}function O1(){return O1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},O1.apply(this,arguments)}function UM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function zM(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?UM(Object(r),!0).forEach(function(s){SSe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):UM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function SSe(e,t,r){return t=CSe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function CSe(e){var t=kSe(e,"string");return Pp(t)=="symbol"?t:t+""}function kSe(e,t){if(Pp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Pp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var BM={curveBasisClosed:She,curveBasisOpen:Che,curveBasis:Nhe,curveBumpX:dhe,curveBumpY:uhe,curveLinearClosed:khe,curveLinear:Cj,curveMonotoneX:Phe,curveMonotoneY:The,curveNatural:Ahe,curveStep:Ehe,curveStepAfter:Mhe,curveStepBefore:Ohe},_x=function(t){return t.x===+t.x&&t.y===+t.y},zf=function(t){return t.x},Bf=function(t){return t.y},PSe=function(t,r){if(_t(t))return t;var s="curve".concat(Nj(t));return(s==="curveMonotone"||s==="curveBump")&&r?BM["".concat(s).concat(r==="vertical"?"Y":"X")]:BM[s]||Cj},TSe=function(t){var r=t.type,s=r===void 0?"linear":r,a=t.points,i=a===void 0?[]:a,o=t.baseLine,l=t.layout,c=t.connectNulls,d=c===void 0?!1:c,u=PSe(s,l),h=d?i.filter(function(p){return _x(p)}):i,f;if(Array.isArray(o)){var m=d?o.filter(function(p){return _x(p)}):o,g=h.map(function(p,y){return zM(zM({},p),{},{base:m[y]})});return l==="vertical"?f=fx().y(Bf).x1(zf).x0(function(p){return p.base.x}):f=fx().x(zf).y1(Bf).y0(function(p){return p.base.y}),f.defined(_x).curve(u),f(g)}return l==="vertical"&&Be(o)?f=fx().y(Bf).x1(zf).x0(o):Be(o)?f=fx().x(zf).y1(Bf).y0(o):f=qU().x(zf).y(Bf),f.defined(_x).curve(u),f(h)},M1=function(t){var r=t.className,s=t.points,a=t.path,i=t.pathRef;if((!s||!s.length)&&!a)return null;var o=s&&s.length?TSe(t):a;return x.createElement("path",O1({},$t(t,!1),ny(t),{className:It("recharts-curve",r),d:o,ref:i}))},WB={exports:{}},ASe="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED",ESe=ASe,OSe=ESe;function HB(){}function VB(){}VB.resetWarningCache=HB;var MSe=function(){function e(s,a,i,o,l,c){if(c!==OSe){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}e.isRequired=e;function t(){return e}var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:VB,resetWarningCache:HB};return r.PropTypes=r,r};WB.exports=MSe();var DSe=WB.exports;const tr=fr(DSe);var RSe=Object.getOwnPropertyNames,$Se=Object.getOwnPropertySymbols,ISe=Object.prototype.hasOwnProperty;function qM(e,t){return function(s,a,i){return e(s,a,i)&&t(s,a,i)}}function Nx(e){return function(r,s,a){if(!r||!s||typeof r!="object"||typeof s!="object")return e(r,s,a);var i=a.cache,o=i.get(r),l=i.get(s);if(o&&l)return o===s&&l===r;i.set(r,s),i.set(s,r);var c=e(r,s,a);return i.delete(r),i.delete(s),c}}function WM(e){return RSe(e).concat($Se(e))}var LSe=Object.hasOwn||function(e,t){return ISe.call(e,t)};function Id(e,t){return e===t||!e&&!t&&e!==e&&t!==t}var FSe="__v",USe="__o",zSe="_owner",HM=Object.getOwnPropertyDescriptor,VM=Object.keys;function BSe(e,t,r){var s=e.length;if(t.length!==s)return!1;for(;s-- >0;)if(!r.equals(e[s],t[s],s,s,e,t,r))return!1;return!0}function qSe(e,t){return Id(e.getTime(),t.getTime())}function WSe(e,t){return e.name===t.name&&e.message===t.message&&e.cause===t.cause&&e.stack===t.stack}function HSe(e,t){return e===t}function KM(e,t,r){var s=e.size;if(s!==t.size)return!1;if(!s)return!0;for(var a=new Array(s),i=e.entries(),o,l,c=0;(o=i.next())&&!o.done;){for(var d=t.entries(),u=!1,h=0;(l=d.next())&&!l.done;){if(a[h]){h++;continue}var f=o.value,m=l.value;if(r.equals(f[0],m[0],c,h,e,t,r)&&r.equals(f[1],m[1],f[0],m[0],e,t,r)){u=a[h]=!0;break}h++}if(!u)return!1;c++}return!0}var VSe=Id;function KSe(e,t,r){var s=VM(e),a=s.length;if(VM(t).length!==a)return!1;for(;a-- >0;)if(!KB(e,t,r,s[a]))return!1;return!0}function qf(e,t,r){var s=WM(e),a=s.length;if(WM(t).length!==a)return!1;for(var i,o,l;a-- >0;)if(i=s[a],!KB(e,t,r,i)||(o=HM(e,i),l=HM(t,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function GSe(e,t){return Id(e.valueOf(),t.valueOf())}function YSe(e,t){return e.source===t.source&&e.flags===t.flags}function GM(e,t,r){var s=e.size;if(s!==t.size)return!1;if(!s)return!0;for(var a=new Array(s),i=e.values(),o,l;(o=i.next())&&!o.done;){for(var c=t.values(),d=!1,u=0;(l=c.next())&&!l.done;){if(!a[u]&&r.equals(o.value,l.value,o.value,l.value,e,t,r)){d=a[u]=!0;break}u++}if(!d)return!1}return!0}function QSe(e,t){var r=e.length;if(t.length!==r)return!1;for(;r-- >0;)if(e[r]!==t[r])return!1;return!0}function XSe(e,t){return e.hostname===t.hostname&&e.pathname===t.pathname&&e.protocol===t.protocol&&e.port===t.port&&e.hash===t.hash&&e.username===t.username&&e.password===t.password}function KB(e,t,r,s){return(s===zSe||s===USe||s===FSe)&&(e.$$typeof||t.$$typeof)?!0:LSe(t,s)&&r.equals(e[s],t[s],s,s,e,t,r)}var ZSe="[object Arguments]",JSe="[object Boolean]",eCe="[object Date]",tCe="[object Error]",rCe="[object Map]",nCe="[object Number]",
731sCe="[object Object]",aCe="[object RegExp]",iCe="[object Set]",oCe="[object String]",lCe="[object URL]",cCe=Array.isArray,YM=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,QM=Object.assign,dCe=Object.prototype.toString.call.bind(Object.prototype.toString);function uCe(e){var t=e.areArraysEqual,r=e.areDatesEqual,s=e.areErrorsEqual,a=e.areFunctionsEqual,i=e.areMapsEqual,o=e.areNumbersEqual,l=e.areObjectsEqual,c=e.arePrimitiveWrappersEqual,d=e.areRegExpsEqual,u=e.areSetsEqual,h=e.areTypedArraysEqual,f=e.areUrlsEqual;return function(g,p,y){if(g===p)return!0;if(g==null||p==null)return!1;var v=typeof g;if(v!==typeof p)return!1;if(v!=="object")return v==="number"?o(g,p,y):v==="function"?a(g,p,y):!1;var j=g.constructor;if(j!==p.constructor)return!1;if(j===Object)return l(g,p,y);if(cCe(g))return t(g,p,y);if(YM!=null&&YM(g))return h(g,p,y);if(j===Date)return r(g,p,y);if(j===RegExp)return d(g,p,y);if(j===Map)return i(g,p,y);if(j===Set)return u(g,p,y);var b=dCe(g);return b===eCe?r(g,p,y):b===aCe?d(g,p,y):b===rCe?i(g,p,y):b===iCe?u(g,p,y):b===sCe?typeof g.then!="function"&&typeof p.then!="function"&&l(g,p,y):b===lCe?f(g,p,y):b===tCe?s(g,p,y):b===ZSe?l(g,p,y):b===JSe||b===nCe||b===oCe?c(g,p,y):!1}}function hCe(e){var t=e.circular,r=e.createCustomConfig,s=e.strict,a={areArraysEqual:s?qf:BSe,areDatesEqual:qSe,areErrorsEqual:WSe,areFunctionsEqual:HSe,areMapsEqual:s?qM(KM,qf):KM,areNumbersEqual:VSe,areObjectsEqual:s?qf:KSe,arePrimitiveWrappersEqual:GSe,areRegExpsEqual:YSe,areSetsEqual:s?qM(GM,qf):GM,areTypedArraysEqual:s?qf:QSe,areUrlsEqual:XSe};if(r&&(a=QM({},a,r(a))),t){var i=Nx(a.areArraysEqual),o=Nx(a.areMapsEqual),l=Nx(a.areObjectsEqual),c=Nx(a.areSetsEqual);a=QM({},a,{areArraysEqual:i,areMapsEqual:o,areObjectsEqual:l,areSetsEqual:c})}return a}function fCe(e){return function(t,r,s,a,i,o,l){return e(t,r,l)}}function mCe(e){var t=e.circular,r=e.comparator,s=e.createState,a=e.equals,i=e.strict;if(s)return function(c,d){var u=s(),h=u.cache,f=h===void 0?t?new WeakMap:void 0:h,m=u.meta;return r(c,d,{cache:f,equals:a,meta:m,strict:i})};if(t)return function(c,d){return r(c,d,{cache:new WeakMap,equals:a,meta:void 0,strict:i})};var o={cache:void 0,equals:a,meta:void 0,strict:i};return function(c,d){return r(c,d,o)}}var pCe=yc();yc({strict:!0});yc({circular:!0});yc({circular:!0,strict:!0});yc({createInternalComparator:function(){return Id}});yc({strict:!0,createInternalComparator:function(){return Id}});yc({circular:!0,createInternalComparator:function(){return Id}});yc({circular:!0,createInternalComparator:function(){return Id},strict:!0});function yc(e){e===void 0&&(e={});var t=e.circular,r=t===void 0?!1:t,s=e.createInternalComparator,a=e.createState,i=e.strict,o=i===void 0?!1:i,l=hCe(e),c=uCe(l),d=s?s(c):fCe(c);return mCe({circular:r,comparator:c,createState:a,equals:d,strict:o})}function gCe(e){typeof requestAnimationFrame<"u"&&requestAnimationFrame(e)}function XM(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=-1,s=function a(i){r<0&&(r=i),i-r>t?(e(i),r=-1):gCe(a)};requestAnimationFrame(s)}function D1(e){"@babel/helpers - typeof";return D1=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D1(e)}function xCe(e){return bCe(e)||jCe(e)||yCe(e)||vCe()}function vCe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
732In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yCe(e,t){if(e){if(typeof e=="string")return ZM(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ZM(e,t)}}function ZM(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function jCe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function bCe(e){if(Array.isArray(e))return e}function wCe(){var e={},t=function(){return null},r=!1,s=function a(i){if(!r){if(Array.isArray(i)){if(!i.length)return;var o=i,l=xCe(o),c=l[0],d=l.slice(1);if(typeof c=="number"){XM(a.bind(null,d),c);return}a(c),XM(a.bind(null,d));return}D1(i)==="object"&&(e=i,t(e)),typeof i=="function"&&i()}};return{stop:function(){r=!0},start:function(i){r=!1,s(i)},subscribe:function(i){return t=i,function(){t=function(){return null}}}}}function Tp(e){"@babel/helpers - typeof";return Tp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tp(e)}function JM(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function e4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};
vendor: 161,005 bytes, lines 732-754
732t%2?JM(Object(r),!0).forEach(function(s){GB(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):JM(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function GB(e,t,r){return t=_Ce(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _Ce(e){var t=NCe(e,"string");return Tp(t)==="symbol"?t:String(t)}function NCe(e,t){if(Tp(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Tp(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var SCe=function(t,r){return[Object.keys(t),Object.keys(r)].reduce(function(s,a){return s.filter(function(i){return a.includes(i)})})},CCe=function(t){return t},kCe=function(t){return t.replace(/([A-Z])/g,function(r){return"-".concat(r.toLowerCase())})},Cm=function(t,r){return Object.keys(r).reduce(function(s,a){return e4(e4({},s),{},GB({},a,t(a,r[a])))},{})},t4=function(t,r,s){return t.map(function(a){return"".concat(kCe(a)," ").concat(r,"ms ").concat(s)}).join(",")};function PCe(e,t){return ECe(e)||ACe(e,t)||YB(e,t)||TCe()}function TCe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
733In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ACe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function ECe(e){if(Array.isArray(e))return e}function OCe(e){return RCe(e)||DCe(e)||YB(e)||MCe()}function MCe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
734In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function YB(e,t){if(e){if(typeof e=="string")return R1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return R1(e,t)}}function DCe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function RCe(e){if(Array.isArray(e))return R1(e)}function R1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}var Ry=1e-4,QB=function(t,r){return[0,3*t,3*r-6*t,3*t-3*r+1]},XB=function(t,r){return t.map(function(s,a){return s*Math.pow(r,a)}).reduce(function(s,a){return s+a})},r4=function(t,r){return function(s){var a=QB(t,r);return XB(a,s)}},$Ce=function(t,r){return function(s){var a=QB(t,r),i=[].concat(OCe(a.map(function(o,l){return o*l}).slice(1)),[0]);return XB(i,s)}},n4=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];var a=r[0],i=r[1],o=r[2],l=r[3];if(r.length===1)switch(r[0]){case"linear":a=0,i=0,o=1,l=1;break;case"ease":a=.25,i=.1,o=.25,l=1;break;case"ease-in":a=.42,i=0,o=1,l=1;break;case"ease-out":a=.42,i=0,o=.58,l=1;break;case"ease-in-out":a=0,i=0,o=.58,l=1;break;default:{var c=r[0].split("(");if(c[0]==="cubic-bezier"&&c[1].split(")")[0].split(",").length===4){var d=c[1].split(")")[0].split(",").map(function(y){return parseFloat(y)}),u=PCe(d,4);a=u[0],i=u[1],o=u[2],l=u[3]}}}var h=r4(a,o),f=r4(i,l),m=$Ce(a,o),g=function(v){return v>1?1:v<0?0:v},p=function(v){for(var j=v>1?1:v,b=j,_=0;_<8;++_){var w=h(b)-j,N=m(b);if(Math.abs(w-j)<Ry||N<Ry)return f(b);b=g(b-w/N)}return f(b)};return p.isStepper=!1,p},ICe=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=t.stiff,s=r===void 0?100:r,a=t.damping,i=a===void 0?8:a,o=t.dt,l=o===void 0?17:o,c=function(u,h,f){var m=-(u-h)*s,g=f*i,p=f+(m-g)*l/1e3,y=f*l/1e3+u;return Math.abs(y-h)<Ry&&Math.abs(p)<Ry?[h,0]:[y,p]};return c.isStepper=!0,c.dt=l,c},LCe=function(){for(var t=arguments.length,r=new Array(t),s=0;s<t;s++)r[s]=arguments[s];var a=r[0];if(typeof a=="string")switch(a){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return n4(a);case"spring":return ICe();default:if(a.split("(")[0]==="cubic-bezier")return n4(a)}return typeof a=="function"?a:null};function Ap(e){"@babel/helpers - typeof";return Ap=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ap(e)}function s4(e){return zCe(e)||UCe(e)||ZB(e)||FCe()}function FCe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
735In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function UCe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function zCe(e){if(Array.isArray(e))return I1(e)}function a4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Mn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?a4(Object(r),!0).forEach(function(s){$1(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function $1(e,t,r){return t=BCe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function BCe(e){var t=qCe(e,"string");return Ap(t)==="symbol"?t:String(t)}function qCe(e,t){if(Ap(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Ap(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function WCe(e,t){return KCe(e)||VCe(e,t)||ZB(e,t)||HCe()}function HCe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
736In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ZB(e,t){if(e){if(typeof e=="string")return I1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return I1(e,t)}}function I1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function VCe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function KCe(e){if(Array.isArray(e))return e}var $y=function(t,r,s){return t+(r-t)*s},L1=function(t){var r=t.from,s=t.to;return r!==s},GCe=function e(t,r,s){var a=Cm(function(i,o){if(L1(o)){var l=t(o.from,o.to,o.velocity),c=WCe(l,2),d=c[0],u=c[1];return Mn(Mn({},o),{},{from:d,velocity:u})}return o},r);return s<1?Cm(function(i,o){return L1(o)?Mn(Mn({},o),{},{velocity:$y(o.velocity,a[i].velocity,s),from:$y(o.from,a[i].from,s)}):o},r):e(t,a,s-1)};const YCe=function(e,t,r,s,a){var i=SCe(e,t),o=i.reduce(function(y,v){return Mn(Mn({},y),{},$1({},v,[e[v],t[v]]))},{}),l=i.reduce(function(y,v){return Mn(Mn({},y),{},$1({},v,{from:e[v],velocity:0,to:t[v]}))},{}),c=-1,d,u,h=function(){return null},f=function(){return Cm(function(v,j){return j.from},l)},m=function(){return!Object.values(l).filter(L1).length},g=function(v){d||(d=v);var j=v-d,b=j/r.dt;l=GCe(r,l,b),a(Mn(Mn(Mn({},e),t),f())),d=v,m()||(c=requestAnimationFrame(h))},p=function(v){u||(u=v);var j=(v-u)/s,b=Cm(function(w,N){return $y.apply(void 0,s4(N).concat([r(j)]))},o);if(a(Mn(Mn(Mn({},e),t),b)),j<1)c=requestAnimationFrame(h);else{var _=Cm(function(w,N){return $y.apply(void 0,s4(N).concat([r(1)]))},o);a(Mn(Mn(Mn({},e),t),_))}};return h=r.isStepper?g:p,function(){return requestAnimationFrame(h),function(){cancelAnimationFrame(c)}}};function _h(e){"@babel/helpers - typeof";return _h=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_h(e)}var QCe=["children","begin","duration","attributeName","easing","isActive","steps","from","to","canBegin","onAnimationEnd","shouldReAnimate","onAnimationReStart"];function XCe(e,t){if(e==null)return{};var r=ZCe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function ZCe(e,t){if(e==null)return{};var r={},s=Object.keys(e),a,i;for(i=0;i<s.length;i++)a=s[i],!(t.indexOf(a)>=0)&&(r[a]=e[a]);return r}function Rw(e){return rke(e)||tke(e)||eke(e)||JCe()}function JCe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
737In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function eke(e,t){if(e){if(typeof e=="string")return F1(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return F1(e,t)}}function tke(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function rke(e){if(Array.isArray(e))return F1(e)}function F1(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function i4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function za(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?i4(Object(r),!0).forEach(function(s){am(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function am(e,t,r){return t=JB(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nke(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ske(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,JB(s.key),s)}}function ake(e,t,r){return t&&ske(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function JB(e){var t=ike(e,"string");return _h(t)==="symbol"?t:String(t)}function ike(e,t){if(_h(e)!=="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(_h(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function oke(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&U1(e,t)}function U1(e,t){return U1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},U1(e,t)}function lke(e){var t=cke();return function(){var s=Iy(e),a;if(t){var i=Iy(this).constructor;a=Reflect.construct(s,arguments,i)}else a=s.apply(this,arguments);return z1(this,a)}}function z1(e,t){if(t&&(_h(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return B1(e)}function B1(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function cke(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Iy(e){return Iy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Iy(e)}var Ko=function(e){oke(r,e);var t=lke(r);function r(s,a){var i;nke(this,r),i=t.call(this,s,a);var o=i.props,l=o.isActive,c=o.attributeName,d=o.from,u=o.to,h=o.steps,f=o.children,m=o.duration;if(i.handleStyleChange=i.handleStyleChange.bind(B1(i)),i.changeStyle=i.changeStyle.bind(B1(i)),!l||m<=0)return i.state={style:{}},typeof f=="function"&&(i.state={style:u}),z1(i);if(h&&h.length)i.state={style:h[0].style};else if(d){if(typeof f=="function")return i.state={style:d},z1(i);i.state={style:c?am({},c,d):d}}else i.state={style:{}};return i}return ake(r,[{key:"componentDidMount",value:function(){var a=this.props,i=a.isActive,o=a.canBegin;this.mounted=!0,!(!i||!o)&&this.runAnimation(this.props)}},{key:"componentDidUpdate",value:function(a){var i=this.props,o=i.isActive,l=i.canBegin,c=i.attributeName,d=i.shouldReAnimate,u=i.to,h=i.from,f=this.state.style;if(l){if(!o){var m={style:c?am({},c,u):u};this.state&&f&&(c&&f[c]!==u||!c&&f!==u)&&this.setState(m);return}if(!(pCe(a.to,u)&&a.canBegin&&a.isActive)){var g=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var p=g||d?h:a.to;if(this.state&&f){var y={style:c?am({},c,p):p};(c&&f[c]!==p||!c&&f!==p)&&this.setState(y)}this.runAnimation(za(za({},this.props),{},{from:p,begin:0}))}}}},{key:"componentWillUnmount",value:function(){this.mounted=!1;var a=this.props.onAnimationEnd;this.unSubscribe&&this.unSubscribe(),this.manager&&(this.manager.stop(),this.manager=null),this.stopJSAnimation&&this.stopJSAnimation(),a&&a()}},{key:"handleStyleChange",value:function(a){this.changeStyle(a)}},{key:"changeStyle",value:function(a){this.mounted&&this.setState({style:a})}},{key:"runJSAnimation",value:function(a){var i=this,o=a.from,l=a.to,c=a.duration,d=a.easing,u=a.begin,h=a.onAnimationEnd,f=a.onAnimationStart,m=YCe(o,l,LCe(d),c,this.changeStyle),g=function(){i.stopJSAnimation=m()};this.manager.start([f,u,g,c,h])}},{key:"runStepAnimation",value:function(a){var i=this,o=a.steps,l=a.begin,c=a.onAnimationStart,d=o[0],u=d.style,h=d.duration,f=h===void 0?0:h,m=function(p,y,v){if(v===0)return p;var j=y.duration,b=y.easing,_=b===void 0?"ease":b,w=y.style,N=y.properties,S=y.onAnimationEnd,C=v>0?o[v-1]:y,P=N||Object.keys(w);if(typeof _=="function"||_==="spring")return[].concat(Rw(p),[i.runJSAnimation.bind(i,{from:C.style,to:w,duration:j,easing:_}),j]);var M=t4(P,j,_),D=za(za(za({},C.style),w),{},{transition:M});return[].concat(Rw(p),[D,j,S]).filter(CCe)};return this.manager.start([c].concat(Rw(o.reduce(m,[u,Math.max(f,l)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=wCe());var i=a.begin,o=a.duration,l=a.attributeName,c=a.to,d=a.easing,u=a.onAnimationStart,h=a.onAnimationEnd,f=a.steps,m=a.children,g=this.manager;if(this.unSubscribe=g.subscribe(this.handleStyleChange),typeof d=="function"||typeof m=="function"||d==="spring"){this.runJSAnimation(a);return}if(f.length>1){this.runStepAnimation(a);return}var p=l?am({},l,c):c,y=t4(Object.keys(p),o,d);g.start([u,i,za(za({},p),{},{transition:y}),o,h])}},{key:"render",value:function(){var a=this.props,i=a.children;a.begin;var o=a.duration;a.attributeName,a.easing;var l=a.isActive;a.steps,a.from,a.to,a.canBegin,a.onAnimationEnd,a.shouldReAnimate,a.onAnimationReStart;var c=XCe(a,QCe),d=x.Children.count(i),u=this.state.style;if(typeof i=="function")return i(u);if(!l||d===0||o<=0)return i;var h=function(m){var g=m.props,p=g.style,y=p===void 0?{}:p,v=g.className,j=x.cloneElement(m,za(za({},c),{},{style:za(za({},y),u),className:v}));return j};return d===1?h(x.Children.only(i)):G.createElement("div",null,x.Children.map(i,function(f){return h(f)}))}}]),r}(x.PureComponent);Ko.displayName="Animate";Ko.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};Ko.propTypes={from:tr.oneOfType([tr.object,tr.string]),to:tr.oneOfType([tr.object,tr.string]),attributeName:tr.string,duration:tr.number,begin:tr.number,easing:tr.oneOfType([tr.string,tr.func]),steps:tr.arrayOf(tr.shape({duration:tr.number.isRequired,style:tr.object.isRequired,easing:tr.oneOfType([tr.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),tr.func]),properties:tr.arrayOf("string"),onAnimationEnd:tr.func})),children:tr.oneOfType([tr.node,tr.func]),isActive:tr.bool,canBegin:tr.bool,onAnimationEnd:tr.func,shouldReAnimate:tr.bool,onAnimationStart:tr.func,onAnimationReStart:tr.func};function Ep(e){"@babel/helpers - typeof";return Ep=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ep(e)}function Ly(){return Ly=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Ly.apply(this,arguments)}function dke(e,t){return mke(e)||fke(e,t)||hke(e,t)||uke()}function uke(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
738In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hke(e,t){if(e){if(typeof e=="string")return o4(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o4(e,t)}}function o4(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function fke(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function mke(e){if(Array.isArray(e))return e}function l4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function c4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?l4(Object(r),!0).forEach(function(s){pke(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function pke(e,t,r){return t=gke(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function gke(e){var t=xke(e,"string");return Ep(t)=="symbol"?t:t+""}function xke(e,t){if(Ep(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Ep(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var d4=function(t,r,s,a,i){var o=Math.min(Math.abs(s)/2,Math.abs(a)/2),l=a>=0?1:-1,c=s>=0?1:-1,d=a>=0&&s>=0||a<0&&s<0?1:0,u;if(o>0&&i instanceof Array){for(var h=[0,0,0,0],f=0,m=4;f<m;f++)h[f]=i[f]>o?o:i[f];u="M".concat(t,",").concat(r+l*h[0]),h[0]>0&&(u+="A ".concat(h[0],",").concat(h[0],",0,0,").concat(d,",").concat(t+c*h[0],",").concat(r)),u+="L ".concat(t+s-c*h[1],",").concat(r),h[1]>0&&(u+="A ".concat(h[1],",").concat(h[1],",0,0,").concat(d,`,
739        `).concat(t+s,",").concat(r+l*h[1])),u+="L ".concat(t+s,",").concat(r+a-l*h[2]),h[2]>0&&(u+="A ".concat(h[2],",").concat(h[2],",0,0,").concat(d,`,
740        `).concat(t+s-c*h[2],",").concat(r+a)),u+="L ".concat(t+c*h[3],",").concat(r+a),h[3]>0&&(u+="A ".concat(h[3],",").concat(h[3],",0,0,").concat(d,`,
741        `).concat(t,",").concat(r+a-l*h[3])),u+="Z"}else if(o>0&&i===+i&&i>0){var g=Math.min(o,i);u="M ".concat(t,",").concat(r+l*g,`
742            A `).concat(g,",").concat(g,",0,0,").concat(d,",").concat(t+c*g,",").concat(r,`
743            L `).concat(t+s-c*g,",").concat(r,`
744            A `).concat(g,",").concat(g,",0,0,").concat(d,",").concat(t+s,",").concat(r+l*g,`
745            L `).concat(t+s,",").concat(r+a-l*g,`
746            A `).concat(g,",").concat(g,",0,0,").concat(d,",").concat(t+s-c*g,",").concat(r+a,`
747            L `).concat(t+c*g,",").concat(r+a,`
748            A `).concat(g,",").concat(g,",0,0,").concat(d,",").concat(t,",").concat(r+a-l*g," Z")}else u="M ".concat(t,",").concat(r," h ").concat(s," v ").concat(a," h ").concat(-s," Z");return u},vke=function(t,r){if(!t||!r)return!1;var s=t.x,a=t.y,i=r.x,o=r.y,l=r.width,c=r.height;if(Math.abs(l)>0&&Math.abs(c)>0){var d=Math.min(i,i+l),u=Math.max(i,i+l),h=Math.min(o,o+c),f=Math.max(o,o+c);return s>=d&&s<=u&&a>=h&&a<=f}return!1},yke={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},N2=function(t){var r=c4(c4({},yke),t),s=x.useRef(),a=x.useState(-1),i=dke(a,2),o=i[0],l=i[1];x.useEffect(function(){if(s.current&&s.current.getTotalLength)try{var _=s.current.getTotalLength();_&&l(_)}catch{}},[]);var c=r.x,d=r.y,u=r.width,h=r.height,f=r.radius,m=r.className,g=r.animationEasing,p=r.animationDuration,y=r.animationBegin,v=r.isAnimationActive,j=r.isUpdateAnimationActive;if(c!==+c||d!==+d||u!==+u||h!==+h||u===0||h===0)return null;var b=It("recharts-rectangle",m);return j?G.createElement(Ko,{canBegin:o>0,from:{width:u,height:h,x:c,y:d},to:{width:u,height:h,x:c,y:d},duration:p,animationEasing:g,isActive:j},function(_){var w=_.width,N=_.height,S=_.x,C=_.y;return G.createElement(Ko,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:y,duration:p,isActive:v,easing:g},G.createElement("path",Ly({},$t(r,!0),{className:b,d:d4(S,C,w,N,f),ref:s})))}):G.createElement("path",Ly({},$t(r,!0),{className:b,d:d4(c,d,u,h,f)}))};function q1(){return q1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},q1.apply(this,arguments)}var S2=function(t){var r=t.cx,s=t.cy,a=t.r,i=t.className,o=It("recharts-dot",i);return r===+r&&s===+s&&a===+a?x.createElement("circle",q1({},$t(t,!1),ny(t),{className:o,cx:r,cy:s,r:a})):null};function Op(e){"@babel/helpers - typeof";return Op=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Op(e)}var jke=["x","y","top","left","width","height","className"];function W1(){return W1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},W1.apply(this,arguments)}function u4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function bke(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?u4(Object(r),!0).forEach(function(s){wke(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function wke(e,t,r){return t=_ke(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _ke(e){var t=Nke(e,"string");return Op(t)=="symbol"?t:t+""}function Nke(e,t){if(Op(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Op(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ske(e,t){if(e==null)return{};var r=Cke(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function Cke(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var kke=function(t,r,s,a,i,o){return"M".concat(t,",").concat(i,"v").concat(a,"M").concat(o,",").concat(r,"h").concat(s)},Pke=function(t){var r=t.x,s=r===void 0?0:r,a=t.y,i=a===void 0?0:a,o=t.top,l=o===void 0?0:o,c=t.left,d=c===void 0?0:c,u=t.width,h=u===void 0?0:u,f=t.height,m=f===void 0?0:f,g=t.className,p=Ske(t,jke),y=bke({x:s,y:i,top:l,left:d,width:h,height:m},p);return!Be(s)||!Be(i)||!Be(h)||!Be(m)||!Be(l)||!Be(d)?null:G.createElement("path",W1({},$t(y,!0),{className:It("recharts-cross",g),d:kke(s,i,h,m,l,d)}))},Tke=fz,Ake=Tke(Object.getPrototypeOf,Object),Eke=Ake,Oke=el,Mke=Eke,Dke=tl,Rke="[object Object]",$ke=Function.prototype,Ike=Object.prototype,eq=$ke.toString,Lke=Ike.hasOwnProperty,Fke=eq.call(Object);function Uke(e){if(!Dke(e)||Oke(e)!=Rke)return!1;var t=Mke(e);if(t===null)return!0;var r=Lke.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&eq.call(r)==Fke}var zke=Uke;const Bke=fr(zke);var qke=el,Wke=tl,Hke="[object Boolean]";function Vke(e){return e===!0||e===!1||Wke(e)&&qke(e)==Hke}var Kke=Vke;const Gke=fr(Kke);function Mp(e){"@babel/helpers - typeof";return Mp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mp(e)}function Fy(){return Fy=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Fy.apply(this,arguments)}function Yke(e,t){return Jke(e)||Zke(e,t)||Xke(e,t)||Qke()}function Qke(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
749In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Xke(e,t){if(e){if(typeof e=="string")return h4(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return h4(e,t)}}function h4(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function Zke(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function Jke(e){if(Array.isArray(e))return e}function f4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function m4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?f4(Object(r),!0).forEach(function(s){e2e(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function e2e(e,t,r){return t=t2e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t2e(e){var t=r2e(e,"string");return Mp(t)=="symbol"?t:t+""}function r2e(e,t){if(Mp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Mp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var p4=function(t,r,s,a,i){var o=s-a,l;return l="M ".concat(t,",").concat(r),l+="L ".concat(t+s,",").concat(r),l+="L ".concat(t+s-o/2,",").concat(r+i),l+="L ".concat(t+s-o/2-a,",").concat(r+i),l+="L ".concat(t,",").concat(r," Z"),l},n2e={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},s2e=function(t){var r=m4(m4({},n2e),t),s=x.useRef(),a=x.useState(-1),i=Yke(a,2),o=i[0],l=i[1];x.useEffect(function(){if(s.current&&s.current.getTotalLength)try{var b=s.current.getTotalLength();b&&l(b)}catch{}},[]);var c=r.x,d=r.y,u=r.upperWidth,h=r.lowerWidth,f=r.height,m=r.className,g=r.animationEasing,p=r.animationDuration,y=r.animationBegin,v=r.isUpdateAnimationActive;if(c!==+c||d!==+d||u!==+u||h!==+h||f!==+f||u===0&&h===0||f===0)return null;var j=It("recharts-trapezoid",m);return v?G.createElement(Ko,{canBegin:o>0,from:{upperWidth:0,lowerWidth:0,height:f,x:c,y:d},to:{upperWidth:u,lowerWidth:h,height:f,x:c,y:d},duration:p,animationEasing:g,isActive:v},function(b){var _=b.upperWidth,w=b.lowerWidth,N=b.height,S=b.x,C=b.y;return G.createElement(Ko,{canBegin:o>0,from:"0px ".concat(o===-1?1:o,"px"),to:"".concat(o,"px 0px"),attributeName:"strokeDasharray",begin:y,duration:p,easing:g},G.createElement("path",Fy({},$t(r,!0),{className:j,d:p4(S,C,_,w,N),ref:s})))}):G.createElement("g",null,G.createElement("path",Fy({},$t(r,!0),{className:j,d:p4(c,d,u,h,f)})))},a2e=["option","shapeType","propTransformer","activeClassName","isActive"];function Dp(e){"@babel/helpers - typeof";return Dp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dp(e)}function i2e(e,t){if(e==null)return{};var r=o2e(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function o2e(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function g4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Uy(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?g4(Object(r),!0).forEach(function(s){l2e(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function l2e(e,t,r){return t=c2e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c2e(e){var t=d2e(e,"string");return Dp(t)=="symbol"?t:t+""}function d2e(e,t){if(Dp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Dp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function u2e(e,t){return Uy(Uy({},t),e)}function h2e(e,t){return e==="symbols"}function x4(e){var t=e.shapeType,r=e.elementProps;switch(t){case"rectangle":return G.createElement(N2,r);case"trapezoid":return G.createElement(s2e,r);case"sector":return G.createElement(qB,r);case"symbols":if(h2e(t))return G.createElement(qk,r);break;default:return null}}function f2e(e){return x.isValidElement(e)?e.props:e}function m2e(e){var t=e.option,r=e.shapeType,s=e.propTransformer,a=s===void 0?u2e:s,i=e.activeClassName,o=i===void 0?"recharts-active-shape":i,l=e.isActive,c=i2e(e,a2e),d;if(x.isValidElement(t))d=x.cloneElement(t,Uy(Uy({},c),f2e(t)));else if(_t(t))d=t(c);else if(Bke(t)&&!Gke(t)){var u=a(t,c);d=G.createElement(x4,{shapeType:r,elementProps:u})}else{var h=c;d=G.createElement(x4,{shapeType:r,elementProps:h})}return l?G.createElement(en,{className:o},d):d}function Bj(e,t){return t!=null&&"trapezoids"in e.props}function qj(e,t){return t!=null&&"sectors"in e.props}function Rp(e,t){return t!=null&&"points"in e.props}function p2e(e,t){var r,s,a=e.x===(t==null||(r=t.labelViewBox)===null||r===void 0?void 0:r.x)||e.x===t.x,i=e.y===(t==null||(s=t.labelViewBox)===null||s===void 0?void 0:s.y)||e.y===t.y;return a&&i}function g2e(e,t){var r=e.endAngle===t.endAngle,s=e.startAngle===t.startAngle;return r&&s}function x2e(e,t){var r=e.x===t.x,s=e.y===t.y,a=e.z===t.z;return r&&s&&a}function v2e(e,t){var r;return Bj(e,t)?r=p2e:qj(e,t)?r=g2e:Rp(e,t)&&(r=x2e),r}function y2e(e,t){var r;return Bj(e,t)?r="trapezoids":qj(e,t)?r="sectors":Rp(e,t)&&(r="points"),r}function j2e(e,t){if(Bj(e,t)){var r;return(r=t.tooltipPayload)===null||r===void 0||(r=r[0])===null||r===void 0||(r=r.payload)===null||r===void 0?void 0:r.payload}if(qj(e,t)){var s;return(s=t.tooltipPayload)===null||s===void 0||(s=s[0])===null||s===void 0||(s=s.payload)===null||s===void 0?void 0:s.payload}return Rp(e,t)?t.payload:{}}function b2e(e){var t=e.activeTooltipItem,r=e.graphicalItem,s=e.itemData,a=y2e(r,t),i=j2e(r,t),o=s.filter(function(c,d){var u=Fj(i,c),h=r.props[a].filter(function(g){var p=v2e(r,t);return p(g,t)}),f=r.props[a].indexOf(h[h.length-1]),m=d===f;return u&&m}),l=s.indexOf(o[o.length-1]);return l}var w2e=Math.ceil,_2e=Math.max;function N2e(e,t,r,s){for(var a=-1,i=_2e(w2e((t-e)/(r||1)),0),o=Array(i);i--;)o[s?i:++a]=e,e+=r;return o}var S2e=N2e,C2e=Oz,v4=1/0,k2e=17976931348623157e292;function P2e(e){if(!e)return e===0?e:0;if(e=C2e(e),e===v4||e===-v4){var t=e<0?-1:1;return t*k2e}return e===e?e:0}var tq=P2e,T2e=S2e,A2e=Aj,$w=tq;function E2e(e){return function(t,r,s){return s&&typeof s!="number"&&A2e(t,r,s)&&(r=s=void 0),t=$w(t),r===void 0?(r=t,t=0):r=$w(r),s=s===void 0?t<r?1:-1:$w(s),T2e(t,r,s,e)}}var O2e=E2e,M2e=O2e,D2e=M2e(),R2e=D2e;const zy=fr(R2e);function $p(e){"@babel/helpers - typeof";return $p=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},$p(e)}function y4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function j4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?y4(Object(r),!0).forEach(function(s){rq(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):y4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function rq(e,t,r){return t=$2e(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function $2e(e){var t=I2e(e,"string");return $p(t)=="symbol"?t:t+""}function I2e(e,t){if($p(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if($p(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var L2e=["Webkit","Moz","O","ms"],F2e=function(t,r){var s=t.replace(/(\w)/,function(i){return i.toUpperCase()}),a=L2e.reduce(function(i,o){return j4(j4({},i),{},rq({},o+s,r))},{});return a[t]=r,a};function Nh(e){"@babel/helpers - typeof";return Nh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nh(e)}function By(){return By=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},By.apply(this,arguments)}function b4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Iw(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?b4(Object(r),!0).forEach(function(s){Ks(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function U2e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function w4(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,sq(s.key),s)}}function z2e(e,t,r){return t&&w4(e.prototype,t),r&&w4(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function B2e(e,t,r){return t=qy(t),q2e(e,nq()?Reflect.construct(t,r||[],qy(e).constructor):t.apply(e,r))}function q2e(e,t){if(t&&(Nh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return W2e(e)}function W2e(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function nq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(nq=function(){return!!e})()}function qy(e){return qy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},qy(e)}function H2e(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&H1(e,t)}function H1(e,t){return H1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},H1(e,t)}function Ks(e,t,r){return t=sq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sq(e){var t=V2e(e,"string");return Nh(t)=="symbol"?t:t+""}function V2e(e,t){if(Nh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Nh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var K2e=function(t){var r=t.data,s=t.startIndex,a=t.endIndex,i=t.x,o=t.width,l=t.travellerWidth;if(!r||!r.length)return{};var c=r.length,d=Nm().domain(zy(0,c)).range([i,i+o-l]),u=d.domain().map(function(h){return d(h)});return{isTextActive:!1,isSlideMoving:!1,isTravellerMoving:!1,isTravellerFocused:!1,startX:d(s),endX:d(a),scale:d,scaleValues:u}},_4=function(t){return t.changedTouches&&!!t.changedTouches.length},Sh=function(e){function t(r){var s;return U2e(this,t),s=B2e(this,t,[r]),Ks(s,"handleDrag",function(a){s.leaveTimer&&(clearTimeout(s.leaveTimer),s.leaveTimer=null),s.state.isTravellerMoving?s.handleTravellerMove(a):s.state.isSlideMoving&&s.handleSlideDrag(a)}),Ks(s,"handleTouchMove",function(a){a.changedTouches!=null&&a.changedTouches.length>0&&s.handleDrag(a.changedTouches[0])}),Ks(s,"handleDragEnd",function(){s.setState({isTravellerMoving:!1,isSlideMoving:!1},function(){var a=s.props,i=a.endIndex,o=a.onDragEnd,l=a.startIndex;o==null||o({endIndex:i,startIndex:l})}),s.detachDragEndListener()}),Ks(s,"handleLeaveWrapper",function(){(s.state.isTravellerMoving||s.state.isSlideMoving)&&(s.leaveTimer=window.setTimeout(s.handleDragEnd,s.props.leaveTimeOut))}),Ks(s,"handleEnterSlideOrTraveller",function(){s.setState({isTextActive:!0})}),Ks(s,"handleLeaveSlideOrTraveller",function(){s.setState({isTextActive:!1})}),Ks(s,"handleSlideDragStart",function(a){var i=_4(a)?a.changedTouches[0]:a;s.setState({isTravellerMoving:!1,isSlideMoving:!0,slideMoveStartX:i.pageX}),s.attachDragEndListener()}),s.travellerDragStartHandlers={startX:s.handleTravellerDragStart.bind(s,"startX"),endX:s.handleTravellerDragStart.bind(s,"endX")},s.state={},s}return H2e(t,e),z2e(t,[{key:"componentWillUnmount",value:function(){this.leaveTimer&&(clearTimeout(this.leaveTimer),this.leaveTimer=null),this.detachDragEndListener()}},{key:"getIndex",value:function(s){var a=s.startX,i=s.endX,o=this.state.scaleValues,l=this.props,c=l.gap,d=l.data,u=d.length-1,h=Math.min(a,i),f=Math.max(a,i),m=t.getIndexInRange(o,h),g=t.getIndexInRange(o,f);return{startIndex:m-m%c,endIndex:g===u?u:g-g%c}}},{key:"getTextOfTick",value:function(s){var a=this.props,i=a.data,o=a.tickFormatter,l=a.dataKey,c=la(i[s],l,s);return _t(o)?o(c,s):c}},{key:"attachDragEndListener",value:function(){window.addEventListener("mouseup",this.handleDragEnd,!0),window.addEventListener("touchend",this.handleDragEnd,!0),window.addEventListener("mousemove",this.handleDrag,!0)}},{key:"detachDragEndListener",value:function(){window.removeEventListener("mouseup",this.handleDragEnd,!0),window.removeEventListener("touchend",this.handleDragEnd,!0),window.removeEventListener("mousemove",this.handleDrag,!0)}},{key:"handleSlideDrag",value:function(s){var a=this.state,i=a.slideMoveStartX,o=a.startX,l=a.endX,c=this.props,d=c.x,u=c.width,h=c.travellerWidth,f=c.startIndex,m=c.endIndex,g=c.onChange,p=s.pageX-i;p>0?p=Math.min(p,d+u-h-l,d+u-h-o):p<0&&(p=Math.max(p,d-o,d-l));var y=this.getIndex({startX:o+p,endX:l+p});(y.startIndex!==f||y.endIndex!==m)&&g&&g(y),this.setState({startX:o+p,endX:l+p,slideMoveStartX:s.pageX})}},{key:"handleTravellerDragStart",value:function(s,a){var i=_4(a)?a.changedTouches[0]:a;this.setState({isSlideMoving:!1,isTravellerMoving:!0,movingTravellerId:s,brushMoveStartX:i.pageX}),this.attachDragEndListener()}},{key:"handleTravellerMove",value:function(s){var a=this.state,i=a.brushMoveStartX,o=a.movingTravellerId,l=a.endX,c=a.startX,d=this.state[o],u=this.props,h=u.x,f=u.width,m=u.travellerWidth,g=u.onChange,p=u.gap,y=u.data,v={startX:this.state.startX,endX:this.state.endX},j=s.pageX-i;j>0?j=Math.min(j,h+f-m-d):j<0&&(j=Math.max(j,h-d)),v[o]=d+j;var b=this.getIndex(v),_=b.startIndex,w=b.endIndex,N=function(){var C=y.length-1;return o==="startX"&&(l>c?_%p===0:w%p===0)||l<c&&w===C||o==="endX"&&(l>c?w%p===0:_%p===0)||l>c&&w===C};this.setState(Ks(Ks({},o,d+j),"brushMoveStartX",s.pageX),function(){g&&N()&&g(b)})}},{key:"handleTravellerMoveKeyboard",value:function(s,a){var i=this,o=this.state,l=o.scaleValues,c=o.startX,d=o.endX,u=this.state[a],h=l.indexOf(u);if(h!==-1){var f=h+s;if(!(f===-1||f>=l.length)){var m=l[f];a==="startX"&&m>=d||a==="endX"&&m<=c||this.setState(Ks({},a,m),function(){i.props.onChange(i.getIndex({startX:i.state.startX,endX:i.state.endX}))})}}}},{key:"renderBackground",value:function(){var s=this.props,a=s.x,i=s.y,o=s.width,l=s.height,c=s.fill,d=s.stroke;return G.createElement("rect",{stroke:d,fill:c,x:a,y:i,width:o,height:l})}},{key:"renderPanorama",value:function(){var s=this.props,a=s.x,i=s.y,o=s.width,l=s.height,c=s.data,d=s.children,u=s.padding,h=x.Children.only(d);return h?G.cloneElement(h,{x:a,y:i,width:o,height:l,margin:u,compact:!0,data:c}):null}},{key:"renderTravellerLayer",value:function(s,a){var i,o,l=this,c=this.props,d=c.y,u=c.travellerWidth,h=c.height,f=c.traveller,m=c.ariaLabel,g=c.data,p=c.startIndex,y=c.endIndex,v=Math.max(s,this.props.x),j=Iw(Iw({},$t(this.props,!1)),{},{x:v,y:d,width:u,height:h}),b=m||"Min value: ".concat((i=g[p])===null||i===void 0?void 0:i.name,", Max value: ").concat((o=g[y])===null||o===void 0?void 0:o.name);return G.createElement(en,{tabIndex:0,role:"slider","aria-label":b,"aria-valuenow":s,className:"recharts-brush-traveller",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.travellerDragStartHandlers[a],onTouchStart:this.travellerDragStartHandlers[a],onKeyDown:function(w){["ArrowLeft","ArrowRight"].includes(w.key)&&(w.preventDefault(),w.stopPropagation(),l.handleTravellerMoveKeyboard(w.key==="ArrowRight"?1:-1,a))},onFocus:function(){l.setState({isTravellerFocused:!0})},onBlur:function(){l.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},t.renderTraveller(f,j))}},{key:"renderSlide",value:function(s,a){var i=this.props,o=i.y,l=i.height,c=i.stroke,d=i.travellerWidth,u=Math.min(s,a)+d,h=Math.max(Math.abs(a-s)-d,0);return G.createElement("rect",{className:"recharts-brush-slide",onMouseEnter:this.handleEnterSlideOrTraveller,onMouseLeave:this.handleLeaveSlideOrTraveller,onMouseDown:this.handleSlideDragStart,onTouchStart:this.handleSlideDragStart,style:{cursor:"move"},stroke:"none",fill:c,fillOpacity:.2,x:u,y:o,width:h,height:l})}},{key:"renderText",value:function(){var s=this.props,a=s.startIndex,i=s.endIndex,o=s.y,l=s.height,c=s.travellerWidth,d=s.stroke,u=this.state,h=u.startX,f=u.endX,m=5,g={pointerEvents:"none",fill:d};return G.createElement(en,{className:"recharts-brush-texts"},G.createElement(vy,By({textAnchor:"end",verticalAnchor:"middle",x:Math.min(h,f)-m,y:o+l/2},g),this.getTextOfTick(a)),G.createElement(vy,By({textAnchor:"start",verticalAnchor:"middle",x:Math.max(h,f)+c+m,y:o+l/2},g),this.getTextOfTick(i)))}},{key:"render",value:function(){var s=this.props,a=s.data,i=s.className,o=s.children,l=s.x,c=s.y,d=s.width,u=s.height,h=s.alwaysShowText,f=this.state,m=f.startX,g=f.endX,p=f.isTextActive,y=f.isSlideMoving,v=f.isTravellerMoving,j=f.isTravellerFocused;if(!a||!a.length||!Be(l)||!Be(c)||!Be(d)||!Be(u)||d<=0||u<=0)return null;var b=It("recharts-brush",i),_=G.Children.count(o)===1,w=F2e("userSelect","none");return G.createElement(en,{className:b,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:w},this.renderBackground(),_&&this.renderPanorama(),this.renderSlide(m,g),this.renderTravellerLayer(m,"startX"),this.renderTravellerLayer(g,"endX"),(p||y||v||j||h)&&this.renderText())}}],[{key:"renderDefaultTraveller",value:function(s){var a=s.x,i=s.y,o=s.width,l=s.height,c=s.stroke,d=Math.floor(i+l/2)-1;return G.createElement(G.Fragment,null,G.createElement("rect",{x:a,y:i,width:o,height:l,fill:c,stroke:"none"}),G.createElement("line",{x1:a+1,y1:d,x2:a+o-1,y2:d,fill:"none",stroke:"#fff"}),G.createElement("line",{x1:a+1,y1:d+2,x2:a+o-1,y2:d+2,fill:"none",stroke:"#fff"}))}},{key:"renderTraveller",value:function(s,a){var i;return G.isValidElement(s)?i=G.cloneElement(s,a):_t(s)?i=s(a):i=t.renderDefaultTraveller(a),i}},{key:"getDerivedStateFromProps",value:function(s,a){var i=s.data,o=s.width,l=s.x,c=s.travellerWidth,d=s.updateId,u=s.startIndex,h=s.endIndex;if(i!==a.prevData||d!==a.prevUpdateId)return Iw({prevData:i,prevTravellerWidth:c,prevUpdateId:d,prevX:l,prevWidth:o},i&&i.length?K2e({data:i,width:o,x:l,travellerWidth:c,startIndex:u,endIndex:h}):{scale:null,scaleValues:null});if(a.scale&&(o!==a.prevWidth||l!==a.prevX||c!==a.prevTravellerWidth)){a.scale.range([l,l+o-c]);var f=a.scale.domain().map(function(m){return a.scale(m)});return{prevData:i,prevTravellerWidth:c,prevUpdateId:d,prevX:l,prevWidth:o,startX:a.scale(s.startIndex),endX:a.scale(s.endIndex),scaleValues:f}}return null}},{key:"getIndexInRange",value:function(s,a){for(var i=s.length,o=0,l=i-1;l-o>1;){var c=Math.floor((o+l)/2);s[c]>a?l=c:o=c}return a>=s[l]?l:o}}])}(x.PureComponent);Ks(Sh,"displayName","Brush");Ks(Sh,"defaultProps",{height:40,travellerWidth:5,gap:1,fill:"#fff",stroke:"#666",padding:{top:1,right:1,bottom:1,left:1},leaveTimeOut:1e3,alwaysShowText:!1});var G2e=Qk;function Y2e(e,t){var r;return G2e(e,function(s,a,i){return r=t(s,a,i),!r}),!!r}var Q2e=Y2e,X2e=az,Z2e=gc,J2e=Q2e,ePe=Hs,tPe=Aj;function rPe(e,t,r){var s=ePe(e)?X2e:J2e;return r&&tPe(e,t,r)&&(t=void 0),s(e,Z2e(t))}var nPe=rPe;const sPe=fr(nPe);var $i=function(t,r){var s=t.alwaysShow,a=t.ifOverflow;return s&&(a="extendDomain"),a===r},N4=kz;function aPe(e,t,r){t=="__proto__"&&N4?N4(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var iPe=aPe,oPe=iPe,lPe=Sz,cPe=gc;function dPe(e,t){var r={};return t=cPe(t),lPe(e,function(s,a,i){oPe(r,a,t(s,a,i))}),r}var uPe=dPe;const hPe=fr(uPe);function fPe(e,t){for(var r=-1,s=e==null?0:e.length;++r<s;)if(!t(e[r],r,e))return!1;return!0}var mPe=fPe,pPe=Qk;function gPe(e,t){var r=!0;return pPe(e,function(s,a,i){return r=!!t(s,a,i),r}),r}var xPe=gPe,vPe=mPe,yPe=xPe,jPe=gc,bPe=Hs,wPe=Aj;function _Pe(e,t,r){var s=bPe(e)?vPe:yPe;return r&&wPe(e,t,r)&&(t=void 0),s(e,jPe(t))}var NPe=_Pe;const aq=fr(NPe);var SPe=["x","y"];function Ip(e){"@babel/helpers - typeof";return Ip=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ip(e)}function V1(){return V1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},V1.apply(this,arguments)}function S4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Wf(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?S4(Object(r),!0).forEach(function(s){CPe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):S4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function CPe(e,t,r){return t=kPe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function kPe(e){var t=PPe(e,"string");return Ip(t)=="symbol"?t:t+""}function PPe(e,t){if(Ip(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Ip(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function TPe(e,t){if(e==null)return{};var r=APe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function APe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function EPe(e,t){var r=e.x,s=e.y,a=TPe(e,SPe),i="".concat(r),o=parseInt(i,10),l="".concat(s),c=parseInt(l,10),d="".concat(t.height||a.height),u=parseInt(d,10),h="".concat(t.width||a.width),f=parseInt(h,10);return Wf(Wf(Wf(Wf(Wf({},t),a),o?{x:o}:{}),c?{y:c}:{}),{},{height:u,width:f,name:t.name,radius:t.radius})}function C4(e){return G.createElement(m2e,V1({shapeType:"rectangle",propTransformer:EPe,activeClassName:"recharts-active-bar"},e))}var OPe=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return function(s,a){if(typeof t=="number")return t;var i=Be(s)||Yde(s);return i?t(s,a):(i||Cd(),r)}},MPe=["value","background"],iq;function Ch(e){"@babel/helpers - typeof";return Ch=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ch(e)}function DPe(e,t){if(e==null)return{};var r=RPe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function RPe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function Wy(){return Wy=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Wy.apply(this,arguments)}function k4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function an(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?k4(Object(r),!0).forEach(function(s){$l(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function $Pe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function P4(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,lq(s.key),s)}}function IPe(e,t,r){return t&&P4(e.prototype,t),r&&P4(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function LPe(e,t,r){return t=Hy(t),FPe(e,oq()?Reflect.construct(t,r||[],Hy(e).constructor):t.apply(e,r))}function FPe(e,t){if(t&&(Ch(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return UPe(e)}function UPe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function oq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(oq=function(){return!!e})()}function Hy(e){return Hy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Hy(e)}function zPe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&K1(e,t)}function K1(e,t){return K1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},K1(e,t)}function $l(e,t,r){return t=lq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function lq(e){var t=BPe(e,"string");return Ch(t)=="symbol"?t:t+""}function BPe(e,t){if(Ch(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Ch(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var js=function(e){function t(){var r;$Pe(this,t);for(var s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];return r=LPe(this,t,[].concat(a)),$l(r,"state",{isAnimationFinished:!1}),$l(r,"id",Ng("recharts-bar-")),$l(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),o&&o()}),$l(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),o&&o()}),r}return zPe(t,e),IPe(t,[{key:"renderRectanglesStatically",value:function(s){var a=this,i=this.props,o=i.shape,l=i.dataKey,c=i.activeIndex,d=i.activeBar,u=$t(this.props,!1);return s&&s.map(function(h,f){var m=f===c,g=m?d:o,p=an(an(an({},u),h),{},{isActive:m,option:g,index:f,dataKey:l,onAnimationStart:a.handleAnimationStart,onAnimationEnd:a.handleAnimationEnd});return G.createElement(en,Wy({className:"recharts-bar-rectangle"},sy(a.props,h,f),{key:"rectangle-".concat(h==null?void 0:h.x,"-").concat(h==null?void 0:h.y,"-").concat(h==null?void 0:h.value,"-").concat(f)}),G.createElement(C4,p))})}},{key:"renderRectanglesWithAnimation",value:function(){var s=this,a=this.props,i=a.data,o=a.layout,l=a.isAnimationActive,c=a.animationBegin,d=a.animationDuration,u=a.animationEasing,h=a.animationId,f=this.state.prevData;return G.createElement(Ko,{begin:c,duration:d,isActive:l,easing:u,from:{t:0},to:{t:1},key:"bar-".concat(h),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(m){var g=m.t,p=i.map(function(y,v){var j=f&&f[v];if(j){var b=Za(j.x,y.x),_=Za(j.y,y.y),w=Za(j.width,y.width),N=Za(j.height,y.height);return an(an({},y),{},{x:b(g),y:_(g),width:w(g),height:N(g)})}if(o==="horizontal"){var S=Za(0,y.height),C=S(g);return an(an({},y),{},{y:y.y+y.height-C,height:C})}var P=Za(0,y.width),M=P(g);return an(an({},y),{},{width:M})});return G.createElement(en,null,s.renderRectanglesStatically(p))})}},{key:"renderRectangles",value:function(){var s=this.props,a=s.data,i=s.isAnimationActive,o=this.state.prevData;return i&&a&&a.length&&(!o||!Fj(o,a))?this.renderRectanglesWithAnimation():this.renderRectanglesStatically(a)}},{key:"renderBackground",value:function(){var s=this,a=this.props,i=a.data,o=a.dataKey,l=a.activeIndex,c=$t(this.props.background,!1);return i.map(function(d,u){d.value;var h=d.background,f=DPe(d,MPe);if(!h)return null;var m=an(an(an(an(an({},f),{},{fill:"#eee"},h),c),sy(s.props,d,u)),{},{onAnimationStart:s.handleAnimationStart,onAnimationEnd:s.handleAnimationEnd,dataKey:o,index:u,className:"recharts-bar-background-rectangle"});return G.createElement(C4,Wy({key:"background-bar-".concat(u),option:s.props.background,isActive:u===l},m))})}},{key:"renderErrorBar",value:function(s,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.data,l=i.xAxis,c=i.yAxis,d=i.layout,u=i.children,h=ka(u,Ag);if(!h)return null;var f=d==="vertical"?o[0].height/2:o[0].width/2,m=function(y,v){var j=Array.isArray(y.value)?y.value[1]:y.value;return{x:y.x,y:y.y,value:j,errorVal:la(y,v)}},g={clipPath:s?"url(#clipPath-".concat(a,")"):null};return G.createElement(en,g,h.map(function(p){return G.cloneElement(p,{key:"error-bar-".concat(a,"-").concat(p.props.dataKey),data:o,xAxis:l,yAxis:c,layout:d,offset:f,dataPointFormatter:m})}))}},{key:"render",value:function(){var s=this.props,a=s.hide,i=s.data,o=s.className,l=s.xAxis,c=s.yAxis,d=s.left,u=s.top,h=s.width,f=s.height,m=s.isAnimationActive,g=s.background,p=s.id;if(a||!i||!i.length)return null;var y=this.state.isAnimationFinished,v=It("recharts-bar",o),j=l&&l.allowDataOverflow,b=c&&c.allowDataOverflow,_=j||b,w=Pt(p)?this.id:p;return G.createElement(en,{className:v},j||b?G.createElement("defs",null,G.createElement("clipPath",{id:"clipPath-".concat(w)},G.createElement("rect",{x:j?d:d-h/2,y:b?u:u-f/2,width:j?h:h*2,height:b?f:f*2}))):null,G.createElement(en,{className:"recharts-bar-rectangles",clipPath:_?"url(#clipPath-".concat(w,")"):null},g?this.renderBackground():null,this.renderRectangles()),this.renderErrorBar(_,w),(!m||y)&&Ql.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(s,a){return s.animationId!==a.prevAnimationId?{prevAnimationId:s.animationId,curData:s.data,prevData:a.curData}:s.data!==a.curData?{curData:s.data}:null}}])}(x.PureComponent);iq=js;$l(js,"displayName","Bar");$l(js,"defaultProps",{xAxisId:0,yAxisId:0,legendType:"rect",minPointSize:0,hide:!1,data:[],layout:"vertical",activeBar:!1,isAnimationActive:!Po.isSsr,animationBegin:0,animationDuration:400,animationEasing:"ease"});$l(js,"getComposedData",function(e){var t=e.props,r=e.item,s=e.barPosition,a=e.bandSize,i=e.xAxis,o=e.yAxis,l=e.xAxisTicks,c=e.yAxisTicks,d=e.stackedData,u=e.dataStartIndex,h=e.displayedData,f=e.offset,m=v1e(s,r);if(!m)return null;var g=t.layout,p=r.type.defaultProps,y=p!==void 0?an(an({},p),r.props):r.props,v=y.dataKey,j=y.children,b=y.minPointSize,_=g==="horizontal"?o:i,w=d?_.scale.domain():null,N=C1e({numericAxis:_}),S=ka(j,Dz),C=h.map(function(P,M){var D,A,U,F,L,$;d?D=y1e(d[u+M],w):(D=la(P,v),Array.isArray(D)||(D=[N,D]));var R=OPe(b,iq.defaultProps.minPointSize)(D[1],M);if(g==="horizontal"){var T,k=[o.scale(D[0]),o.scale(D[1])],W=k[0],q=k[1];A=kM({axis:i,ticks:l,bandSize:a,offset:m.offset,entry:P,index:M}),U=(T=q??W)!==null&&T!==void 0?T:void 0,F=m.size;var Q=W-q;if(L=Number.isNaN(Q)?0:Q,$={x:A,y:o.y,width:F,height:o.height},Math.abs(R)>0&&Math.abs(L)<Math.abs(R)){var ue=ri(L||R)*(Math.abs(R)-Math.abs(L));U-=ue,L+=ue}}else{var X=[i.scale(D[0]),i.scale(D[1])],le=X[0],pe=X[1];if(A=le,U=kM({axis:o,ticks:c,bandSize:a,offset:m.offset,entry:P,index:M}),F=pe-le,L=m.size,$={x:i.x,y:U,width:i.width,height:L},Math.abs(R)>0&&Math.abs(F)<Math.abs(R)){var ce=ri(F||R)*(Math.abs(R)-Math.abs(F));F+=ce}}return an(an(an({},P),{},{x:A,y:U,width:F,height:L,value:d?D:D[1],payload:P,background:$},S&&S[M]&&S[M].props),{},{tooltipPayload:[UB(r,P)],tooltipPosition:{x:A+F/2,y:U+L/2}})});return an({data:C,layout:g},f)});function Lp(e){"@babel/helpers - typeof";return Lp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lp(e)}function qPe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function T4(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,cq(s.key),s)}}function WPe(e,t,r){return t&&T4(e.prototype,t),r&&T4(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function A4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Ya(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?A4(Object(r),!0).forEach(function(s){Wj(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):A4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Wj(e,t,r){return t=cq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cq(e){var t=HPe(e,"string");return Lp(t)=="symbol"?t:t+""}function HPe(e,t){if(Lp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Lp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var dq=function(t,r,s,a,i){var o=t.width,l=t.height,c=t.layout,d=t.children,u=Object.keys(r),h={left:s.left,leftMirror:s.left,right:o-s.right,rightMirror:o-s.right,top:s.top,topMirror:s.top,bottom:l-s.bottom,bottomMirror:l-s.bottom},f=!!Ys(d,js);return u.reduce(function(m,g){var p=r[g],y=p.orientation,v=p.domain,j=p.padding,b=j===void 0?{}:j,_=p.mirror,w=p.reversed,N="".concat(y).concat(_?"Mirror":""),S,C,P,M,D;if(p.type==="number"&&(p.padding==="gap"||p.padding==="no-gap")){var A=v[1]-v[0],U=1/0,F=p.categoricalDomain.sort(Zde);if(F.forEach(function(X,le){le>0&&(U=Math.min((X||0)-(F[le-1]||0),U))}),Number.isFinite(U)){var L=U/A,$=p.layout==="vertical"?s.height:s.width;if(p.padding==="gap"&&(S=L*$/2),p.padding==="no-gap"){var R=Nd(t.barCategoryGap,L*$),T=L*$/2;S=T-R-(T-R)/$*R}}}a==="xAxis"?C=[s.left+(b.left||0)+(S||0),s.left+s.width-(b.right||0)-(S||0)]:a==="yAxis"?C=c==="horizontal"?[s.top+s.height-(b.bottom||0),s.top+(b.top||0)]:[s.top+(b.top||0)+(S||0),s.top+s.height-(b.bottom||0)-(S||0)]:C=p.range,w&&(C=[C[1],C[0]]);var k=g1e(p,i,f),W=k.scale,q=k.realScaleType;W.domain(v).range(C),x1e(W);var Q=S1e(W,Ya(Ya({},p),{},{realScaleType:q}));a==="xAxis"?(D=y==="top"&&!_||y==="bottom"&&_,P=s.left,M=h[N]-D*p.height):a==="yAxis"&&(D=y==="left"&&!_||y==="right"&&_,P=h[N]-D*p.width,M=s.top);var ue=Ya(Ya(Ya({},p),Q),{},{realScaleType:q,x:P,y:M,scale:W,width:a==="xAxis"?s.width:p.width,height:a==="yAxis"?s.height:p.height});return ue.bandSize=Oy(ue,Q),!p.hide&&a==="xAxis"?h[N]+=(D?-1:1)*ue.height:p.hide||(h[N]+=(D?-1:1)*ue.width),Ya(Ya({},m),{},Wj({},g,ue))},{})},uq=function(t,r){var s=t.x,a=t.y,i=r.x,o=r.y;return{x:Math.min(s,i),y:Math.min(a,o),width:Math.abs(i-s),height:Math.abs(o-a)}},VPe=function(t){var r=t.x1,s=t.y1,a=t.x2,i=t.y2;return uq({x:r,y:s},{x:a,y:i})},hq=function(){function e(t){qPe(this,e),this.scale=t}return WPe(e,[{key:"domain",get:function(){return this.scale.domain}},{key:"range",get:function(){return this.scale.range}},{key:"rangeMin",get:function(){return this.range()[0]}},{key:"rangeMax",get:function(){return this.range()[1]}},{key:"bandwidth",get:function(){return this.scale.bandwidth}},{key:"apply",value:function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=s.bandAware,i=s.position;if(r!==void 0){if(i)switch(i){case"start":return this.scale(r);case"middle":{var o=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+o}case"end":{var l=this.bandwidth?this.bandwidth():0;return this.scale(r)+l}default:return this.scale(r)}if(a){var c=this.bandwidth?this.bandwidth()/2:0;return this.scale(r)+c}return this.scale(r)}}},{key:"isInRange",value:function(r){var s=this.range(),a=s[0],i=s[s.length-1];return a<=i?r>=a&&r<=i:r>=i&&r<=a}}],[{key:"create",value:function(r){return new e(r)}}])}();Wj(hq,"EPS",1e-4);var C2=function(t){var r=Object.keys(t).reduce(function(s,a){return Ya(Ya({},s),{},Wj({},a,hq.create(t[a])))},{});return Ya(Ya({},r),{},{apply:function(a){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.bandAware,l=i.position;return hPe(a,function(c,d){return r[d].apply(c,{bandAware:o,position:l})})},isInRange:function(a){return aq(a,function(i,o){return r[o].isInRange(i)})}})};function KPe(e){return(e%180+180)%180}var GPe=function(t){var r=t.width,s=t.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=KPe(a),o=i*Math.PI/180,l=Math.atan(s/r),c=o>l&&o<Math.PI-l?s/Math.sin(o):r/Math.cos(o);return Math.abs(c)},YPe=gc,QPe=Sg,XPe=Pj;function ZPe(e){return function(t,r,s){var a=Object(t);if(!QPe(t)){var i=YPe(r);t=XPe(t),r=function(l){return i(a[l],l,a)}}var o=e(t,r,s);return o>-1?a[i?t[o]:o]:void 0}}var JPe=ZPe,eTe=tq;function tTe(e){var t=eTe(e),r=t%1;return t===t?r?t-r:t:0}var rTe=tTe,nTe=yz,sTe=gc,aTe=rTe,iTe=Math.max;function oTe(e,t,r){var s=e==null?0:e.length;if(!s)return-1;var a=r==null?0:aTe(r);return a<0&&(a=iTe(s+a,0)),nTe(e,sTe(t),a)}var lTe=oTe,cTe=JPe,dTe=lTe,uTe=cTe(dTe),hTe=uTe;const fTe=fr(hTe);var mTe=Jce(function(e){return{x:e.left,y:e.top,width:e.width,height:e.height}},function(e){return["l",e.left,"t",e.top,"w",e.width,"h",e.height].join("")}),k2=x.createContext(void 0),P2=x.createContext(void 0),fq=x.createContext(void 0),mq=x.createContext({}),pq=x.createContext(void 0),gq=x.createContext(0),xq=x.createContext(0),E4=function(t){var r=t.state,s=r.xAxisMap,a=r.yAxisMap,i=r.offset,o=t.clipPathId,l=t.children,c=t.width,d=t.height,u=mTe(i);return G.createElement(k2.Provider,{value:s},G.createElement(P2.Provider,{value:a},G.createElement(mq.Provider,{value:i},G.createElement(fq.Provider,{value:u},G.createElement(pq.Provider,{value:o},G.createElement(gq.Provider,{value:d},G.createElement(xq.Provider,{value:c},l)))))))},pTe=function(){return x.useContext(pq)},vq=function(t){var r=x.useContext(k2);r==null&&Cd();var s=r[t];return s==null&&Cd(),s},gTe=function(){var t=x.useContext(k2);return bl(t)},xTe=function(){var t=x.useContext(P2),r=fTe(t,function(s){return aq(s.domain,Number.isFinite)});return r||bl(t)},yq=function(t){var r=x.useContext(P2);r==null&&Cd();var s=r[t];return s==null&&Cd(),s},vTe=function(){var t=x.useContext(fq);return t},yTe=function(){return x.useContext(mq)},T2=function(){return x.useContext(xq)},A2=function(){return x.useContext(gq)};function kh(e){"@babel/helpers - typeof";return kh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kh(e)}function jTe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function bTe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,bq(s.key),s)}}function wTe(e,t,r){return t&&bTe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _Te(e,t,r){return t=Vy(t),NTe(e,jq()?Reflect.construct(t,r||[],Vy(e).constructor):t.apply(e,r))}function NTe(e,t){if(t&&(kh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return STe(e)}function STe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function jq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(jq=function(){return!!e})()}function Vy(e){return Vy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Vy(e)}function CTe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&G1(e,t)}function G1(e,t){return G1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},G1(e,t)}function O4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function M4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?O4(Object(r),!0).forEach(function(s){E2(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):O4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function E2(e,t,r){return t=bq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bq(e){var t=kTe(e,"string");return kh(t)=="symbol"?t:t+""}function kTe(e,t){if(kh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(kh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function PTe(e,t){return OTe(e)||ETe(e,t)||ATe(e,t)||TTe()}function TTe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
750In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ATe(e,t){if(e){if(typeof e=="string")return D4(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return D4(e,t)}}function D4(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function ETe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function OTe(e){if(Array.isArray(e))return e}function Y1(){return Y1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Y1.apply(this,arguments)}var MTe=function(t,r){var s;return G.isValidElement(t)?s=G.cloneElement(t,r):_t(t)?s=t(r):s=G.createElement("line",Y1({},r,{className:"recharts-reference-line-line"})),s},DTe=function(t,r,s,a,i,o,l,c,d){var u=i.x,h=i.y,f=i.width,m=i.height;if(s){var g=d.y,p=t.y.apply(g,{position:o});if($i(d,"discard")&&!t.y.isInRange(p))return null;var y=[{x:u+f,y:p},{x:u,y:p}];return c==="left"?y.reverse():y}if(r){var v=d.x,j=t.x.apply(v,{position:o});if($i(d,"discard")&&!t.x.isInRange(j))return null;var b=[{x:j,y:h+m},{x:j,y:h}];return l==="top"?b.reverse():b}if(a){var _=d.segment,w=_.map(function(N){return t.apply(N,{position:o})});return $i(d,"discard")&&sPe(w,function(N){return!t.isInRange(N)})?null:w}return null};function RTe(e){var t=e.x,r=e.y,s=e.segment,a=e.xAxisId,i=e.yAxisId,o=e.shape,l=e.className,c=e.alwaysShow,d=pTe(),u=vq(a),h=yq(i),f=vTe();if(!d||!f)return null;Co(c===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var m=C2({x:u.scale,y:h.scale}),g=yn(t),p=yn(r),y=s&&s.length===2,v=DTe(m,g,p,y,f,e.position,u.orientation,h.orientation,e);if(!v)return null;var j=PTe(v,2),b=j[0],_=b.x,w=b.y,N=j[1],S=N.x,C=N.y,P=$i(e,"hidden")?"url(#".concat(d,")"):void 0,M=M4(M4({clipPath:P},$t(e,!0)),{},{x1:_,y1:w,x2:S,y2:C});return G.createElement(en,{className:It("recharts-reference-line",l)},MTe(o,M),es.renderCallByParent(e,VPe({x1:_,y1:w,x2:S,y2:C})))}var O2=function(e){function t(){return jTe(this,t),_Te(this,t,arguments)}return CTe(t,e),wTe(t,[{key:"render",value:function(){return G.createElement(RTe,this.props)}}])}(G.Component);E2(O2,"displayName","ReferenceLine");E2(O2,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle"});function Q1(){return Q1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Q1.apply(this,arguments)}function Ph(e){"@babel/helpers - typeof";return Ph=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ph(e)}function R4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function $4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?R4(Object(r),!0).forEach(function(s){Hj(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):R4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function $Te(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ITe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,_q(s.key),s)}}function LTe(e,t,r){return t&&ITe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function FTe(e,t,r){return t=Ky(t),UTe(e,wq()?Reflect.construct(t,r||[],Ky(e).constructor):t.apply(e,r))}function UTe(e,t){if(t&&(Ph(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return zTe(e)}function zTe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function wq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(wq=function(){return!!e})()}function Ky(e){return Ky=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ky(e)}function BTe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X1(e,t)}function X1(e,t){return X1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},X1(e,t)}function Hj(e,t,r){return t=_q(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _q(e){var t=qTe(e,"string");return Ph(t)=="symbol"?t:t+""}function qTe(e,t){if(Ph(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Ph(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var WTe=function(t){var r=t.x,s=t.y,a=t.xAxis,i=t.yAxis,o=C2({x:a.scale,y:i.scale}),l=o.apply({x:r,y:s},{bandAware:!0});return $i(t,"discard")&&!o.isInRange(l)?null:l},Vj=function(e){function t(){return $Te(this,t),FTe(this,t,arguments)}return BTe(t,e),LTe(t,[{key:"render",value:function(){var s=this.props,a=s.x,i=s.y,o=s.r,l=s.alwaysShow,c=s.clipPathId,d=yn(a),u=yn(i);if(Co(l===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.'),!d||!u)return null;var h=WTe(this.props);if(!h)return null;var f=h.x,m=h.y,g=this.props,p=g.shape,y=g.className,v=$i(this.props,"hidden")?"url(#".concat(c,")"):void 0,j=$4($4({clipPath:v},$t(this.props,!0)),{},{cx:f,cy:m});return G.createElement(en,{className:It("recharts-reference-dot",y)},t.renderDot(p,j),es.renderCallByParent(this.props,{x:f-o,y:m-o,width:2*o,height:2*o}))}}])}(G.Component);Hj(Vj,"displayName","ReferenceDot");Hj(Vj,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#fff",stroke:"#ccc",fillOpacity:1,strokeWidth:1});Hj(Vj,"renderDot",function(e,t){var r;return G.isValidElement(e)?r=G.cloneElement(e,t):_t(e)?r=e(t):r=G.createElement(S2,Q1({},t,{cx:t.cx,cy:t.cy,className:"recharts-reference-dot-dot"})),r});function Z1(){return Z1=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Z1.apply(this,arguments)}function Th(e){"@babel/helpers - typeof";return Th=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Th(e)}function I4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function L4(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?I4(Object(r),!0).forEach(function(s){Kj(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):I4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function HTe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function VTe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Sq(s.key),s)}}function KTe(e,t,r){return t&&VTe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function GTe(e,t,r){return t=Gy(t),YTe(e,Nq()?Reflect.construct(t,r||[],Gy(e).constructor):t.apply(e,r))}function YTe(e,t){if(t&&(Th(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return QTe(e)}function QTe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Nq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Nq=function(){return!!e})()}function Gy(e){return Gy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Gy(e)}function XTe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&J1(e,t)}function J1(e,t){return J1=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},J1(e,t)}function Kj(e,t,r){return t=Sq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Sq(e){var t=ZTe(e,"string");return Th(t)=="symbol"?t:t+""}function ZTe(e,t){if(Th(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Th(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var JTe=function(t,r,s,a,i){var o=i.x1,l=i.x2,c=i.y1,d=i.y2,u=i.xAxis,h=i.yAxis;if(!u||!h)return null;var f=C2({x:u.scale,y:h.scale}),m={x:t?f.x.apply(o,{position:"start"}):f.x.rangeMin,y:s?f.y.apply(c,{position:"start"}):f.y.rangeMin},g={x:r?f.x.apply(l,{position:"end"}):f.x.rangeMax,y:a?f.y.apply(d,{position:"end"}):f.y.rangeMax};return $i(i,"discard")&&(!f.isInRange(m)||!f.isInRange(g))?null:uq(m,g)},Gj=function(e){function t(){return HTe(this,t),GTe(this,t,arguments)}return XTe(t,e),KTe(t,[{key:"render",value:function(){var s=this.props,a=s.x1,i=s.x2,o=s.y1,l=s.y2,c=s.className,d=s.alwaysShow,u=s.clipPathId;Co(d===void 0,'The alwaysShow prop is deprecated. Please use ifOverflow="extendDomain" instead.');var h=yn(a),f=yn(i),m=yn(o),g=yn(l),p=this.props.shape;if(!h&&!f&&!m&&!g&&!p)return null;var y=JTe(h,f,m,g,this.props);if(!y&&!p)return null;var v=$i(this.props,"hidden")?"url(#".concat(u,")"):void 0;return G.createElement(en,{className:It("recharts-reference-area",c)},t.renderRect(p,L4(L4({clipPath:v},$t(this.props,!0)),y)),es.renderCallByParent(this.props,y))}}])}(G.Component);Kj(Gj,"displayName","ReferenceArea");Kj(Gj,"defaultProps",{isFront:!1,ifOverflow:"discard",xAxisId:0,yAxisId:0,r:10,fill:"#ccc",fillOpacity:.5,stroke:"none",strokeWidth:1});Kj(Gj,"renderRect",function(e,t){var r;return G.isValidElement(e)?r=G.cloneElement(e,t):_t(e)?r=e(t):r=G.createElement(N2,Z1({},t,{className:"recharts-reference-area-rect"})),r});function Cq(e,t,r){if(t<1)return[];if(t===1&&r===void 0)return e;for(var s=[],a=0;a<e.length;a+=t)s.push(e[a]);return s}function eAe(e,t,r){var s={width:e.width+t.width,height:e.height+t.height};return GPe(s,r)}function tAe(e,t,r){var s=r==="width",a=e.x,i=e.y,o=e.width,l=e.height;return t===1?{start:s?a:i,end:s?a+o:i+l}:{start:s?a+o:i+l,end:s?a:i}}function Yy(e,t,r,s,a){if(e*t<e*s||e*t>e*a)return!1;var i=r();return e*(t-e*i/2-s)>=0&&e*(t+e*i/2-a)<=0}function rAe(e,t){return Cq(e,t+1)}function nAe(e,t,r,s,a){for(var i=(s||[]).slice(),o=t.start,l=t.end,c=0,d=1,u=o,h=function(){var g=s==null?void 0:s[c];if(g===void 0)return{v:Cq(s,d)};var p=c,y,v=function(){return y===void 0&&(y=r(g,p)),y},j=g.coordinate,b=c===0||Yy(e,j,v,u,l);b||(c=0,u=o,d+=1),b&&(u=j+e*(v()/2+a),c+=d)},f;d<=i.length;)if(f=h(),f)return f.v;return[]}function Fp(e){"@babel/helpers - typeof";return Fp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fp(e)}function F4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Zn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?F4(Object(r),!0).forEach(function(s){sAe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):F4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function sAe(e,t,r){return t=aAe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function aAe(e){var t=iAe(e,"string");return Fp(t)=="symbol"?t:t+""}function iAe(e,t){if(Fp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Fp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function oAe(e,t,r,s,a){for(var i=(s||[]).slice(),o=i.length,l=t.start,c=t.end,d=function(f){var m=i[f],g,p=function(){return g===void 0&&(g=r(m,f)),g};if(f===o-1){var y=e*(m.coordinate+e*p()/2-c);i[f]=m=Zn(Zn({},m),{},{tickCoord:y>0?m.coordinate-y*e:m.coordinate})}else i[f]=m=Zn(Zn({},m),{},{tickCoord:m.coordinate});var v=Yy(e,m.tickCoord,p,l,c);v&&(c=m.tickCoord-e*(p()/2+a),i[f]=Zn(Zn({},m),{},{isShow:!0}))},u=o-1;u>=0;u--)d(u);return i}function lAe(e,t,r,s,a,i){var o=(s||[]).slice(),l=o.length,c=t.start,d=t.end;if(i){var u=s[l-1],h=r(u,l-1),f=e*(u.coordinate+e*h/2-d);o[l-1]=u=Zn(Zn({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate});var m=Yy(e,u.tickCoord,function(){return h},c,d);m&&(d=u.tickCoord-e*(h/2+a),o[l-1]=Zn(Zn({},u),{},{isShow:!0}))}for(var g=i?l-1:l,p=function(j){var b=o[j],_,w=function(){return _===void 0&&(_=r(b,j)),_};if(j===0){var N=e*(b.coordinate-e*w()/2-c);o[j]=b=Zn(Zn({},b),{},{tickCoord:N<0?b.coordinate-N*e:b.coordinate})}else o[j]=b=Zn(Zn({},b),{},{tickCoord:b.coordinate});var S=Yy(e,b.tickCoord,w,c,d);S&&(c=b.tickCoord+e*(w()/2+a),o[j]=Zn(Zn({},b),{},{isShow:!0}))},y=0;y<g;y++)p(y);return o}function M2(e,t,r){var s=e.tick,a=e.ticks,i=e.viewBox,o=e.minTickGap,l=e.orientation,c=e.interval,d=e.tickFormatter,u=e.unit,h=e.angle;if(!a||!a.length||!s)return[];if(Be(c)||Po.isSsr)return rAe(a,typeof c=="number"&&Be(c)?c:0);var f=[],m=l==="top"||l==="bottom"?"width":"height",g=u&&m==="width"?_m(u,{fontSize:t,letterSpacing:r}):{width:0,height:0},p=function(b,_){var w=_t(d)?d(b.value,_):b.value;return m==="width"?eAe(_m(w,{fontSize:t,letterSpacing:r}),g,h):_m(w,{fontSize:t,letterSpacing:r})[m]},y=a.length>=2?ri(a[1].coordinate-a[0].coordinate):1,v=tAe(i,y,m);return c==="equidistantPreserveStart"?nAe(y,v,p,a,o):(c==="preserveStart"||c==="preserveStartEnd"?f=lAe(y,v,p,a,o,c==="preserveStartEnd"):f=oAe(y,v,p,a,o),f.filter(function(j){return j.isShow}))}var cAe=["viewBox"],dAe=["viewBox"],uAe=["ticks"];function Ah(e){"@babel/helpers - typeof";return Ah=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ah(e)}function yu(){return yu=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},yu.apply(this,arguments)}function U4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function dn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U4(Object(r),!0).forEach(function(s){D2(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function Lw(e,t){if(e==null)return{};var r=hAe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function hAe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function fAe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function z4(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Pq(s.key),s)}}function mAe(e,t,r){return t&&z4(e.prototype,t),r&&z4(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function pAe(e,t,r){return t=Qy(t),gAe(e,kq()?Reflect.construct(t,r||[],Qy(e).constructor):t.apply(e,r))}function gAe(e,t){if(t&&(Ah(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return xAe(e)}function xAe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function kq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(kq=function(){return!!e})()}function Qy(e){return Qy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Qy(e)}function vAe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&eS(e,t)}function eS(e,t){return eS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},eS(e,t)}function D2(e,t,r){return t=Pq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Pq(e){var t=yAe(e,"string");return Ah(t)=="symbol"?t:t+""}function yAe(e,t){if(Ah(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Ah(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var pf=function(e){function t(r){var s;return fAe(this,t),s=pAe(this,t,[r]),s.state={fontSize:"",letterSpacing:""},s}return vAe(t,e),mAe(t,[{key:"shouldComponentUpdate",value:function(s,a){var i=s.viewBox,o=Lw(s,cAe),l=this.props,c=l.viewBox,d=Lw(l,dAe);return!Du(i,c)||!Du(o,d)||!Du(a,this.state)}},{key:"componentDidMount",value:function(){var s=this.layerReference;if(s){var a=s.getElementsByClassName("recharts-cartesian-axis-tick-value")[0];a&&this.setState({fontSize:window.getComputedStyle(a).fontSize,letterSpacing:window.getComputedStyle(a).letterSpacing})}}},{key:"getTickLineCoord",value:function(s){var a=this.props,i=a.x,o=a.y,l=a.width,c=a.height,d=a.orientation,u=a.tickSize,h=a.mirror,f=a.tickMargin,m,g,p,y,v,j,b=h?-1:1,_=s.tickSize||u,w=Be(s.tickCoord)?s.tickCoord:s.coordinate;switch(d){case"top":m=g=s.coordinate,y=o+ +!h*c,p=y-b*_,j=p-b*f,v=w;break;case"left":p=y=s.coordinate,g=i+ +!h*l,m=g-b*_,v=m-b*f,j=w;break;case"right":p=y=s.coordinate,g=i+ +h*l,m=g+b*_,v=m+b*f,j=w;break;default:m=g=s.coordinate,y=o+ +h*c,p=y+b*_,j=p+b*f,v=w;break}return{line:{x1:m,y1:p,x2:g,y2:y},tick:{x:v,y:j}}}},{key:"getTickTextAnchor",value:function(){var s=this.props,a=s.orientation,i=s.mirror,o;switch(a){case"left":o=i?"start":"end";break;case"right":o=i?"end":"start";break;default:o="middle";break}return o}},{key:"getTickVerticalAnchor",value:function(){var s=this.props,a=s.orientation,i=s.mirror,o="end";switch(a){case"left":case"right":o="middle";break;case"top":o=i?"start":"end";break;default:o=i?"end":"start";break}return o}},{key:"renderAxisLine",value:function(){var s=this.props,a=s.x,i=s.y,o=s.width,l=s.height,c=s.orientation,d=s.mirror,u=s.axisLine,h=dn(dn(dn({},$t(this.props,!1)),$t(u,!1)),{},{fill:"none"});if(c==="top"||c==="bottom"){var f=+(c==="top"&&!d||c==="bottom"&&d);h=dn(dn({},h),{},{x1:a,y1:i+f*l,x2:a+o,y2:i+f*l})}else{var m=+(c==="left"&&!d||c==="right"&&d);h=dn(dn({},h),{},{x1:a+m*o,y1:i,x2:a+m*o,y2:i+l})}return G.createElement("line",yu({},h,{className:It("recharts-cartesian-axis-line",Ca(u,"className"))}))}},{key:"renderTicks",value:function(s,a,i){var o=this,l=this.props,c=l.tickLine,d=l.stroke,u=l.tick,h=l.tickFormatter,f=l.unit,m=M2(dn(dn({},this.props),{},{ticks:s}),a,i),g=this.getTickTextAnchor(),p=this.getTickVerticalAnchor(),y=$t(this.props,!1),v=$t(u,!1),j=dn(dn({},y),{},{fill:"none"},$t(c,!1)),b=m.map(function(_,w){var N=o.getTickLineCoord(_),S=N.line,C=N.tick,P=dn(dn(dn(dn({textAnchor:g,verticalAnchor:p},y),{},{stroke:"none",fill:d},v),C),{},{index:w,payload:_,visibleTicksCount:m.length,tickFormatter:h});return G.createElement(en,yu({className:"recharts-cartesian-axis-tick",key:"tick-".concat(_.value,"-").concat(_.coordinate,"-").concat(_.tickCoord)},sy(o.props,_,w)),c&&G.createElement("line",yu({},j,S,{className:It("recharts-cartesian-axis-tick-line",Ca(c,"className"))})),u&&t.renderTickItem(u,P,"".concat(_t(h)?h(_.value,w):_.value).concat(f||"")))});return G.createElement("g",{className:"recharts-cartesian-axis-ticks"},b)}},{key:"render",value:function(){var s=this,a=this.props,i=a.axisLine,o=a.width,l=a.height,c=a.ticksGenerator,d=a.className,u=a.hide;if(u)return null;var h=this.props,f=h.ticks,m=Lw(h,uAe),g=f;return _t(c)&&(g=f&&f.length>0?c(this.props):c(m)),o<=0||l<=0||!g||!g.length?null:G.createElement(en,{className:It("recharts-cartesian-axis",d),ref:function(y){s.layerReference=y}},i&&this.renderAxisLine(),this.renderTicks(g,this.state.fontSize,this.state.letterSpacing),es.renderCallByParent(this.props))}}],[{key:"renderTickItem",value:function(s,a,i){var o,l=It(a.className,"recharts-cartesian-axis-tick-value");return G.isValidElement(s)?o=G.cloneElement(s,dn(dn({},a),{},{className:l})):_t(s)?o=s(dn(dn({},a),{},{className:l})):o=G.createElement(vy,yu({},a,{className:"recharts-cartesian-axis-tick-value"}),i),o}}])}(x.Component);D2(pf,"displayName","CartesianAxis");D2(pf,"defaultProps",{x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd"});var jAe=["x1","y1","x2","y2","key"],bAe=["offset"];function kd(e){"@babel/helpers - typeof";return kd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kd(e)}function B4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function ts(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?B4(Object(r),!0).forEach(function(s){wAe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function wAe(e,t,r){return t=_Ae(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _Ae(e){var t=NAe(e,"string");return kd(t)=="symbol"?t:t+""}function NAe(e,t){if(kd(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(kd(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Vc(){return Vc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},Vc.apply(this,arguments)}function q4(e,t){if(e==null)return{};var r=SAe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function SAe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}var CAe=function(t){var r=t.fill;if(!r||r==="none")return null;var s=t.fillOpacity,a=t.x,i=t.y,o=t.width,l=t.height,c=t.ry;return G.createElement("rect",{x:a,y:i,ry:c,width:o,height:l,stroke:"none",fill:r,fillOpacity:s,className:"recharts-cartesian-grid-bg"})};function Tq(e,t){var r;if(G.isValidElement(e))r=G.cloneElement(e,t);else if(_t(e))r=e(t);else{var s=t.x1,a=t.y1,i=t.x2,o=t.y2,l=t.key,c=q4(t,jAe),d=$t(c,!1);d.offset;var u=q4(d,bAe);r=G.createElement("line",Vc({},u,{x1:s,y1:a,x2:i,y2:o,fill:"none",key:l}))}return r}function kAe(e){var t=e.x,r=e.width,s=e.horizontal,a=s===void 0?!0:s,i=e.horizontalPoints;if(!a||!i||!i.length)return null;var o=i.map(function(l,c){var d=ts(ts({},e),{},{x1:t,y1:l,x2:t+r,y2:l,key:"line-".concat(c),index:c});return Tq(a,d)});return G.createElement("g",{className:"recharts-cartesian-grid-horizontal"},o)}function PAe(e){var t=e.y,r=e.height,s=e.vertical,a=s===void 0?!0:s,i=e.verticalPoints;if(!a||!i||!i.length)return null;var o=i.map(function(l,c){var d=ts(ts({},e),{},{x1:l,y1:t,x2:l,y2:t+r,key:"line-".concat(c),index:c});return Tq(a,d)});return G.createElement("g",{className:"recharts-cartesian-grid-vertical"},o)}function TAe(e){var t=e.horizontalFill,r=e.fillOpacity,s=e.x,a=e.y,i=e.width,o=e.height,l=e.horizontalPoints,c=e.horizontal,d=c===void 0?!0:c;if(!d||!t||!t.length)return null;var u=l.map(function(f){return Math.round(f+a-a)}).sort(function(f,m){return f-m});a!==u[0]&&u.unshift(0);var h=u.map(function(f,m){var g=!u[m+1],p=g?a+o-f:u[m+1]-f;if(p<=0)return null;var y=m%t.length;return G.createElement("rect",{key:"react-".concat(m),y:f,x:s,height:p,width:i,stroke:"none",fill:t[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return G.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},h)}function AAe(e){var t=e.vertical,r=t===void 0?!0:t,s=e.verticalFill,a=e.fillOpacity,i=e.x,o=e.y,l=e.width,c=e.height,d=e.verticalPoints;if(!r||!s||!s.length)return null;var u=d.map(function(f){return Math.round(f+i-i)}).sort(function(f,m){return f-m});i!==u[0]&&u.unshift(0);var h=u.map(function(f,m){var g=!u[m+1],p=g?i+l-f:u[m+1]-f;if(p<=0)return null;var y=m%s.length;return G.createElement("rect",{key:"react-".concat(m),x:f,y:o,width:p,height:c,stroke:"none",fill:s[y],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return G.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},h)}var EAe=function(t,r){var s=t.xAxis,a=t.width,i=t.height,o=t.offset;return LB(M2(ts(ts(ts({},pf.defaultProps),s),{},{ticks:_o(s,!0),viewBox:{x:0,y:0,width:a,height:i}})),o.left,o.left+o.width,r)},OAe=function(t,r){var s=t.yAxis,a=t.width,i=t.height,o=t.offset;return LB(M2(ts(ts(ts({},pf.defaultProps),s),{},{ticks:_o(s,!0),viewBox:{x:0,y:0,width:a,height:i}})),o.top,o.top+o.height,r)},tu={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function hr(e){var t,r,s,a,i,o,l=T2(),c=A2(),d=yTe(),u=ts(ts({},e),{},{stroke:(t=e.stroke)!==null&&t!==void 0?t:tu.stroke,fill:(r=e.fill)!==null&&r!==void 0?r:tu.fill,horizontal:(s=e.horizontal)!==null&&s!==void 0?s:tu.horizontal,horizontalFill:(a=e.horizontalFill)!==null&&a!==void 0?a:tu.horizontalFill,vertical:(i=e.vertical)!==null&&i!==void 0?i:tu.vertical,verticalFill:(o=e.verticalFill)!==null&&o!==void 0?o:tu.verticalFill,x:Be(e.x)?e.x:d.left,y:Be(e.y)?e.y:d.top,width:Be(e.width)?e.width:d.width,height:Be(e.height)?e.height:d.height}),h=u.x,f=u.y,m=u.width,g=u.height,p=u.syncWithTicks,y=u.horizontalValues,v=u.verticalValues,j=gTe(),b=xTe();if(!Be(m)||m<=0||!Be(g)||g<=0||!Be(h)||h!==+h||!Be(f)||f!==+f)return null;var _=u.verticalCoordinatesGenerator||EAe,w=u.horizontalCoordinatesGenerator||OAe,N=u.horizontalPoints,S=u.verticalPoints;if((!N||!N.length)&&_t(w)){var C=y&&y.length,P=w({yAxis:b?ts(ts({},b),{},{ticks:C?y:b.ticks}):void 0,width:l,height:c,offset:d},C?!0:p);Co(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(kd(P),"]")),Array.isArray(P)&&(N=P)}if((!S||!S.length)&&_t(_)){var M=v&&v.length,D=_({xAxis:j?ts(ts({},j),{},{ticks:M?v:j.ticks}):void 0,width:l,height:c,offset:d},M?!0:p);Co(Array.isArray(D),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(kd(D),"]")),Array.isArray(D)&&(S=D)}return G.createElement("g",{className:"recharts-cartesian-grid"},G.createElement(CAe,{fill:u.fill,fillOpacity:u.fillOpacity,x:u.x,y:u.y,width:u.width,height:u.height,ry:u.ry}),G.createElement(kAe,Vc({},u,{offset:d,horizontalPoints:N,xAxis:j,yAxis:b})),G.createElement(PAe,Vc({},u,{offset:d,verticalPoints:S,xAxis:j,yAxis:b})),G.createElement(TAe,Vc({},u,{horizontalPoints:N})),G.createElement(AAe,Vc({},u,{verticalPoints:S})))}hr.displayName="CartesianGrid";var MAe=["type","layout","connectNulls","ref"],DAe=["key"];function Eh(e){"@babel/helpers - typeof";return Eh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Eh(e)}function W4(e,t){if(e==null)return{};var r=RAe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function RAe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function km(){return km=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},km.apply(this,arguments)}function H4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Vs(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?H4(Object(r),!0).forEach(function(s){Qa(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function ru(e){return FAe(e)||LAe(e)||IAe(e)||$Ae()}function $Ae(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
751In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function IAe(e,t){if(e){if(typeof e=="string")return tS(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tS(e,t)}}function LAe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function FAe(e){if(Array.isArray(e))return tS(e)}function tS(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function UAe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function V4(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Eq(s.key),s)}}function zAe(e,t,r){return t&&V4(e.prototype,t),r&&V4(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function BAe(e,t,r){return t=Xy(t),qAe(e,Aq()?Reflect.construct(t,r||[],Xy(e).constructor):t.apply(e,r))}function qAe(e,t){if(t&&(Eh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WAe(e)}function WAe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Aq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Aq=function(){return!!e})()}function Xy(e){return Xy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Xy(e)}function HAe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&rS(e,t)}function rS(e,t){return rS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},rS(e,t)}function Qa(e,t,r){return t=Eq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Eq(e){var t=VAe(e,"string");return Eh(t)=="symbol"?t:t+""}function VAe(e,t){if(Eh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Eh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Qt=function(e){function t(){var r;UAe(this,t);for(var s=arguments.length,a=new Array(s),i=0;i<s;i++)a[i]=arguments[i];return r=BAe(this,t,[].concat(a)),Qa(r,"state",{isAnimationFinished:!0,totalLength:0}),Qa(r,"generateSimpleStrokeDasharray",function(o,l){return"".concat(l,"px ").concat(o-l,"px")}),Qa(r,"getStrokeDasharray",function(o,l,c){var d=c.reduce(function(v,j){return v+j});if(!d)return r.generateSimpleStrokeDasharray(l,o);for(var u=Math.floor(o/d),h=o%d,f=l-o,m=[],g=0,p=0;g<c.length;p+=c[g],++g)if(p+c[g]>h){m=[].concat(ru(c.slice(0,g)),[h-p]);break}var y=m.length%2===0?[0,f]:[f];return[].concat(ru(t.repeat(c,u)),ru(m),y).map(function(v){return"".concat(v,"px")}).join(", ")}),Qa(r,"id",Ng("recharts-line-")),Qa(r,"pathRef",function(o){r.mainCurve=o}),Qa(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Qa(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return HAe(t,e),zAe(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var s=this.getTotalLength();this.setState({totalLength:s})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var s=this.getTotalLength();s!==this.state.totalLength&&this.setState({totalLength:s})}}},{key:"getTotalLength",value:function(){var s=this.mainCurve;try{return s&&s.getTotalLength&&s.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(s,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,l=i.xAxis,c=i.yAxis,d=i.layout,u=i.children,h=ka(u,Ag);if(!h)return null;var f=function(p,y){return{x:p.x,y:p.y,value:p.value,errorVal:la(p.payload,y)}},m={clipPath:s?"url(#clipPath-".concat(a,")"):null};return G.createElement(en,m,h.map(function(g){return G.cloneElement(g,{key:"bar-".concat(g.props.dataKey),data:o,xAxis:l,yAxis:c,layout:d,dataPointFormatter:f})}))}},{key:"renderDots",value:function(s,a,i){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.dot,d=l.points,u=l.dataKey,h=$t(this.props,!1),f=$t(c,!0),m=d.map(function(p,y){var v=Vs(Vs(Vs({key:"dot-".concat(y),r:3},h),f),{},{index:y,cx:p.x,cy:p.y,value:p.value,dataKey:u,payload:p.payload,points:d});return t.renderDotItem(c,v)}),g={clipPath:s?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return G.createElement(en,km({className:"recharts-line-dots",key:"dots"},g),m)}},{key:"renderCurveStatically",value:function(s,a,i,o){var l=this.props,c=l.type,d=l.layout,u=l.connectNulls;l.ref;var h=W4(l,MAe),f=Vs(Vs(Vs({},$t(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(i,")"):null,points:s},o),{},{type:c,layout:d,connectNulls:u});return G.createElement(M1,km({},f,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(s,a){var i=this,o=this.props,l=o.points,c=o.strokeDasharray,d=o.isAnimationActive,u=o.animationBegin,h=o.animationDuration,f=o.animationEasing,m=o.animationId,g=o.animateNewValues,p=o.width,y=o.height,v=this.state,j=v.prevPoints,b=v.totalLength;return G.createElement(Ko,{begin:u,duration:h,isActive:d,easing:f,from:{t:0},to:{t:1},key:"line-".concat(m),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(_){var w=_.t;if(j){var N=j.length/l.length,S=l.map(function(A,U){var F=Math.floor(U*N);if(j[F]){var L=j[F],$=Za(L.x,A.x),R=Za(L.y,A.y);return Vs(Vs({},A),{},{x:$(w),y:R(w)})}if(g){var T=Za(p*2,A.x),k=Za(y/2,A.y);return Vs(Vs({},A),{},{x:T(w),y:k(w)})}return Vs(Vs({},A),{},{x:A.x,y:A.y})});return i.renderCurveStatically(S,s,a)}var C=Za(0,b),P=C(w),M;if(c){var D="".concat(c).split(/[,\s]+/gim).map(function(A){return parseFloat(A)});M=i.getStrokeDasharray(P,b,D)}else M=i.generateSimpleStrokeDasharray(b,P);return i.renderCurveStatically(l,s,a,{strokeDasharray:M})})}},{key:"renderCurve",value:function(s,a){var i=this.props,o=i.points,l=i.isAnimationActive,c=this.state,d=c.prevPoints,u=c.totalLength;return l&&o&&o.length&&(!d&&u>0||!Fj(d,o))?this.renderCurveWithAnimation(s,a):this.renderCurveStatically(o,s,a)}},{key:"render",value:function(){var s,a=this.props,i=a.hide,o=a.dot,l=a.points,c=a.className,d=a.xAxis,u=a.yAxis,h=a.top,f=a.left,m=a.width,g=a.height,p=a.isAnimationActive,y=a.id;if(i||!l||!l.length)return null;var v=this.state.isAnimationFinished,j=l.length===1,b=It("recharts-line",c),_=d&&d.allowDataOverflow,w=u&&u.allowDataOverflow,N=_||w,S=Pt(y)?this.id:y,C=(s=$t(o,!1))!==null&&s!==void 0?s:{r:3,strokeWidth:2},P=C.r,M=P===void 0?3:P,D=C.strokeWidth,A=D===void 0?2:D,U=oue(o)?o:{},F=U.clipDot,L=F===void 0?!0:F,$=M*2+A;return G.createElement(en,{className:b},_||w?G.createElement("defs",null,G.createElement("clipPath",{id:"clipPath-".concat(S)},G.createElement("rect",{x:_?f:f-m/2,y:w?h:h-g/2,width:_?m:m*2,height:w?g:g*2})),!L&&G.createElement("clipPath",{id:"clipPath-dots-".concat(S)},G.createElement("rect",{x:f-$/2,y:h-$/2,width:m+$,height:g+$}))):null,!j&&this.renderCurve(N,S),this.renderErrorBar(N,S),(j||o)&&this.renderDots(N,L,S),(!p||v)&&Ql.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(s,a){return s.animationId!==a.prevAnimationId?{prevAnimationId:s.animationId,curPoints:s.points,prevPoints:a.curPoints}:s.points!==a.curPoints?{curPoints:s.points}:null}},{key:"repeat",value:function(s,a){for(var i=s.length%2!==0?[].concat(ru(s),[0]):s,o=[],l=0;l<a;++l)o=[].concat(ru(o),ru(i));return o}},{key:"renderDotItem",value:function(s,a){var i;if(G.isValidElement(s))i=G.cloneElement(s,a);else if(_t(s))i=s(a);else{var o=a.key,l=W4(a,DAe),c=It("recharts-line-dot",typeof s!="boolean"?s.className:"");i=G.createElement(S2,km({key:o},l,{className:c}))}return i}}])}(x.PureComponent);Qa(Qt,"displayName","Line");Qa(Qt,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Po.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});Qa(Qt,"getComposedData",function(e){var t=e.props,r=e.xAxis,s=e.yAxis,a=e.xAxisTicks,i=e.yAxisTicks,o=e.dataKey,l=e.bandSize,c=e.displayedData,d=e.offset,u=t.layout,h=c.map(function(f,m){var g=la(f,o);return u==="horizontal"?{x:CM({axis:r,ticks:a,bandSize:l,entry:f,index:m}),y:Pt(g)?null:s.scale(g),value:g,payload:f}:{x:Pt(g)?null:r.scale(g),y:CM({axis:s,ticks:i,bandSize:l,entry:f,index:m}),value:g,payload:f}});return Vs({points:h,layout:u},d)});function Oh(e){"@babel/helpers - typeof";return Oh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Oh(e)}function KAe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function GAe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Dq(s.key),s)}}function YAe(e,t,r){return t&&GAe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function QAe(e,t,r){return t=Zy(t),XAe(e,Oq()?Reflect.construct(t,r||[],Zy(e).constructor):t.apply(e,r))}function XAe(e,t){if(t&&(Oh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ZAe(e)}function ZAe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Oq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Oq=function(){return!!e})()}function Zy(e){return Zy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Zy(e)}function JAe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&nS(e,t)}function nS(e,t){return nS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},nS(e,t)}function Mq(e,t,r){return t=Dq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Dq(e){var t=eEe(e,"string");return Oh(t)=="symbol"?t:t+""}function eEe(e,t){if(Oh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Oh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function sS(){return sS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},sS.apply(this,arguments)}function tEe(e){var t=e.xAxisId,r=T2(),s=A2(),a=vq(t);return a==null?null:x.createElement(pf,sS({},a,{className:It("recharts-".concat(a.axisType," ").concat(a.axisType),a.className),viewBox:{x:0,y:0,width:r,height:s},ticksGenerator:function(o){return _o(o,!0)}}))}var Zt=function(e){function t(){return KAe(this,t),QAe(this,t,arguments)}return JAe(t,e),YAe(t,[{key:"render",value:function(){return x.createElement(tEe,this.props)}}])}(x.Component);Mq(Zt,"displayName","XAxis");Mq(Zt,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function Mh(e){"@babel/helpers - typeof";return Mh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Mh(e)}function rEe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function nEe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Iq(s.key),s)}}function sEe(e,t,r){return t&&nEe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function aEe(e,t,r){return t=Jy(t),iEe(e,Rq()?Reflect.construct(t,r||[],Jy(e).constructor):t.apply(e,r))}function iEe(e,t){if(t&&(Mh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return oEe(e)}function oEe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Rq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Rq=function(){return!!e})()}function Jy(e){return Jy=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Jy(e)}function lEe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&aS(e,t)}function aS(e,t){return aS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},aS(e,t)}function $q(e,t,r){return t=Iq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Iq(e){var t=cEe(e,"string");return Mh(t)=="symbol"?t:t+""}function cEe(e,t){if(Mh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Mh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function iS(){return iS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},iS.apply(this,arguments)}var dEe=function(t){var r=t.yAxisId,s=T2(),a=A2(),i=yq(r);return i==null?null:x.createElement(pf,iS({},i,{className:It("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:s,height:a},ticksGenerator:function(l){return _o(l,!0)}}))},Jt=function(e){function t(){return rEe(this,t),aEe(this,t,arguments)}return lEe(t,e),sEe(t,[{key:"render",value:function(){return x.createElement(dEe,this.props)}}])}(x.Component);$q(Jt,"displayName","YAxis");$q(Jt,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function K4(e){return mEe(e)||fEe(e)||hEe(e)||uEe()}function uEe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
752In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hEe(e,t){if(e){if(typeof e=="string")return oS(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return oS(e,t)}}function fEe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function mEe(e){if(Array.isArray(e))return oS(e)}function oS(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}var lS=function(t,r,s,a,i){var o=ka(t,O2),l=ka(t,Vj),c=[].concat(K4(o),K4(l)),d=ka(t,Gj),u="".concat(a,"Id"),h=a[0],f=r;if(c.length&&(f=c.reduce(function(p,y){if(y.props[u]===s&&$i(y.props,"extendDomain")&&Be(y.props[h])){var v=y.props[h];return[Math.min(p[0],v),Math.max(p[1],v)]}return p},f)),d.length){var m="".concat(h,"1"),g="".concat(h,"2");f=d.reduce(function(p,y){if(y.props[u]===s&&$i(y.props,"extendDomain")&&Be(y.props[m])&&Be(y.props[g])){var v=y.props[m],j=y.props[g];return[Math.min(p[0],v,j),Math.max(p[1],v,j)]}return p},f)}return i&&i.length&&(f=i.reduce(function(p,y){return Be(y)?[Math.min(p[0],y),Math.max(p[1],y)]:p},f)),f},Lq={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,r="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(r=!1));function a(c,d,u){this.fn=c,this.context=d,this.once=u||!1}function i(c,d,u,h,f){if(typeof u!="function")throw new TypeError("The listener must be a function");var m=new a(u,h||c,f),g=r?r+d:d;return c._events[g]?c._events[g].fn?c._events[g]=[c._events[g],m]:c._events[g].push(m):(c._events[g]=m,c._eventsCount++),c}function o(c,d){--c._eventsCount===0?c._events=new s:delete c._events[d]}function l(){this._events=new s,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],u,h;if(this._eventsCount===0)return d;for(h in u=this._events)t.call(u,h)&&d.push(r?h.slice(1):h);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},l.prototype.listeners=function(d){var u=r?r+d:d,h=this._events[u];if(!h)return[];if(h.fn)return[h.fn];for(var f=0,m=h.length,g=new Array(m);f<m;f++)g[f]=h[f].fn;return g},l.prototype.listenerCount=function(d){var u=r?r+d:d,h=this._events[u];return h?h.fn?1:h.length:0},l.prototype.emit=function(d,u,h,f,m,g){var p=r?r+d:d;if(!this._events[p])return!1;var y=this._events[p],v=arguments.length,j,b;if(y.fn){switch(y.once&&this.removeListener(d,y.fn,void 0,!0),v){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,u),!0;case 3:return y.fn.call(y.context,u,h),!0;case 4:return y.fn.call(y.context,u,h,f),!0;case 5:return y.fn.call(y.context,u,h,f,m),!0;case 6:return y.fn.call(y.context,u,h,f,m,g),!0}for(b=1,j=new Array(v-1);b<v;b++)j[b-1]=arguments[b];y.fn.apply(y.context,j)}else{var _=y.length,w;for(b=0;b<_;b++)switch(y[b].once&&this.removeListener(d,y[b].fn,void 0,!0),v){case 1:y[b].fn.call(y[b].context);break;case 2:y[b].fn.call(y[b].context,u);break;case 3:y[b].fn.call(y[b].context,u,h);break;case 4:y[b].fn.call(y[b].context,u,h,f);break;default:if(!j)for(w=1,j=new Array(v-1);w<v;w++)j[w-1]=arguments[w];y[b].fn.apply(y[b].context,j)}}return!0},l.prototype.on=function(d,u,h){return i(this,d,u,h,!1)},l.prototype.once=function(d,u,h){return i(this,d,u,h,!0)},l.prototype.removeListener=function(d,u,h,f){var m=r?r+d:d;if(!this._events[m])return this;if(!u)return o(this,m),this;var g=this._events[m];if(g.fn)g.fn===u&&(!f||g.once)&&(!h||g.context===h)&&o(this,m);else{for(var p=0,y=[],v=g.length;p<v;p++)(g[p].fn!==u||f&&!g[p].once||h&&g[p].context!==h)&&y.push(g[p]);y.length?this._events[m]=y.length===1?y[0]:y:o(this,m)}return this},l.prototype.removeAllListeners=function(d){var u;return d?(u=r?r+d:d,this._events[u]&&o(this,u)):(this._events=new s,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=r,l.EventEmitter=l,e.exports=l})(Lq);var pEe=Lq.exports;const gEe=fr(pEe);var Fw=new gEe,Uw="recharts.syncMouseEvents";function Up(e){"@babel/helpers - typeof";return Up=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Up(e)}function xEe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function vEe(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,Fq(s.key),s)}}function yEe(e,t,r){return t&&vEe(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function zw(e,t,r){return t=Fq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fq(e){var t=jEe(e,"string");return Up(t)=="symbol"?t:t+""}function jEe(e,t){if(Up(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t);if(Up(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var bEe=function(){function e(){xEe(this,e),zw(this,"activeIndex",0),zw(this,"coordinateList",[]),zw(this,"layout","horizontal")}return yEe(e,[{key:"setDetails",value:function(r){var s,a=r.coordinateList,i=a===void 0?null:a,o=r.container,l=o===void 0?null:o,c=r.layout,d=c===void 0?null:c,u=r.offset,h=u===void 0?null:u,f=r.mouseHandlerCallback,m=f===void 0?null:f;this.coordinateList=(s=i??this.coordinateList)!==null&&s!==void 0?s:[],this.container=l??this.container,this.layout=d??this.layout,this.offset=h??this.offset,this.mouseHandlerCallback=m??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(r){if(this.coordinateList.length!==0)switch(r.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(r){this.activeIndex=r}},{key:"spoofMouse",value:function(){var r,s;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var a=this.container.getBoundingClientRect(),i=a.x,o=a.y,l=a.height,c=this.coordinateList[this.activeIndex].coordinate,d=((r=window)===null||r===void 0?void 0:r.scrollX)||0,u=((s=window)===null||s===void 0?void 0:s.scrollY)||0,h=i+c+d,f=o+this.offset.top+l/2+u;this.mouseHandlerCallback({pageX:h,pageY:f})}}}])}();function wEe(e,t,r){if(r==="number"&&t===!0&&Array.isArray(e)){var s=e==null?void 0:e[0],a=e==null?void 0:e[1];if(s&&a&&Be(s)&&Be(a))return!0}return!1}function _Ee(e,t,r,s){var a=s/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-a:r.left+.5,y:e==="horizontal"?r.top+.5:t.y-a,width:e==="horizontal"?s:r.width-1,height:e==="horizontal"?r.height-1:s}}function Uq(e){var t=e.cx,r=e.cy,s=e.radius,a=e.startAngle,i=e.endAngle,o=Rn(t,r,s,a),l=Rn(t,r,s,i);return{points:[o,l],cx:t,cy:r,radius:s,startAngle:a,endAngle:i}}function NEe(e,t,r){var s,a,i,o;if(e==="horizontal")s=t.x,i=s,a=r.top,o=r.top+r.height;else if(e==="vertical")a=t.y,o=a,s=r.left,i=r.left+r.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var l=t.cx,c=t.cy,d=t.innerRadius,u=t.outerRadius,h=t.angle,f=Rn(l,c,d,h),m=Rn(l,c,u,h);s=f.x,a=f.y,i=m.x,o=m.y}else return Uq(t);return[{x:s,y:a},{x:i,y:o}]}function zp(e){"@babel/helpers - typeof";return zp=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zp(e)}function G4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Sx(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?G4(Object(r),!0).forEach(function(s){SEe(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function SEe(e,t,r){return t=CEe(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function CEe(e){var t=kEe(e,"string");return zp(t)=="symbol"?t:t+""}function kEe(e,t){if(zp(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(zp(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function PEe(e){var t,r,s=e.element,a=e.tooltipEventType,i=e.isActive,o=e.activeCoordinate,l=e.activePayload,c=e.offset,d=e.activeTooltipIndex,u=e.tooltipAxisBandSize,h=e.layout,f=e.chartName,m=(t=s.props.cursor)!==null&&t!==void 0?t:(r=s.type.defaultProps)===null||r===void 0?void 0:r.cursor;if(!s||!m||!i||!o||f!=="ScatterChart"&&a!=="axis")return null;var g,p=M1;if(f==="ScatterChart")g=o,p=Pke;else if(f==="BarChart")g=_Ee(h,o,c,u),p=N2;else if(h==="radial"){var y=Uq(o),v=y.cx,j=y.cy,b=y.radius,_=y.startAngle,w=y.endAngle;g={cx:v,cy:j,startAngle:_,endAngle:w,innerRadius:b,outerRadius:b},p=qB}else g={points:NEe(h,o,c)},p=M1;var N=Sx(Sx(Sx(Sx({stroke:"#ccc",pointerEvents:"none"},c),g),$t(m,!1)),{},{payload:l,payloadIndex:d,className:It("recharts-tooltip-cursor",m.className)});return x.isValidElement(m)?x.cloneElement(m,N):x.createElement(p,N)}var TEe=["item"],AEe=["children","className","width","height","style","compact","title","desc"];function Dh(e){"@babel/helpers - typeof";return Dh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Dh(e)}function ju(){return ju=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},ju.apply(this,arguments)}function Y4(e,t){return MEe(e)||OEe(e,t)||Bq(e,t)||EEe()}function EEe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
753In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function OEe(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var s,a,i,o,l=[],c=!0,d=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(c=(s=i.call(r)).done)&&(l.push(s.value),l.length!==t);c=!0);}catch(u){d=!0,a=u}finally{try{if(!c&&r.return!=null&&(o=r.return(),Object(o)!==o))return}finally{if(d)throw a}}return l}}function MEe(e){if(Array.isArray(e))return e}function Q4(e,t){if(e==null)return{};var r=DEe(e,t),s,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)s=i[a],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function DEe(e,t){if(e==null)return{};var r={};for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){if(t.indexOf(s)>=0)continue;r[s]=e[s]}return r}function REe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function $Ee(e,t){for(var r=0;r<t.length;r++){var s=t[r];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,qq(s.key),s)}}function IEe(e,t,r){return t&&$Ee(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function LEe(e,t,r){return t=e0(t),FEe(e,zq()?Reflect.construct(t,r||[],e0(e).constructor):t.apply(e,r))}function FEe(e,t){if(t&&(Dh(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return UEe(e)}function UEe(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zq(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zq=function(){return!!e})()}function e0(e){return e0=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},e0(e)}function zEe(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&cS(e,t)}function cS(e,t){return cS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(s,a){return s.__proto__=a,s},cS(e,t)}function Rh(e){return WEe(e)||qEe(e)||Bq(e)||BEe()}function BEe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
754In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bq(e,t){if(e){if(typeof e=="string")return dS(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return dS(e,t)}}function qEe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function WEe(e){if(Array.isArray(e))return dS(e)}function dS(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,s=new Array(t);r<t;r++)s[r]=e[r];return s}function X4(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,s)}return r}function Ne(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?X4(Object(r),!0).forEach(function(s){lt(e,s,r[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):X4(Object(r)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(r,s))})}return e}function lt(e,t,r){return t=qq(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qq(e){var t=HEe(e,"string");return Dh(t)=="symbol"?t:t+""}function HEe(e,t){if(Dh(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var s=r.call(e,t||"default");if(Dh(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var VEe={xAxis:["bottom","top"],yAxis:["left","right"]},KEe={width:"100%",height:"100%"},Wq={x:0,y:0};function Cx(e){return e}var GEe=function(t,r){return r==="horizontal"?t.x:r==="vertical"?t.y:r==="centric"?t.angle:t.radius},YEe=function(t,r,s,a){var i=r.find(function(u){return u&&u.index===s});if(i){if(t==="horizontal")return{x:i.coordinate,y:a.y};if(t==="vertical")return{x:a.x,y:i.coordinate};if(t==="centric"){var o=i.coordinate,l=a.radius;return Ne(Ne(Ne({},a),Rn(a.cx,a.cy,l,o)),{},{angle:o,radius:l})}var c=i.coordinate,d=a.angle;return Ne(Ne(Ne({},a),Rn(a.cx,a.cy,c,d)),{},{angle:d,radius:c})}return Wq},Yj=function(t,r){var s=r.graphicalItems,a=r.dataStartIndex,i=r.dataEndIndex,o=(s??[]).reduce(function(l,c){var d=c.props.data;return d&&d.length?[].concat(Rh(l),Rh(d)):l},[]);return o.length>0?o:t&&t.length&&Be(a)&&Be(i)?t.slice(a,i+1):[]};function Hq(e){return e==="number"?[0,"auto"]:void 0}var uS=function(t,r,s,a){var i=t.graphicalItems,o=t.tooltipAxis,l=Yj(r,t);return s<0||!i||!i.length||s>=l.length?null:i.reduce(function(c,d){var u,h=(u=d.props.data)!==null&&u!==void 0?u:r;h&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=s&&(h=h.slice(t.dataStartIndex,t.dataEndIndex+1));var f;if(o.dataKey&&!o.allowDuplicatedCategory){var m=h===void 0?l:h;f=ry(m,o.dataKey,a)}else f=h&&h[s]||l[s];return f?[].concat(Rh(c),[UB(d,f)]):c},[])},Z4=function(t,r,s,a){var i=a||{x:t.chartX,y:t.chartY},o=GEe(i,s),l=t.orderedTooltipTicks,c=t.tooltipAxis,d=t.tooltipTicks,u=d1e(o,l,d,c);if(u>=0&&d){var h=d[u]&&d[u].value,f=uS(t,r,u,h),m=YEe(s,l,u,i);return{activeTooltipIndex:u,activeLabel:h,activePayload:f,activeCoordinate:m}}return null},QEe=function(t,r){var s=r.axes,a=r.graphicalItems,i=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,u=t.layout,h=t.children,f=t.stackOffset,m=IB(u,i);return s.reduce(function(g,p){var y,v=p.type.defaultProps!==void 0?Ne(Ne({},p.type.defaultProps),p.props):p.props,j=v.type,b=v.dataKey,_=v.allowDataOverflow,w=v.allowDuplicatedCategory,N=v.scale,S=v.ticks,C=v.includeHidden,P=v[o];if(g[P])return g;var M=Yj(t.data,{graphicalItems:a.filter(function(Q){var ue,X=o in Q.props?Q.props[o]:(ue=Q.type.defaultProps)===null||ue===void 0?void 0:ue[o];return X===P}),dataStartIndex:c,dataEndIndex:d}),D=M.length,A,U,F;wEe(v.domain,_,j)&&(A=P1(v.domain,null,_),m&&(j==="number"||N!=="auto")&&(F=Sm(M,b,"category")));var L=Hq(j);if(!A||A.length===0){var $,R=($=v.domain)!==null&&$!==void 0?$:L;if(b){if(A=Sm(M,b,j),j==="category"&&m){var T=Xde(A);w&&T?(U=A,A=zy(0,D)):w||(A=AM(R,A,p).reduce(function(Q,ue){return Q.indexOf(ue)>=0?Q:[].concat(Rh(Q),[ue])},[]))}else if(j==="category")w?A=A.filter(function(Q){return Q!==""&&!Pt(Q)}):A=AM(R,A,p).reduce(function(Q,ue){return Q.indexOf(ue)>=0||ue===""||Pt(ue)?Q:[].concat(Rh(Q),[ue])},[]);else if(j==="number"){var k=p1e(M,a.filter(function(Q){var ue,X,le=o in Q.props?Q.props[o]:(ue=Q.type.defaultProps)===null||ue===void 0?void 0:ue[o],pe="hide"in Q.props?Q.props.hide:(X=Q.type.defaultProps)===null||X===void 0?void 0:X.hide;return le===P&&(C||!pe)}),b,i,u);k&&(A=k)}m&&(j==="number"||N!=="auto")&&(F=Sm(M,b,"category"))}else m?A=zy(0,D):l&&l[P]&&l[P].hasStack&&j==="number"?A=f==="expand"?[0,1]:FB(l[P].stackGroups,c,d):A=$B(M,a.filter(function(Q){var ue=o in Q.props?Q.props[o]:Q.type.defaultProps[o],X="hide"in Q.props?Q.props.hide:Q.type.defaultProps.hide;return ue===P&&(C||!X)}),j,u,!0);if(j==="number")A=lS(h,A,P,i,S),R&&(A=P1(R,A,_));else if(j==="category"&&R){var W=R,q=A.every(function(Q){return W.indexOf(Q)>=0});q&&(A=W)}}return Ne(Ne({},g),{},lt({},P,Ne(Ne({},v),{},{axisType:i,domain:A,categoricalDomain:F,duplicateDomain:U,originalDomain:(y=v.domain)!==null&&y!==void 0?y:L,isCategorical:m,layout:u})))},{})},XEe=function(t,r){var s=r.graphicalItems,a=r.Axis,i=r.axisType,o=r.axisIdKey,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,u=t.layout,h=t.children,f=Yj(t.data,{graphicalItems:s,dataStartIndex:c,dataEndIndex:d}),m=f.length,g=IB(u,i),p=-1;return s.reduce(function(y,v){var j=v.type.defaultProps!==void 0?Ne(Ne({},v.type.defaultProps),v.props):v.props,b=j[o],_=Hq("number");if(!y[b]){p++;var w;return g?w=zy(0,m):l&&l[b]&&l[b].hasStack?(w=FB(l[b].stackGroups,c,d),w=lS(h,w,b,i)):(w=P1(_,$B(f,s.filter(function(N){var S,C,P=o in N.props?N.props[o]:(S=N.type.defaultProps)===null||S===void 0?void 0:S[o],M="hide"in N.props?N.props.hide:(C=N.type.defaultProps)===null||C===void 0?void 0:C.hide;return P===b&&!M}),"number",u),a.defaultProps.allowDataOverflow),w=lS(h,w,b,i)),Ne(Ne({},y),{},lt({},b,Ne(Ne({axisType:i},a.defaultProps),{},{hide:!0,orientation:Ca(VEe,"".concat(i,".").concat(p%2),null),domain:w,originalDomain:_,isCategorical:g,layout:u})))}return y},{})},ZEe=function(t,r){var s=r.axisType,a=s===void 0?"xAxis":s,i=r.AxisComp,o=r.graphicalItems,l=r.stackGroups,c=r.dataStartIndex,d=r.dataEndIndex,u=t.children,h="".concat(a,"Id"),f=ka(u,i),m={};return f&&f.length?m=QEe(t,{axes:f,graphicalItems:o,axisType:a,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:d}):o&&o.length&&(m=XEe(t,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:h,stackGroups:l,dataStartIndex:c,dataEndIndex:d})),m},JEe=function(t){var r=bl(t),s=_o(r,!1,!0);return{tooltipTicks:s,orderedTooltipTicks:Xk(s,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:Oy(r,s)}},J4=function(t){var r=t.children,s=t.defaultShowTooltip,a=Ys(r,Sh),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!s}},eOe=function(t){return!t||!t.length?!1:t.some(function(r){var s=So(r&&r.type);return s&&s.indexOf("Bar")>=0})},eD=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},tOe=function(t,r){var s=t.props,a=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,l=t.yAxisMap,c=l===void 0?{}:l,d=s.width,u=s.height,h=s.children,f=s.margin||{},m=Ys(h,Sh),g=Ys(h,ko),p=Object.keys(c).reduce(function(w,N){var S=c[N],C=S.orientation;return!S.mirror&&!S.hide?Ne(Ne({},w),{},lt({},C,w[C]+S.width)):w},{left:f.left||0,right:f.right||0}),y=Object.keys(o).reduce(function(w,N){var S=o[N],C=S.orientation;return!S.mirror&&!S.hide?Ne(Ne({},w),{},lt({},C,Ca(w,"".concat(C))+S.height)):w},{top:f.top||0,bottom:f.bottom||0}),v=Ne(Ne({},y),p),j=v.bottom;m&&(v.bottom+=m.props.height||Sh.defaultProps.height),g&&r&&(v=f1e(v,a,s,r));var b=d-v.left-v.right,_=u-v.top-v.bottom;return Ne(Ne({brushBottom:j},v),{},{width:Math.max(b,0),height:Math.max(_,0)})},rOe=function(t,r){if(r==="xAxis")return t[r].width;if(r==="yAxis")return t[r].height},Vq=function(t){var r=t.chartName,s=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,o=t.validateTooltipEventTypes,l=o===void 0?["axis"]:o,c=t.axisComponents,d=t.legendContent,u=t.formatAxisMap,h=t.defaultProps,f=function(v,j){var b=j.graphicalItems,_=j.stackGroups,w=j.offset,N=j.updateId,S=j.dataStartIndex,C=j.dataEndIndex,P=v.barSize,M=v.layout,D=v.barGap,A=v.barCategoryGap,U=v.maxBarSize,F=eD(M),L=F.numericAxisName,$=F.cateAxisName,R=eOe(b),T=[];return b.forEach(function(k,W){var q=Yj(v.data,{graphicalItems:[k],dataStartIndex:S,dataEndIndex:C}),Q=k.type.defaultProps!==void 0?Ne(Ne({},k.type.defaultProps),k.props):k.props,ue=Q.dataKey,X=Q.maxBarSize,le=Q["".concat(L,"Id")],pe=Q["".concat($,"Id")],ce={},se=c.reduce(function(O,I){var Y=j["".concat(I.axisType,"Map")],te=Q["".concat(I.axisType,"Id")];Y&&Y[te]||I.axisType==="zAxis"||Cd();var K=Y[te];return Ne(Ne({},O),{},lt(lt({},I.axisType,K),"".concat(I.axisType,"Ticks"),_o(K)))},ce),oe=se[$],V=se["".concat($,"Ticks")],fe=_&&_[le]&&_[le].hasStack&&k1e(k,_[le].stackGroups),ne=So(k.type).indexOf("Bar")>=0,Ce=Oy(oe,V),Pe=[],he=R&&u1e({barSize:P,stackGroups:_,totalSize:rOe(se,$)});if(ne){var ke,Me,Je=Pt(X)?U:X,Ke=(ke=(Me=Oy(oe,V,!0))!==null&&Me!==void 0?Me:Je)!==null&&ke!==void 0?ke:0;Pe=h1e({barGap:D,barCategoryGap:A,bandSize:Ke!==Ce?Ke:Ce,sizeList:he[pe],maxBarSize:Je}),Ke!==Ce&&(Pe=Pe.map(function(O){return Ne(Ne({},O),{},{position:Ne(Ne({},O.position),{},{offset:O.position.offset-Ke/2})})}))}var E=k&&k.type&&k.type.getComposedData;E&&T.push({props:Ne(Ne({},E(Ne(Ne({},se),{},{displayedData:q,props:v,dataKey:ue,item:k,bandSize:Ce,barPosition:Pe,offset:w,stackedData:fe,layout:M,dataStartIndex:S,dataEndIndex:C}))),{},lt(lt(lt({key:k.key||"item-".concat(W)},L,se[L]),$,se[$]),"animationId",N)),childIndex:due(k,v.children),item:k})}),T},m=function(v,j){var b=v.props,_=v.dataStartIndex,w=v.dataEndIndex,N=v.updateId;if(!_E({props:b}))return null;var S=b.children,C=b.layout,P=b.stackOffset,M=b.data,D=b.reverseStackOrder,A=eD(C),U=A.numericAxisName,F=A.cateAxisName,L=ka(S,s),$=N1e(M,L,"".concat(U,"Id"),"".concat(F,"Id"),P,D),R=c.reduce(function(Q,ue){var X="".concat(ue.axisType,"Map");return Ne(Ne({},Q),{},lt({},X,ZEe(b,Ne(Ne({},ue),{},{graphicalItems:L,stackGroups:ue.axisType===U&&$,dataStartIndex:_,dataEndIndex:w}))))},{}),T=tOe(Ne(Ne({},R),{},{props:b,graphicalItems:L}),j==null?void 0:j.legendBBox);Object.keys(R).forEach(function(Q){R[Q]=u(b,R[Q],T,Q.replace("Map",""),r)});var k=R["".concat(F,"Map")],W=JEe(k),q=f(b,Ne(Ne({},R),{},{dataStartIndex:_,dataEndIndex:w,updateId:N,graphicalItems:L,stackGroups:$,offset:T}));return Ne(Ne({formattedGraphicalItems:q,graphicalItems:L,offset:T,stackGroups:$},W),R)},g=function(y){function v(j){var b,_,w;return REe(this,v),w=LEe(this,v,[j]),lt(w,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),lt(w,"accessibilityManager",new bEe),lt(w,"handleLegendBBoxUpdate",function(N){if(N){var S=w.state,C=S.dataStartIndex,P=S.dataEndIndex,M=S.updateId;w.setState(Ne({legendBBox:N},m({props:w.props,dataStartIndex:C,dataEndIndex:P,updateId:M},Ne(Ne({},w.state),{},{legendBBox:N}))))}}),lt(w,"handleReceiveSyncEvent",function(N,S,C){if(w.props.syncId===N){if(C===w.eventEmitterSymbol&&typeof w.props.syncMethod!="function")return;w.applySyncEvent(S)}}),lt(w,"handleBrushChange",function(N){var S=N.startIndex,C=N.endIndex;if(S!==w.state.dataStartIndex||C!==w.state.dataEndIndex){var P=w.state.updateId;w.setState(function(){return Ne({dataStartIndex:S,dataEndIndex:C},m({props:w.props,dataStartIndex:S,dataEndIndex:C,updateId:P},w.state))}),w.triggerSyncEvent({dataStartIndex:S,dataEndIndex:C})}}),lt(w,"handleMouseEnter",function(N){var S=w.getMouseInfo(N);if(S){var C=Ne(Ne({},S),{},{isTooltipActive:!0});w.setState(C),w.triggerSyncEvent(C);var P=w.props.onMouseEnter;_t(P)&&P(C,N)}}),lt(w,"triggeredAfterMouseMove",function(N){var S=w.getMouseInfo(N),C=S?Ne(Ne({},S),{},{isTooltipActive:!0}):{isTooltipActive:!1};w.setState(C),w.triggerSyncEvent(C);var P=w.props.onMouseMove;_t(P)&&P(C,N)}),lt(w,"handleItemMouseEnter",function(N){w.setState(function(){return{isTooltipActive:!0,activeItem:N,activePayload:N.tooltipPayload,activeCoordinate:N.tooltipPosition||{x:N.cx,y:N.cy}}})}),lt(w,"handleItemMouseLeave",function(){w.setState(function(){return{isTooltipActive:!1}})}),lt(w,"handleMouseMove",function(N){N.persist(),w.throttleTriggeredAfterMouseMove(N)}),lt(w,"handleMouseLeave",function(N){w.throttleTriggeredAfterMouseMove.cancel();var S={isTooltipActive:!1};w.setState(S),w.triggerSyncEvent(S);var C=w.props.onMouseLeave;_t(C)&&C(S,N)}),lt(w,"handleOuterEvent",function(N){var S=cue(N),C=Ca(w.props,"".concat(S));if(S&&_t(C)){var P,M;/.*touch.*/i.test(S)?M=w.getMouseInfo(N.changedTouches[0]):M=w.getMouseInfo(N),C((P=M)!==null&&P!==void 0?P:{},N)}}),lt(w,"handleClick",function(N){var S=w.getMouseInfo(N);if(S){var C=Ne(Ne({},S),{},{isTooltipActive:!0});w.setState(C),w.triggerSyncEvent(C);var P=w.props.onClick;_t(P)&&P(C,N)}}),lt(w,"handleMouseDown",function(N){var S=w.props.onMouseDown;if(_t(S)){var C=w.getMouseInfo(N);S(C,N)}}),lt(w,"handleMouseUp",function(N){var S=w.props.onMouseUp;if(_t(S)){var C=w.getMouseInfo(N);S(C,N)}}),lt(w,"handleTouchMove",function(N){N.changedTouches!=null&&N.changedTouches.length>0&&w.throttleTriggeredAfterMouseMove(N.changedTouches[0])}),lt(w,"handleTouchStart",function(N){N.changedTouches!=null&&N.changedTouches.length>0&&w.handleMouseDown(N.changedTouches[0])}),lt(w,"handleTouchEnd",function(N){N.changedTouches!=null&&N.changedTouches.length>0&&w.handleMouseUp(N.changedTouches[0])}),lt(w,"handleDoubleClick",function(N){var S=w.props.onDoubleClick;if(_t(S)){var C=w.getMouseInfo(N);S(C,N)}}),lt(w,"handleContextMenu",function(N){var S=w.props.onContextMenu;if(_t(S)){var C=w.getMouseInfo(N);S(C,N)}}),lt(w,"triggerSyncEvent",function(N){w.props.syncId!==void 0&&Fw.emit(Uw,w.props.syncId,N,w.eventEmitterSymbol)}),lt(w,"applySyncEvent",function(N){var S=w.props,C=S.layout,P=S.syncMethod,M=w.state.updateId,D=N.dataStartIndex,A=N.dataEndIndex;if(N.dataStartIndex!==void 0||N.dataEndIndex!==void 0)w.setState(Ne({dataStartIndex:D,dataEndIndex:A},m({props:w.props,dataStartIndex:D,dataEndIndex:A,updateId:M},w.state)));else if(N.activeTooltipIndex!==void 0){var U=N.chartX,F=N.chartY,L=N.activeTooltipIndex,$=w.state,R=$.offset,T=$.tooltipTicks;if(!R)return;if(typeof P=="function")L=P(T,N);else if(P==="value"){L=-1;for(var k=0;k<T.length;k++)if(T[k].value===N.activeLabel){L=k;break}}var W=Ne(Ne({},R),{},{x:R.left,y:R.top}),q=Math.min(U,W.x+W.width),Q=Math.min(F,W.y+W.height),ue=T[L]&&T[L].value,X=uS(w.state,w.props.data,L),le=T[L]?{x:C==="horizontal"?T[L].coordinate:q,y:C==="horizontal"?Q:T[L].coordinate}:Wq;w.setState(Ne(Ne({},N),{},{activeLabel:ue,activeCoordinate:le,activePayload:X,activeTooltipIndex:L}))}else w.setState(N)}),lt(w,"renderCursor",function(N){var S,C=w.state,P=C.isTooltipActive,M=C.activeCoordinate,D=C.activePayload,A=C.offset,U=C.activeTooltipIndex,F=C.tooltipAxisBandSize,L=w.getTooltipEventType(),$=(S=N.props.active)!==null&&S!==void 0?S:P,R=w.props.layout,T=N.key||"_recharts-cursor";return G.createElement(PEe,{key:T,activeCoordinate:M,activePayload:D,activeTooltipIndex:U,chartName:r,element:N,isActive:$,layout:R,offset:A,tooltipAxisBandSize:F,tooltipEventType:L})}),lt(w,"renderPolarAxis",function(N,S,C){var P=Ca(N,"type.axisType"),M=Ca(w.state,"".concat(P,"Map")),D=N.type.defaultProps,A=D!==void 0?Ne(Ne({},D),N.props):N.props,U=M&&M[A["".concat(P,"Id")]];return x.cloneElement(N,Ne(Ne({},U),{},{className:It(P,U.className),key:N.key||"".concat(S,"-").concat(C),ticks:_o(U,!0)}))}),lt(w,"renderPolarGrid",function(N){var S=N.props,C=S.radialLines,P=S.polarAngles,M=S.polarRadius,D=w.state,A=D.radiusAxisMap,U=D.angleAxisMap,F=bl(A),L=bl(U),$=L.cx,R=L.cy,T=L.innerRadius,k=L.outerRadius;return x.cloneElement(N,{polarAngles:Array.isArray(P)?P:_o(L,!0).map(function(W){return W.coordinate}),polarRadius:Array.isArray(M)?M:_o(F,!0).map(function(W){return W.coordinate}),cx:$,cy:R,innerRadius:T,outerRadius:k,key:N.key||"polar-grid",radialLines:C})}),lt(w,"renderLegend",function(){var N=w.state.formattedGraphicalItems,S=w.props,C=S.children,P=S.width,M=S.height,D=w.props.margin||{},A=P-(D.left||0)-(D.right||0),U=DB({children:C,formattedGraphicalItems:N,legendWidth:A,legendContent:d});if(!U)return null;var F=U.item,L=Q4(U,TEe);return x.cloneElement(F,Ne(Ne({},L),{},{chartWidth:P,chartHeight:M,margin:D,onBBoxUpdate:w.handleLegendBBoxUpdate}))}),lt(w,"renderTooltip",function(){var N,S=w.props,C=S.children,P=S.accessibilityLayer,M=Ys(C,Ot);if(!M)return null;var D=w.state,A=D.isTooltipActive,U=D.activeCoordinate,F=D.activePayload,L=D.activeLabel,$=D.offset,R=(N=M.props.active)!==null&&N!==void 0?N:A;return x.cloneElement(M,{viewBox:Ne(Ne({},$),{},{x:$.left,y:$.top}),active:R,label:L,payload:R?F:[],coordinate:U,accessibilityLayer:P})}),lt(w,"renderBrush",function(N){var S=w.props,C=S.margin,P=S.data,M=w.state,D=M.offset,A=M.dataStartIndex,U=M.dataEndIndex,F=M.updateId;return x.cloneElement(N,{key:N.key||"_recharts-brush",onChange:bx(w.handleBrushChange,N.props.onChange),data:P,x:Be(N.props.x)?N.props.x:D.left,y:Be(N.props.y)?N.props.y:D.top+D.height+D.brushBottom-(C.bottom||0),width:Be(N.props.width)?N.props.width:D.width,startIndex:A,endIndex:U,updateId:"brush-".concat(F)})}),lt(w,"renderReferenceElement",function(N,S,C){if(!N)return null;var P=w,M=P.clipPathId,D=w.state,A=D.xAxisMap,U=D.yAxisMap,F=D.offset,L=N.type.defaultProps||{},$=N.props,R=$.xAxisId,T=R===void 0?L.xAxisId:R,k=$.yAxisId,W=k===void 0?L.yAxisId:k;return x.cloneElement(N,{key:N.key||"".concat(S,"-").concat(C),xAxis:A[T],yAxis:U[W],viewBox:{x:F.left,y:F.top,width:F.width,height:F.height},clipPathId:M})}),lt(w,"renderActivePoints",function(N){var S=N.item,C=N.activePoint,P=N.basePoint,M=N.childIndex,D=N.isRange,A=[],U=S.props.key,F=S.item.type.defaultProps!==void 0?Ne(Ne({},S.item.type.defaultProps),S.item.props):S.item.props,L=F.activeDot,$=F.dataKey,R=Ne(Ne({index:M,dataKey:$,cx:C.x,cy:C.y,r:4,fill:_2(S.item),strokeWidth:2,stroke:"#fff",payload:C.payload,value:C.value},$t(L,!1)),ny(L));return A.push(v.renderActiveDot(L,R,"".concat(U,"-activePoint-").concat(M))),P?A.push(v.renderActiveDot(L,Ne(Ne({},R),{},{cx:P.x,cy:P.y}),"".concat(U,"-basePoint-").concat(M))):D&&A.push(null),A}),lt(w,"renderGraphicChild",function(N,S,C){var P=w.filterFormatItem(N,S,C);if(!P)return null;var M=w.getTooltipEventType(),D=w.state,A=D.isTooltipActive,U=D.tooltipAxis,F=D.activeTooltipIndex,L=D.activeLabel,$=w.props.children,R=Ys($,Ot),T=P.props,k=T.points,W=T.isRange,q=T.baseLine,Q=P.item.type.defaultProps!==void 0?Ne(Ne({},P.item.type.defaultProps),P.item.props):P.item.props,ue=Q.activeDot,X=Q.hide,le=Q.activeBar,pe=Q.activeShape,ce=!!(!X&&A&&R&&(ue||le||pe)),se={};M!=="axis"&&R&&R.props.trigger==="click"?se={onClick:bx(w.handleItemMouseEnter,N.props.onClick)}:M!=="axis"&&(se={onMouseLeave:bx(w.handleItemMouseLeave,N.props.onMouseLeave),onMouseEnter:bx(w.handleItemMouseEnter,N.props.onMouseEnter)});var oe=x.cloneElement(N,Ne(Ne({},P.props),se));function V(I){return typeof U.dataKey=="function"?U.dataKey(I.payload):null}if(ce)if(F>=0){var fe,ne;if(U.dataKey&&!U.allowDuplicatedCategory){var Ce=typeof U.dataKey=="function"?V:"payload.".concat(U.dataKey.toString());fe=ry(k,Ce,L),ne=W&&q&&ry(q,Ce,L)}else fe=k==null?void 0:k[F],ne=W&&q&&q[F];if(pe||le){var Pe=N.props.activeIndex!==void 0?N.props.activeIndex:F;return[x.cloneElement(N,Ne(Ne(Ne({},P.props),se),{},{activeIndex:Pe})),null,null]}if(!Pt(fe))return[oe].concat(Rh(w.renderActivePoints({item:P,activePoint:fe,basePoint:ne,childIndex:F,isRange:W})))}else{var he,ke=(he=w.getItemByXY(w.state.activeCoordinate))!==null&&he!==void 0?he:{graphicalItem:oe},Me=ke.graphicalItem,Je=Me.item,Ke=Je===void 0?N:Je,E=Me.childIndex,O=Ne(Ne(Ne({},P.props),se),{},{activeIndex:E});return[x.cloneElement(Ke,O),null,null]}return W?[oe,null,null]:[oe,null]}),lt(w,"renderCustomized",function(N,S,C){return x.cloneElement(N,Ne(Ne({key:"recharts-customized-".concat(C)},w.props),w.state))}),lt(w,"renderMap",{CartesianGrid:{handler:Cx,once:!0},ReferenceArea:{handler:w.renderReferenceElement},ReferenceLine:{handler:Cx},ReferenceDot:{handler:w.renderReferenceElement},XAxis:{handler:Cx},YAxis:{handler:Cx},Brush:{handler:w.renderBrush,once:!0},Bar:{handler:w.renderGraphicChild},Line:{handler:w.renderGraphicChild},Area:{handler:w.renderGraphicChild},Radar:{handler:w.renderGraphicChild},RadialBar:{handler:w.renderGraphicChild},Scatter:{handler:w.renderGraphicChild},Pie:{handler:w.renderGraphicChild},Funnel:{handler:w.renderGraphicChild},Tooltip:{handler:w.renderCursor,once:!0},PolarGrid:{handler:w.renderPolarGrid,once:!0},PolarAngleAxis:{handler:w.renderPolarAxis},PolarRadiusAxis:{handler:w.renderPolarAxis},Customized:{handler:w.renderCustomized}}),w.clipPathId="".concat((b=j.id)!==null&&b!==void 0?b:Ng("recharts"),"-clip"),w.throttleTriggeredAfterMouseMove=Mz(w.triggeredAfterMouseMove,(_=j.throttleDelay)!==null&&_!==void 0?_:1e3/60),w.state={},w}return zEe(v,y),IEe(v,[{key:"componentDidMount",value:function(){var b,_;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(b=this.props.margin.left)!==null&&b!==void 0?b:0,top:(_=this.props.margin.top)!==null&&_!==void 0?_:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var b=this.props,_=b.children,w=b.data,N=b.height,S=b.layout,C=Ys(_,Ot);if(C){var P=C.props.defaultIndex;if(!(typeof P!="number"||P<0||P>this.state.tooltipTicks.length-1)){var M=this.state.tooltipTicks[P]&&this.state.tooltipTicks[P].value,D=uS(this.state,w,P,M),A=this.state.tooltipTicks[P].coordinate,U=(this.state.offset.top+N)/2,F=S==="horizontal",L=F?{x:A,y:U}:{y:A,x:U},$=this.state.formattedGraphicalItems.find(function(T){var k=T.item;return k.type.name==="Scatter"});$&&(L=Ne(Ne({},L),$.props.points[P].tooltipPosition),D=$.props.points[P].tooltipPayload);var R={activeTooltipIndex:P,isTooltipActive:!0,activeLabel:M,activePayload:D,activeCoordinate:L};this.setState(R),this.renderCursor(C),this.accessibilityManager.setIndex(P)}}}},{key:"getSnapshotBeforeUpdate",value:function(b,_){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==_.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==b.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==b.margin){var w,N;this.accessibilityManager.setDetails({offset:{left:(w=this.props.margin.left)!==null&&w!==void 0?w:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0}})}return null}},{key:"componentDidUpdate",value:function(b){qN([Ys(b.children,Ot)],[Ys(this.props.children,Ot)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var b=Ys(this.props.children,Ot);if(b&&typeof b.props.shared=="boolean"){var _=b.props.shared?"axis":"item";return l.indexOf(_)>=0?_:i}return i}},{key:"getMouseInfo",value:function(b){if(!this.container)return null;var _=this.container,w=_.getBoundingClientRect(),N=$je(w),S={chartX:Math.round(b.pageX-N.left),chartY:Math.round(b.pageY-N.top)},C=w.width/_.offsetWidth||1,P=this.inRange(S.chartX,S.chartY,C);if(!P)return null;var M=this.state,D=M.xAxisMap,A=M.yAxisMap,U=this.getTooltipEventType(),F=Z4(this.state,this.props.data,this.props.layout,P);if(U!=="axis"&&D&&A){var L=bl(D).scale,$=bl(A).scale,R=L&&L.invert?L.invert(S.chartX):null,T=$&&$.invert?$.invert(S.chartY):null;return Ne(Ne({},S),{},{xValue:R,yValue:T},F)}return F?Ne(Ne({},S),F):null}},{key:"inRange",value:function(b,_){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,N=this.props.layout,S=b/w,C=_/w;if(N==="horizontal"||N==="vertical"){var P=this.state.offset,M=S>=P.left&&S<=P.left+P.width&&C>=P.top&&C<=P.top+P.height;return M?{x:S,y:C}:null}var D=this.state,A=D.angleAxisMap,U=D.radiusAxisMap;if(A&&U){var F=bl(A);return MM({x:S,y:C},F)}return null}},{key:"parseEventsOfWrapper",value:function(){var b=this.props.children,_=this.getTooltipEventType(),w=Ys(b,Ot),N={};w&&_==="axis"&&(w.props.trigger==="click"?N={onClick:this.handleClick}:N={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var S=ny(this.props,this.handleOuterEvent);return Ne(Ne({},S),N)}},{key:"addListener",value:function(){Fw.on(Uw,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Fw.removeListener(Uw,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(b,_,w){for(var N=this.state.formattedGraphicalItems,S=0,C=N.length;S<C;S++){var P=N[S];if(P.item===b||P.props.key===b.key||_===So(P.item.type)&&w===P.childIndex)return P}return null}},{key:"renderClipPath",value:function(){var b=this.clipPathId,_=this.state.offset,w=_.left,N=_.top,S=_.height,C=_.width;return G.createElement("defs",null,G.createElement("clipPath",{id:b},G.createElement("rect",{x:w,y:N,height:S,width:C})))}},{key:"getXScales",value:function(){var b=this.state.xAxisMap;return b?Object.entries(b).reduce(function(_,w){var N=Y4(w,2),S=N[0],C=N[1];return Ne(Ne({},_),{},lt({},S,C.scale))},{}):null}},{key:"getYScales",value:function(){var b=this.state.yAxisMap;return b?Object.entries(b).reduce(function(_,w){var N=Y4(w,2),S=N[0],C=N[1];return Ne(Ne({},_),{},lt({},S,C.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(b){var _;return(_=this.state.xAxisMap)===null||_===void 0||(_=_[b])===null||_===void 0?void 0:_.scale}},{key:"getYScaleByAxisId",value:function(b){var _;return(_=this.state.yAxisMap)===null||_===void 0||(_=_[b])===null||_===void 0?void 0:_.scale}},{key:"getItemByXY",value:function(b){var _=this.state,w=_.formattedGraphicalItems,N=_.activeItem;if(w&&w.length)for(var S=0,C=w.length;S<C;S++){var P=w[S],M=P.props,D=P.item,A=D.type.defaultProps!==void 0?Ne(Ne({},D.type.defaultProps),D.props):D.props,U=So(D.type);if(U==="Bar"){var F=(M.data||[]).find(function(T){return vke(b,T)});if(F)return{graphicalItem:P,payload:F}}else if(U==="RadialBar"){var L=(M.data||[]).find(function(T){return MM(b,T)});if(L)return{graphicalItem:P,payload:L}}else if(Bj(P,N)||qj(P,N)||Rp(P,N)){var $=b2e({graphicalItem:P,activeTooltipItem:N,itemData:A.data}),R=A.activeIndex===void 0?$:A.activeIndex;return{graphicalItem:Ne(Ne({},P),{},{childIndex:R}),payload:Rp(P,N)?A.data[$]:P.props.data[$]}}}return null}},{key:"render",value:function(){var b=this;if(!_E(this))return null;var _=this.props,w=_.children,N=_.className,S=_.width,C=_.height,P=_.style,M=_.compact,D=_.title,A=_.desc,U=Q4(_,AEe),F=$t(U,!1);if(M)return G.createElement(E4,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},G.createElement(HN,ju({},F,{width:S,height:C,title:D,desc:A}),this.renderClipPath(),SE(w,this.renderMap)));if(this.props.accessibilityLayer){var L,$;F.tabIndex=(L=this.props.tabIndex)!==null&&L!==void 0?L:0,F.role=($=this.props.role)!==null&&$!==void 0?$:"application",F.onKeyDown=function(T){b.accessibilityManager.keyboardEvent(T)},F.onFocus=function(){b.accessibilityManager.focus()}}var R=this.parseEventsOfWrapper();return G.createElement(E4,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},G.createElement("div",ju({className:It("recharts-wrapper",N),style:Ne({position:"relative",cursor:"default",width:S,height:C},P)},R,{ref:function(k){b.container=k}}),G.createElement(HN,ju({},F,{width:S,height:C,title:D,desc:A,style:KEe}),this.renderClipPath(),SE(w,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(x.Component);lt(g,"displayName",r),lt(g,"defaultProps",Ne({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},h)),lt(g,"getDerivedStateFromProps",function(y,v){var j=y.dataKey,b=y.data,_=y.children,w=y.width,N=y.height,S=y.layout,C=y.stackOffset,P=y.margin,M=v.dataStartIndex,D=v.dataEndIndex;if(v.updateId===void 0){var A=J4(y);return Ne(Ne(Ne({},A),{},{updateId:0},m(Ne(Ne({props:y},A),{},{updateId:0}),v)),{},{prevDataKey:j,prevData:b,prevWidth:w,prevHeight:N,prevLayout:S,prevStackOffset:C,prevMargin:P,prevChildren:_})}if(j!==v.prevDataKey||b!==v.prevData||w!==v.prevWidth||N!==v.prevHeight||S!==v.prevLayout||C!==v.prevStackOffset||!Du(P,v.prevMargin)){var U=J4(y),F={chartX:v.chartX,chartY:v.chartY,isTooltipActive:v.isTooltipActive},L=Ne(Ne({},Z4(v,b,S)),{},{updateId:v.updateId+1}),$=Ne(Ne(Ne({},U),F),L);return Ne(Ne(Ne({},$),m(Ne({props:y},$),v)),{},{prevDataKey:j,prevData:b,prevWidth:w,prevHeight:N,prevLayout:S,prevStackOffset:C,prevMargin:P,prevChildren:_})}if(!qN(_,v.prevChildren)){var R,T,k,W,q=Ys(_,Sh),Q=q&&(R=(T=q.props)===null||T===void 0?void 0:T.startIndex)!==null&&R!==void 0?R:M,ue=q&&(k=(W=q.props)===null||W===void 0?void 0:W.endIndex)!==null&&k!==void 0?k:D,X=Q!==M||ue!==D,le=!Pt(b),pe=le&&!X?v.updateId:v.updateId+1;return Ne(Ne({updateId:pe},m(Ne(Ne({props:y},v),{},{updateId:pe,dataStartIndex:Q,dataEndIndex:ue}),v)),{},{prevChildren:_,dataStartIndex:Q,dataEndIndex:ue})}return null}),lt(g,"renderActiveDot",function(y,v,j){var b;return x.isValidElement(y)?b=x.cloneElement(y,v):_t(y)?b=y(v):b=G.createElement(S2,v),G.createElement(en,{className:"recharts-active-dot",ke
754y:j},b)});var p=x.forwardRef(function(v,j){return G.createElement(g,ju({},v,{ref:j}))});return p.displayName=g.displayName,p},Yr=Vq({chartName:"LineChart",GraphicalChild:Qt,axisComponents:[{axisType:"xAxis",AxisComp:Zt},{axisType:"yAxis",AxisComp:Jt}],formatAxisMap:dq}),Bp=Vq({chartName:"BarChart",GraphicalChild:js,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Zt},{axisType:"yAxis",AxisComp:Jt}],formatAxisMap:dq});const nOe=["website","saas","server","database"],Bw=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))"];function sOe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{agents:i}=Lt(e),o=(i==null?void 0:i.filter(g=>nOe.includes(g.asset_type)))||[],l=x.useMemo(()=>t?o.find(g=>g.id===t):o[0],[o,t]),{checks:c,isLoading:d}=mc(l==null?void 0:l.id,50),u=x.useMemo(()=>!c||c.length===0?[]:c.filter(g=>g.response_time_ms).slice(0,20).reverse().map(g=>({time:new Date(g.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),responseTime:g.response_time_ms})),[c]),h=x.useMemo(()=>{if(!c)return[];const g=c.reduce((p,y)=>{if(y.http_status_code){const v=y.http_status_code.toString();p[v]=(p[v]||0)+1}return p},{});return Object.entries(g).map(([p,y])=>({code:p,count:y}))},[c]),f=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length;v+=g){const j=y.slice(v,v+g),_=j.filter(S=>S.status==="success").length/j.length*100,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,uptime:parseFloat(_.toFixed(2))})}return p},[c]),m=()=>{l&&a.invalidateQueries({queryKey:["monitor-checks",l.id]})};return!l||!c||c.length===0?null:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"Performance Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:l.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:m,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"response-time",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsx(at,{value:"response-time",children:"Response Time"}),n.jsx(at,{value:"status-codes",children:"Status Codes"}),n.jsx(at,{value:"uptime",children:"Uptime"})]}),n.jsx(it,{value:"response-time",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:u,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Response Time (ms)",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"responseTime",stroke:Bw[0],strokeWidth:2,dot:{fill:Bw[0]},name:"Response Time"})]})})}),n.jsxs(it,{value:"status-codes",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Status code distribution for last 50 checks"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Bp,{data:h,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"code",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Count",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(js,{dataKey:"count",fill:Bw[0],name:"Count"})]})})]}),n.jsxs(it,{value:"uptime",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Uptime trend based on last 50 checks (grouped)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:f,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Uptime (%)",angle:-90,position:"insideLeft"},domain:[0,100]}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:g=>`${g}%`}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"},name:"Uptime"})]})})]})]})})]})}function eo({clientId:e,onRefresh:t,selectedMonitors:r,onAddMonitor:s}){const{runSingleMonitorCheck:a,isSingleCheckRunning:i}=Ra(),o=di(),l=async()=>
754{if(!r||r.size===0)return;const c=Array.from(r);for(const d of c)a(d);t&&setTimeout(t,2e3)};return n.jsx("div",{className:"flex flex-col sm:flex-row gap-2 items-stretch sm:items-center justify-between","data-monitor-actions":!0,children:n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{onClick:s||(()=>o("/dashboard/overview")),variant:"outline",children:[n.jsx(Ws,{className:"h-4 w-4 mr-2"}),"Add Monitor"]}),n.jsxs(H,{onClick:l,disabled:!r||r.size===0||i,variant:"outline",children:[i?n.jsx(sr,{className:"h-4 w-4 mr-2 animate-spin"}):n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Test Selected Monitors"]})]})})}const tD=[{id:"http",name:"HTTP/HTTPS Monitoring",description:"Monitor websites and web services",icon:Pn,features:["Website uptime monitoring","Response time tracking","Status code validation","Content verification"]},{id:"api",name:"API Monitoring",description:"Monitor REST APIs and web services",icon:mC,features:["REST API endpoint monitoring","Custom HTTP methods (GET, POST, PUT, DELETE)","API authentication support","Custom headers & request bodies","Response status code validation","Response time monitoring"]},{id:"tcp",name:"TCP/UDP Port Monitoring",description:"Monitor TCP ports and UDP services (DNS, NTP)",icon:N0,features:["TCP port connectivity checks","UDP DNS & NTP monitoring","Common service presets","Conservative check intervals","Response time tracking"]},{id:"ping",name:"Ping Monitoring",description:"Monitor host reachability using TCP connectivity tests",icon:gC,features:["Host reachability checks","Connection latency monitoring","Multi-port connectivity testing","Packet loss detection"]},{id:"dns",name:"DNS Entry Monitor",description:"Monitor DNS records for changes and consistency",icon:qt,features:["A, AAAA, CNAME, MX, TXT, NS records","Change detection","Baseline comparison","Multiple record type support"]},{id:"ssl",name:"SSL Certificate Monitoring",description:"Monitor SSL/TLS certificate health and expiration",icon:yt,features:["Certificate expiration alerts","SSL/TLS validation","Certificate chain analysis","Protocol version monitoring"]},{id:"keyword",name:"Keyword Monitoring",description:"Monitor web page content for specific text or elements",icon:qt,features:["Text string monitoring","HTML element detection","CSS selector support","Presence/absence detection","Case sensitivity options","Regex pattern matching"]},{id:"smtp",name:"SMTP Server Monitoring",description:"Monitor SMTP servers for availability and banner validation",icon:aa,features:["SMTP service availability","Banner hostname validation","STARTTLS capability testing","Multi-port support (25, 587, 465)","MX record resolution","Certificate validation"]},{id:"ftp",name:"FTP Server Monitoring",description:"Monitor FTP servers for connectivity and file operations",icon:pC,features:["FTP server connectivity","Anonymous and authenticated access","Active/Passive mode support","Directory listing tests","File transfer validation","Banner response monitoring"]},{id:"sftp",name:"SFTP Server Monitoring",description:"Monitor secure SFTP servers over SSH protocol",icon:ng,features:["SSH-based secure file transfer","Key-based authentication","Password authentication","Directory operations","File upload/download tests","Connection encryption validation"]},{id:"ftps",name:"FTPS Server Monitoring",description:"Monitor FTP servers with SSL/TLS encryption",icon:yt,features:["FTP over SSL/TLS monitoring","Explicit/Implicit TLS modes","Certificate validation","Encrypted data channel","Secure authentication","SSL handshake verification"]}];function aOe({onSelectType:e,selectedType:t}){const[r,s]=x.useState(1),a=6,i=Math.ceil(tD.length/a),o=(r-1)*a,l=tD.slice(o,o+a),c=d=>{s(d)};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"text-center",children:[n.jsx("h2",{className:"text-2xl font-bold",children:"Select Monitor Type"}),n.jsx("p",{className:"text-muted-foreground mt-2",children:"Choose the type of monitoring you want to set up"})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map(d=>{const u=d.icon,h=t===d.id,f=d.comingSoon;
754return n.jsxs(ee,{className:`cursor-pointer transition-all hover:shadow-md relative ${h?"ring-2 ring-primary":""} ${f?"opacity-60 cursor-not-allowed":"hover:scale-105"}`,onClick:()=>!f&&e(d.id),children:[d.comingSoon&&n.jsx("div",{className:"absolute top-2 right-2 bg-orange-500 text-white text-xs px-2 py-1 rounded-full",children:"Coming Soon"}),n.jsxs(de,{className:"pb-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("div",{className:`p-2 rounded-lg ${h?"bg-primary text-primary-foreground":"bg-muted"}`,children:n.jsx(u,{className:"h-6 w-6"})}),n.jsx(me,{className:"text-lg",children:d.name})]}),n.jsx(De,{className:"text-sm",children:d.description})]}),n.jsx(re,{children:n.jsxs("ul",{className:"space-y-1",children:[d.features.slice(0,4).map((m,g)=>n.jsxs("li",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[n.jsx("div",{className:"w-1.5 h-1.5 bg-primary rounded-full flex-shrink-0"}),m]},g)),d.features.length>4&&n.jsxs("li",{className:"text-sm text-muted-foreground italic",children:["+",d.features.length-4," more features"]})]})})]},d.id)})}),i>1&&n.jsx("div",{className:"flex justify-center",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>c(Math.max(1,r-1)),className:r===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:i},(d,u)=>u+1).map(d=>n.jsx(wt,{children:n.jsx(ss,{onClick:()=>c(d),isActive:r===d,className:"cursor-pointer",children:d})},d)),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>c(Math.min(i,r+1)),className:r===i?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})}const iOe={A:1,NS:2,CNAME:5,MX:15,TXT:16,AAAA:28,PTR:12};async function Qj(e){try{let t=e;if(e.includes("://"))try{t=new URL(e).hostname}catch{t=e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0]}if(t=t.split(":")[0],/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(t))return t;const r=await Kq(t,"A");return r.length>0?r[0].data:null}catch(t){return console.warn("DNS lookup failed:",t),null}}async function Kq(e,t){try{let r=e;if(e.includes("://"))try{r=new URL(e).hostname}catch{r=e.replace(/^https?:\/\//,"").split("/")[0].split(":")[0]}r=r.split(":")[0];const s=iOe[t];if(!s)throw new Error(`Unsupported DNS record type: ${t}`);console.log(`Performing ${t} DNS lookup for: ${r}`);const a=await fetch(`https://cloudflare-dns.com/dns-query?name=${encodeURIComponent(r)}&type=${t}`,{headers:{Accept:"application/dns-json"}});if(!a.ok)throw new Error(`DNS lookup failed with status: ${a.status}`);const i=await a.json();if(i.Answer&&i.Answer.length>0){const o=i.Answer.filter(l=>l.type===s).map(l=>({type:t,name:l.name,data:l.data,ttl:l.TTL}));return console.log(`Found ${o.length} ${t} records for ${r}:`,o.map(l=>l.data)),o}return console.log(`No ${t} records found for ${r}`),[]}catch(r){throw console.error(`DNS ${t} lookup failed for ${e}:`,r),r}}const Nc=[{title:"Agent Details",description:"Basic information about your HTTP/HTTPS monitor",icon:ht},{title:"Website Configuration",description:"Configure the website URL and connection details",icon:Pn},{title:"Monitoring Settings",description:"Set up monitoring intervals and status code expectations",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function oOe({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState(!1),[d,u]=x.useState({name:"",description:"",asset_type:"website",hostname_or_url:"",ip_address:"",port:443,protocol:"https",tags:[]}),[h,f]=x.useState({check_interval:300,timeout_seconds:30,alert_threshold:3,escalation_enabled:!1,expected_status_codes:"200,201,202,204",follow_redirects:!0,status_monitoring_strategy:"standard"}),{createAgent:m,updateAgent:g,isCreating:p,isUpdating:y}=Lt(s);x.useEffect(()=>{if(a&&e){u({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",port:a.port,protocol:a.protocol||"https",tags:a.tags||[]});const S=a.monitoring_config||{};f({check_interval:S.check_interval||300,timeout_seconds:S.timeout_seconds||30,alert_threshold:S.alert_threshold||3,escalation_enabled:S.escalation_enabled||!1,expected_status_codes:S.expected_status_codes||"200,201,202,204",follow_redirects:S.follow_redirects!==void 0?S.follow_redirects:!0,status_monitoring_strategy:S.status_monitoring_strategy||"standard"})}},[a,e]);const v=async()=>
754{if(d.hostname_or_url.trim()&&!d.ip_address.trim()&&!l){c(!0);try{const S=await Qj(d.hostname_or_url);S&&!d.ip_address.trim()&&u(C=>({...C,ip_address:S}))}catch(S){console.warn("Failed to resolve DNS:",S)}finally{c(!1)}}},j=S=>{switch(S){case 0:return d.name.trim()!==""&&d.asset_type!=="";case 1:return d.hostname_or_url.trim()!=="";case 2:return h.check_interval>0&&h.timeout_seconds>0;default:return!0}},b=()=>{i<Nc.length-1&&o(i+1)},_=()=>{i>0&&o(i-1)},w=async()=>{if(!s)return;const S={client_id:s,name:d.name,description:d.description||null,asset_type:d.asset_type,hostname_or_url:d.hostname_or_url||null,ip_address:d.ip_address||null,port:d.port,protocol:d.protocol,monitoring_config:h,status:"active",tags:d.tags};try{a?await g({id:a.id,...S}):await m(S),t()}catch(C){console.error("Error saving HTTP monitor:",C)}},N=()=>{var S;switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"HTTP/HTTPS Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your website monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:d.name,onChange:C=>u({...d,name:C.target.value}),placeholder:"e.g., Company Website Monitor"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:d.description,onChange:C=>u({...d,description:C.target.value}),placeholder:"Monitor website availability and performance"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:d.tags.join(", "),onChange:C=>{const M=C.target.value.split(",").map(D=>D.trim()).filter(D=>D.length>0);u({...d,tags:M})},placeholder:"e.g., production, critical, web-server"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"asset_type",children:"Asset Type *"}),n.jsxs(Fe,{value:d.asset_type,onValueChange:C=>u({...d,asset_type:C}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"website",children:"Website"}),n.jsx(J,{value:"saas",children:"SaaS Service"})]})]})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Pn,{className:"h-5 w-5"}),"Website Configuration"]}),n.jsx(De,{children:"Configure the website URL and connection details"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"Website URL *"}),n.jsx(ie,{id:"hostname_or_url",value:d.hostname_or_url,onChange:C=>u({...d,hostname_or_url:C.target.value}),onBlur:v,placeholder:"e.g., https://example.com"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter the complete URL including protocol (http:// or https://)"})]}),n.jsxs("div",{children:[n.jsxs(z,{htmlFor:"ip_address",children:["IP Address ",l&&n.jsx("span",{className:"text-xs text-muted-foreground",children:"(resolving...)"})]}),n.jsx(ie,{id:"ip_address",value:d.ip_address,onChange:C=>u({...d,ip_address:C.target.value}),placeholder:"e.g., 192.168.1.100 (auto-resolved from URL)",disabled:l}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Will be auto-populated from hostname/URL"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"protocol",children:"Protocol"}),n.jsxs(Fe,{value:d.protocol,onValueChange:C=>{u({...d,protocol:C,port:C==="https"?443:C==="http"?80:null})},children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"http",children:"HTTP"}),n.jsx(J,{value:"https",children:"HTTPS"})]})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"Port"}),n.jsx(ie,{id:"port",type:"number",value:d.port||"",onChange:C=>u({...d,port:parseInt(C.target.value)||null}),placeholder:"e.g., 80, 443",min:"1",max:"65535"})]})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"HTTP Monitoring Settings"]}),n.jsx(De,{children:"Configure monitoring behavior and status code expectations"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"status_monitoring_strategy",children:"Status Code Strategy"}),n.jsxs(Fe,{value:h.status_monitoring_strategy,onValueChange:C=>f({...h,status_monitoring_strategy:C}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"standard",children:"Standard (2xx, 3xx = UP)"}),n.jsx(J,{value:"restricted",children:"Restricted (2xx only = UP)"}),n.jsx(J,{value:"custom",children:"Custom Status Codes"})]})]})]}),h.status_monitoring_strategy==="custom"&&n.jsxs("div",{children:[n.jsx(z,{htmlFor:"expected_status_codes",children:"Expected Status Codes"}),n.jsx(ie,{id:"expected_status_codes",value:h.expected_status_codes,onChange:C=>f({...h,expected_status_codes:C.target.value}),placeholder:"e.g., 200,201,202,204"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Comma-separated list of acceptable HTTP status codes"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"follow_redirects",checked:h.follow_redirects,onChange:C=>f({...h,follow_redirects:C.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"follow_redirects",className:"text-sm",children:"Follow HTTP redirects automatically"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:h.check_interval,onChange:C=>{const P=C.target.value.replace(/[^0-9]/g,"");f({...h,check_interval:parseInt(P)||0})}}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 60 seconds)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"timeout_seconds",children:"Timeout (seconds)"}),n.jsx(ie,{id:"timeout_seconds",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:h.timeout_seconds,onChange:C=>{const P=C.target.value.replace(/[^0-9]/g,"");f({...h,timeout_seconds:parseInt(P)||0})}})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"text",inputMode:"numeric",pattern:"[0-9]*",value:h.alert_threshold,onChange:C=>{const P=C.target.value.replace(/[^0-9]/g,"");f({...h,alert_threshold:parseInt(P)||0})}}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive failures before alerting"})]})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review HTTP Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Asset Type"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.asset_type})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Website URL"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Protocol"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:(S=d.protocol)==null?void 0:S.toUpperCase()})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Status Strategy"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:h.status_monitoring_strategy})]})]}),d.description&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),d.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.tags.join(", ")})]})]})]});default:return null}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:Nc.map((S,C)=>n.jsxs("div",{className:`flex items-center ${C<Nc.length-1?"flex-1":""}`,children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${C<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:C+1}),C<Nc.length-1&&n.jsx("div",{className:`h-0.5 flex-1 mx-2 ${C<i?"bg-primary":"bg-muted"}`})]},C))}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",i+1," of ",Nc.length,": ",Nc[i].title]})]})]}),N(),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:_,disabled:i===0,children:"Previous"}),n.jsxs("div",{className:"space-x-2",children:[n.jsx(H,{variant:"outline",onClick:t,children:"Cancel"}),i===Nc.length-1?n.jsx(H,{onClick:w,disabled:p||y,children:a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:b,disabled:!j(i),children:"Next"})]})]})]})}const rD=[{name:"JSON API",headers:{"Content-Type":"application/json",Accept:"application/json"}},{name:"REST API with User-Agent",headers:{"Content-Type":"application/json",Accept:"application/json","User-Agent":"API-Monitor/1.0"}},{name:"XML API",headers:{"Content-Type":"application/xml",Accept:"application/xml"}},{name:"Form Data",headers:{"Content-Type":"application/x-www-form-urlencoded"}}],Hf=[{title:"Agent Details",description:"Basic information about your API monitor",icon:ht},{title:"API Configuration",description:"Configure the API endpoint, method, and headers",icon:mC},{title:"Authentication & Body",description:"Set up authentication and request body (if needed)",icon:yt},{title:"Monitoring Settings",description:"Configure monitoring intervals and status expectations",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function lOe({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState(!1),[d,u]=x.useState("none"),[h,f]=x.use
754State(""),[m,g]=x.useState(""),[p,y]=x.useState(""),[v,j]=x.useState({name:"",description:"",asset_type:"api",hostname_or_url:"",ip_address:"",port:443,protocol:"https",tags:[]}),[b,_]=x.useState({check_interval:300,timeout_seconds:30,alert_threshold:3,escalation_enabled:!1,expected_status_codes:"200,201,202,204",follow_redirects:!0,status_monitoring_strategy:"standard",method:"GET",headers:{},request_body:""}),{createAgent:w,updateAgent:N,isCreating:S,isUpdating:C}=Lt(s);x.useEffect(()=>{if(a&&e){j({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",port:a.port,protocol:a.protocol||"https",tags:a.tags||[]});const T=a.monitoring_config||{};_({check_interval:T.check_interval||300,timeout_seconds:T.timeout_seconds||30,alert_threshold:T.alert_threshold||3,escalation_enabled:T.escalation_enabled||!1,expected_status_codes:T.expected_status_codes||"200,201,202,204",follow_redirects:T.follow_redirects!==void 0?T.follow_redirects:!0,status_monitoring_strategy:T.status_monitoring_strategy||"standard",method:T.method||"GET",headers:T.headers||{},request_body:T.request_body||""})}},[a,e]);const P=async()=>{if(v.hostname_or_url.trim()&&!v.ip_address.trim()&&!l){c(!0);try{const T=await Qj(v.hostname_or_url);T&&!v.ip_address.trim()&&j(k=>({...k,ip_address:T}))}catch(T){console.warn("Failed to resolve DNS:",T)}finally{c(!1)}}},M=T=>{switch(T){case 0:return v.name.trim()!==""&&v.asset_type!=="";case 1:return v.hostname_or_url.trim()!=="";case 2:return!0;case 3:return b.check_interval>0&&b.timeout_seconds>0;default:return!0}},D=()=>{i<Hf.length-1&&o(i+1)},A=()=>{i>0&&o(i-1)},U=T=>{_({...b,headers:{...b.headers,...T.headers}})},F=()=>{const T=prompt("Header name:"),k=prompt("Header value:");T&&k&&_({...b,headers:{...b.headers,[T]:k}})},L=T=>{const k={...b.headers};delete k[T],_({...b,headers:k})},$=async()=>{if(!s)return;let T={...b.headers};if(d==="basic"&&h&&m){const q=btoa(`${h}:${m}`);T.Authorization=`Basic ${q}`}else d==="bearer"&&p?T.Authorization=`Bearer ${p}`:d==="api_key"&&p&&(T["X-API-Key"]=p);const k={...b,headers:T},W={client_id:s,name:v.name,description:v.description||null,asset_type:v.asset_type,hostname_or_url:v.hostname_or_url||null,ip_address:v.ip_address||null,port:v.port,protocol:v.protocol,monitoring_config:k,status:"active",tags:v.tags};try{a?await N({id:a.id,...W}):await w(W),t()}catch(q){console.error("Error saving API monitor:",q)}},R=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"API Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your API monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:v.name,onChange:T=>j({...v,name:T.target.value}),placeholder:"e.g., User API Monitor"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:v.description,onChange:T=>j({...v,description:T.target.value}),placeholder:"Monitor API endpoint availability and performance"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:v.tags.join(", "),onChange:T=>{const W=T.target.value.split(",").map(q=>q.trim()).filter(q=>q.length>0);j({...v,tags:W})},placeholder:"e.g., production, api, rest"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(mC,{className:"h-5 w-5"}),"API Configuration"]}),n.jsx(De,{children:"Configure the API endpoint, method, and headers"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"API Endpoint URL *"}),n.jsx(ie,{id:"hostname_or_url",value:v.hostname_or_url,onChange:T=>j({...v,hostname_or_url:T.target.value}),onBlur:P,placeholder:"e.g., https://api.example.com/v1/health"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter the complete API endpoint URL including protocol"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"method",children:"HTTP Method"}),n.jsxs(Fe,{value:b.method,onValueChange:T=>_({...b,method:T}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"GET",children:"GET"}),n.jsx(J,{value:"POST",children:"POST"}),n.jsx(J,{value:"PUT",children:"PUT"}),n.jsx(J,{value:"PATCH",children:"PATCH"}),n.jsx(J,{value:"DELETE",children:"DELETE"}),n.jsx(J,{value:"HEAD",children:"HEAD"}),n.jsx(J,{value:"OPTIONS",children:"OPTIONS"})]})]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsx(z,{children:"HTTP Headers"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(Fe,{onValueChange:T=>{const k=rD.find(W=>W.name===T);k&&U(k)},children:[n.jsx(Ie,{className:"w-[180px]",children:n.jsx(Ue,{placeholder:"Use preset"})}),n.jsx(Le,{children:rD.map(T=>n.jsx(J,{value:T.name,children:T.name},T.name))})]}),n.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:F,children:n.jsx(Ws,{className:"h-4 w-4"})})]})]}),n.jsxs("div",{className:"space-y-2 max-h-32 overflow-y-auto",children:[Object.entries(b.headers).map(([T,k])=>n.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded",children:[n.jsxs("span",{className:"font-mono text-sm flex-1",children:[T,": ",k]}),n.jsx(H,{type:"button",variant:"ghost",size:"sm",onClick:()=>L(T),children:n.jsx(vn,{className:"h-4 w-4"})})]},T)),Object.keys(b.headers).length===0&&n.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No headers configured. Use presets or add custom headers."})]})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Authentication & Request Body"]}),n.jsx(De,{children:"Configure authentication and request body (if needed)"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"auth_type",children:"Authentication Type"}),n.jsxs(Fe,{value:d,onValueChange:T=>u(T),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"none",children:"None"}),n.jsx(J,{value:"basic",children:"Basic Auth"}),n.jsx(J,{value:"bearer",children:"Bearer Token"}),n.jsx(J,{value:"api_key",children:"API Key"})]})]})]}),d==="basic"&&n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"auth_username",children:"Username"}),n.jsx(ie,{id:"auth_username",type:"text",value:h,onChange:T=>f(T.target.value),placeholder:"Username"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"auth_password",children:"Password"}),n.jsx(ie,{id:"auth_password",type:"password",value:m,onChange:T=>g(T.target.value),placeholder:"Password"})]})]}),(d==="bearer"||d==="api_key")&&n.jsxs("div",{children:[n.jsx(z,{htmlFor:"auth_token",children:d==="bearer"?"Bearer Token":"API Key"}),n.jsx(ie,{id:"auth_token",type:"password",value:p,onChange:T=>y(T.target.value),placeholder:d==="bearer"?"Bearer token":"API key"})]}),(b.method==="POST"||b.method==="PUT"||b.method==="PATCH")&&n.jsxs("div",{children:[n.jsx(z,{htmlFor:"request_body",children:"Request Body (JSON)"}),n.jsx(kr,{id:"request_body",value:b.request_body,onChange:T=>_({...b,request_body:T.target.value}),placeholder:'{"key": "value"}',rows:6}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter valid JSON for the request body (optional)"})]}),n.jsx("div",{className:"p-3 bg-muted rounded-lg",children:n.jsxs("p",{className:"text-sm text-muted-foreground",children:[n.jsx("strong",{children:"Note:"})," Authentication credentials are not stored permanently. You'll need to re-enter them if you edit this monitor later."]})})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"API Monitoring Settings"]}),n.jsx(De,{children:"Configure monitoring behavior and status code expectations"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"status_monitoring_strategy",children:"Status Code Strategy"}),n.jsxs(Fe,{value:b.status_monitoring_strategy,onValueChange:T=>_({...b,status_monitoring_strategy:T}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"standard",children:"Standard (2xx, 3xx = UP)"}),n.jsx(J,{value:"restricted",children:"Restricted (2xx only = UP)"}),n.jsx(J,{value:"custom",children:"Custom Status Codes"})]})]})]}),b.status_monitoring_strategy==="custom"&&n.jsxs("div",{children:[n.jsx(z,{htmlFor:"expected_status_codes",children:"Expected Status Codes"}),n.jsx(ie,{id:"expected_status_codes",value:b.expected_status_codes,onChange:T=>_({...b,expected_status_codes:T.target.value}),placeholder:"e.g., 200,201,202,204"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Comma-separated list of acceptable HTTP status codes"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"follow_redirects",checked:b.follow_redirects,onChange:T=>_({...b,follow_redirects:T.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"follow_redirects",className:"text-sm",children:"Follow HTTP redirects automatically"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:b.check_interval,onChange:T=>_({...b,check_interval:parseInt(T.target.value)||300}),min:"60"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 60 seconds)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"timeout_seconds",children:"Timeout (seconds)"}),n.jsx(ie,{id:"timeout_seconds",type:"number",value:b.timeout_seconds,onChange:T=>_({...b,timeout_seconds:parseInt(T.target.value)||30}),min:"5",max:"120"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:b.alert_threshold,onChange:T=>_({...b,alert_threshold:parseInt(T.target.value)||3}),min:"1",max:"10"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive failures before alerting"})]})]})]});case 4:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review API Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:v.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Asset Type"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:v.asset_type})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"API Endpoint"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:v.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"HTTP Method"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:b.method})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Headers Count"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[Object.keys(b.headers).length," configured"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Authentication"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d==="none"?"None":d})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.check_interval," seconds"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Alert Threshold"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[b.alert_threshold," failures"]})]})]}),Object.keys(b.headers).length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Headers"}),n.jsx("div",{className:"mt-2 p-3 bg-muted rounded text-sm",children:Object.entries(b.headers).map(([T,k])=>n.jsxs("div",{className:"font-mono",children:[T,": ",k]},T))})]})]})]});default:return null}};return e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(H,{variant:"ghost",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back"]}),n.jsx("div",{className:"flex items-center space-x-2",children:Hf.map((T,k)=>{const W=T.icon;return n.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full ${k===i?"bg-primary text-primary-foreground":k<i?"bg-primary/20 text-primary":"bg-muted text-muted-foreground"}`,children:n.jsx(W,{className:"h-4 w-4"})},k)})})]}),n.jsxs("div",{className:"min-h-[600px]",children:[n.jsxs("div",{className:"mb-6",children:[n.jsx("h2",{className:"text-2xl font-bold",children:Hf[i].title}),n.jsx("p",{className:"text-muted-foreground",children:Hf[i].description})]}),R()]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:A,disabled:i===0,children:"Previous"}),i===Hf.length-1?n.jsx(H,{onClick:$,disabled:!M(i)||S||C,children:S||C?"Creating...":a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:D,disabled:!M(i),children:"Next"})]})]}):null}const Sc=[{title:"Agent Details",description:"Basic information about your SSL certificate monitor",icon:ht},{title:"SSL Configuration",description:"Configure the hostname and port for SSL monitoring",icon:Io},{title:"SSL Settings",description:"Configure SSL certificate validation settings",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function Gq({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState({name:"",description:"",asset_type:"ssl",hostname_or_url:"",port:443,tags:[]}),[d,u]=x.useState({check_interval:3600,alert_threshold:2,regions:["US"],regional_failure_threshold:"warning",cert_expiration_days:30,check_future_cert:!1,check_hostname_match:!0,check_weak_signature:!0,min_key_size:2048,check_chain_complete:!0,check_revocation:!1,min_tls_version:"TLS 1.2",check_weak_ciphers:!0,require_perfect_forward_secrecy:!1}),{createAgent:h,updateAgent:f,isCreating:m,isUpdating:g}=Lt(s);x.useEffect(()=>{if(a&&e){c({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",port:a.port||443,tags:a.tags||[]});const _=a.monitoring_config||{};u({check_interval:_.check_interval||3600,alert_threshold:_.alert_threshold||2,sni_host_override:_.sni_host_override,regions:_.regions||["US"],regional_failure_threshold:_.regional_failure_threshold||"warning",cert_expiration_days:_.cert_expiration_days||30,check_future_cert:_.check_future_cert||!1,check_hostname_match:_.check_hostname_match!==void 0?_.check_hostname_match:!0,check_weak_signature:_.check_weak_signature!==void 0?_.check_weak_signature:!0,min_key_size:_.min_key_size||2048,check_chain_complete:_.check_chain_complete!==void 0?_.check_chain_complete:!0,check_revocation:_.check_revocation||!1,min_tls_version:_.min_tls_version||"TLS 1.2",check_weak_ciphers:_.check_weak_ciphers!==void 0?_.check_weak_ciphers:!0,require_perfect_forward_secrecy:_.require_perfect_forward_secrecy||!1})}},[a,e]);const p=_=>{switch(_){case 0:return l.name.trim()!=="";case 1:return l.hostname_or_url.trim()!==""&&l.port>0;case 2:return d.check_interval>0;default:return!0}},y=()=>{i<Sc.length-1&&o(i+1)},v=()=>{i>0&&o(i-1)},j=async()=>
754{if(!s)return;const _={client_id:s,name:l.name,description:l.description||null,asset_type:l.asset_type,hostname_or_url:l.hostname_or_url||null,ip_address:null,port:l.port,protocol:"https",monitoring_config:d,status:"active",tags:l.tags};try{a?await f({id:a.id,..._}):await h(_),t()}catch(w){console.error("Error saving SSL monitor:",w)}},b=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"SSL Certificate Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your SSL certificate monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:l.name,onChange:_=>c({...l,name:_.target.value}),placeholder:"e.g., SSL Certificate Monitor - example.com"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:l.description,onChange:_=>c({...l,description:_.target.value}),placeholder:"SSL certificate monitoring for domain security"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:l.tags.join(", "),onChange:_=>{const N=_.target.value.split(",").map(S=>S.trim()).filter(S=>S.length>0);c({...l,tags:N})},placeholder:"e.g., ssl, security, certificates, production"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Io,{className:"h-5 w-5"}),"SSL Certificate Configuration"]}),n.jsx(De,{children:"Configure the hostname and port for SSL certificate monitoring"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"SSL Certificate Hostname *"}),n.jsx(ie,{id:"hostname_or_url",value:l.hostname_or_url,onChange:_=>c({...l,hostname_or_url:_.target.value}),placeholder:"e.g., example.com"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter the hostname to check SSL certificate for"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"SSL Port"}),n.jsx(ie,{id:"port",type:"number",value:l.port,onChange:_=>c({...l,port:parseInt(_.target.value)||443}),placeholder:"443",min:"1",max:"65535"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Port to check SSL certificate on (default: 443)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"sni_host_override",children:"SNI Host Override (Optional)"}),n.jsx(ie,{id:"sni_host_override",value:d.sni_host_override||"",onChange:_=>u({...d,sni_host_override:_.target.value||void 0}),placeholder:"Leave empty to use hostname"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Override the Server Name Indication (SNI) hostname if needed"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"SSL Certificate Validation Settings"]}),n.jsx(De,{children:"Configure SSL certificate security and validation checks"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"cert_expiration_days",children:"Certificate Expiration Warning (days)"}),n.jsx(ie,{id:"cert_expiration_days",type:"number",value:d.cert_expiration_days,onChange:_=>u({...d,cert_expiration_days:parseInt(_.target.value)||30}),min:"1",max:"365"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Alert when certificate expires within this many days"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"min_tls_version",children:"Minimum TLS Version"}),n.jsxs(Fe,{value:d.min_tls_version,onValueChange:_=>u({...d,min_tls_version:_}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"TLS 1.0",children:"TLS 1.0"}),n.jsx(J,{value:"TLS 1.1",children:"TLS 1.1"}),n.jsx(J,{value:"TLS 1.2",children:"TLS 1.2"}),n.jsx(J,{value:"TLS 1.3",children:"TLS 1.3"})]})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"min_key_size",children:"Minimum Key Size (bits)"}),n.jsxs(Fe,{value:d.min_key_size.toString(),onValueChange:_=>u({...d,min_key_size:parseInt(_)}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"1024",children:"1024 bits"}),n.jsx(J,{value:"2048",children:"2048 bits"}),n.jsx(J,{value:"4096",children:"4096 bits"})]})]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_hostname_match",checked:d.check_hostname_match,onChange:_=>u({...d,check_hostname_match:_.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_hostname_match",className:"text-sm",children:"Verify hostname matches certificate"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_chain_complete",checked:d.check_chain_complete,onChange:_=>u({...d,check_chain_complete:_.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_chain_complete",className:"text-sm",children:"Verify certificate chain is complete"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_weak_signature",checked:d.check_weak_signature,onChange:_=>u({...d,check_weak_signature:_.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_weak_signature",className:"text-sm",children:"Check for weak signature algorithms"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_weak_ciphers",checked:d.check_weak_ciphers,onChange:_=>u({...d,check_weak_ciphers:_.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_weak_ciphers",className:"text-sm",children:"Check for weak cipher suites"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:d.check_interval,onChange:_=>u({...d,check_interval:parseInt(_.target.value)||3600}),min:"300"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"SSL checks every hour+ (certificates change infrequently)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:d.alert_threshold,onChange:_=>u({...d,alert_threshold:parseInt(_.target.value)||2}),min:"1",max:"5"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive failures before alerting"})]})]})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review SSL Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Hostname"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Port"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.port})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Expiration Warning"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.cert_expiration_days," days"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Min TLS Version"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.min_tls_version})]})]}),l.description&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Security Checks"}),n.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[d.check_hostname_match&&n.jsx("div",{children:"• Hostname verification"}),d.check_chain_complete&&n.jsx("div",{children:"• Certificate chain validation"}),d.check_weak_signature&&n.jsx("div",{children:"• Weak signature detection"}),d.check_weak_ciphers&&n.jsx("div",{children:"• Weak cipher detection"})]})]}),l.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.tags.join(", ")})]})]})]});default:return null}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:Sc.map((_,w)=>n.jsxs("div",{className:`flex items-center ${w<Sc.length-1?"flex-1":""}`,children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${w<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:w+1}),w<Sc.length-1&&n.jsx("div",{className:`h-0.5 flex-1 mx-2 ${w<i?"bg-primary":"bg-muted"}`})]},w))}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",i+1," of ",Sc.length,": ",Sc[i].title]})]})]}),b(),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:v,disabled:i===0,children:"Previous"}),n.jsxs("div",{className:"space-x-2",children:[n.jsx(H,{variant:"outline",onClick:t,children:"Cancel"}),i===Sc.length-1?n.jsx(H,{onClick:j,disabled:m||g,children:a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:y,disabled:!p(i),children:"Next"})]})]})]})}const Cc=[{title:"Agent Details",description:"Basic information about your DNS monitor",icon:ht},{title:"Domain Configuration",description:"Configure the domain to monitor",icon:qt},{title:"DNS Settings",description:"Configure DNS record type and baseline values",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function cOe({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState(!1),[d,u]=x.useState([]),[h,f]=x.use
754State([]),[m,g]=x.useState({name:"",description:"",asset_type:"dns",hostname_or_url:"",tags:[]}),[p,y]=x.useState({check_interval:900,alert_threshold:2,dns_record_type:"A",dns_baseline_value:[],dns_case_sensitive:!1,dns_auto_update_baseline:!1}),{createAgent:v,createAgentAsync:j,updateAgent:b,isCreating:_,isUpdating:w}=Lt(s),{runSingleMonitorCheck:N}=Ra(),S=Et();x.useEffect(()=>{if(a&&e){g({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",tags:a.tags||[]});const R=a.monitoring_config||{};y({check_interval:R.check_interval||900,alert_threshold:R.alert_threshold||2,dns_record_type:R.dns_record_type||"A",dns_baseline_value:R.dns_baseline_value||[],dns_case_sensitive:R.dns_case_sensitive||!1,dns_auto_update_baseline:R.dns_auto_update_baseline||!1})}},[a,e]);const C=async()=>{if(!(!m.hostname_or_url||l)){c(!0);try{const T=(await Kq(m.hostname_or_url,p.dns_record_type)).map(k=>k.data);u(T),f([])}catch(R){console.error("DNS lookup failed:",R)}finally{c(!1)}}},P=(R,T)=>{f(T?k=>[...k,R]:k=>k.filter(W=>W!==R))},M=R=>{f(R?[...d]:[])},D=()=>{const R=p.dns_baseline_value,T=h.filter(k=>!R.includes(k));y({...p,dns_baseline_value:[...R,...T]}),f([])},A=R=>{switch(R){case 0:return m.name.trim()!=="";case 1:return m.hostname_or_url.trim()!=="";case 2:return p.check_interval>0;default:return!0}},U=()=>{i<Cc.length-1&&o(i+1)},F=()=>{i>0&&o(i-1)},L=async()=>{if(!s){console.error("DNS Monitor: No clientId provided");return}console.log("DNS Monitor: Starting creation process",{clientId:s,agentData:m,monitoringConfig:p,existingAgent:!!a});const R={client_id:s,name:m.name,description:m.description||null,asset_type:m.asset_type,hostname_or_url:m.hostname_or_url||null,ip_address:null,port:null,protocol:"https",monitoring_config:p,status:"active",tags:m.tags};console.log("DNS Monitor: Payload prepared",R);try{if(a)console.log("DNS Monitor: Updating existing agent"),await b({id:a.id,...R}),console.log("DNS Monitor: Update successful"),N(a.id);else{console.log("DNS Monitor: Creating new agent");const T=await j(R);console.log("DNS Monitor: Creation successful",T),T!=null&&T.id&&(console.log("DNS Monitor: Triggering immediate check for new agent",T.id),N(T.id))}S.invalidateQueries({queryKey:["dns-monitor-stats",s]}),console.log("DNS Monitor: Closing wizard"),t()}catch(T){throw console.error("DNS Monitor: Error saving",T),T}},$=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"DNS Entry Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your DNS monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:m.name,onChange:R=>g({...m,name:R.target.value}),placeholder:"e.g., DNS Monitor for example.com"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:m.description,onChange:R=>g({...m,description:R.target.value}),placeholder:"DNS record monitoring for domain reliability and security"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:m.tags.join(", "),onChange:R=>{const k=R.target.value.split(",").map(W=>W.trim()).filter(W=>W.length>0);g({...m,tags:k})},placeholder:"e.g., dns, domain, records, nameserver"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(qt,{className:"h-5 w-5"}),"Domain Configuration"]}),n.jsx(De,{children:"Configure the domain name to monitor DNS records for"})]}),n.jsx(re,{className:"space-y-4",children:n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"Domain Name to Monitor *"}),n.jsx(ie,{id:"hostname_or_url",value:m.hostname_or_url,onChange:R=>g({...m,hostname_or_url:R.target.value}),placeholder:"e.g., example.com"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter the domain name to monitor DNS records for (without protocol)"})]})})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"DNS Entry Monitoring Settings"]}),n.jsx(De,{children:"Configure DNS record type and baseline values for monitoring"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"dns_record_type",children:"DNS Record Type"}),n.jsxs(Fe,{value:p.dns_record_type,onValueChange:R=>{y({...p,dns_record_type:R,dns_baseline_value:[]}),u([]),f([])},children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"A",children:"A Record (IPv4 Address)"}),n.jsx(J,{value:"AAAA",children:"AAAA Record (IPv6 Address)"}),n.jsx(J,{value:"CNAME",children:"CNAME Record (Canonical Name)"}),n.jsx(J,{value:"MX",children:"MX Record (Mail Exchange)"}),n.jsx(J,{value:"TXT",children:"TXT Record (Text)"}),n.jsx(J,{value:"NS",children:"NS Record (Name Server)"}),n.jsx(J,{value:"PTR",children:"PTR Record (Reverse DNS)"})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Type of DNS record to monitor for changes"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"dns_baseline_value",children:"Baseline DNS Values"}),n.jsxs("div",{className:"space-y-3",children:[n.jsx("div",{className:"flex gap-2",children:n.jsx(H,{type:"button",variant:"outline",onClick:C,disabled:!m.hostname_or_url||l,size:"sm",children:l?"Looking up...":"Lookup Current Values"})}),d.length>0&&n.jsxs("div",{className:"border rounded-lg p-3 space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(z,{className:"text-sm font-medium",children:"DNS Lookup Results"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:()=>M(!0),disabled:h.length===d.length,children:"Select All"}),n.jsx(H,{type:"button",variant:"outline",size:"sm",onClick:()=>M(!1),disabled:h.length===0,children:"Clear All"}),n.jsxs(H,{type:"button",size:"sm",onClick:D,disabled:h.length===0,children:["Add Selected (",h.length,")"]})]})]}),n.jsx("div",{className:"grid gap-2 max-h-40 overflow-y-auto",children:d.map((R,T)=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:`record-${T}`,checked:h.includes(R),onCheckedChange:k=>P(R,k)}),n.jsx(z,{htmlFor:`record-${T}
754`,className:"text-sm font-mono cursor-pointer flex-1",children:R})]},T))}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Select the DNS records you want to add to your baseline monitoring values."})]}),n.jsx(kr,{id:"dns_baseline_value",value:p.dns_baseline_value.join(`
755`),onChange:R=>{const T=R.target.value.split(`
756`).filter(k=>k.trim());y({...p,dns_baseline_value:T})},placeholder:"Enter expected DNS values (one per line) or use lookup above",rows:4})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Expected DNS record values. Monitoring will alert if current values don't match these."})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"dns_case_sensitive",checked:p.dns_case_sensitive,onChange:R=>y({...p,dns_case_sensitive:R.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"dns_case_sensitive",className:"text-sm",children:"Case sensitive comparison"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:p.check_interval,onChange:R=>y({...p,check_interval:parseInt(R.target.value)||900}),min:"300"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"DNS checks every 15+ minutes (DNS changes infrequently)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:p.alert_threshold,onChange:R=>y({...p,alert_threshold:parseInt(R.target.value)||2}),min:"1",max:"5"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive DNS changes before alerting"})]})]})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review DNS Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:m.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Domain"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:m.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Record Type"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:p.dns_record_type})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[p.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Case Sensitive"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:p.dns_case_sensitive?"Yes":"No"})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Alert Threshold"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:p.alert_threshold})]})]}),m.description&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:m.description})]}),p.dns_baseline_value.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Baseline Values"}),n.jsx("div",{className:"text-sm text-muted-foreground space-y-1",children:p.dns_baseline_value.map((R,T)=>n.jsxs("div",{children:["• ",R]},T))})]}),m.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:m.tags.join(", ")})]})]})]});default:return null}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:Cc.map((R,T)=>n.jsxs("div",{className:`flex items-center ${T<Cc.length-1?"flex-1":""}`,children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${T<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:T+1}),T<Cc.length-1&&n.jsx("div",{className:`h-0.5 flex-1 mx-2 ${T<i?"bg-primary":"bg-muted"}`})]},T))}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",i+1," of ",Cc.length,": ",Cc[i].title]})]})]}),$(),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:F,disabled:i===0,children:"Previous"}),n.jsxs("div",{className:"space-x-2",children:[n.jsx(H,{variant:"outline",onClick:t,children:"Cancel"}),i===Cc.length-1?n.jsx(H,{onClick:L,disabled:_||w,children:a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:U,disabled:!A(i),children:"Next"})]})]})]})}const kc=[{title:"Agent Details",description:"Basic information about your TCP/UDP port monitor",icon:ht},{title:"Port Configuration",description:"Configure the server and port to monitor",icon:N0},{title:"Probe Selection",description:"Select which probe agent will perform the monitoring",icon:Cn},{title:"Monitoring Settings",description:"Set up monitoring intervals and thresholds",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function R2({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState({name:"",description:"",asset_type:"tcp_udp",hostname_or_url:"",port:22,protocol:"tcp",tags:[],probe_agent_id:null}),[d,u]=x.useState({check_interval:3600,timeout_seconds:30,alert_threshold:3}),{createAgent:h,updateAgent:f,isCreating:m,isUpdating:g}=Lt(s),{data:p=[]}=Ve({queryKey:["probe-agents",s],queryFn:async()=>
756{if(!s)return[];const{data:w,error:N}=await B.from("monitoring_agents").select("id, name, is_probe_agent, probe_capabilities, probe_location").eq("client_id",s).eq("is_probe_agent",!0);if(N)throw N;return(w||[]).filter(S=>{const C=S.probe_capabilities||[];return Array.isArray(C)&&(C.includes("tcp")||C.includes("udp"))})},enabled:!!s});x.useEffect(()=>{var w;if(a&&e){c({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",port:a.port,protocol:a.protocol||"tcp",tags:a.tags||[],probe_agent_id:((w=a.monitoring_config)==null?void 0:w.probe_agent_id)||null});const N=a.monitoring_config||{};u({check_interval:N.check_interval||3600,timeout_seconds:N.timeout_seconds||30,alert_threshold:N.alert_threshold||3})}},[a,e]);const y=w=>{switch(w){case 0:return l.name.trim()!=="";case 1:return l.hostname_or_url.trim()!==""&&l.port&&l.port>0;case 2:return!!l.probe_agent_id;case 3:return d.check_interval>0&&d.timeout_seconds>0;default:return!0}},v=()=>{i<kc.length-1&&o(i+1)},j=()=>{i>0&&o(i-1)},b=async()=>{if(!s)return;const w={client_id:s,name:l.name,description:l.description||null,asset_type:l.asset_type,hostname_or_url:l.hostname_or_url||null,ip_address:null,port:l.port,protocol:l.protocol,monitoring_config:{...d,probe_agent_id:l.probe_agent_id},status:"active",tags:l.tags};try{a?await f({id:a.id,...w}):await h(w),t()}catch(N){console.error("Error saving TCP/UDP monitor:",N)}},_=()=>{var w,N,S;switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"TCP/UDP Port Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your port monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:l.name,onChange:C=>c({...l,name:C.target.value}),placeholder:"e.g., SSH Server Monitor"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:l.description,onChange:C=>c({...l,description:C.target.value}),placeholder:"TCP/UDP port monitoring for service availability"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:l.tags.join(", "),onChange:C=>{const M=C.target.value.split(",").map(D=>D.trim()).filter(D=>D.length>0);c({...l,tags:M})},placeholder:"e.g., tcp, udp, port, service, infrastructure"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(N0,{className:"h-5 w-5"}),"Port Configuration"]}),n.jsx(De,{children:"Configure the server and port details for monitoring"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"Server or IP Address *"}),n.jsx(ie,{id:"hostname_or_url",value:l.hostname_or_url,onChange:C=>c({...l,hostname_or_url:C.target.value}),placeholder:"e.g., server.example.com or 192.168.1.100"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter hostname or IP address to monitor"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"protocol",children:"Protocol *"}),n.jsxs(Fe,{value:l.protocol,onValueChange:C=>{let P=l.port;C==="tcp"?P=22:C==="udp"&&(P=53),c({...l,protocol:C,port:P})},children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"tcp",children:"TCP"}),n.jsx(J,{value:"udp",children:"UDP"})]})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"Port *"}),l.protocol==="tcp"?n.jsxs(Fe,{value:((w=l.port)==null?void 0:w.toString())||"22",onValueChange:C=>{c(C==="custom"?{...l,port:null}:{...l,port:parseInt(C)})},children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"21",children:"FTP (21)"}),n.jsx(J,{value:"22",children:"SSH (22)"}),n.jsx(J,{value:"23",children:"TELNET (23)"}),n.jsx(J,{value:"25",children:"SMTP (25)"}),n.jsx(J,{value:"587",children:"SMTP Submission (587)"}),n.jsx(J,{value:"2525",children:"SMTP Alt (2525)"}),n.jsx(J,{value:"80",children:"HTTP (80)"}),n.jsx(J,{value:"110",children:"POP3 (110)"}),n.jsx(J,{value:"143",children:"IMAP (143)"}),n.jsx(J,{value:"389",children:"LDAP (389)"}),n.jsx(J,{value:"443",children:"HTTPS/SSL (443)"}),n.jsx(J,{value:"1433",children:"MSSQL (1433)"}
756),n.jsx(J,{value:"1521",children:"ORACLE (1521)"}),n.jsx(J,{value:"3306",children:"MySQL (3306)"}),n.jsx(J,{value:"3389",children:"RDP (3389)"}),n.jsx(J,{value:"5432",children:"PostgreSQL (5432)"}),n.jsx(J,{value:"6379",children:"Redis (6379)"}),n.jsx(J,{value:"8080",children:"HTTP Alt (8080)"}),n.jsx(J,{value:"8443",children:"HTTPS Alt (8443)"}),n.jsx(J,{value:"27017",children:"MongoDB (27017)"}),n.jsx(J,{value:"custom",children:"Custom Port"})]})]}):n.jsxs(Fe,{value:((N=l.port)==null?void 0:N.toString())||"53",onValueChange:C=>c({...l,port:parseInt(C)}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"53",children:"DNS (53)"}),n.jsx(J,{value:"123",children:"NTP (123)"})]})]})]})]}),l.protocol==="tcp"&&!l.port&&n.jsxs("div",{children:[n.jsx(z,{htmlFor:"custom_port",children:"Custom Port"}),n.jsx(ie,{id:"custom_port",type:"number",value:"",onChange:C=>c({...l,port:parseInt(C.target.value)||null}),placeholder:"Enter custom port number",min:"1",max:"65535"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-5 w-5"}),"Probe Selection"]}),n.jsx(De,{children:"Select which probe agent will perform the TCP/UDP monitoring"})]}),n.jsx(re,{className:"space-y-4",children:p.length===0?n.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-lg",children:[n.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("h3",{className:"font-medium text-lg mb-2",children:"No Probe Agents Available"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"You need to enable at least one agent as a probe with TCP/UDP capabilities first."}),n.jsx(H,{variant:"outline",onClick:t,children:"Configure Probe Agents"})]}):n.jsxs("div",{children:[n.jsx(z,{htmlFor:"probe_agent",children:"Select Probe Agent *"}),n.jsxs(Fe,{value:l.probe_agent_id||"",onValueChange:C=>c({...l,probe_agent_id:C}),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Choose a probe agent..."})}),n.jsx(Le,{children:p.map(C=>n.jsx(J,{value:C.id,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-4 w-4"}),n.jsx("span",{children:C.name}),C.probe_location&&n.jsxs("span",{className:"text-muted-foreground",children:["(",C.probe_location,")"]})]})},C.id))})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"The selected probe will connect to the target server and report status"})]})})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"TCP/UDP Monitoring Settings"]}),n.jsx(De,{children:"Configure monitoring behavior and timing"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:d.check_interval,onChange:C=>u({...d,check_interval:parseInt(C.target.value)||3600}),min:"3600"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Port checks every hour+ (minimum 1 hour)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"timeout_seconds",children:"Connection Timeout (seconds)"}),n.jsx(ie,{id:"timeout_seconds",type:"number",value:d.timeout_seconds,onChange:C=>u({...d,timeout_seconds:parseInt(C.target.value)||30}),min:"5",max:"120"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How long to wait for connection"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:d.alert_threshold,onChange:C=>u({...d,alert_threshold:parseInt(C.target.value)||3}),min:"1",max:"10"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive connection failures before alerting"})]})]})]});case 4:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review TCP/UDP Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Server"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Protocol"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:(S=l.protocol)==null?void 0:S.toUpperCase()})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Port"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.port})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Timeout"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.timeout_seconds,"s"]})]})]}),l.description&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.description})]}),l.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.tags.join(", ")})]})]})]});default:return null}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:kc.map((w,N)=>n.jsxs("div",{className:`flex items-center ${N<kc.length-1?"flex-1":""}`,children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${N<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:N+1}),N<kc.length-1&&n.jsx("div",{className:`h-0.5 flex-1 mx-2 ${N<i?"bg-primary":"bg-muted"}`})]},N))}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",i+1," of ",kc.length,": ",kc[i].title]})]})]}),_(),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:j,disabled:i===0,children:"Previous"}),n.jsxs("div",{className:"space-x-2",children:[n.jsx(H,{variant:"outline",onClick:t,children:"Cancel"}),i===kc.length-1?n.jsx(H,{onClick:b,disabled:m||g,children:a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:v,disabled:!y(i),children:"Next"})]})]})]})}const Pc=[{title:"Agent Details",description:"Basic information about your ping monitor",icon:ht},{title:"Host Configuration",description:"Configure the host to ping",icon:Wr},{title:"Ping Settings",description:"Set up ping thresholds and monitoring intervals",
756icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function dOe({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState(!1),[d,u]=x.useState({name:"",description:"",asset_type:"ping",hostname_or_url:"",ip_address:"",tags:[]}),[h,f]=x.useState({check_interval:300,alert_threshold:3,ping_latency_threshold_ms:1e3,ping_packet_loss_threshold:50}),{createAgent:m,updateAgent:g,isCreating:p,isUpdating:y}=Lt(s);x.useEffect(()=>{if(a&&e){u({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",tags:a.tags||[]});const S=a.monitoring_config||{};f({check_interval:S.check_interval||300,alert_threshold:S.alert_threshold||3,ping_latency_threshold_ms:S.ping_latency_threshold_ms||1e3,ping_packet_loss_threshold:S.ping_packet_loss_threshold||50})}},[a,e]);const v=async()=>{if(d.hostname_or_url.trim()&&!d.ip_address.trim()&&!l){c(!0);try{const S=await Qj(d.hostname_or_url);S&&!d.ip_address.trim()&&u(C=>({...C,ip_address:S}))}catch(S){console.warn("Failed to resolve DNS:",S)}finally{c(!1)}}},j=S=>{switch(S){case 0:return d.name.trim()!=="";case 1:return d.hostname_or_url.trim()!==""||d.ip_address.trim()!=="";case 2:return h.check_interval>0&&h.ping_latency_threshold_ms>0;default:return!0}},b=()=>{i<Pc.length-1&&o(i+1)},_=()=>{i>0&&o(i-1)},w=async()=>{if(!s)return;const S={client_id:s,name:d.name,description:d.description||null,asset_type:d.asset_type,hostname_or_url:d.hostname_or_url||null,ip_address:d.ip_address||null,port:null,protocol:"icmp",monitoring_config:h,status:"active",tags:d.tags};try{a?await g({id:a.id,...S}):await m(S),t()}catch(C){console.error("Error saving Ping monitor:",C)}},N=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"Ping/Host Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your ping monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:d.name,onChange:S=>u({...d,name:S.target.value}),placeholder:"e.g., Production Server Ping Monitor"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:d.description,onChange:S=>u({...d,description:S.target.value}),placeholder:"Ping monitoring for host reachability and latency"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:d.tags.join(", "),onChange:S=>{const P=S.target.value.split(",").map(M=>M.trim()).filter(M=>M.length>0);u({...d,tags:P})},placeholder:"e.g., ping, connectivity, latency, network"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Wr,{className:"h-5 w-5"}),"Host Configuration"]}),n.jsx(De,{children:"Configure the host or IP address to ping"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"Hostname or IP Address *"}),n.jsx(ie,{id:"hostname_or_url",value:d.hostname_or_url,onChange:S=>u({...d,hostname_or_url:S.target.value}),onBlur:v,placeholder:"e.g., server.example.com or 192.168.1.100"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter hostname or IP address to ping"})]}),n.jsxs("div",{children:[n.jsxs(z,{htmlFor:"ip_address",children:["IP Address ",l&&n.jsx("span",{className:"text-xs text-muted-foreground",children:"(resolving...)"})]}),n.jsx(ie,{id:"ip_address",value:d.ip_address,onChange:S=>u({...d,ip_address:S.target.value}),placeholder:"e.g., 192.168.1.100 (auto-resolved from hostname)",disabled:l}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Will be auto-populated from hostname if provided"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Ping Monitoring Settings"]}),n.jsx(De,{children:"Configure ping thresholds and monitoring behavior"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"ping_latency_threshold_ms",children:"Latency Threshold (ms)"}),n.jsx(ie,{id:"ping_latency_threshold_ms",type:"number",value:h.ping_latency_threshold_ms,onChange:S=>f({...h,ping_latency_threshold_ms:parseInt(S.target.value)||1e3}),min:"50",max:"10000"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Alert when ping latency exceeds this value"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"ping_packet_loss_threshold",children:"Packet Loss Threshold (%)"}),n.jsx(ie,{id:"ping_packet_loss_threshold",type:"number",value:h.ping_packet_loss_threshold,onChange:S=>f({...h,ping_packet_loss_threshold:parseInt(S.target.value)||50}),min:"0",max:"100"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Alert when packet loss exceeds this percentage"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:h.check_interval,onChange:S=>f({...h,check_interval:parseInt(S.target.value)||300}),min:"60"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to ping (minimum 60 seconds)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:h.alert_threshold,onChange:S=>f({...h,alert_threshold:parseInt(S.target.value)||3}),min:"1",max:"10"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive ping failures before alerting"})]})]})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review Ping Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Target Host"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"IP Address"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.ip_address||"N/A"})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Latency Threshold"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.ping_latency_threshold_ms,"ms"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Packet Loss Threshold"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.ping_packet_loss_threshold,"%"]})]})]}),d.description&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),d.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.tags.join(", ")})]})]})]});default:return null}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:Pc.map((S,C)=>n.jsxs("div",{className:`flex items-center ${C<Pc.length-1?"flex-1":""}`,children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${C<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:C+1}),C<Pc.length-1&&n.jsx("div",{className:`h-0.5 flex-1 mx-2 ${C<i?"bg-primary":"bg-muted"}`})]},C))}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",i+1," of ",Pc.length,": ",Pc[i].title]})]})]}),N(),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:_,disabled:i===0,children:"Previous"}),n.jsxs("div",{className:"space-x-2",children:[n.jsx(H,{variant:"outline",onClick:t,children:"Cancel"}),i===Pc.length-1?n.jsx(H,{onClick:w,disabled:p||y,children:a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:b,disabled:!j(i),children:"Next"})]})]})]})}const Tc=[{title:"Agent Details",description:"Basic information about your keyword monitor",icon:ht},{title:"Website Configuration",description:"Configure the website URL to monitor",icon:qt},{title:"Keyword Settings",description:"Set up keyword search and matching criteria",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function Yq({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState(!1),[d,u]=x.useState({name:"",description:"",asset_type:"keyword",hostname_or_url:"",ip_address:"",tags:[]}
756),[h,f]=x.useState({check_interval:300,alert_threshold:3,keyword_type:"text",keyword_target:"",keyword_expect_present:!0,keyword_case_sensitive:!1,keyword_match_type:"contains"}),{createAgent:m,updateAgent:g,isCreating:p,isUpdating:y}=Lt(s);x.useEffect(()=>{if(a&&e){u({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",tags:a.tags||[]});const S=a.monitoring_config||{};f({check_interval:S.check_interval||300,alert_threshold:S.alert_threshold||3,keyword_type:S.keyword_type||"text",keyword_target:S.keyword_target||"",keyword_expect_present:S.keyword_expect_present!==void 0?S.keyword_expect_present:!0,keyword_case_sensitive:S.keyword_case_sensitive||!1,keyword_match_type:S.keyword_match_type||"contains"})}},[a,e]);const v=async()=>{if(d.hostname_or_url.trim()&&!d.ip_address.trim()&&!l){c(!0);try{const S=await Qj(d.hostname_or_url);S&&!d.ip_address.trim()&&u(C=>({...C,ip_address:S}))}catch(S){console.warn("Failed to resolve DNS:",S)}finally{c(!1)}}},j=S=>{switch(S){case 0:return d.name.trim()!=="";case 1:return d.hostname_or_url.trim()!=="";case 2:return h.check_interval>0&&h.keyword_target.trim()!=="";default:return!0}},b=()=>{i<Tc.length-1&&o(i+1)},_=()=>{i>0&&o(i-1)},w=async()=>{if(!s)return;const S={client_id:s,name:d.name,description:d.description||null,asset_type:d.asset_type,hostname_or_url:d.hostname_or_url||null,ip_address:d.ip_address||null,port:443,protocol:"https",monitoring_config:h,status:"active",tags:d.tags};try{a?await g({id:a.id,...S}):await m(S),t()}catch(C){console.error("Error saving Keyword monitor:",C)}},N=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"Keyword Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your keyword monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:d.name,onChange:S=>u({...d,name:S.target.value}),placeholder:"e.g., Homepage Content Monitor"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:d.description,onChange:S=>u({...d,description:S.target.value}),placeholder:"Keyword monitoring for specific content on web pages"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:d.tags.join(", "),onChange:S=>{const P=S.target.value.split(",").map(M=>M.trim()).filter(M=>M.length>0);u({...d,tags:P})},placeholder:"e.g., keyword, content, text, monitoring"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(qt,{className:"h-5 w-5"}),"Website Configuration"]}),n.jsx(De,{children:"Configure the website URL to monitor for keywords"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"Website URL *"}),n.jsx(ie,{id:"hostname_or_url",value:d.hostname_or_url,onChange:S=>u({...d,hostname_or_url:S.target.value}),onBlur:v,placeholder:"e.g., https://example.com"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Enter the complete URL including protocol (http:// or https://)"})]}),n.jsxs("div",{children:[n.jsxs(z,{htmlFor:"ip_address",children:["IP Address ",l&&n.jsx("span",{className:"text-xs text-muted-foreground",children:"(resolving...)"})]}),n.jsx(ie,{id:"ip_address",value:d.ip_address,onChange:S=>u({...d,ip_address:S.target.value}),placeholder:"e.g., 192.168.1.100 (auto-resolved from URL)",disabled:l}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Will be auto-populated from hostname/URL"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Keyword Monitoring Settings"]}),n.jsx(De,{children:"Configure keyword search criteria and matching behavior"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"keyword_type",children:"Keyword Search Type"}),n.jsxs(Fe,{value:h.keyword_type,onValueChange:S=>f({...h,keyword_type:S}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"text",children:"Plain Text Search"}),n.jsx(J,{value:"html_element",children:"HTML Element"}),n.jsx(J,{value:"css_selector",children:"CSS Selector"}),n.jsx(J,{value:"css_class",children:"CSS Class"})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How to search for the keyword in the page content"})]}),n.jsxs("div",{children:[n.jsxs(z,{htmlFor:"keyword_target",children:[h.keyword_type==="text"&&"Text to Search For *",h.keyword_type==="html_element"&&"HTML Element (e.g., title, h1, p) *",h.keyword_type==="css_selector"&&"CSS Selector (e.g., .class, #i
756d) *",h.keyword_type==="css_class"&&"CSS Class Name *"]}),n.jsx(ie,{id:"keyword_target",value:h.keyword_target,onChange:S=>f({...h,keyword_target:S.target.value}),placeholder:h.keyword_type==="text"?"e.g., Welcome to our website":h.keyword_type==="html_element"?"e.g., title, h1, p":h.keyword_type==="css_selector"?"e.g., .header, #main-content":"e.g., navigation, footer"}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[h.keyword_type==="text"&&"The exact text string to search for on the page",h.keyword_type==="html_element"&&"HTML element tag name to find",h.keyword_type==="css_selector"&&"CSS selector to locate elements",h.keyword_type==="css_class"&&"CSS class name to search for"]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"keyword_expect_present",checked:h.keyword_expect_present,onChange:S=>f({...h,keyword_expect_present:S.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"keyword_expect_present",className:"text-sm",children:"Expect content to be present (uncheck if content should NOT be found)"})]}),h.keyword_type==="text"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"keyword_case_sensitive",checked:h.keyword_case_sensitive,onChange:S=>f({...h,keyword_case_sensitive:S.target.checked}),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"keyword_case_sensitive",className:"text-sm",children:"Case sensitive search"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"keyword_match_type",children:"Match Type"}),n.jsxs(Fe,{value:h.keyword_match_type,onValueChange:S=>f({...h,keyword_match_type:S}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"contains",children:"Contains (substring match)"}),n.jsx(J,{value:"exact",children:"Exact match"}),n.jsx(J,{value:"regex",children:"Regular expression"})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How to match the text string"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:h.check_interval,onChange:S=>f({...h,check_interval:parseInt(S.target.value)||300}),min:"60"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 60 seconds)"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:h.alert_threshold,onChange:S=>f({...h,alert_threshold:parseInt(S.target.value)||3}),min:"1",max:"10"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive failures before alerting"})]})]})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review Keyword Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Website URL"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.hostname_or_url})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Search Type"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:h.keyword_type})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[h.check_interval,"s"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Expect Present"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:h.keyword_expect_present?"Yes":"No"})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Alert Threshold"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:h.alert_threshold})]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Search Target"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:h.keyword_target})]}),d.description&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.description})]}),h.keyword_type==="text"&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Text Matching"}),n.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[n.jsxs("div",{children:["• Match type: ",h.keyword_match_type]}),n.jsxs("div",{children:["• Case sensitive: ",h.keyword_case_sensitive?"Yes":"No"]})]})]}),d.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.tags.join(", ")})]})]})]});default:return null}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs(H,{variant:"ghost",size:"sm",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"flex items-center justify-between mb-2",children:Tc.map((S,C)=>n.jsxs("div",{className:`flex items-center ${C<Tc.length-1?"flex-1":""}`,children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium ${C<=i?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:C+1}),C<Tc.length-1&&n.jsx("div",{className:`h-0.5 flex-1 mx-2 ${C<i?"bg-primary":"bg-muted"}`})]},C))}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Step ",i+1," of ",Tc.length,": ",Tc[i].title]})]})]}),N(),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:_,disabled:i===0,children:"Previous"}),n.jsxs("div",{className:"space-x-2",children:[n.jsx(H,{variant:"outline",onClick:t,children:"Cancel"}),i===Tc.length-1?n.jsx(H,{onClick:w,disabled:p||y,children:a?"Update Monitor":"Create Monitor"}):n.jsx(H,{onClick:b,disabled:!j(i),children:"Next"})]})]})]})}const kx=[{title:"SMTP Monitor Details",description:"Basic information about your SMTP monitor",icon:ht},{title:"SMTP Configuration",description:"Configure domain, mode, and connection settings",icon:aa},{title:"Advanced Settings",description:"Configure timeouts, TLS settings, and validation rules",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function $2({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState({name:"",description:"",asset_type:"smtp",hostname_or_url:"",ip_address:"",port:25,protocol:"smtp",tags:[]}),[d,u]=x.useState({domain:"",mode:"by-domain",ports:[25,587,465],connect_timeout_ms:5e3,read_timeout_ms:5e3,tls_handshake_timeout_ms:5e3,retries:2,expected_hostnames:[],allow_any_mx_hostname:!0,require_fqdn_in_banner:!0,verify_cert:!1,send_sni:!0,ipv6_enabled:!0,check_interval:10800,alert_threshold:3}),{createAgent:h,updateAgent:f,isCreating:m,isUpdating:g}=Lt(s);x.useEffect(()=>{if(a&&e){c({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",port:a.port,protocol:a.protocol||"smtp",tags:a.tags||[]});const _=a.monitoring_config||{};u({domain:_.domain||"",mode:_.mode||"by-domain",ports:_.ports||[25,587,465],connect_timeout_ms:_.connect_timeout_ms||5e3,read_timeout_ms:_.read_timeout_ms||5e3,tls_handshake_timeout_ms:_.tls_handshake_timeout_ms||5e3,retries:_.retries||2,expected_hostnames:_.expected_hostnames||[],allow_any_mx_hostname:_.allow_any_mx_hostname!==void 0?_.allow_any_mx_hostname:!0,require_fqdn_in_banner:_.require_fqdn_in_banner!==void 0?_.require_fqdn_in_banner:!0,verify_cert:_.verify_cert||!1,send_sni:_.send_sni!==void 0?_.send_sni:!0,ipv6_enabled:_.ipv6_enabled!==void 0?_.ipv6_enabled:!0,check_interval:_.check_interval||10800,alert_threshold:_.alert_threshold||3})}},[a,e]);const p=_=>{switch(_){case 0:return l.name.trim()!=="";case 1:return d.domain.trim()!==""&&d.ports.length>0;case 2:return d.connect_timeout_ms>0&&d.read_timeout_ms>0;default:return!0}},y=()=>{i<kx.length-1&&o(i+1)},v=()=>{i>0&&o(i-1)},j=async()=>
756{if(!s)return;const _={client_id:s,name:l.name,description:l.description||null,asset_type:l.asset_type,hostname_or_url:d.domain,ip_address:l.ip_address||null,port:l.port,protocol:l.protocol,monitoring_config:d,status:"active",tags:l.tags};try{a?await f({id:a.id,..._}):await h(_),t()}catch(w){console.error("Error saving SMTP monitor:",w)}},b=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"SMTP Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your SMTP monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:l.name,onChange:_=>c({...l,name:_.target.value}),placeholder:"e.g., Company SMTP Server Monitor"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:l.description,onChange:_=>c({...l,description:_.target.value}),placeholder:"Monitor SMTP server availability and banner validation"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags"}),n.jsx(ie,{id:"tags",value:l.tags.join(", "),onChange:_=>{const N=_.target.value.split(",").map(S=>S.trim()).filter(S=>S.length>0);c({...l,tags:N})},placeholder:"e.g., email, smtp, mail-server"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Separate multiple tags with commas"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(aa,{className:"h-5 w-5"}),"SMTP Configuration"]}),n.jsx(De,{children:"Configure domain and SMTP connection settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"domain",children:"Domain *"}),n.jsx(ie,{id:"domain",value:d.domain,onChange:_=>u({...d,domain:_.target.value}),placeholder:"e.g., example.com"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"The domain to monitor SMTP services for"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"mode",children:"Monitoring Mode"}),n.jsxs(Fe,{value:d.mode,onValueChange:_=>u({...d,mode:_}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"by-domain",children:"By Domain (MX Lookup)"}),n.jsx(J,{value:"by-host",children:"By Host (Direct)"})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:d.mode==="by-domain"?"Resolve MX records and test each target host":"Test the specific hostname/IP directly"})]}),n.jsxs("div",{children:[n.jsx(z,{children:"SMTP Ports"}),n.jsx("div",{className:"space-y-2",children:[{port:25,label:"SMTP (25)"},{port:587,label:"Submission (587)"},{port:465,label:"SMTPS (465)"}].map(({port:_,label:w})=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:`port-${_}`,checked:d.ports.includes(_),onCheckedChange:N=>{u(N?{...d,ports:[...d.ports,_].sort((S,C)=>S-C)}:{...d,ports:d.ports.filter(S=>S!==_)})}}),n.jsx(z,{htmlFor:`port-${_}`,children:w})]},_))})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:d.check_interval,onChange:_=>u({...d,check_interval:parseInt(_.target.value)||10800}),min:"10800"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 3 hours / 10800 seconds to avoid overwhelming email servers)"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Advanced SMTP Settings"]}),n.jsx(De,{children:"Configure timeouts, TLS settings, and validation rules"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"connect_timeout",children:"Connect Timeout (ms)"}),n.jsx(ie,{id:"connect_timeout",type:"number",value:d.connect_timeout_ms,onChange:_=>u({...d,connect_timeout_ms:parseInt(_.target.value)||5e3}),min:"1000",max:"30000"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"read_timeout",children:"Read Timeout (ms)"}),n.jsx(ie,{id:"read_timeout",type:"number",value:d.read_timeout_ms,onChange:_=>u({...d,read_timeout_ms:parseInt(_.target.value)||5e3}),min:"1000",max:"30000"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tls_timeout",children:"TLS Timeout (ms)"}),n.jsx(ie,{id:"tls_timeout",type:"number",value:d.tls_handshake_timeout_ms,onChange:_=>u({...d,tls_handshake_timeout_ms:parseInt(_.target.value)||5e3}),min:"1000",max:"30000"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"expected_hostnames",children:"Expected Hostnames (optional)"}),n.jsx(ie,{id:"expected_hostnames",value:d.expected_hostnames.join(", "),onChange:_=>{const w=_.target.value.split(",").map(N=>N.trim()).filter(N=>N.length>0);u({...d,expected_hostnames:w})},placeholder:"e.g., mail.example.com, smtp.example.com"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Acceptable banner FQDNs (leave empty to allow any MX hostname)"})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"allow_any_mx_hostname",checked:d.allow_any_mx_hostname,onCheckedChange:_=>u({...d,allow_any_mx_hostname:_})}),n.jsx(z,{htmlFor:"allow_any_mx_hostname",children:"Allow any MX hostname in banner"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"require_fqdn_in_banner",checked:d.require_fqdn_in_banner,onCheckedChange:_=>u({...d,require_fqdn_in_banner:_})}),n.jsx(z,{htmlFor:"require_fqdn_in_banner",children:"Require FQDN in banner"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"verify_cert",checked:d.verify_cert,onCheckedChange:_=>u({...d,verify_cert:_})}),n.jsx(z,{htmlFor:"verify_cert",children:"Verify TLS certificate"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"ipv6_enabled",checked:d.ipv6_enabled,onCheckedChange:_=>u({...d,ipv6_enabled:_})}),n.jsx(z,{htmlFor:"ipv6_enabled",children:"Enable IPv6 testing"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:d.alert_threshold,onChange:_=>u({...d,alert_threshold:parseInt(_.target.value)||3}),min:"1",max:"10"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Number of consecutive failures before alerting"})]})]})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review SMTP Monitor Configuration"]}),n.jsx(De,{children:"Please review your settings before creating the monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Monitor Name"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.name})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Domain"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.domain})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Mode"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.mode==="by-domain"?"By Domain (MX Lookup)":"By Host (Direct)"})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Ports"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.ports.join(", ")})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Check Interval"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.check_interval," seconds"]})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Alert Threshold"}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:[d.alert_threshold," 
756consecutive failures"]})]})]}),d.expected_hostnames.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Expected Hostnames"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:d.expected_hostnames.join(", ")})]}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Options"}),n.jsxs("div",{className:"text-sm text-muted-foreground space-y-1",children:[d.allow_any_mx_hostname&&n.jsx("p",{children:"• Allow any MX hostname in banner"}),d.require_fqdn_in_banner&&n.jsx("p",{children:"• Require FQDN in banner"}),d.verify_cert&&n.jsx("p",{children:"• Verify TLS certificate"}),d.ipv6_enabled&&n.jsx("p",{children:"• IPv6 testing enabled"})]})]}),l.tags.length>0&&n.jsxs("div",{children:[n.jsx(z,{className:"text-sm font-medium",children:"Tags"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:l.tags.join(", ")})]})]})]});default:return null}};return e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(H,{variant:"outline",onClick:r,className:"flex items-center gap-2",children:[n.jsx(Ma,{className:"h-4 w-4"}),"Back to Monitor Types"]}),n.jsx("div",{className:"flex items-center space-x-2",children:kx.map((_,w)=>{const N=_.icon,S=w===i,C=w<i;return n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full border-2 ${S||C?"border-primary bg-primary text-primary-foreground":"border-muted bg-background text-muted-foreground"}`,children:n.jsx(N,{className:"h-4 w-4"})}),w<kx.length-1&&n.jsx("div",{className:`w-8 h-0.5 ${w<i?"bg-primary":"bg-muted"}`})]},w)})})]}),n.jsx("div",{className:"min-h-[400px]",children:b()}),n.jsxs("div",{className:"flex justify-between",children:[n.jsx(H,{variant:"outline",onClick:v,disabled:i===0,children:"Previous"}),i<kx.length-1?n.jsx(H,{onClick:y,disabled:!p(i),children:"Next"}):n.jsx(H,{onClick:j,disabled:!p(i)||m||g,children:m||g?"Creating...":a?"Update Monitor":"Create Monitor"})]})]}):null}const Px=[{title:"FTP Monitor Details",description:"Basic information about your FTP monitor",icon:ht},{title:"FTP Configuration",description:"Configure server, authentication, and connection settings",icon:pC},{title:"Probe Selection",description:"Select a probe agent to perform the monitoring",icon:Cn},{title:"Advanced Settings",description:"Configure timeouts, tests, and monitoring intervals",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function Qq({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState({name:"",description:"",asset_type:"ftp",hostname_or_url:"",ip_address:"",port:21,protocol:"ftp",tags:[],probe_agent_id:""}),[d,u]=x.useState({hostname:"",port:21,username:"anonymous",password:"[email protected]",use_anonymous:!0,connection_mode:"passive",test_directory_listing:!0,test_file_operations:!1,connect_timeout_ms:1e4,read_timeout_ms:1e4,retries:3,check_interval:3600,alert_threshold:3}),{createAgent:h,updateAgent:f,isLoading:m}=Lt(s),{data:g=[]}=Ve({queryKey:["probe-agents-ftp",s],queryFn:async()=>{if(!s)return[];const{data:w,error:N}=await B.from("monitoring_agents").select("id, name, is_probe_agent, probe_capabilities, probe_location").eq("client_id",s).eq("is_probe_agent",!0);if(N)throw N;return(w||[]).filter(S=>{const C=S.probe_capabilities||[];return Array.isArray(C)&&C.includes("ftp")})},enabled:!!s});x.useEffect(()=>{if(a){const w=a.monitoring_config;c({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",port:a.port,protocol:a.protocol||"ftp",tags:a.tags||[],probe_agent_id:(w==null?void 0:w.probe_agent_id)||""}),w&&u({hostname:w.hostname||"",port:w.port||21,username:w.username||"anonymous",password:w.password||"[email protected]",use_anonymous:w.use_anonymous!==void 0?w.use_anonymous:!0,connection_mode:w.connection_mode||"passive",test_directory_listing:w.test_directory_listing!==void 0?w.test_directory_listing:!0,test_file_operations:w.test_file_operations!==void 0?w.test_file_operations:!1,connect_timeout_ms:w.connect_timeout_ms||1e4,read_timeout_ms:w.read_timeout_ms||1e4,retries:w.retries||3,check_interval:w.check_interval||3600,alert_threshold:w.alert_threshold||3})}},[a]);const p=w=>{switch(w){case 0:return!!l.name.trim();case 1:return!!d.hostname.trim();case 2:return!!l.probe_agent_id;case 3:return!0;default:return!0}},y=()=>{i<Px.length-1&&p(i)&&o(i+1)},v=()=>{i>0&&o(i-1)},j=async()=>{try{const w={...d,monitor_type:"ftp",probe_agent_id:l.probe_agent_id},N={...l,monitoring_config:w,client_id:s,hostname_or_url:d.hostname,port:d.port};a?await f({id:a.id,...N}):await h(N),t()}catch(w){console.error("Error saving FTP monitor:",w)}},b=g.find(w=>w.id===l.probe_agent_id),_=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"FTP Monitor Details"]}
756),n.jsx(De,{children:"Provide basic information about your FTP monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:l.name,onChange:w=>c({...l,name:w.target.value}),placeholder:"e.g., Production FTP Server"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:l.description,onChange:w=>c({...l,description:w.target.value}),placeholder:"Brief description of what this monitor checks"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags (comma-separated)"}),n.jsx(ie,{id:"tags",value:l.tags.join(", "),onChange:w=>c({...l,tags:w.target.value.split(",").map(N=>N.trim()).filter(Boolean)}),placeholder:"e.g., production, file-server, critical"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(pC,{className:"h-5 w-5"}),"FTP Configuration"]}),n.jsx(De,{children:"Configure your FTP server connection settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname",children:"FTP Server Hostname *"}),n.jsx(ie,{id:"hostname",value:d.hostname,onChange:w=>u({...d,hostname:w.target.value}),placeholder:"ftp.example.com"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"Port"}),n.jsx(ie,{id:"port",type:"number",value:d.port,onChange:w=>u({...d,port:parseInt(w.target.value)||21}),min:"1",max:"65535"})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"use_anonymous",checked:d.use_anonymous,onCheckedChange:w=>u({...d,use_anonymous:w})}),n.jsx(z,{htmlFor:"use_anonymous",children:"Use Anonymous Login"})]}),!d.use_anonymous&&n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"username",children:"Username"}),n.jsx(ie,{id:"username",value:d.username,onChange:w=>u({...d,username:w.target.value}),placeholder:"username"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"password",children:"Password"}),n.jsx(ie,{id:"password",type:"password",value:d.password,onChange:w=>u({...d,password:w.target.value}),placeholder:"password"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"connection_mode",children:"Connection Mode"}),n.jsxs(Fe,{value:d.connection_mode,onValueChange:w=>u({...d,connection_mode:w}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"passive",children:"Passive (Recommended)"}),n.jsx(J,{value:"active",children:"Active"})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Passive mode works better through firewalls"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-5 w-5"}),"Probe Selection"]}),n.jsx(De,{children:"Select which probe agent will perform the FTP monitoring"})]}),n.jsx(re,{className:"space-y-4",children:g.length===0?n.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-lg",children:[n.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("h3",{className:"font-medium text-lg mb-2",children:"No Probe Agents Available"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"You need to configure at least one probe agent with FTP capabilities first."}),n.jsx(H,{variant:"outline",onClick:t,children:"Configure Probe Agents"})]}):n.jsxs("div",{children:[n.jsx(z,{htmlFor:"probe_agent",children:"Select Probe Agent *"}),n.jsxs(Fe,{value:l.probe_agent_id,onValueChange:w=>c({...l,probe_agent_id:w}),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Choose a probe agent..."})}),n.jsx(Le,{children:g.map(w=>n.jsx(J,{value:w.id,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-4 w-4"}),n.jsx("span",{children:w.name}),w.probe_location&&n.jsxs("span",{className:"text-muted-foreground",children:["(",w.probe_location,")"]})]})},w.id))})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"The probe agent will connect to the FTP server and perform connectivity tests."})]})})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Advanced Settings"]}),n.jsx(De,{children:"Configure monitoring behavior and test settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_directory_listing",checked:d.test_directory_listing,onCheckedChange:w=>u({...d,test_directory_listing:w})}),n.jsx(z,{htmlFor:"test_directory_listing",children:"Test Directory Listing"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_file_operations",checked:d.test_file_operations,onCheckedChange:w=>u({...d,test_file_operations:w})}),n.jsx(z,{htmlFor:"test_file_operations",children:"Test File Operations (Upload/Download)"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"connect_timeout",children:"Connection Timeout (ms)"}),n.jsx(ie,{id:"connect_timeout",type:"number",value:d.connect_timeout_ms,onChange:w=>u({...d,connect_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"read_timeout",children:"Read Timeout (ms)"}),n.jsx(ie,{id:"read_timeout",type:"number",value:d.read_timeout_ms,onChange:w=>u({...d,read_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"retries",children:"Retry Attempts"}),n.jsx(ie,{id:"retries",type:"number",value:d.retries,onChange:w=>
756u({...d,retries:parseInt(w.target.value)||3}),min:"1",max:"10"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:d.alert_threshold,onChange:w=>u({...d,alert_threshold:parseInt(w.target.value)||3}),min:"1"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:d.check_interval,onChange:w=>u({...d,check_interval:parseInt(w.target.value)||3600}),min:"3600"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 1 hour / 3600 seconds to avoid overwhelming FTP servers)"})]})]})]});case 4:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review & Create"]}),n.jsx(De,{children:"Review your FTP monitor configuration"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"Monitor Details"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Name:"})," ",l.name]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Description:"})," ",l.description||"None"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Tags:"})," ",l.tags.join(", ")||"None"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"FTP Configuration"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Server:"})," ",d.hostname,":",d.port]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Authentication:"})," ",d.use_anonymous?"Anonymous":"Username/Password"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Connection Mode:"})," ",d.connection_mode]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Tests:"})," ",[d.test_directory_listing&&"Directory Listing",d.test_file_operations&&"File Operations"].filter(Boolean).join(", ")||"Connection Only"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Check Interval:"})," ",d.check_interval," seconds"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"Probe Agent"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Selected Probe:"})," ",(b==null?void 0:b.name)||"Not selected"]}),(b==null?void 0:b.probe_location)&&n.jsxs("p",{children:[n.jsx("strong",{children:"Location:"})," ",b.probe_location]})]})]})]});default:return null}};return e?n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between mb-6",children:Px.map((w,N)=>n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full border-2 ${N<=i?"border-primary bg-primary text-primary-foreground":"border-muted-foreground text-muted-foreground"}`,children:n.jsx(w.icon,{className:"h-4 w-4"})}),N<Px.length-1&&n.jsx("div",{className:`w-12 h-0.5 mx-2 ${N<i?"bg-primary":"bg-muted"}`})]},N))}),_(),n.jsxs("div",{className:"flex justify-between",children:[n.jsxs("div",{className:"flex gap-2",children:[i===0&&n.jsxs(H,{variant:"outline",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),i>0&&n.jsx(H,{variant:"outline",onClick:v,children:"Previous"})]}),i<Px.length-1?n.jsx(H,{onClick:y,disabled:!p(i),children:"Next"}):n.jsx(H,{onClick:j,disabled:m||!l.probe_agent_id,children:a?"Update Monitor":"Create Monitor"})]})]}):null}const Tx=[{title:"SFTP Monitor Details",description:"Basic information about your SFTP monitor",icon:ht},{title:"SFTP Configuration",description:"Configure server, authentication, and connection settings",icon:ng},{title:"Probe Selection",description:"Select a probe agent to perform the monitoring",icon:Cn},{title:"Advanced Settings",description:"Configure timeouts, tests, and monitoring intervals",icon:yt},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function Xq({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState({name:"",description:"",asset_type:"sftp",hostname_or_url:"",ip_address:"",port:22,protocol:"sftp",tags:[],probe_agent_id:""}),[d,u]=x.useState({hostname:"",port:22,username:"",auth_method:"password",password:"",private_key:"",test_directory_listing:!0,test_file_operations:!1,connect_timeout_ms:1e4,read_timeout_ms:1e4,retries:3,check_interval:3600,alert_threshold:3}),{createAgent:h,updateAgent:f,isLoading:m}=Lt(s),{data:g=[]}=Ve({queryKey:["probe-agents-sftp",s],queryFn:async()=>
756{if(!s)return[];const{data:w,error:N}=await B.from("monitoring_agents").select("id, name, is_probe_agent, probe_capabilities, probe_location").eq("client_id",s).eq("is_probe_agent",!0);if(N)throw N;return(w||[]).filter(S=>{const C=S.probe_capabilities||[];return Array.isArray(C)&&C.includes("sftp")})},enabled:!!s});x.useEffect(()=>{if(a){const w=a.monitoring_config;c({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",port:a.port,protocol:a.protocol||"sftp",tags:a.tags||[],probe_agent_id:(w==null?void 0:w.probe_agent_id)||""}),w&&u({hostname:w.hostname||"",port:w.port||22,username:w.username||"",auth_method:w.auth_method||"password",password:w.password||"",private_key:w.private_key||"",test_directory_listing:w.test_directory_listing!==void 0?w.test_directory_listing:!0,test_file_operations:w.test_file_operations!==void 0?w.test_file_operations:!1,connect_timeout_ms:w.connect_timeout_ms||1e4,read_timeout_ms:w.read_timeout_ms||1e4,retries:w.retries||3,check_interval:w.check_interval||3600,alert_threshold:w.alert_threshold||3})}},[a]);const p=w=>{switch(w){case 0:return!!l.name.trim();case 1:return!!d.hostname.trim()&&!!d.username.trim();case 2:return!!l.probe_agent_id;case 3:return!0;default:return!0}},y=()=>{i<Tx.length-1&&p(i)&&o(i+1)},v=()=>{i>0&&o(i-1)},j=async()=>{try{const w={...d,monitor_type:"sftp",probe_agent_id:l.probe_agent_id},N={...l,monitoring_config:w,client_id:s,hostname_or_url:d.hostname,port:d.port};a?await f({id:a.id,...N}):await h(N),t()}catch(w){console.error("Error saving SFTP monitor:",w)}},b=g.find(w=>w.id===l.probe_agent_id),_=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"SFTP Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your SFTP monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:l.name,onChange:w=>c({...l,name:w.target.value}),placeholder:"e.g., Production SFTP Server"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:l.description,onChange:w=>c({...l,description:w.target.value}),placeholder:"Brief description of what this monitor checks"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags (comma-separated)"}),n.jsx(ie,{id:"tags",value:l.tags.join(", "),onChange:w=>c({...l,tags:w.target.value.split(",").map(N=>N.trim()).filter(Boolean)}),placeholder:"e.g., production, secure-transfer, critical"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ng,{className:"h-5 w-5"}),"SFTP Configuration"]}),n.jsx(De,{children:"Configure your SFTP server connection settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname",children:"SFTP Server Hostname *"}),n.jsx(ie,{id:"hostname",value:d.hostname,onChange:w=>u({...d,hostname:w.target.value}),placeholder:"sftp.example.com"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"Port"}),n.jsx(ie,{id:"port",type:"number",value:d.port,onChange:w=>u({...d,port:parseInt(w.target.value)||22}),min:"1",max:"65535"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"username",children:"Username *"}),n.jsx(ie,{id:"username",value:d.username,onChange:w=>u({...d,username:w.target.value}),placeholder:"username"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"auth_method",children:"Authentication Method"}),n.jsxs(Fe,{value:d.auth_method,onValueChange:w=>u({...d,auth_method:w}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"password",children:"Password"}),n.jsx(J,{value:"key",children:"SSH Private Key"})]})]})]}),d.auth_method==="password"?n.jsxs("div",{children:[n.jsx(z,{htmlFor:"password",children:"Password"}),n.jsx(ie,{id:"password",type:"password",value:d.password,onChange:w=>u({...d,password:w.target.value}),placeholder:"password"})]}):n.jsxs("div",{children:[n.jsx(z,{htmlFor:"private_key",children:"SSH Private Key"}),n.jsx(kr,{id:"private_key",value:d.private_key,onChange:w=>u({...d,private_key:w.target.value}),placeholder:"-----BEGIN OPENSSH PRIVATE KEY-----",rows:8}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Paste your SSH private key here (OpenSSH format)"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-5 w-5"}),"Probe Selection"]}),n.jsx(De,{children:"Select which probe agent will perform the SFTP monitoring"})]}),n.jsx(re,{className:"space-y-4",children:g.length===0?n.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-lg",children:[n.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("h3",{className:"font-medium text-lg mb-2",children:"No Probe Agents Available"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"You need to configure at least one probe agent with SFTP capabilities first."}),n.jsx(H,{variant:"outline",onClick:t,children:"Configure Probe Agents"})]}):n.jsxs("div",{children:[n.jsx(z,{htmlFor:"probe_agent",children:"Select Probe Agent *"}),n.jsxs(Fe,{value:l.probe_agent_id,onValueChange:w=>c({...l,probe_agent_id:w}),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Choose a probe agent..."})}),n.jsx(Le,{children:g.map(w=>n.jsx(J,{value:w.id,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-4 w-4"}),n.jsx("span",{children:w.name}),w.probe_location&&n.jsxs("span",{className:"text-muted-foreground",children:["(",w.probe_location,")"]})]})},w.id))})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"The probe agent will connect to the SFTP server and perform secure connectivity tests."})]})})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Advanced Settings"]}),n.jsx(De,{children:"Configure monitoring behavior and test settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_directory_listing",checked:d.test_directory_listing,onCheckedChange:w=>u({...d,test_directory_listing:w})}),n.jsx(z,{htmlFor:"test_directory_listing",children:"Test Directory Listing"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_file_operations",checked:d.test_file_operations,onCheckedChange:w=>u({...d,test_file_operations:w})}),n.jsx(z,{htmlFor:"test_file_operations",children:"Test File Operations (Upload/Download)"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"connect_timeout",children:"Connection Timeout (ms)"}),n.jsx(ie,{id:"connect_timeout",type:"number",value:d.connect_timeout_ms,onChange:w=>u({...d,connect_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"read_timeout",children:"Read Timeout (ms)"}),n.jsx(ie,{id:"read_timeout",type:"number",value:d.read_timeout_ms,onChange:w=>u({...d,read_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"retries",children:"Retry Attempts"}),n.jsx(ie,{id:"retries",type:"number",value:d.retries,onChange:w=>
756u({...d,retries:parseInt(w.target.value)||3}),min:"1",max:"10"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:d.alert_threshold,onChange:w=>u({...d,alert_threshold:parseInt(w.target.value)||3}),min:"1"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:d.check_interval,onChange:w=>u({...d,check_interval:parseInt(w.target.value)||3600}),min:"3600"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 1 hour / 3600 seconds to avoid overwhelming SFTP servers)"})]})]})]});case 4:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review & Create"]}),n.jsx(De,{children:"Review your SFTP monitor configuration"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"Monitor Details"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Name:"})," ",l.name]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Description:"})," ",l.description||"None"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Tags:"})," ",l.tags.join(", ")||"None"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"SFTP Configuration"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Server:"})," ",d.hostname,":",d.port]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Username:"})," ",d.username]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Authentication:"})," ",d.auth_method==="password"?"Password":"SSH Private Key"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Tests:"})," ",[d.test_directory_listing&&"Directory Listing",d.test_file_operations&&"File Operations"].filter(Boolean).join(", ")||"Connection Only"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Check Interval:"})," ",d.check_interval," seconds"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"Probe Agent"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Selected Probe:"})," ",(b==null?void 0:b.name)||"Not selected"]}),(b==null?void 0:b.probe_location)&&n.jsxs("p",{children:[n.jsx("strong",{children:"Location:"})," ",b.probe_location]})]})]})]});default:return null}};return e?n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between mb-6",children:Tx.map((w,N)=>n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full border-2 ${N<=i?"border-primary bg-primary text-primary-foreground":"border-muted-foreground text-muted-foreground"}`,children:n.jsx(w.icon,{className:"h-4 w-4"})}),N<Tx.length-1&&n.jsx("div",{className:`w-12 h-0.5 mx-2 ${N<i?"bg-primary":"bg-muted"}`})]},N))}),_(),n.jsxs("div",{className:"flex justify-between",children:[n.jsxs("div",{className:"flex gap-2",children:[i===0&&n.jsxs(H,{variant:"outline",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),i>0&&n.jsx(H,{variant:"outline",onClick:v,children:"Previous"})]}),i<Tx.length-1?n.jsx(H,{onClick:y,disabled:!p(i),children:"Next"}):n.jsx(H,{onClick:j,disabled:m||!l.probe_agent_id,children:a?"Update Monitor":"Create Monitor"})]})]}):null}const Ax=[{title:"FTPS Monitor Details",description:"Basic information about your FTPS monitor",icon:ht},{title:"FTPS Configuration",description:"Configure server, authentication, and TLS settings",icon:yt},{title:"Probe Selection",description:"Select a probe agent to perform the monitoring",icon:Cn},{title:"Advanced Settings",description:"Configure timeouts, tests, and monitoring intervals",icon:Io},{title:"Review & Create",description:"Review your configuration and create the monitor",icon:Tt}];function Zq({open:e,onClose:t,onBack:r,clientId:s,existingAgent:a}){const[i,o]=x.useState(0),[l,c]=x.useState({name:"",description:"",asset_type:"ftps",hostname_or_url:"",ip_address:"",port:990,protocol:"ftps",tags:[],probe_agent_id:""}),[d,u]=x.useState({hostname:"",port:990,username:"anonymous",password:"[email protected]",use_anonymous:!0,tls_mode:"implicit",connection_mode:"passive",verify_cert:!0,test_directory_listing:!0,test_file_operations:!1,test_data_encryption:!0,connect_timeout_ms:1e4,read_timeout_ms:1e4,tls_handshake_timeout_ms:1e4,retries:3,check_interval:3600,alert_threshold:3}),{createAgent:h,updateAgent:f,isLoading:m}=Lt(s),{data:g=[]}=Ve({queryKey:["probe-agents-ftps",s],queryFn:async()=>
756{if(!s)return[];const{data:w,error:N}=await B.from("monitoring_agents").select("id, name, is_probe_agent, probe_capabilities, probe_location").eq("client_id",s).eq("is_probe_agent",!0);if(N)throw N;return(w||[]).filter(S=>{const C=S.probe_capabilities||[];return Array.isArray(C)&&C.includes("ftps")})},enabled:!!s});x.useEffect(()=>{if(a){const w=a.monitoring_config;c({name:a.name,description:a.description||"",asset_type:a.asset_type,hostname_or_url:a.hostname_or_url||"",ip_address:a.ip_address||"",port:a.port,protocol:a.protocol||"ftps",tags:a.tags||[],probe_agent_id:(w==null?void 0:w.probe_agent_id)||""}),w&&u({hostname:w.hostname||"",port:w.port||990,username:w.username||"anonymous",password:w.password||"[email protected]",use_anonymous:w.use_anonymous!==void 0?w.use_anonymous:!0,tls_mode:w.tls_mode||"implicit",connection_mode:w.connection_mode||"passive",verify_cert:w.verify_cert!==void 0?w.verify_cert:!0,test_directory_listing:w.test_directory_listing!==void 0?w.test_directory_listing:!0,test_file_operations:w.test_file_operations!==void 0?w.test_file_operations:!1,test_data_encryption:w.test_data_encryption!==void 0?w.test_data_encryption:!0,connect_timeout_ms:w.connect_timeout_ms||1e4,read_timeout_ms:w.read_timeout_ms||1e4,tls_handshake_timeout_ms:w.tls_handshake_timeout_ms||1e4,retries:w.retries||3,check_interval:w.check_interval||3600,alert_threshold:w.alert_threshold||3})}},[a]);const p=w=>{switch(w){case 0:return!!l.name.trim();case 1:return!!d.hostname.trim();case 2:return!!l.probe_agent_id;case 3:return!0;default:return!0}},y=()=>{i<Ax.length-1&&p(i)&&o(i+1)},v=()=>{i>0&&o(i-1)},j=async()=>{try{const w={...d,monitor_type:"ftps",probe_agent_id:l.probe_agent_id},N={...l,monitoring_config:w,client_id:s,hostname_or_url:d.hostname,port:d.port};a?await f({id:a.id,...N}):await h(N),t()}catch(w){console.error("Error saving FTPS monitor:",w)}},b=g.find(w=>w.id===l.probe_agent_id),_=()=>{switch(i){case 0:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"FTPS Monitor Details"]}),n.jsx(De,{children:"Provide basic information about your FTPS monitor"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Monitor Name *"}),n.jsx(ie,{id:"name",value:l.name,onChange:w=>c({...l,name:w.target.value}),placeholder:"e.g., Production FTPS Server"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:l.description,onChange:w=>c({...l,description:w.target.value}),placeholder:"Brief description of what this monitor checks"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags (comma-separated)"}),n.jsx(ie,{id:"tags",value:l.tags.join(", "),onChange:w=>c({...l,tags:w.target.value.split(",").map(N=>N.trim()).filter(Boolean)}),placeholder:"e.g., production, secure-transfer, encrypted"})]})]})]});case 1:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"FTPS Configuration"]}),n.jsx(De,{children:"Configure your FTPS server connection and security settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname",children:"FTPS Server Hostname *"}),n.jsx(ie,{id:"hostname",value:d.hostname,onChange:w=>u({...d,hostname:w.target.value}),placeholder:"ftps.example.com"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"Port"}),n.jsx(ie,{id:"port",type:"number",value:d.port,onChange:w=>u({...d,port:parseInt(w.target.value)||990}),min:"1",max:"65535"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tls_mode",children:"TLS Mode"}),n.jsxs(Fe,{value:d.tls_mode,onValueChange:w=>{u({...d,tls_mode:w,port:w==="implicit"?990:21})},children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"implicit",children:"Implicit (FTPS) - Port 990"}),n.jsx(J,{value:"explicit",children:"Explicit (FTPES) - Port 21"})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Implicit: TLS from start. Explicit: STARTTLS after connection"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"use_anonymous",checked:d.use_anonymous,onCheckedChange:w=>u({...d,use_anonymous:w})}),n.jsx(z,{htmlFor:"use_anonymous",children:"Use Anonymous Login"})]}),!d.use_anonymous&&n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"username",children:"Username"}),n.jsx(ie,{id:"username",value:d.username,onChange:w=>u({...d,username:w.target.value}),placeholder:"username"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"password",children:"Password"}),n.jsx(ie,{id:"password",type:"password",value:d.password,onChange:w=>u({...d,password:w.target.value}),placeholder:"password"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"connection_mode",children:"Connection Mode"}),n.jsxs(Fe,{value:d.connection_mode,onValueChange:w=>u({...d,connection_mode:w}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"passive",children:"Passive (Recommended)"}),n.jsx(J,{value:"active",children:"Active"})]})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"verify_cert",checked:d.verify_cert,onCheckedChange:w=>u({...d,verify_cert:w})}),n.jsx(z,{htmlFor:"verify_cert",children:"Verify SSL Certificate"})]})]})]});case 2:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-5 w-5"}),"Probe Selection"]}),n.jsx(De,{children:"Select which probe agent will perform the FTPS monitoring"})]}),n.jsx(re,{className:"space-y-4",children:g.length===0?n.jsxs("div",{className:"text-center py-8 border-2 border-dashed border-border rounded-lg",children:[n.jsx(Cn,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),n.jsx("h3",{className:"font-medium text-lg mb-2",children:"No Probe Agents Available"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"You need to configure at least one probe agent with FTPS capabilities first."}),n.jsx(H,{variant:"outline",onClick:t,children:"Configure Probe Agents"})]}):n.jsxs("div",{children:[n.jsx(z,{htmlFor:"probe_agent",children:"Select Probe Agent *"}),n.jsxs(Fe,{value:l.probe_agent_id,onValueChange:w=>c({...l,probe_agent_id:w}),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Choose a probe agent..."})}),n.jsx(Le,{children:g.map(w=>n.jsx(J,{value:w.id,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Cn,{className:"h-4 w-4"}),n.jsx("span",{children:w.name}),w.probe_location&&n.jsxs("span",{className:"text-muted-foreground",children:["(",w.probe_location,")"]})]})},w.id))})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"The probe agent will connect to the FTPS server and perform secure connectivity tests."})]})})]});case 3:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Io,{className:"h-5 w-5"}),"Advanced Settings"]}),n.jsx(De,{children:"Configure monitoring behavior and test settings"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_directory_listing",checked:d.test_directory_listing,onCheckedChange:w=>u({...d,test_directory_listing:w})}),n.jsx(z,{htmlFor:"test_directory_listing",children:"Test Directory Listing"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_file_operations",checked:d.test_file_operations,onCheckedChange:w=>u({...d,test_file_operations:w})}),n.jsx(z,{htmlFor:"test_file_operations",children:"Test File Operations (Upload/Download)"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"test_data_encryption",checked:d.test_data_encryption,onCheckedChange:w=>u({...d,test_data_encryption:w})}),n.jsx(z,{htmlFor:"test_data_encryption",children:"Test Data Channel Encryption"})]})]}),n.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"connect_timeout",children:"Connection Timeout (ms)"}),n.jsx(ie,{id:"connect_timeout",type:"number",value:d.connect_timeout_ms,onChange:w=>u({...d,connect_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"read_timeout",children:"Read Timeout (ms)"}),n.jsx(ie,{id:"read_timeout",type:"number",value:d.read_timeout_ms,onChange:w=>u({...d,read_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tls_timeout",children:"TLS Handshake Timeout (ms)"}),n.jsx(ie,{id:"tls_timeout",type:"number",value:d.tls_handshake_timeout_ms,onChange:w=>u({...d,tls_handshake_timeout_ms:parseInt(w.target.value)||1e4}),min:"1000"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"retries",children:"Retry Attempts"}),n.jsx(ie,{id:"retries",type:"number",value:d.retries,onChange:w=>
756u({...d,retries:parseInt(w.target.value)||3}),min:"1",max:"10"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:d.alert_threshold,onChange:w=>u({...d,alert_threshold:parseInt(w.target.value)||3}),min:"1"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:d.check_interval,onChange:w=>u({...d,check_interval:parseInt(w.target.value)||3600}),min:"3600"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"How often to check (minimum 1 hour / 3600 seconds to avoid overwhelming FTPS servers)"})]})]})]});case 4:return n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Tt,{className:"h-5 w-5"}),"Review & Create"]}),n.jsx(De,{children:"Review your FTPS monitor configuration"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"Monitor Details"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Name:"})," ",l.name]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Description:"})," ",l.description||"None"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Tags:"})," ",l.tags.join(", ")||"None"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"FTPS Configuration"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Server:"})," ",d.hostname,":",d.port]}),n.jsxs("p",{children:[n.jsx("strong",{children:"TLS Mode:"})," ",d.tls_mode==="implicit"?"Implicit (FTPS)":"Explicit (FTPES)"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Authentication:"})," ",d.use_anonymous?"Anonymous":"Username/Password"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Connection Mode:"})," ",d.connection_mode]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Verify Certificate:"})," ",d.verify_cert?"Yes":"No"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Tests:"})," ",[d.test_directory_listing&&"Directory Listing",d.test_file_operations&&"File Operations",d.test_data_encryption&&"Data Encryption"].filter(Boolean).join(", ")||"Connection Only"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Check Interval:"})," ",d.check_interval," seconds"]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-semibold",children:"Probe Agent"}),n.jsxs("p",{children:[n.jsx("strong",{children:"Selected Probe:"})," ",(b==null?void 0:b.name)||"Not selected"]}),(b==null?void 0:b.probe_location)&&n.jsxs("p",{children:[n.jsx("strong",{children:"Location:"})," ",b.probe_location]})]})]})]});default:return null}};return e?n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between mb-6",children:Ax.map((w,N)=>n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full border-2 ${N<=i?"border-primary bg-primary text-primary-foreground":"border-muted-foreground text-muted-foreground"}`,children:n.jsx(w.icon,{className:"h-4 w-4"})}),N<Ax.length-1&&n.jsx("div",{className:`w-12 h-0.5 mx-2 ${N<i?"bg-primary":"bg-muted"}`})]},N))}),_(),n.jsxs("div",{className:"flex justify-between",children:[n.jsxs("div",{className:"flex gap-2",children:[i===0&&n.jsxs(H,{variant:"outline",onClick:r,children:[n.jsx(Ma,{className:"h-4 w-4 mr-2"}),"Back to Monitor Types"]}),i>0&&n.jsx(H,{variant:"outline",onClick:v,children:"Previous"})]}),i<Ax.length-1?n.jsx(H,{onClick:y,disabled:!p(i),children:"Next"}):n.jsx(H,{onClick:j,disabled:m||!l.probe_agent_id,children:a?"Update Monitor":"Create Monitor"})]})]}):null}function jc({open:e,onClose:t,clientId:r,existingAgent:s,preSelectedType:a}){const i=f=>{switch(console.log("Mapping asset type:",f),f){case"website":case"saas":return"http";case"tcp_udp":return"tcp";default:return f}},[o,l]=x.useState(s!=null&&s.asset_type?i(s.asset_type):a||"");x.useEffect(()=>{if(e){const f=s!=null&&s.asset_type?i(s.asset_type):a||"";l(f)}}
756,[e,a,s]),console.log("MonitorWizardSelector props:",{open:e,existingAgent:s?{id:s.id,name:s.name,asset_type:s.asset_type}:null,selectedType:o});const c=o||(s!=null&&s.asset_type?i(s.asset_type):""),d=f=>{l(f)},u=()=>{l("")},h=()=>{if(!o&&!s)return n.jsx("div",{className:"max-w-6xl mx-auto",children:n.jsx(aOe,{selectedType:o,onSelectType:d})});const f={open:!0,onClose:t,onBack:u,clientId:r,existingAgent:s};switch(c){case"http":return n.jsx(oOe,{...f});case"api":return n.jsx(lOe,{...f});case"ssl":return n.jsx(Gq,{...f});case"dns":return n.jsx(cOe,{...f});case"tcp":return n.jsx(R2,{...f});case"ping":return n.jsx(dOe,{...f});case"keyword":return n.jsx(Yq,{...f});case"smtp":return n.jsx($2,{...f});case"ftp":return n.jsx(Qq,{...f});case"sftp":return n.jsx(Xq,{...f});case"ftps":return n.jsx(Zq,{...f});default:return n.jsx("div",{children:"Unknown monitor type"})}};return n.jsx(er,{open:e,onOpenChange:t,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[n.jsx(zr,{children:n.jsx(Br,{children:s?`Edit ${c.toUpperCase()} Monitor`:c?`Setup ${c.toUpperCase()} Monitor`:"Add New Monitor"})}),h()]})})}function uOe(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(null),[s,a]=x.useState(new Set),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=c=>{const d=c.target;!d.closest("[data-monitor-list]")&&!d.closest("[data-monitor-actions]")&&s.size>0&&a(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[s]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"HTTP/HTTPS Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor the availability and performance of your websites and HTTP services"})]}),n.jsx(Oae,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(goe,{clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a})}),n.jsx(sOe,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"http"})]}):n.jsx("div",{className:"space-y-6",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"HTTP/HTTPS Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Please select a client to view HTTP/HTTPS monitors"})]})})}function hOe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["ssl-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","ssl").eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,expiringSoon:0,expired:0,avgDaysUntilExpiry:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const{data:o,error:l}=await B.from("monitors").select("id").in("monitoring_agent_id",a.map(T=>T.id));if(l)throw l;if(!o||o.length===0)return{total:a.length,online:0,offline:0,warning:0,expiringSoon:0,expired:0,avgDaysUntilExpiry:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const c=o.map(T=>T.id),d=new Date,u=new Date(d.getTime()-24*60*60*1e3),h=new Date(d.getTime()-7*24*60*60*1e3),f=new Date(d.getTime()-30*24*60*60*1e3),{data:m,error:g}=await B.from("monitor_checks").select("*").in("monitor_id",c).order("timestamp",{ascending:!1}).limit(c.length*5);if(g)throw g;const{data:p,error:y}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",u.toISOString()),{data:v,error:j}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",h.toISOString()),{data:b,error:_}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",f.toISOString());if(y||j||_)throw y||j||_;const w=new Map;m==null||m.forEach(T=>{(!w.has(T.monitor_id)||new Date(T.timestamp)>new Date(w.get(T.monitor_id).timestamp))&&w.set(T.monitor_id,T)});let N=0,S=0,C=0,P=0,M=0,D=0,A=0;w.forEach(T=>{const k=T.ssl_cert_days_remaining||0;k<=0?(M++,S++):k<7?(P++,S++):k<30?(P++,C++):N++,T.ssl_cert_days_remaining!==null&&(D+=k,A++)});const U=p&&p.length>0?p.filter(T=>T.status==="success").length/p.length*100:100,F=v&&v.length>0?v.filter(T=>T.status==="success").length/v.length*100:100,L=b&&b.length>0?b.filter(T=>T.status==="success").length/b.length*100:100,$=(p==null?void 0:p.filter(T=>T.status==="failed").length)||0,R=A>0?Math.round(D/A):0;return{total:a.length,online:N,offline:S,warning:C,expiringSoon:P,expired:M,avgDaysUntilExpiry:R,uptime24h:Math.round(U*100)/100,uptime7d:Math.round(F*100)/100,uptime30d:Math.round(L*100)/100,recentIncidents:$}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function fOe({clientId:e}){const{stats:t,isLoading:r}=hOe(e);if(r)return n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded-full"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-1"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total SSL Monitors",value:t.total,description:"Active monitors",icon:Wr,color:"text-primary"},{title:"Valid Certificates",value:t.online,description:`${t.total>0?Math.round(t.online/t.total*100):0}
756% of certificates`,icon:zs,color:"text-green-500"},{title:"Expiring Soon",value:t.expiringSoon,description:"Within 30 days",icon:tn,color:t.expiringSoon>0?"text-orange-500":"text-muted-foreground"},{title:"Avg Days Until Expiry",value:`${t.avgDaysUntilExpiry} days`,description:"Across all certificates",icon:fI,color:t.avgDaysUntilExpiry<30?"text-red-500":t.avgDaysUntilExpiry<60?"text-orange-500":"text-green-500"},{title:"Check Uptime (24h)",value:`${t.uptime24h.toFixed(2)}%`,description:`7d: ${t.uptime7d.toFixed(1)}% | 30d: ${t.uptime30d.toFixed(1)}%`,icon:Bi,color:t.uptime24h>=99?"text-green-500":t.uptime24h>=95?"text-orange-500":"text-red-500"},{title:"Expired Certificates",value:t.expired,description:t.expired>0?"Requires immediate attention":"All certificates valid",icon:sa,color:t.expired>0?"text-red-500":"text-muted-foreground"}];return n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>n.jsxs(ee,{className:"hover:bg-accent/50 transition-colors cursor-pointer",children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(a.icon,{className:`h-4 w-4 ${a.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a.description})]})]},a.title))})}function mOe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["ssl-monitor-metrics",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","ssl").eq("status","active");if(i)throw i;if(!a||a.length===0)return[];const o=a.map(g=>g.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",o);if(c)throw c;if(!l||l.length===0)return[];const d=l.map(g=>g.id),u=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:h,error:f}=await B.from("monitor_checks").select("monitor_id, status, ssl_cert_days_remaining, timestamp").in("monitor_id",d).gte("timestamp",u).order("timestamp",{ascending:!1});if(f)throw f;const m=new Map;return l.forEach(g=>{const p=(h==null?void 0:h.filter(w=>w.monitor_id===g.id))||[],y=p.find(w=>w.ssl_cert_days_remaining!==null),v=(y==null?void 0:y.ssl_cert_days_remaining)||null,j=p.filter(w=>w.status==="success").length,b=p.length>0?Math.round(j/p.length*1e4)/100:100,_=p.length>0?p[0].timestamp:null;m.set(g.monitoring_agent_id,{monitorId:g.id,agentId:g.monitoring_agent_id,daysRemaining:v,uptime24h:b,lastCheckTime:_})}),Array.from(m.values())},enabled:!!e,refetchInterval:6e4});return{metrics:t||[],isLoading:r,error:(s==null?void 0:s.message)||null}}function gf({monitoringAgentId:e,agentStatus:t}){const{status:r,isLoading:s}=eU(e),a=()=>t==="suspended"?"bg-muted":t==="active"?s?"bg-muted":r===null?"bg-amber-500":r==="up"?"bg-success":"bg-destructive":"bg-muted",i=()=>t==="suspended"?"Agent suspended":t==="active"?s?"Agent active • Checking monitor status...":r===null?"Agent active • No monitor data":`Agent active • Monitor ${r==="up"?"online":"offline"}`:`Agent ${t}`;return n.jsx(Eu,{children:n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsx("div",{className:`w-3 h-3 rounded-full ${a()} flex-shrink-0`})}),n.jsx(Pi,{children:n.jsx("p",{children:i()})})]})})}function pOe({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const[i,o]=x.useState(null),[l,c]=x.useState(new Set),d=t!==void 0?t:i,u=s!==void 0?s:l,h=Z=>{r?r(Z):o(Z)},f=Z=>{a?a(Z):c(Z)},[m,g]=x.useState(""),[p,y]=x.useState("all"),[v,j]=x.useState("all"),[b,_]=x.useState("all"),[w,N]=x.useState("name-asc"),[S,C]=x.useState(!1),[P,M]=x.useState(1),[D,A]=x.useState(null),[U,F]=x.useState(null),[L,$]=x.useState(!1),{runSingleMonitorCheck:R,isSingleCheckRunning:T}=Ra(),k=5,{agents:W,isLoading:q,toggleAgentStatus:Q,deleteAgent:ue,isDeleting:X}=Lt(e),{metrics:le}=mOe(e),pe=(W==null?void 0:W.filter(Z=>Z.asset_type==="ssl"))||[],ce=x.useMemo(()=>{const Z=new Set;return pe.forEach(je=>{var _e;(_e=je.tags)==null||_e.forEach(Ee=>Z.add(Ee))}),Array.from(Z).sort()},[pe]),se=x.useMemo(()=>pe.filter(Z=>{var je;if(m){const _e=m.toLowerCase(),Ee=Z.name.toLowerCase().includes(_e),Ze=(je=Z.hostname_or_url)==null?void 0:je.toLowerCase().includes(_e);if(!Ee&&!Ze)return!1}if(p!=="all"&&Z.status!==p)return!1;if(v!=="all"){const _e=le.find(Ze=>Ze.agentId===Z.id),Ee=(_e==null?void 0:_e.daysRemaining)??null;if(v==="expired"&&(Ee===null||Ee>0)||v==="expiring-soon"&&(Ee===null||Ee<=0||Ee>30)||v==="valid"&&(Ee===null||Ee<=30))return!1}
756return!(b!=="all"&&(!Z.tags||!Z.tags.includes(b)))}),[pe,m,p,v,b,le]),oe=x.useMemo(()=>{const Z=[...se];return Z.sort((je,_e)=>{var Ee,Ze,st,xt,Dt,xe,qe,St;switch(w){case"name-asc":return je.name.localeCompare(_e.name);case"name-desc":return _e.name.localeCompare(je.name);case"days-remaining-asc":const Pr=le.find(Ct=>Ct.agentId===je.id),wn=le.find(Ct=>Ct.agentId===_e.id);return((Pr==null?void 0:Pr.daysRemaining)??999)-((wn==null?void 0:wn.daysRemaining)??999);case"days-remaining-desc":const An=le.find(Ct=>Ct.agentId===je.id),En=le.find(Ct=>Ct.agentId===_e.id);return((En==null?void 0:En.daysRemaining)??999)-((An==null?void 0:An.daysRemaining)??999);case"uptime-desc":const ls=((Ee=le.find(Ct=>Ct.agentId===je.id))==null?void 0:Ee.uptime24h)??100;return(((Ze=le.find(Ct=>Ct.agentId===_e.id))==null?void 0:Ze.uptime24h)??100)-ls;case"uptime-asc":const ze=((st=le.find(Ct=>Ct.agentId===je.id))==null?void 0:st.uptime24h)??100,xf=((xt=le.find(Ct=>Ct.agentId===_e.id))==null?void 0:xt.uptime24h)??100;return ze-xf;case"last-check-desc":const dt=(Dt=le.find(Ct=>Ct.agentId===je.id))==null?void 0:Dt.lastCheckTime,zt=(xe=le.find(Ct=>Ct.agentId===_e.id))==null?void 0:xe.lastCheckTime;return dt?zt?new Date(zt).getTime()-new Date(dt).getTime():-1:1;case"last-check-asc":const Ft=(qe=le.find(Ct=>Ct.agentId===je.id))==null?void 0:qe.lastCheckTime,ds=(St=le.find(Ct=>Ct.agentId===_e.id))==null?void 0:St.lastCheckTime;return Ft?ds?new Date(Ft).getTime()-new Date(ds).getTime():-1:1;default:return 0}}),Z},[se,w,le]),V=Math.ceil(oe.length/k),fe=(P-1)*k,ne=fe+k,Ce=oe.slice(fe,ne);x.useEffect(()=>{M(1)},[m,p,v,b,w]),x.useEffect(()=>{P>V&&V>0&&M(V)},[P,V]);const Pe=p!=="all"||v!=="all"||b!=="all",he=()=>{g(""),y("all"),j("all"),_("all")};x.useEffect(()=>{const Z=je=>{const _e=je.target,Ee=_e.closest("[data-monitor-list]"),Ze=_e.closest("[data-monitor-actions]");!Ee&&!Ze&&f(new Set)};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[]);const ke=Z=>{h(Z),Me(Z)},Me=Z=>{const je=new Set(u);je.has(Z)?je.delete(Z):je.add(Z),f(je)},Je=()=>{if(u.size===Ce.length&&Ce.every(Z=>u.has(Z.id))){const Z=new Set(u);Ce.forEach(je=>Z.delete(je.id)),f(Z)}else{const Z=new Set(u);Ce.forEach(je=>Z.add(je.id)),f(Z)}},Ke=()=>{let Z=0;for(const je of Array.from(u)){const _e=pe.find(Ee=>Ee.id===je);(_e==null?void 0:_e.status)==="active"&&(Q(_e),Z++)}Z>0&&ye.success(`Pausing ${Z} monitor(s)`)},E=()=>{let Z=0;for(const je of Array.from(u)){const _e=pe.find(Ee=>Ee.id===je);(_e==null?void 0:_e.status)==="suspended"&&(Q(_e),Z++)}Z>0&&ye.success(`Resuming ${Z} monitor(s)`)},O=()=>{const Z=pe.filter(Ee=>u.has(Ee.id)),je=Z.filter(Ee=>Ee.status==="active").length,_e=Z.filter(Ee=>Ee.status==="suspended").length;je>=_e?Ke():(E(),f(new Set))},I=x.useMemo(()=>{const Z=pe.filter(Ee=>u.has(Ee.id)),je=Z.filter(Ee=>Ee.status==="active").length,_e=Z.filter(Ee=>Ee.status==="suspended").length;return je>=_e},[pe,u]),Y=async()=>{const Z=Array.from(u);for(const je of Z)await ue(je);f(new Set),$(!1)},te=Z=>Z===null?"text-muted-foreground":Z<=0?"text-red-500":Z<7?"text-orange-500":Z<30?"text-yellow-600":"text-green-500",K=Z=>Z===null?null:Z<=0?n.jsx(ve,{variant:"destructive",children:"Expired"}):Z<7?n.jsxs(ve,{variant:"destructive",children:[Z,"d"]}):Z<30?n.jsxs(ve,{className:"bg-orange-500",children:[Z,"d"]}):n.jsxs(ve,{variant:"outline",children:[Z,"d"]});return q?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((Z,je)=>n.jsx(tt,{className:"h-16 w-full"},je))})})]}):n.jsxs("div",{"data-monitor-list":!0,children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[u.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:O,disabled:u.size===0,children:I?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:Y,disabled:u.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[n.jsxs(me,{children:["SSL Certificate Monitors",oe.length>0&&n.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-2",children:["Showing ",fe+1,"-",Math.min(ne,oe.length)," of ",oe.length]})]}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 w-full sm:w-auto",children:[n.jsxs("div",{className:"relative flex-1 sm:flex-initial",children:[n.jsx(qt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search by name or hostname...",value:m,onChange:Z=>g(Z.target.value),className:"pl-8 w-full sm:w-[250px]"})]}),n.jsxs(H,{variant:Pe?"default":"outline",size:"default",onClick:()=>C(!S),className:"w-full sm:w-auto",children:[n.jsx(Ui,{className:"h-4 w-4 mr-2"}),"Filters",Pe&&n.jsx(ve,{variant:"secondary",className:"ml-2",children:[p!=="all",v!=="all",b!=="all"].filter(
756Boolean).length})]})]})]})]})}),n.jsx(re,{children:n.jsxs("div",{className:"space-y-4",children:[n.jsx(ur,{open:S,children:n.jsxs(Er,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 p-4 border rounded-lg bg-muted/50",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Status"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Status"}),n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"suspended",children:"Suspended"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Certificate Status"}),n.jsxs(Fe,{value:v,onValueChange:j,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Certificates"}),n.jsx(J,{value:"valid",children:"Valid (> 30 days)"}),n.jsx(J,{value:"expiring-soon",children:"Expiring Soon (< 30 days)"}),n.jsx(J,{value:"expired",children:"Expired"})]})]})]}),ce.length>0&&n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Tags"}),n.jsxs(Fe,{value:b,onValueChange:_,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),ce.map(Z=>n.jsx(J,{value:Z,children:Z},Z))]})]})]}),n.jsx("div",{className:"flex items-end",children:Pe&&n.jsxs(H,{variant:"ghost",size:"sm",onClick:he,className:"w-full",children:[n.jsx(vn,{className:"h-4 w-4 mr-2"}),"Clear Filters"]})})]}),n.jsxs("div",{className:"flex items-center gap-2 px-4",children:[n.jsx(ns,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("label",{className:"text-sm font-medium",children:"Sort by:"}),n.jsxs(Fe,{value:w,onValueChange:N,children:[n.jsx(Ie,{className:"w-[200px]",children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"name-asc",children:"Name (A-Z)"}),n.jsx(J,{value:"name-desc",children:"Name (Z-A)"}),n.jsx(J,{value:"days-remaining-asc",children:"Days Remaining (Least)"}),n.jsx(J,{value:"days-remaining-desc",children:"Days Remaining (Most)"}),n.jsx(J,{value:"uptime-desc",children:"Uptime (Highest)"}),n.jsx(J,{value:"uptime-asc",children:"Uptime (Lowest)"}),n.jsx(J,{value:"last-check-desc",children:"Last Check (Newest)"}),n.jsx(J,{value:"last-check-asc",children:"Last Check (Oldest)"})]})]})]})]})}),n.jsx("div",{className:"rounded-md border",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:Ce.length>0&&Ce.every(Z=>u.has(Z.id)),onCheckedChange:Je})}),n.jsx(Se,{className:"w-12",children:"Status"}),n.jsx(Se,{children:"Monitor"}),n.jsx(Se,{children:"Certificate"}),n.jsx(Se,{children:"Days Remaining"}),n.jsx(Se,{children:"Uptime (24h)"}),n.jsx(Se,{className:"hidden lg:table-cell",children:"History"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:Ce.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:9,className:"text-center text-muted-foreground py-8",children:Pe?"No monitors match your filters":"No SSL monitors found"})}):Ce.map(Z=>{const je=le.find(st=>st.agentId===Z.id),_e=u.has(Z.id),Ee=d===Z.id,Ze=(je==null?void 0:je.daysRemaining)??null;return n.jsxs(gt,{className:`cursor-pointer hover:bg-muted/50 ${_e?"bg-muted/30":""} ${Ee?"border-l-4 border-l-primary":""}`,onClick:()=>ke(Z.id),children:[n.jsx(be,{onClick:st=>st.stopPropagation(),children:n.jsx(ct,{checked:_e,onCheckedChange:()=>Me(Z.id)})}),n.jsx(be,{children:n.jsx(gf,{monitoringAgentId:Z.id,agentStatus:Z.status})}),n.jsx(be,{children:n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:Z.name}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:[Z.hostname_or_url,":",Z.port||443]}),Z.tags&&Z.tags.length>0&&n.jsx("div",{className:"flex gap-1 mt-1",children:Z.tags.map(st=>n.jsx(ve,{variant:"outline",className:"text-xs",children:st},st))})]})}),n.jsx(be,{children:K(Ze)}),n.jsx(be,{className:te(Ze),children:n.jsx("span",{className:"font-medium",children:Ze!==null?`${Ze} days`:"N/A"})}),n.jsx(be,{children:je?`${je.uptime24h.toFixed(2)}%`:"N/A"}),n.jsx(be,{className:"hidden lg:table-cell",children:n.jsx(Ki,{monitoringAgentId:Z.id,createdAt:Z.created_at})}),n.jsx(be,{className:"text-sm text-muted-foreground",children:je!=null&&je.lastCheckTime?is(new Date(je.lastCheckTime),{addSuffix:!0}):"Never"}),n.jsx(be,{className:"text-right",onClick:st=>st.stopPropagation(),children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{R(Z.id),ye.info("Testing SSL monitor...")},disabled:T,title:"Test Monitor",children:n.jsx(sr,{className:`h-4 w-4 ${T?"animate-spin":""}`})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>F(Z),title:"Edit",children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>A(Z),className:"text-destructive hover:text-destructive",title:"Delete",children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]}
756,Z.id)})})]})}),oe.length>0&&n.jsx("div",{className:"mt-6",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>M(Z=>Math.max(1,Z-1)),className:P===1?"pointer-events-none opacity-50":"cursor-pointer"})}),n.jsx(wt,{children:n.jsx(ss,{onClick:()=>M(1),isActive:P===1,className:"cursor-pointer",children:"1"})}),P>3&&V>4&&n.jsx(wt,{children:n.jsx(qo,{})}),Array.from({length:V},(Z,je)=>je+1).filter(Z=>Z===1||Z===V?!1:Math.abs(Z-P)<=1).map(Z=>n.jsx(wt,{children:n.jsx(ss,{onClick:()=>M(Z),isActive:P===Z,className:"cursor-pointer",children:Z})},Z)),P<V-2&&V>4&&n.jsx(wt,{children:n.jsx(qo,{})}),V>1&&n.jsx(wt,{children:n.jsx(ss,{onClick:()=>M(V),isActive:P===V,className:"cursor-pointer",children:V})}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>M(Z=>Math.min(V,Z+1)),className:P===V?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})})]}),U&&n.jsx(er,{open:!!U,onOpenChange:Z=>!Z&&F(null),children:n.jsx(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:n.jsx(Gq,{open:!!U,onClose:()=>F(null),onBack:()=>F(null),clientId:e,existingAgent:U})})}),D&&n.jsx(Gi,{monitor:D,open:!!D,onOpenChange:Z=>!Z&&A(null)}),n.jsx(jg,{open:L,onOpenChange:$,count:u.size,onConfirm:Y})]})}const nD=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))"];function gOe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{agents:i}=Lt(e),o=(i==null?void 0:i.filter(g=>g.asset_type==="ssl"))||[],l=x.useMemo(()=>t?o.find(g=>g.id===t):o[0],[o,t]),{checks:c,isLoading:d}=mc(l==null?void 0:l.id,50),u=x.useMemo(()=>!c||c.length===0?[]:c.filter(g=>g.ssl_cert_days_remaining!==null).slice(0,20).reverse().map(g=>({time:new Date(g.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),daysRemaining:g.ssl_cert_days_remaining})),[c]),h=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length&&p.length<10;v+=g){const j=y.slice(v,v+g),b=j.filter(S=>S.status==="success").length,_=j.filter(S=>S.status==="failed"||S.status==="error").length,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,success:b,failed:_})}return p},[c]),f=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length;v+=g){const j=y.slice(v,v+g),_=j.filter(S=>S.status==="success").length/j.length*100,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,uptime:parseFloat(_.toFixed(2))})}return p},[c]),m=()=>{l&&a.invalidateQueries({queryKey:["monitor-checks",l.id]})};return!l||!c||c.length===0?null:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"Certificate Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:l.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:m,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"expiry",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsx(at,{value:"expiry",children:"Certificate Expiry"}),n.jsx(at,{value:"check-status",children:"Check Status"}),n.jsx(at,{value:"uptime",children:"Uptime"})]}),n.jsx(it,{value:"expiry",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:u,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Days Remaining",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"daysRemaining",stroke:nD[0],strokeWidth:2,dot:{fill:nD[0]},name:"Days Remaining"})]})})}),n.jsxs(it,{value:"check-status",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"SSL check 
756status over time (grouped by 5 checks)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:h,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Check Count",angle:-90,position:"insideLeft"},allowDecimals:!1}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"success",stroke:"hsl(var(--green))",strokeWidth:2,dot:{fill:"hsl(var(--green))"},name:"Successful Checks"}),n.jsx(Qt,{type:"monotone",dataKey:"failed",stroke:"hsl(var(--destructive))",strokeWidth:2,dot:{fill:"hsl(var(--destructive))"},name:"Failed Checks"})]})})]}),n.jsxs(it,{value:"uptime",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Check success rate trend based on last 50 checks (grouped)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:f,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Uptime (%)",angle:-90,position:"insideLeft"},domain:[0,100]}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:g=>`${g}%`}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"},name:"Uptime"})]})})]})]})})]})}function xOe(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(null),[s,a]=x.useState(new Set),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=c=>{const d=c.target,u=d.closest("[data-monitor-list]"),h=d.closest("[data-monitor-actions]");!u&&!h&&a(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"SSL Certificate Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor SSL certificate expiration and validity"})]}),n.jsx(fOe,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(pOe,{clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a})}),n.jsx(gOe,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"ssl"})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"SSL Certificate Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor SSL certificate expiration and validity"})]}),n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Please select a client to view SSL monitors"})]})}function vOe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["dns-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("id, name, status, created_at, monitoring_config").eq("client_id",e).eq("asset_type","dns").eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,baselineMatches:0,baselineMismatches:0,uptime24h:0,uptime7d:0,uptime30d:0,recentIncidents:0,mostCommonRecordType:"N/A",recordTypeDistribution:{}};const o=a.map(L=>L.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id, name").in("monitoring_agent_id",o).eq("status","active");if(c)throw c;const d=(l==null?void 0:l.map(L=>L.id))||[],u=new Date,h=new Date(u.getTime()-24*60*60*1e3),f=new Date(u.getTime()-7*24*60*60*1e3),m=new Date(u.getTime()-30*24*60*60*1e3),{data:g}=await B.from("monitor_checks").select("monitor_id, status, timestamp, error_message").in("monitor_id",d).gte("timestamp",h.toISOString()).order("timestamp",{ascending:!1}),{data:p}=await B.from("monitor_checks").select("monitor_id, status, timestamp").in("monitor_id",d).gte("timestamp",f.toISOString()),{data:y}=await B.from("monitor_checks").select("monitor_id, status, timestamp").in("monitor_id",d).gte("timestamp",m.toISOString()),v={};a.forEach(L=>{const $=L.monitoring_config,R=($==null?void 0:$.dns_record_type)||"A";v[R]=(v[R]||0)+1});let j="A",b=0;Object.entries(v).forEach(([L,$])=>{$>b&&(b=$,j=L)});let _=0,w=0,N=0,S=0,C=0;a.forEach(L=>{var k;const $=(l==null?void 0:l.filter(W=>W.monitoring_agent_id===L.id))||[];if($.length===0)return;const R=$[0].id,T=g==null?void 0:g.find(W=>W.monitor_id===R);if(!T){N++;return}T.status==="success"?(_++,S++):T.status==="failure"?(k=T.error_message)!=null&&k.includes("baseline")?(C++,N++):w++:N++});const P=L=>!L||L.length===0?0:L.filter(R=>R.status==="success").length/L.length*100,M=P(g||[]),D=P(p||[]),A=P(y||[]),U=(g==null?void 0:g.filter(L=>L.status==="failure").length)||0;return{total:a.length,online:_,offline:w,warning:N,baselineMatches:S,baselineMismatches:C,uptime24h:M,uptime7d:D,uptime30d:A,recentIncidents:U,mostCommonRecordType:j,recordTypeDistribution:v}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:s}}function yOe({clientId:e}){const{stats:t,isLoading:r}=vOe(e);return r?n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((s,a)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4"})]}),n.jsx(re,{children:n.jsx(tt,{className:"h-8 w-16"})})]},a))}):t?n.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Total DNS Monitors"}),n.jsx(Wr,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:t.total}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.online," online, ",t.offline," offline"]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Baseline Matches"}),n.jsx(zs,{className:"h-4 w-4 text-green-500"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:t.baselineMatches}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Records matching baseline"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Baseline Mismatches"}),n.jsx(tn,{className:"h-4 w-4 text-orange-500"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:t.baselineMismatches}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Records not matching baseline"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Check Uptime (24h)"}),n.jsx(Bi,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsxs("div",{className:"text-2xl font-bold",children:[t.uptime24h.toFixed(2),"%"]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["7d: ",t.uptime7d.toFixed(2),"% | 30d: ",t.uptime30d.toFixed(2),"%"]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Most Common Record Type"}),n.jsx(ht,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:t.mostCommonRecordType}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[Object.keys(t.recordTypeDistribution).length," types monitored"]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Recent Incidents"}),n.jsx(sa,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:t.recentIncidents}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Failed checks in last 24h"})]})]})]}):null}var hS=["Enter"," "],jOe=["ArrowDown","PageUp","Home"],Jq=["ArrowUp","PageDown","End"],bOe=[...jOe,...Jq],wOe={ltr:[...hS,"ArrowRight"],rtl:[...hS,"ArrowLeft"]},_Oe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Eg="Menu",[qp,NOe,SOe]=eg(Eg),[Ld,Xj]=Qr(Eg,[SOe,tf,Jh]),Zj=tf(),e8=Jh(),[COe,Fd]=Ld(Eg),[kOe,Og]=Ld(Eg),t8=e=>{const{__scopeMenu:t,open:r=!1,children:s,dir:a,onOpenChange:i,modal:o=!0}
vendor: 16,241 bytes, line 756
756=e,l=Zj(t),[c,d]=x.useState(null),u=x.useRef(!1),h=Sr(i),f=Md(a);return x.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",g,{capture:!0,once:!0}),document.addEventListener("pointermove",g,{capture:!0,once:!0})},g=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",g,{capture:!0}),document.removeEventListener("pointermove",g,{capture:!0})}},[]),n.jsx(JC,{...l,children:n.jsx(COe,{scope:t,open:r,onOpenChange:h,content:c,onContentChange:d,children:n.jsx(kOe,{scope:t,onClose:x.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:u,dir:f,modal:o,children:s})})})};t8.displayName=Eg;var POe="MenuAnchor",I2=x.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e,a=Zj(r);return n.jsx(Q0,{...a,...s,ref:t})});I2.displayName=POe;var L2="MenuPortal",[TOe,r8]=Ld(L2,{forceMount:void 0}),n8=e=>{const{__scopeMenu:t,forceMount:r,children:s,container:a}=e,i=Fd(L2,t);return n.jsx(TOe,{scope:t,forceMount:r,children:n.jsx(jn,{present:r||i.open,children:n.jsx(Uh,{asChild:!0,container:a,children:s})})})};n8.displayName=L2;var Pa="MenuContent",[AOe,F2]=Ld(Pa),s8=x.forwardRef((e,t)=>{const r=r8(Pa,e.__scopeMenu),{forceMount:s=r.forceMount,...a}=e,i=Fd(Pa,e.__scopeMenu),o=Og(Pa,e.__scopeMenu);return n.jsx(qp.Provider,{scope:e.__scopeMenu,children:n.jsx(jn,{present:s||i.open,children:n.jsx(qp.Slot,{scope:e.__scopeMenu,children:o.modal?n.jsx(EOe,{...a,ref:t}):n.jsx(OOe,{...a,ref:t})})})})}),EOe=x.forwardRef((e,t)=>{const r=Fd(Pa,e.__scopeMenu),s=x.useRef(null),a=nt(t,s);return x.useEffect(()=>{const i=s.current;if(i)return V0(i)},[]),n.jsx(U2,{...e,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Te(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),OOe=x.forwardRef((e,t)=>{const r=Fd(Pa,e.__scopeMenu);return n.jsx(U2,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),MOe=Jl("MenuContent.ScrollLock"),U2=x.forwardRef((e,t)=>{const{__scopeMenu:r,loop:s=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:l,onEntryFocus:c,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:m,disableOutsideScroll:g,...p}=e,y=Fd(Pa,r),v=Og(Pa,r),j=Zj(r),b=e8(r),_=NOe(r),[w,N]=x.useState(null),S=x.useRef(null),C=nt(t,S,y.onContentChange),P=x.useRef(0),M=x.useRef(""),D=x.useRef(0),A=x.useRef(null),U=x.useRef("right"),F=x.useRef(0),L=g?hg:x.Fragment,$=g?{as:MOe,allowPinchZoom:!0}:void 0,R=k=>{var ce,se;const W=M.current+k,q=_().filter(oe=>!oe.disabled),Q=document.activeElement,ue=(ce=q.find(oe=>oe.ref.current===Q))==null?void 0:ce.textValue,X=q.map(oe=>oe.textValue),le=HOe(X,W,ue),pe=(se=q.find(oe=>oe.textValue===le))==null?void 0:se.ref.current;(function oe(V){M.current=V,window.clearTimeout(P.current),V!==""&&(P.current=window.setTimeout(()=>oe(""),1e3))})(W),pe&&setTimeout(()=>pe.focus())};x.useEffect(()=>()=>window.clearTimeout(P.current),[]),W0();const T=x.useCallback(k=>{var q,Q;return U.current===((q=A.current)==null?void 0:q.side)&&KOe(k,(Q=A.current)==null?void 0:Q.area)},[]);return n.jsx(AOe,{scope:r,searchRef:M,onItemEnter:x.useCallback(k=>{T(k)&&k.preventDefault()},[T]),onItemLeave:x.useCallback(k=>{var W;T(k)||((W=S.current)==null||W.focus(),N(null))},[T]),onTriggerLeave:x.useCallback(k=>{T(k)&&k.preventDefault()},[T]),pointerGraceTimerRef:D,onPointerGraceIntentChange:x.useCallback(k=>{A.current=k},[]),children:n.jsx(L,{...$,children:n.jsx(ug,{asChild:!0,trapped:a,onMountAutoFocus:Te(i,k=>{var W;k.preventDefault(),(W=S.current)==null||W.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:n.jsx(Fh,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:d,onPointerDownOutside:u,onFocusOutside:h,onInteractOutside:f,onDismiss:m,children:n.jsx(BC,{asChild:!0,...b,dir:v.dir,orientation:"vertical",loop:s,currentTabStopId:w,onCurrentTabStopIdChange:N,onEntryFocus:Te(c,k=>{v.isUsingKeyboardRef.current||k.preventDefault()}),preventScrollOnEntryFocus:!0,children:n.jsx(ek,{role:"menu","aria-orientation":"vertical","data-state":j8(y.open),"data-radix-menu-content":"",dir:v.dir,...j,...p,ref:C,style:{outline:"none",...p.style},onKeyDown:Te(p.onKeyDown,k=>{const q=k.target.closest("[data-radix-menu-content]")===k.currentTarget,Q=k.ctrlKey||k.altKey||k.metaKey,ue=k.key.length===1;q&&(k.key==="Tab"&&k.preventDefault(),!Q&&ue&&R(k.key));const X=S.current;if(k.target!==X||!bOe.includes(k.key))return;k.preventDefault();const pe=_().filter(ce=>!ce.disabled).map(ce=>ce.ref.current);Jq.includes(k.key)&&pe.reverse(),qOe(pe)}),onBlur:Te(e.onBlur,k=>{k.currentTarget.contains(k.target)||(window.clearTimeout(P.current),M.current="")}),onPointerMove:Te(e.onPointerMove,Wp(k=>{const W=k.target,q=F.current!==k.clientX;if(k.currentTarget.contains(W)&&q){const Q=k.clientX>F.current?"right":"left";U.current=Q,F.current=k.clientX}}))})})})})})})});s8.displayName=Pa;var DOe="MenuGroup",z2=x.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e;return n.jsx(We.div,{role:"group",...s,ref:t})});z2.displayName=DOe;var ROe="MenuLabel",a8=x.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e;return n.jsx(We.div,{...s,ref:t})});a8.displayName=ROe;var t0="MenuItem",sD="menu.itemSelect",Jj=x.forwardRef((e,t)=>{const{disabled:r=!1,onSelect:s,...a}=e,i=x.useRef(null),o=Og(t0,e.__scopeMenu),l=F2(t0,e.__scopeMenu),c=nt(t,i),d=x.useRef(!1),u=()=>{const h=i.current;if(!r&&h){const f=new CustomEvent(sD,{bubbles:!0,cancelable:!0});h.addEventListener(sD,m=>s==null?void 0:s(m),{once:!0}),j0(h,f),f.defaultPrevented?d.current=!1:o.onClose()}};return n.jsx(i8,{...a,ref:c,disabled:r,onClick:Te(e.onClick,u),onPointerDown:h=>{var f;(f=e.onPointerDown)==null||f.call(e,h),d.current=!0},onPointerUp:Te(e.onPointerUp,h=>{var f;d.current||(f=h.currentTarget)==null||f.click()}),onKeyDown:Te(e.onKeyDown,h=>{const f=l.searchRef.current!=="";r||f&&h.key===" "||hS.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});Jj.displayName=t0;var i8=x.forwardRef((e,t)=>{const{__scopeMenu:r,disabled:s=!1,textValue:a,...i}=e,o=F2(t0,r),l=e8(r),c=x.useRef(null),d=nt(t,c),[u,h]=x.useState(!1),[f,m]=x.useState("");return x.useEffect(()=>{const g=c.current;g&&m((g.textContent??"").trim())},[i.children]),n.jsx(qp.ItemSlot,{scope:r,disabled:s,textValue:a??f,children:n.jsx(qC,{asChild:!0,...l,focusable:!s,children:n.jsx(We.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":s||void 0,"data-disabled":s?"":void 0,...i,ref:d,onPointerMove:Te(e.onPointerMove,Wp(g=>{s?o.onItemLeave(g):(o.onItemEnter(g),g.defaultPrevented||g.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Te(e.onPointerLeave,Wp(g=>o.onItemLeave(g))),onFocus:Te(e.onFocus,()=>h(!0)),onBlur:Te(e.onBlur,()=>h(!1))})})})}),$Oe="MenuCheckboxItem",o8=x.forwardRef((e,t)=>{const{checked:r=!1,onCheckedChange:s,...a}=e;return n.jsx(h8,{scope:e.__scopeMenu,checked:r,children:n.jsx(Jj,{role:"menuitemcheckbox","aria-checked":r0(r)?"mixed":r,...a,ref:t,"data-state":q2(r),onSelect:Te(a.onSelect,()=>s==null?void 0:s(r0(r)?!0:!r),{checkForDefaultPrevented:!1})})})});o8.displayName=$Oe;var l8="MenuRadioGroup",[IOe,LOe]=Ld(l8,{value:void 0,onValueChange:()=>{}}),c8=x.forwardRef((e,t)=>{const{value:r,onValueChange:s,...a}=e,i=Sr(s);return n.jsx(IOe,{scope:e.__scopeMenu,value:r,onValueChange:i,children:n.jsx(z2,{...a,ref:t})})});c8.displayName=l8;var d8="MenuRadioItem",u8=x.forwardRef((e,t)=>{const{value:r,...s}=e,a=LOe(d8,e.__scopeMenu),i=r===a.value;return n.jsx(h8,{scope:e.__scopeMenu,checked:i,children:n.jsx(Jj,{role:"menuitemradio","aria-checked":i,...s,ref:t,"data-state":q2(i),onSelect:Te(s.onSelect,()=>{var o;return(o=a.onValueChange)==null?void 0:o.call(a,r)},{checkForDefaultPrevented:!1})})})});u8.displayName=d8;var B2="MenuItemIndicator",[h8,FOe]=Ld(B2,{checked:!1}),f8=x.forwardRef((e,t)=>{const{__scopeMenu:r,forceMount:s,...a}=e,i=FOe(B2,r);return n.jsx(jn,{present:s||r0(i.checked)||i.checked===!0,children:n.jsx(We.span,{...a,ref:t,"data-state":q2(i.checked)})})});f8.displayName=B2;var UOe="MenuSeparator",m8=x.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e;return n.jsx(We.div,{role:"separator","aria-orientation":"horizontal",...s,ref:t})});m8.displayName=UOe;var zOe="MenuArrow",p8=x.forwardRef((e,t)=>{const{__scopeMenu:r,...s}=e,a=Zj(r);return n.jsx(tk,{...a,...s,ref:t})});p8.displayName=zOe;var BOe="MenuSub",[pRe,g8]=Ld(BOe),im="MenuSubTrigger",x8=x.forwardRef((e,t)=>{const r=Fd(im,e.__scopeMenu),s=Og(im,e.__scopeMenu),a=g8(im,e.__scopeMenu),i=F2(im,e.__scopeMenu),o=x.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:c}=i,d={__scopeMenu:e.__scopeMenu},u=x.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return x.useEffect(()=>u,[u]),x.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),c(null)}},[l,c]),n.jsx(I2,{asChild:!0,...d,children:n.jsx(i8,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":j8(r.open),...e,ref:y0(t,a.onTriggerChange),onClick:h=>{var f;(f=e.onClick)==null||f.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:Te(e.onPointerMove,Wp(h=>{i.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!r.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{r.onOpenChange(!0),u()},100))})),onPointerLeave:Te(e.onPointerLeave,Wp(h=>{var m,g;u();const f=(m=r.content)==null?void 0:m.getBoundingClientRect();if(f){const p=(g=r.content)==null?void 0:g.dataset.side,y=p==="right",v=y?-5:5,j=f[y?"left":"right"],b=f[y?"right":"left"];i.onPointerGraceIntentChange({area:[{x:h.clientX+v,y:h.clientY},{x:j,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:j,y:f.bottom}],side:p}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(h),h.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Te(e.onKeyDown,h=>{var m;const f=i.searchRef.current!=="";e.disabled||f&&h.key===" "||wOe[s.dir].includes(h.key)&&(r.onOpenChange(!0),(m=r.content)==null||m.focus(),h.preventDefault())})})})});x8.displayName=im;var v8="MenuSubContent",y8=x.forwardRef((e,t)=>{const r=r8(Pa,e.__scopeMenu),{forceMount:s=r.forceMount,...a}=e,i=Fd(Pa,e.__scopeMenu),o=Og(Pa,e.__scopeMenu),l=g8(v8,e.__scopeMenu),c=x.useRef(null),d=nt(t,c);return n.jsx(qp.Provider,{scope:e.__scopeMenu,children:n.jsx(jn,{present:s||i.open,children:n.jsx(qp.Slot,{scope:e.__scopeMenu,children:n.jsx(U2,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:d,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var h;o.isUsingKeyboardRef.current&&((h=c.current)==null||h.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Te(e.onFocusOutside,u=>{u.target!==l.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Te(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Te(e.onKeyDown,u=>{var m;const h=u.currentTarget.contains(u.target),f=_Oe[o.dir].includes(u.key);h&&f&&(i.onOpenChange(!1),(m=l.trigger)==null||m.focus(),u.preventDefault())})})})})})});y8.displayName=v8;function j8(e){return e?"open":"closed"}function r0(e){return e==="indeterminate"}function q2(e){return r0(e)?"indeterminate":e?"checked":"unchecked"}function qOe(e){const t=document.activeElement;for(const r of e)if(r===t||(r.focus(),document.activeElement!==t))return}function WOe(e,t){return e.map((r,s)=>e[(t+s)%e.length])}function HOe(e,t,r){const a=t.length>1&&Array.from(t).every(d=>d===t[0])?t[0]:t,i=r?e.indexOf(r):-1;let o=WOe(e,Math.max(i,0));a.length===1&&(o=o.filter(d=>d!==r));const c=o.find(d=>d.toLowerCase().startsWith(a.toLowerCase()));return c!==r?c:void 0}function VOe(e,t){const{x:r,y:s}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const l=t[i],c=t[o],d=l.x,u=l.y,h=c.x,f=c.y;u>s!=f>s&&r<(h-d)*(s-u)/(f-u)+d&&(a=!a)}return a}function KOe(e,t){if(!t)return!1;const r={x:e.clientX,y:e.clientY};return VOe(r,t)}function Wp(e){return t=>t.pointerType==="mouse"?e(t):void 0}var b8=t8,w8=I2,_8=n8,N8=s8,S8=z2,C8=a8,k8=Jj,P8=o8,T8=c8,A8=u8,E8=f8,O8=m8,M8=p8,D8=x8,R8=y8,eb="DropdownMenu",[GOe,gRe]=Qr(eb,[Xj]),Cs=Xj(),[YOe,$8]=GOe(eb),I8=e=>{const{__scopeDropdownMenu:t,children:r,dir:s,open:a,defaultOpen:i,onOpenChange:o,modal:l=!0}=e,c=Cs(t),d=x.useRef(null),[u,h]=Bs({prop:a,defaultProp:i??!1,onChange:o,caller:eb});return n.jsx(YOe,{scope:t,triggerId:ta(),triggerRef:d,contentId:ta(),open:u,onOpenChange:h,onOpenToggle:x.useCallback(()=>h(f=>!f),[h]),modal:l,children:n.jsx(b8,{...c,open:u,onOpenChange:h,dir:s,modal:l,children:r})})};I8.displayName=eb;var L8="DropdownMenuTrigger",F8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,disabled:s=!1,...a}=e,i=$8(L8,r),o=Cs(r);return n.jsx(w8,{asChild:!0,...o,children:n.jsx(We.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":s?"":void 0,disabled:s,...a,ref:y0(t,i.triggerRef),onPointerDown:Te(e.onPointerDown,l=>{!s&&l.button===0&&l.ctrlKey===!1&&(i.onOpenToggle(),i.open||l.preventDefault())}),onKeyDown:Te(e.onKeyDown,l=>{s||(["Enter"," "].includes(l.key)&&i.onOpenToggle(),l.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});F8.displayName=L8;var QOe="DropdownMenuPortal",U8=e=>{const{__scopeDropdownMenu:t,...r}=e,s=Cs(t);return n.jsx(_8,{...s,...r})};U8.displayName=QOe;var z8="DropdownMenuContent",B8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=$8(z8,r),i=Cs(r),o=x.useRef(!1);return n.jsx(N8,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...s,ref:t,onCloseAutoFocus:Te(e.onCloseAutoFocus,l=>{var c;o.current||(c=a.triggerRef.current)==null||c.focus(),o.current=!1,l.preventDefault()}),onInteractOutside:Te(e.onInteractOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,u=c.button===2||d;(!a.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});B8.displayName=z8;var XOe="DropdownMenuGroup",ZOe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(S8,{...a,...s,ref:t})});ZOe.displayName=XOe;var JOe="DropdownMenuLabel",q8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(C8,{...a,...s,ref:t})});q8.displayName=JOe;var eMe="DropdownMenuItem",W8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(k8,{...a,...s,ref:t})});W8.displayName=eMe;var tMe="DropdownMenuCheckboxItem",H8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(P8,{...a,...s,ref:t})});H8.displayName=tMe;var rMe="DropdownMenuRadioGroup",nMe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(T8,{...a,...s,ref:t})});nMe.displayName=rMe;var sMe="DropdownMenuRadioItem",V8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(A8,{...a,...s,ref:t})});V8.displayName=sMe;var aMe="DropdownMenuItemIndicator",K8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(E8,{...a,...s,ref:t})});K8.displayName=aMe;var iMe="DropdownMenuSeparator",G8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(O8,{...a,...s,ref:t})});G8.displayName=iMe;var oMe="DropdownMenuArrow",lMe=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(M8,{...a,...s,ref:t})});lMe.displayName=oMe;var cMe="DropdownMenuSubTrigger",Y8=x.forwardRef((e,t)=>{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(D8,{...a,...s,ref:t})});Y8.displayName=cMe;var dMe="DropdownMenuSubContent",Q8=x.forwardRef((e,t)=>
756{const{__scopeDropdownMenu:r,...s}=e,a=Cs(r);return n.jsx(R8,{...a,...s,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Q8.displayName=dMe;var uMe=I8,hMe=F8,fMe=U8,X8=B8,Z8=q8,J8=W8,e9=H8,t9=V8,r9=K8,n9=G8,s9=Y8,a9=Q8;const W2=uMe,H2=hMe,mMe=x.forwardRef(({className:e,inset:t,children:r,...s},a)=>n.jsxs(s9,{ref:a,className:we("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...s,children:[r,n.jsx(Yo,{className:"ml-auto h-4 w-4"})]}));mMe.displayName=s9.displayName;const pMe=x.forwardRef(({className:e,...t},r)=>n.jsx(a9,{ref:r,className:we("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));pMe.displayName=a9.displayName;const tb=x.forwardRef(({className:e,sideOffset:t=4,...r},s)=>n.jsx(fMe,{children:n.jsx(X8,{ref:s,sideOffset:t,className:we("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r})}));tb.displayName=X8.displayName;const Ao=x.forwardRef(({className:e,inset:t,...r},s)=>n.jsx(J8,{ref:s,className:we("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...r}));Ao.displayName=J8.displayName;const gMe=x.forwardRef(({className:e,children:t,checked:r,...s},a)=>n.jsxs(e9,{ref:a,className:we("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:r,...s,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(r9,{children:n.jsx(oi,{className:"h-4 w-4"})})}),t]}));gMe.displayName=e9.displayName;const xMe=x.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(t9,{ref:s,className:we("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...r,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(r9,{children:n.jsx(ku,{className:"h-2 w-2 fill-current"})})}),t]}));xMe.displayName=t9.displayName;const vMe=x.forwardRef(({className:e,inset:t,...r},s)=>n.jsx(Z8,{ref:s,className:we("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...r}));vMe.displayName=Z8.displayName;const yMe=x.forwardRef(({className:e,...t},r)=>n.jsx(n9,{ref:r,className:we("-mx-1 my-1 h-px bg-muted",e),...t}));yMe.displayName=n9.displayName;function jMe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["dns-monitor-metrics",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("id, name").eq("client_id",e).eq("asset_type","dns").eq("status","active");if(i)throw i;if(!a||a.length===0)return[];const o=a.map(g=>g.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",o).eq("status","active");if(c)throw c;if(!l||l.length===0)return[];const d=l.map(g=>g.id),u=new Date;u.setHours(u.getHours()-24);const{data:h,error:f}=await B.from("monitor_checks").select("monitor_id, status, timestamp, response_time_ms").in("monitor_id",d).gte("timestamp",u.toISOString()).order("timestamp",{ascending:!1});if(f)throw f;return a.map(g=>{const p=l.filter(C=>C.monitoring_agent_id===g.id);if(p.length===0)return{monitorId:g.id,avgResponseTime:0,uptime24h:0,lastCheckTime:null};const y=p[0].id,v=(h==null?void 0:h.filter(C=>C.monitor_id===y))||[],j=v.length,b=v.filter(C=>C.status==="success").length,_=j>0?b/j*100:0,w=v.filter(C=>C.response_time_ms!==null),N=w.length>0?w.reduce((C,P)=>C+(P.response_time_ms||0),0)/w.length:0,S=v.length>0?v[0].timestamp:null;return{monitorId:g.id,avgResponseTime:N,uptime24h:_,lastCheckTime:S}})},enabled:!!e,refetchInterval:6e4});return{metrics:t,isLoading:r,error:s}}function bMe({clientId:e,onMonitorSelect:t,activeMonitorId:r,selectedMonitors:s,onSelectionChange:a,onEdit:i}){const o=Et(),[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,f]=x.use
756State(!1),{metrics:m}=jMe(e),{toggleAgentStatus:g,deleteAgent:p}=Lt(e),{runSingleMonitorCheck:y,isSingleCheckRunning:v}=Ra();x.useEffect(()=>{if(!e)return;console.log("DnsMonitorList: Setting up real-time subscription");const k=B.channel("dns_monitors_changes").on("postgres_changes",{event:"*",schema:"public",table:"monitoring_agents",filter:`client_id=eq.${e}`},W=>{console.log("DnsMonitorList: Real-time update received:",W),W.new&&W.new.asset_type==="dns"?(o.invalidateQueries({queryKey:["dns-monitors",e]}),o.invalidateQueries({queryKey:["dns-monitor-metrics",e]})):W.old&&W.old.asset_type==="dns"&&(o.invalidateQueries({queryKey:["dns-monitors",e]}),o.invalidateQueries({queryKey:["dns-monitor-metrics",e]}))}).subscribe();return()=>{console.log("DnsMonitorList: Cleaning up real-time subscription"),B.removeChannel(k)}},[e,o]);const{data:j,isLoading:b}=Ve({queryKey:["dns-monitors",e],queryFn:async()=>{const{data:k,error:W}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","dns").order("created_at",{ascending:!1});if(W)throw W;if(!k||k.length===0)return[];const q=k.map(X=>X.id),{data:Q,error:ue}=await B.from("monitors").select("id, name, status, monitoring_agent_id").in("monitoring_agent_id",q);if(ue)throw ue;if(Q&&Q.length>0){const X=Q.map(ce=>ce.id),{data:le}=await B.from("monitor_checks").select("id, status, timestamp, error_message, monitor_id").in("monitor_id",X).order("timestamp",{ascending:!1});return k.map(ce=>{const oe=Q.filter(V=>V.monitoring_agent_id===ce.id).map(V=>({...V,monitor_checks:(le==null?void 0:le.filter(fe=>fe.monitor_id===V.id).slice(0,5))||[]}));return{...ce,monitors:oe}})}return k.map(X=>({...X,monitors:[]}))},enabled:!!e});x.useEffect(()=>{if(!e||!j)return;console.log("DnsMonitorList: Setting up monitor checks subscription");const k=B.channel("dns_monitor_checks_changes").on("postgres_changes",{event:"INSERT",schema:"public",table:"monitor_checks"},W=>{console.log("DnsMonitorList: Monitor check inserted:",W),o.invalidateQueries({queryKey:["dns-monitors",e]}),o.invalidateQueries({queryKey:["dns-monitor-metrics",e]}),o.invalidateQueries({queryKey:["dns-monitor-stats",e]}),j==null||j.forEach(q=>{o.invalidateQueries({queryKey:["monitor-checks",q.id]})})}).subscribe();return()=>{console.log("DnsMonitorList: Cleaning up monitor checks subscription"),B.removeChannel(k)}},[e,o,j]);const _=k=>{a(k&&j?new Set(j.map(W=>W.id)):new Set)},w=(k,W)=>{const q=new Set(s);W?q.add(k):q.delete(k),a(q)},N=k=>{u(k),c(!0)},S=(k,W)=>{W.stopPropagation(),console.log("Manual status check triggered for agent:",k.id);const q=new Set(s);q.delete(k.id),a(q),y(k.id)},C=k=>{var Q,ue,X;if(k.status==="suspended")return"bg-gray-500";const W=k.monitors||[];if(W.length===0)return"bg-gray-500";const q=(ue=(Q=W[0])==null?void 0:Q.monitor_checks)==null?void 0:ue[0];return q?q.status==="success"?"bg-green-500":q.status==="failure"?(X=q.error_message)!=null&&X.includes("baseline")?"bg-orange-500":"bg-red-500":"bg-yellow-500":"bg-yellow-500"},P=k=>{var Q,ue,X;if(k.status==="suspended")return"Paused - Click row to resume";const W=k.monitors||[];if(W.length===0)return"No checks";const q=(ue=(Q=W[0])==null?void 0:Q.monitor_checks)==null?void 0:ue[0];return q?q.status==="success"?"Baseline matches":q.status==="failure"?(X=q.error_message)!=null&&X.includes("baseline")?"Baseline mismatch":"Check failed":"Warning":"Waiting for check"},M=k=>{var Q,ue,X;const W=k.monitors||[];if(W.length===0)return{text:"N/A",variant:"outline"};const q=(ue=(Q=W[0])==null?void 0:Q.monitor_checks)==null?void 0:ue[0];return q?q.status==="success"?{text:"Match",variant:"default"}:(X=q.error_message)!=null&&X.includes("baseline")?{text:"Mismatch",variant:"destructive"}:{text:"Unknown",variant:"outline"}:{text:"Unknown",variant:"outline"}},D=k=>{var Q,ue;const W=k.monitors||[];if(W.length===0)return"Never";const q=(ue=(Q=W[0])==null?void 0:Q.monitor_checks)==null?void 0:ue[0];return q?is(new Date(q.timestamp),{addSuffix:!0}):"Never"},A=k=>{var W;return((W=k.monitoring_config)==null?void 0:W.dns_record_type)||"A"},U=k=>m==null?void 0:m.find(W=>W.monitorId===k),F=()=>{const k=(j==null?void 0:j.filter(Q=>s.has(Q.id)))||[],W=k.filter(Q=>Q.status==="active").length,q=k.filter(Q=>Q.status==="suspended").length;if(W>=q){let Q=0;for(const ue of k)ue.status==="active"&&(g(ue),Q++);Q>0&&ye.success(`Pausing ${Q} monitor(s)`)}else{let Q=0;for(const ue of k)ue.status==="suspended"&&(g(ue),Q++);Q>0&&ye.success(`Resuming ${Q} monitor(s)`)}},L=()=>{const k=(j==null?void 0:j.filter(W=>s.has(W.id)))||[];for(const W of k)y(W.id)},$=x.useMemo(()=>{const k=(j==null?void 0:j.filter(Q=>s.has(Q.id)))||[],W=k.filter(Q=>Q.status==="active").length,q=k.filter(Q=>Q.status==="suspended").length;return W>=q},[s,j]),R=()=>{f(!0)},T=()=>{for(const k of Array.from(s))p(k);ye.success(`Deleting ${s.size} monitor(s)`),a(new Set),f(!1)};return b?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((k,W)=>n.jsx(tt,{className:"h-16 w-full"},W))})})]}):!j||j.length===0?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{children:"DNS Monitors"})}),n.jsx(re,{children:n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:"No DNS monitors found. Create one to get started."})})})]}):n.jsxs(n.Fragment,{children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[s.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:F,disabled:s.size===0,children:$?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"outline",size:"sm",onClick:L,disabled:s.size===0||v,children:[n.jsx(Ym,{className:"h-4 w-4 mr-2"}),"Recycle Selected"]}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:R,disabled:s.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsx(me,{children:"DNS Monitors"})]})}),n.jsx(re,{children:n.jsx("div",{className:"border rounded-lg",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:j.length>0&&s.size===j.length,onCheckedChange:_})}),n.jsx(Se,{className:"w-12",children:"Status"}),n.jsx(Se,{children:"Monitor"}),n.jsx(Se,{children:"Domain/Hostname"}),n.jsx(Se,{children:"Record Type"}),n.jsx(Se,{children:"Baseline Status"}),n.jsx(Se,{children:"Uptime (24h)"}),n.jsx(Se,{className:"hidden lg:table-cell",children:"History"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:j.map(k=>{const W=M(k),q=U(k.id),Q=s.has(k.id),ue=r===k.id;
756return n.jsxs(gt,{className:`cursor-pointer ${Q?"bg-muted/50":""} ${ue?"bg-accent":""}`,onClick:()=>{Q?(w(k.id,!1),t("")):(k.status==="suspended"&&(g(k),ye.success(`Resuming ${k.name}`)),w(k.id,!0),t(k.id))},children:[n.jsx(be,{onClick:X=>X.stopPropagation(),children:n.jsx(ct,{checked:Q,onCheckedChange:X=>w(k.id,X)})}),n.jsx(be,{children:n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:`w-3 h-3 rounded-full ${C(k)}`}),n.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-10 w-48 p-2 bg-popover text-popover-foreground text-xs rounded-md shadow-md border",children:P(k)})]})}),n.jsx(be,{children:n.jsx("div",{children:n.jsx("div",{className:"font-medium",children:k.name})})}),n.jsx(be,{children:n.jsx("div",{className:"font-mono text-sm",children:k.hostname_or_url})}),n.jsx(be,{children:n.jsx(ve,{variant:"outline",children:A(k)})}),n.jsx(be,{children:n.jsx(ve,{variant:W.variant,children:W.text})}),n.jsx(be,{children:q?`${q.uptime24h.toFixed(2)}%`:"N/A"}),n.jsx(be,{className:"hidden lg:table-cell",children:n.jsx(Ki,{monitoringAgentId:k.id,createdAt:k.created_at})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:D(k)})}),n.jsx(be,{className:"text-right",onClick:X=>X.stopPropagation(),children:n.jsxs(W2,{children:[n.jsx(H2,{asChild:!0,children:n.jsx(H,{variant:"ghost",size:"sm",children:n.jsx(gI,{className:"h-4 w-4"})})}),n.jsxs(tb,{align:"end",children:[n.jsxs(Ao,{onClick:X=>S(k,X),disabled:v,children:[n.jsx(Ym,{className:"h-4 w-4 mr-2"}),"Recycle Test"]}),i&&n.jsxs(Ao,{onClick:()=>i(k),children:[n.jsx(zi,{className:"h-4 w-4 mr-2"}),"Edit"]}),n.jsxs(Ao,{onClick:()=>N(k),className:"text-destructive",children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},k.id)})})]})})})]}),d&&n.jsx(Gi,{monitor:d,open:l,onOpenChange:c}),n.jsx(jg,{open:h,onOpenChange:f,count:s.size,onConfirm:T})]})}function wMe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!0),{data:a,isLoading:i,refetch:o}=Ve({queryKey:["dns-monitor-chart",e,t],queryFn:async()=>{let u=t;if(!u){const{data:y}=await B.from("monitoring_agents").select("id, name").eq("client_id",e).eq("asset_type","dns").eq("status","active").limit(1).single();if(!y)return null;u=y.id}const{data:h}=await B.from("monitoring_agents").select("id, name").eq("id",u).single();if(!h)return null;const{data:f}=await B.from("monitors").select("id").eq("monitoring_agent_id",h.id).eq("status","active").limit(1);if(!f||f.length===0)return null;const m=f[0].id,g=Pte(new Date,24),{data:p}=await B.from("monitor_checks").select("status, timestamp, error_message").eq("monitor_id",m).gte("timestamp",g.toISOString()).order("timestamp",{ascending:!0});return{agentName:h.name,checks:p||[]}},enabled:!!e}),l=()=>{if(!(a!=null&&a.checks))return[];const u={};return a.checks.forEach(h=>{var m;const f=$r(new Date(h.timestamp),"HH:00");u[f]||(u[f]={matches:0,mismatches:0,total:0}),u[f].total++,h.status==="success"?u[f].matches++:(m=h.error_message)!=null&&m.includes("baseline")&&u[f].mismatches++}),Object.entries(u).map(([h,f])=>({time:h,matches:f.matches,mismatches:f.mismatches}))},c=()=>{if(!(a!=null&&a.checks))return[];const u={};return a.checks.forEach(h=>{const f=$r(new Date(h.timestamp),"HH:00");u[f]||(u[f]={success:0,failed:0}),h.status==="success"?u[f].success++:u[f].failed++}),Object.entries(u).map(([h,f])=>({time:h,success:f.success,failed:f.failed}))},d=()=>{if(!(a!=null&&a.checks))return[];const u={};return a.checks.forEach(h=>{const f=$r(new Date(h.timestamp),"HH:00");u[f]||(u[f]={total:0,success:0}),u[f].total++,h.status==="success"&&u[f].success++}),Object.entries(u).map(([h,f])=>({time:h,uptime:f.total>0?f.success/f.total*100:0}))};return i?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx(tt,{className:"h-64 w-full"})})]}):a?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(me,{className:"text-lg",children:["DNS Monitor Trends - ",a.agentName]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:()=>o(),children:n.jsx(sr,{className:"h-4 w-4"})}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>s(!r),children:r?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"baseline",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsx(at,{value:"baseline",children:"Baseline Matches"}),n.jsx(at,{value:"status",children:"Check Status"}),n.jsx(at,{value:"uptime",children:"Uptime Trend"})]}),n.jsx(it,{value:"baseline",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Bp,{data:l(),children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"time"}),n.jsx(Jt,{}),n.jsx(Ot,{}),n.jsx(js,{dataKey:"matches",fill:"hsl(var(--chart-2))",name:"Matches"}),n.jsx(js,{dataKey:"mismatches",fill:"hsl(var(--chart-5))",name:"Mismatches"})]})})}),n.jsx(it,{value:"status",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Bp,{data:c(),children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"time"}),n.jsx(Jt,{}),n.jsx(Ot,{}),n.jsx(js,{dataKey:"success",fill:"hsl(var(--chart-2))",name:"Success"}),n.jsx(js,{dataKey:"failed",fill:"hsl(var(--chart-1))",name:"Failed"})]})})}),n.jsx(it,{value:"uptime",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:d(),children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"time"}),n.jsx(Jt,{domain:[0,100]}),n.jsx(Ot,{}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--chart-2))",strokeWidth:2,dot:{fill:"hsl(var(--chart-2))"},name:"Uptime %"})]})})})]})})]}):n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{children:"DNS Monitor Trends"})}),n.jsx(re,{children:n.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No DNS monitor data available"})})]})}function _Me(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(),[s,a]=x.useState(new Set),[i,o]=x.useState(!1),l=Et();x.useEffect(()=>{const d=u=>{const h=u.target,f=h.closest("[data-monitor-list]"),m=h.closest("[data-monitor-actions]");!f&&!m&&a(new Set)};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]);const c=()=>{l.invalidateQueries({queryKey:["dns-monitors"]}),l.invalidateQueries({queryKey:["dns-monitor-stats"]}),l.invalidateQueries({queryKey:["dns-monitor-chart"]})};return e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"DNS Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor DNS resolution and record changes"})]}),n.jsx(yOe,{clientId:e}),n.jsx(eo,{clientId:e,onRefresh:c,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(bMe,{clientId:e,onMonitorSelect:r,activeMonitorId:t,selectedMonitors:s,onSelectionChange:a})}),n.jsx(wMe,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"dns"})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"DNS Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor DNS resolution and record changes"})]}),n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:"Please select a client to view DNS monitors"})})]})}function NMe(e){return Ve({queryKey:["ping-monitor-stats",e],queryFn:async()=>{if(!e)throw new Error("Client ID required");const{data:t,error:r}=await B.from("monitoring_agents").select("id, status, monitoring_config").eq("client_id",e).eq("asset_type","ping").eq("status","active");if(r)throw r;const s=(t==null?void 0:t.map(M=>M.id))||[];if(s.length===0)return{total:0,online:0,offline:0,warning:0,avgLatency:0,uptime24h:0,uptime7d:0,uptime30d:0,recentIncidents:0};const{data:a,error:i}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",s).eq("status","active");if(i)throw i;const o=(a==null?void 0:a.map(M=>M.id))||[];if(o.length===0)return{total:(t==null?void 0:t.length)||0,online:0,offline:0,warning:0,avgLatency:0,uptime24h:0,uptime7d:0,uptime30d:0,recentIncidents:0};const l=new Date,c=new Date(l.getTime()-24*60*60*1e3),d=new Date(l.getTime()-7*24*60*60*1e3),u=new Date(l.getTime()-30*24*60*60*1e3),{data:h}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",o).gte("timestamp",c.toISOString()).order("timestamp",{ascending:!1}),{data:f}=await B.from("monitor_checks").select("monitor_id, status").in("monitor_id",o).gte("timestamp",d.toISOString()),{data:m}=await B.from("monitor_checks").select("monitor_id, status").in("monitor_id",o).gte("timestamp",u.toISOString()),g=new Map;h==null||h.forEach(M=>{g.has(M.monitor_id)||g.set(M.monitor_id,M)});let p=0,y=0,v=0,j=0,b=0;g.forEach(M=>{M.status==="success"?(M.response_time_ms&&M.response_time_ms>100?v++:p++,M.response_time_ms&&(j+=M.response_time_ms,b++)):y++});const _=b>0?Math.round(j/b):0,w=M=>{if(!M||M.length===0)return 0;const D=M.filter(A=>A.status==="success").length;return Math.round(D/M.length*100)},N=w(h||[]),S=w(f||[]),C=w(m||[]),P=(h==null?void 0:h.filter(M=>M.status==="failure").length)||0;return{total:(t==null?void 0:t.length)||0,online:p,offline:y,warning:v,avgLatency:_,uptime24h:N,uptime7d:S,uptime30d:C,recentIncidents:P}},enabled:!!e,refetchInterval:3e4})}function SMe({clientId:e}){const{data:t,isLoading:r}=NMe(e);if(r)return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6",children:[...Array(6)].map((a,i)=>n.jsxs(ee,{className:"p-6 animate-pulse",children:[n.jsx("div",{className:"h-4 bg-muted rounded w-1/2 mb-2"}),n.jsx("div",{className:"h-8 bg-muted rounded w-3/4"})]},i))});const s=[{title:"Total Monitors",value:(t==null?void 0:t.total)||0,icon:Wr,color:"text-primary",bgColor:"bg-primary/10"},{title:"Online",value:(t==null?void 0:t.online)||0,subtitle:t!=null&&t.total?`${Math.round(((t==null?void 0:t.online)||0)/t.total*100)}%`:"0%",icon:zs,color:"text-green-600",bgColor:"bg-green-100 dark:bg-green-900/20"},{title:"Offline",value:(t==null?void 0:t.offline)||0,icon:sa,color:"text-destructive",bgColor:"bg-destructive/10"},{title:"Avg Latency",value:`${(t==null?void 0:t.avgLatency)||0}ms`,icon:Xt,color:((t==null?void 0:t.avgLatency)||0)>100?"text-orange-600":"text-green-600",bgColor:((t==null?void 0:t.avgLatency)||0)>
756100?"bg-orange-100 dark:bg-orange-900/20":"bg-green-100 dark:bg-green-900/20"},{title:"Uptime (24h)",value:`${(t==null?void 0:t.uptime24h)||0}%`,subtitle:`7d: ${(t==null?void 0:t.uptime7d)||0}% | 30d: ${(t==null?void 0:t.uptime30d)||0}%`,icon:Bi,color:((t==null?void 0:t.uptime24h)||0)>=99?"text-green-600":((t==null?void 0:t.uptime24h)||0)>=95?"text-orange-600":"text-destructive",bgColor:((t==null?void 0:t.uptime24h)||0)>=99?"bg-green-100 dark:bg-green-900/20":((t==null?void 0:t.uptime24h)||0)>=95?"bg-orange-100 dark:bg-orange-900/20":"bg-destructive/10"},{title:"Recent Incidents",value:(t==null?void 0:t.recentIncidents)||0,subtitle:"Last 24 hours",icon:tn,color:((t==null?void 0:t.recentIncidents)||0)>0?"text-destructive":"text-muted-foreground",bgColor:((t==null?void 0:t.recentIncidents)||0)>0?"bg-destructive/10":"bg-muted"}];return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6",children:s.map((a,i)=>n.jsx(ee,{className:"p-6",children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{className:"space-y-1 flex-1",children:[n.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:a.title}),n.jsx("p",{className:"text-2xl font-bold",children:a.value}),a.subtitle&&n.jsx("p",{className:"text-xs text-muted-foreground",children:a.subtitle})]}),n.jsx("div",{className:`p-2 rounded-lg ${a.bgColor}`,children:n.jsx(a.icon,{className:`h-4 w-4 ${a.color}`})})]})},i))})}function CMe(e){return Ve({queryKey:["ping-monitor-metrics",e],queryFn:async()=>{if(!e)return[];const{data:t,error:r}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","ping").eq("status","active");if(r)throw r;const s=(t==null?void 0:t.map(h=>h.id))||[];if(s.length===0)return[];const{data:a,error:i}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",s).eq("status","active");if(i)throw i;const o=(a==null?void 0:a.map(h=>h.id))||[];if(o.length===0)return[];const l=new Date(Date.now()-24*60*60*1e3),{data:c,error:d}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",o).gte("timestamp",l.toISOString()).order("timestamp",{ascending:!1});if(d)throw d;const u=new Map;return t==null||t.forEach(h=>{var b;const f=a==null?void 0:a.find(_=>_.monitoring_agent_id===h.id);if(!f)return;const m=(c==null?void 0:c.filter(_=>_.monitor_id===f.id))||[];if(m.length===0){u.set(h.id,{monitorId:h.id,avgResponseTime:0,uptime24h:0});return}const g=m.filter(_=>_.response_time_ms).map(_=>_.response_time_ms),p=g.length>0?Math.round(g.reduce((_,w)=>_+w,0)/g.length):0,y=m.filter(_=>_.status==="success").length,v=Math.round(y/m.length*100),j=(b=m[0])==null?void 0:b.timestamp;u.set(h.id,{monitorId:h.id,avgResponseTime:p,uptime24h:v,lastCheckTime:j})}),Array.from(u.values())},enabled:!!e,refetchInterval:6e4})}function kMe({monitoringAgentId:e}){const{checks:t}
756=mc(e,1),r=t[0];return!r||!r.response_time_ms?null:n.jsxs("span",{className:"text-xs text-muted-foreground",children:[r.response_time_ms,"ms"]})}function PMe({clientId:e,selectedMonitors:t,onSelectionChange:r,activeMonitorId:s,onActiveMonitorChange:a}){const{toggleAgentStatus:i,deleteAgent:o}=Lt(e),{data:l}=CMe(e),{groups:c}=Vi(e),[d,u]=x.useState(""),[h,f]=x.useState("all"),[m,g]=x.useState("all"),[p,y]=x.useState(1),[v,j]=x.useState(null),[b,_]=x.useState(!1),[w,N]=x.useState(!1),S=5,{data:C,isLoading:P}=Ve({queryKey:["ping-monitors",e],queryFn:async()=>{if(!e)return[];const{data:X,error:le}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","ping").order("created_at",{ascending:!1});if(le)throw le;return X||[]},enabled:!!e}),M=(C==null?void 0:C.filter(X=>{var ce,se;const le=((ce=X.name)==null?void 0:ce.toLowerCase().includes(d.toLowerCase()))||((se=X.hostname_or_url)==null?void 0:se.toLowerCase().includes(d.toLowerCase())),pe=h==="all"||h==="online"&&X.status==="active"||h==="offline"&&X.status!=="active"||h==="paused"&&X.status==="suspended";return le&&pe}))||[],D=Math.ceil(M.length/S),A=(p-1)*S,U=M.slice(A,A+S);x.useEffect(()=>{y(1)},[d,h,m]);const F=async X=>{await i(X),ye.success(X.status==="suspended"?"Monitor resumed":"Monitor paused")},L=()=>{t.size!==0&&_(!0)},$=async()=>{ye.success(`${t.size} monitors deleted`),r(new Set),_(!1)},R=X=>X.status==="suspended"?"bg-muted-foreground":X.status==="active"?"bg-success":"bg-destructive",T=X=>X.status==="suspended"?"Paused - Click row to resume":X.status==="active"?"Online":"Offline",k=X=>{if(X){const le=new Set(U.map(pe=>pe.id));r(le)}else r(new Set)},W=X=>{const le=new Set(t);le.has(X)?le.delete(X):le.add(X),r(le)},q=(X,le)=>{const pe=new Set(t);le?pe.add(X):pe.delete(X),r(pe)},Q=X=>{a(X),W(X)},ue=U.length>0&&U.every(X=>t.has(X.id));return P?n.jsx(ee,{className:"p-6",children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((X,le)=>n.jsx("div",{className:"h-20 bg-muted rounded animate-pulse"},le))})}):n.jsxs(n.Fragment,{children:[n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-accent rounded-lg border mb-4",children:[n.jsx(ve,{variant:"secondary",className:"font-semibold",children:t.size>0?`${t.size} selected`:"Bulk Actions"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",disabled:t.size===0,onClick:async()=>{const X=(C==null?void 0:C.filter(ce=>t.has(ce.id)))||[],le=X.filter(ce=>ce.status==="active").length,pe=X.filter(ce=>ce.status==="suspended").length;if(le>=pe){const ce=X.filter(se=>se.status==="active");await Promise.all(ce.map(se=>i(se))),ye.success(`Paused ${ce.length} monitor(s)`)}else{const ce=X.filter(se=>se.status==="suspended");await Promise.all(ce.map(se=>i(se))),ye.success(`Resumed ${ce.length} monitor(s)`)}},children:(()=>{const X=(C==null?void 0:C.filter(ce=>t.has(ce.id)))||[],le=X.filter(ce=>ce.status==="active").length,pe=X.filter(ce=>ce.status==="suspended").length;return le>=pe?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})})()}),n.jsxs(H,{variant:"destructive",size:"sm",disabled:t.size===0,onClick:L,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]}),t.size===0&&n.jsx("div",{className:"text-sm text-muted-foreground ml-auto",children:"Select monitors using checkboxes to perform bulk actions"})]}),n.jsxs("div",{className:"flex items-center justify-between gap-4",children:[n.jsx(me,{children:"Ping Monitors"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:d,onChange:X=>u(X.target.value),className:"pl-8 w-[250px]"})]}),n.jsxs(H,{variant:"outline",size:"default",onClick:()=>N(!w),children:[n.jsx(Ui,{className:"h-4 w-4 mr-2"}),"Filters"]})]})]}),n.jsx(ur,{open:w,children:n.jsx(Er,{children:n.jsxs("div",{className:"grid grid-cols-2 gap-3 p-4 border rounded-lg bg-muted/50 mt-4",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Status"}),n.jsxs(Fe,{value:h,onValueChange:f,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Status"}),n.jsx(J,{value:"online",children:"Online"}),n.jsx(J,{value:"offline",children:"Offline"}),n.jsx(J,{value:"paused",children:"Paused"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-xs font-medium mb-1.5 block",children:"Latency"}),n.jsxs(Fe,{value:m,onValueChange:g,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Latency"}
756),n.jsx(J,{value:"fast",children:"< 50ms"}),n.jsx(J,{value:"medium",children:"50-100ms"}),n.jsx(J,{value:"slow",children:"> 100ms"})]})]})]})]})})})]}),n.jsxs(re,{children:[n.jsx("div",{className:"border rounded-lg",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:ue,onCheckedChange:k})}),n.jsx(Se,{className:"w-12",children:"Status"}),n.jsx(Se,{children:"Monitor"}),n.jsx(Se,{children:"Target"}),n.jsx(Se,{children:"Latency"}),n.jsx(Se,{children:"Uptime (24h)"}),n.jsx(Se,{className:"hidden lg:table-cell",children:"History (12h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:U.map(X=>{var se;const le=t.has(X.id),pe=s===X.id,ce=l==null?void 0:l.find(oe=>oe.monitorId===X.id);return n.jsxs(gt,{className:`cursor-pointer ${le?"bg-muted/50":""} ${pe?"border-l-4 border-l-primary":""}`,onClick:()=>Q(X.id),children:[n.jsx(be,{onClick:oe=>oe.stopPropagation(),children:n.jsx(ct,{checked:le,onCheckedChange:oe=>q(X.id,oe)})}),n.jsx(be,{children:n.jsxs("div",{className:"relative group",children:[n.jsx("div",{className:`w-3 h-3 rounded-full ${R(X)}`}),n.jsx("div",{className:"absolute left-0 top-full mt-1 hidden group-hover:block z-10 w-48 p-2 bg-popover text-popover-foreground text-xs rounded-md shadow-md border",children:T(X)})]})}),n.jsx(be,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"font-medium",children:X.name}),X.group_id&&n.jsx(ve,{variant:"outline",className:"text-xs font-normal",children:((se=c.find(oe=>oe.id===X.group_id))==null?void 0:se.name)||"Unknown"})]})}),n.jsx(be,{children:n.jsx("div",{className:"font-mono text-sm text-muted-foreground",children:X.hostname_or_url})}),n.jsx(be,{children:n.jsx(kMe,{monitoringAgentId:X.id})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm",children:ce?`${ce.uptime24h.toFixed(2)}%`:"N/A"})}),n.jsx(be,{className:"hidden lg:table-cell",children:n.jsx(Ki,{monitoringAgentId:X.id,createdAt:X.created_at})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:X.updated_at?is(new Date(X.updated_at),{addSuffix:!0}):"Never"})}),n.jsx(be,{className:"text-right",onClick:oe=>oe.stopPropagation(),children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(C6,{monitorId:X.id,clientId:e,currentGroupId:X.group_id}),n.jsxs(W2,{children:[n.jsx(H2,{asChild:!0,children:n.jsx(H,{variant:"ghost",size:"sm",children:n.jsx(gI,{className:"h-4 w-4"})})}),n.jsxs(tb,{align:"end",children:[n.jsx(Ao,{onClick:()=>F(X),children:X.status==="suspended"?n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume"]}):n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause"]})}),n.jsxs(Ao,{onClick:()=>j(X),className:"text-destructive",children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]},X.id)})})]})}),M.length===0&&n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No ping monitors found"}),M.length>0&&n.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 bg-muted/50 rounded-lg border",children:[n.jsxs("div",{className:"text-sm font-medium",children:["Showing ",A+1," to ",Math.min(A+S,M.length)," of ",M.length," monitors"]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>y(X=>Math.max(1,X-1)),disabled:p===1,children:[n.jsx(zh,{className:"h-4 w-4"}),"Previous"]}),D>1&&n.jsx("div",{className:"flex items-center gap-1",children:[...Array(D)].map((X,le)=>{const pe=le+1;return pe===1||pe===D||pe>=p-1&&pe<=p+1?n.jsx(H,{variant:p===pe?"default":"outline",size:"sm",onClick:()=>y(pe),className:"min-w-[40px]",children:pe},pe):pe===p-2||pe===p+2?n.jsx("span",{className:"px-2",children:"..."},pe):null})}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>y(X=>Math.min(D,X+1)),disabled:p===D,children:["Next",n.jsx(Yo,{className:"h-4 w-4 ml-1"})]})]})]})]})]}),n.jsx(Gi,{monitor:v,open:!!v,onOpenChange:X=>!X&&j(null)}),n.jsx(jg,{open:b,onOpenChange:_,count:t.size,onConfirm:$})]})}function TMe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{data:i}=Ve({queryKey:["ping-monitors",e],queryFn:async()=>
756{if(!e)return[];const{data:u,error:h}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","ping").order("created_at",{ascending:!1});if(h)throw h;return u||[]},enabled:!!e}),o=x.useMemo(()=>!i||i.length===0?null:t?i.find(u=>u.id===t):i[0],[i,t]),{data:l,isLoading:c}=Ve({queryKey:["ping-monitor-chart",o==null?void 0:o.id],queryFn:async()=>{if(!o)return{latencyData:[],successData:[],uptimeData:[]};const{data:u}=await B.from("monitors").select("id").eq("monitoring_agent_id",o.id).eq("status","active").single();if(!u)return{latencyData:[],successData:[],uptimeData:[]};const h=new Date(Date.now()-24*60*60*1e3),{data:f}=await B.from("monitor_checks").select("status, response_time_ms, timestamp").eq("monitor_id",u.id).gte("timestamp",h.toISOString()).order("timestamp",{ascending:!0});if(!f||f.length===0)return{latencyData:[],successData:[],uptimeData:[]};const m=new Map;f.forEach(v=>{const b=`${new Date(v.timestamp).getHours()}:00`;m.has(b)||m.set(b,{hour:b,latencies:[],success:0,failure:0,total:0});const _=m.get(b);_.total++,v.status==="success"?(_.success++,v.response_time_ms&&_.latencies.push(v.response_time_ms)):_.failure++});const g=Array.from(m.values()).map(v=>({hour:v.hour,latency:v.latencies.length>0?Math.round(v.latencies.reduce((j,b)=>j+b,0)/v.latencies.length):0})),p=Array.from(m.values()).map(v=>({hour:v.hour,success:v.success,failure:v.failure})),y=Array.from(m.values()).map(v=>({hour:v.hour,uptime:v.total>0?Math.round(v.success/v.total*100):0}));return{latencyData:g,successData:p,uptimeData:y}},enabled:!!o,refetchInterval:6e4}),d=()=>{o&&a.invalidateQueries({queryKey:["ping-monitor-chart",o.id]})};return o?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"Performance Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:o.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:d,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"latency",className:"w-full",children:[n.jsxs(nn,{className:"grid w-full grid-cols-3",children:[n.jsx(at,{value:"latency",children:"Latency Trend"}),n.jsx(at,{value:"success",children:"Success Rate"}),n.jsx(at,{value:"uptime",children:"Uptime %"})]}),n.jsx(it,{value:"latency",className:"mt-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:(l==null?void 0:l.latencyData)||[],children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"hour"}),n.jsx(Jt,{label:{value:"Latency (ms)",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{}),n.jsx(Qt,{type:"monotone",dataKey:"latency",stroke:"hsl(var(--primary))",strokeWidth:2})]})})}),n.jsx(it,{value:"success",className:"mt-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Bp,{data:(l==null?void 0:l.successData)||[],children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"hour"}),n.jsx(Jt,{}),n.jsx(Ot,{}),n.jsx(js,{dataKey:"success",fill:"hsl(var(--chart-2))",name:"Success"}),n.jsx(js,{dataKey:"failure",fill:"hsl(var(--destructive))",name:"Failure"})]})})}),n.jsx(it,{value:"uptime",className:"mt-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:(l==null?void 0:l.uptimeData)||[],children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"hour"}),n.jsx(Jt,{domain:[0,100],label:{value:"Uptime %",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--chart-2))",strokeWidth:2})]})})})]})})]}):null}function AMe(){const{selectedClientId:e}=Mt();Et();
756const[t,r]=x.useState(null),[s,a]=x.useState(new Set),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=c=>{const d=c.target;!d.closest("[data-monitor-list]")&&!d.closest("[data-monitor-actions]")&&a(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Ping Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor host availability using ICMP ping"})]}),n.jsx(SMe,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(PMe,{clientId:e,selectedMonitors:s,onSelectionChange:a,activeMonitorId:t,onActiveMonitorChange:r})}),n.jsx(TMe,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"ping"})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Ping Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor host availability using ICMP ping"})]}),n.jsx("div",{className:"text-center py-12",children:n.jsx("p",{className:"text-muted-foreground",children:"Please select a client to view ping monitors"})})]})}function EMe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["tcp-udp-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","tcp_udp").eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const{data:o,error:l}=await B.from("monitors").select("id").in("monitoring_agent_id",a.map(L=>L.id));if(l)throw l;if(!o||o.length===0)return{total:a.length,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const c=o.map(L=>L.id),d=new Date,u=new Date(d.getTime()-24*60*60*1e3),h=new Date(d.getTime()-7*24*60*60*1e3),f=new Date(d.getTime()-30*24*60*60*1e3),{data:m,error:g}=await B.from("monitor_checks").select("*").in("monitor_id",c).order("timestamp",{ascending:!1}).limit(c.length*5);if(g)throw g;const{data:p,error:y}=await B.from("monitor_checks").select("status, response_time_ms").in("monitor_id",c).gte("timestamp",u.toISOString()),{data:v,error:j}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",h.toISOString()),{data:b,error:_}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",f.toISOString());if(y||j||_)throw y||j||_;const w=new Map;m==null||m.forEach(L=>{(!w.has(L.monitor_id)||new Date(L.timestamp)>new Date(w.get(L.monitor_id).timestamp))&&w.set(L.monitor_id,L)});let N=0,S=0,C=0;w.forEach(L=>{L.status==="success"?N++:L.status==="failed"||L.status==="error"?S++:C++});const P=(p==null?void 0:p.filter(L=>L.response_time_ms!==null))||[],M=P.length>0?Math.round(P.reduce((L,$)=>L+($.response_time_ms||0),0)/P.length):0,D=p&&p.length>0?p.filter(L=>L.status==="success").length/p.length*100:100,A=v&&v.length>0?v.filter(L=>L.status==="success").length/v.length*100:100,U=b&&b.length>0?b.filter(L=>L.status==="success").length/b.length*100:100,F=(p==null?void 0:p.filter(L=>L.status==="failed").length)||0;return{total:a.length,online:N,offline:S,warning:C,avgResponseTime:M,uptime24h:Math.round(D*100)/100,uptime7d:Math.round(A*100)/100,uptime30d:Math.round(U*100)/100,recentIncidents:F}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function OMe({clientId:e}){const{stats:t,isLoading:r}=EMe(e);if(r)return n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:[...Array(6)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded-full"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-1"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total TCP/UDP Monitors",value:t.total,description:"Active monitors",icon:Wr,color:"text-primary"},{title:"Online",value:t.online,description:`${t.total>0?Math.round(t.online/t.total*100):0}
756% of monitors`,icon:Tt,color:"text-green-500"},{title:"Offline",value:t.offline,description:t.offline>0?"Requires attention":"All monitors responding",icon:sa,color:t.offline>0?"text-red-500":"text-muted-foreground"},{title:"Avg Response Time",value:`${t.avgResponseTime}ms`,description:"Connection latency",icon:Xt,color:t.avgResponseTime<100?"text-green-500":t.avgResponseTime<300?"text-yellow-500":"text-red-500"},{title:"Uptime (24h)",value:`${t.uptime24h.toFixed(2)}%`,description:`7d: ${t.uptime7d.toFixed(1)}% | 30d: ${t.uptime30d.toFixed(1)}%`,icon:Bi,color:t.uptime24h>=99?"text-green-500":t.uptime24h>=95?"text-orange-500":"text-red-500"},{title:"Recent Incidents",value:t.recentIncidents,description:"Failed checks in 24h",icon:tn,color:t.recentIncidents===0?"text-muted-foreground":t.recentIncidents<5?"text-orange-500":"text-red-500"}];return n.jsx("div",{className:"grid gap-4 grid-cols-1 md:grid-cols-2 lg:grid-cols-3",children:s.map(a=>n.jsxs(ee,{className:"hover:bg-accent/50 transition-colors cursor-pointer",children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(a.icon,{className:`h-4 w-4 ${a.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a.description})]})]},a.title))})}function MMe(e){const{data:t,isLoading:r}=Ve({queryKey:["tcp-udp-monitor-metrics",e],queryFn:async()=>{if(!e)return{};const{data:s}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","tcp_udp").eq("status","active");if(!s||s.length===0)return{};const{data:a}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",s.map(d=>d.id));if(!a||a.length===0)return{};const i=a.map(d=>d.id),o=new Date(Date.now()-24*60*60*1e3),{data:l}=await B.from("monitor_checks").select("*").in("monitor_id",i).gte("timestamp",o.toISOString()).order("timestamp",{ascending:!1}),c={};return a.forEach(d=>{const u=(l==null?void 0:l.filter(y=>y.monitor_id===d.id))||[],h=u[0],f=u.filter(y=>y.status==="success"),m=u.length>0?f.length/u.length*100:0,g=f.length>0?f.reduce((y,v)=>y+(v.response_time_ms||0),0)/f.length:0;let p="warning";h&&(p=h.status==="success"?"online":"offline"),c[d.monitoring_agent_id]={responseTime:Math.round(g),uptime24h:Math.round(m*100)/100,lastCheckTime:h?new Date(h.timestamp):new Date,status:p}}),c},enabled:!!e,refetchInterval:3e4});return{metrics:t||{},isLoading:r}}function DMe({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const[i,o]=x.useState(null),[l,c]=x.useState(new Set),d=s!==void 0?s:l,u=O=>{r?r(O):o(O)},h=O=>{a?a(O):c(O)},[f,m]=x.useState(""),[g,p]=x.useState("all"),[y,v]=x.useState("all"),[j,b]=x.useState("name-asc"),[_,w]=x.useState(!1),[N,S]=x.useState(1),[C,P]=x.useState(null),[M,D]=x.useState(null),{runSingleMonitorCheck:A,isSingleCheckRunning:U}=Ra(),F=5,{agents:L,isLoading:$,toggleAgentStatus:R,deleteAgent:T,isDeleting:k}=Lt(e),{metrics:W}=MMe(e),q=(L==null?void 0:L.filter(O=>O.asset_type==="tcp_udp"))||[],Q=x.useMemo(()=>{const O=new Set;return q.forEach(I=>{var Y;(Y=I.tags)==null||Y.forEach(te=>O.add(te))}),Array.from(O).sort()},[q]),ue=x.useMemo(()=>{let O=[...q];return f&&(O=O.filter(I=>{var Y,te;return I.name.toLowerCase().includes(f.toLowerCase())||((Y=I.description)==null?void 0:Y.toLowerCase().includes(f.toLowerCase()))||((te=I.hostname_or_url)==null?void 0:te.toLowerCase().includes(f.toLowerCase()))})),g!=="all"&&(O=O.filter(I=>{const Y=W[I.id];return g==="online"?(Y==null?void 0:Y.status)==="online":g==="offline"?(Y==null?void 0:Y.status)==="offline":g==="warning"?(Y==null?void 0:Y.status)==="warning":!0})),y!=="all"&&(O=O.filter(I=>{var Y;return(Y=I.tags)==null?void 0:Y.includes(y)})),O.sort((I,Y)=>{const te=W[I.id],K=W[Y.id];switch(j){case"name-asc":return I.name.localeCompare(Y.name);case"name-desc":return Y.name.localeCompare(I.name);case"status-asc":return((te==null?void 0:te.status)||"warning").localeCompare((K==null?void 0:K.status)||"warning");case"status-desc":return((K==null?void 0:K.status)||"warning").localeCompare((te==null?void 0:te.status)||"warning");case"uptime-asc":return((te==null?void 0:te.uptime24h)||0)-((K==null?void 0:K.uptime24h)||0);case"uptime-desc":return((K==null?void 0:K.uptime24h)||0)-((te==null?void 0:te.uptime24h)||0);case"response-asc":return((te==null?void 0:te.responseTime)||0)-((K==null?void 0:K.responseTime)||0);case"response-desc":return((K==null?void 0:K.responseTime)||0)-((te==null?void 0:te.responseTime)||0);default:return 0}}),O},[q,f,g,y,j,W]),X=Math.ceil(ue.length/F),le=(N-1)*F,pe=le+F,ce=ue.slice(le,pe);x.useEffect(()=>{S(1)},[f,g,y,j]);const se=O=>{h(O?new Set(ce.map(I=>I.id)):new Set)},oe=O=>{u(O),V(O)},V=O=>{const I=new Set(d);I.has(O)?I.delete(O):I.add(O),h(I)},fe=(O,I)=>{const Y=new Set(d);I?Y.add(O):Y.delete(O),h(Y)},ne=O=>{D(O)},Ce=O=>{P(O)},Pe=()=>{let O=0;for(const I of Array.from(d)){const Y=q.find(te=>te.id===I);(Y==null?void 0:Y.status)==="active"&&(R(Y),O++)}O>0&&ye.success(`Pausing ${O} monitor(s)`)},he=()=>{let O=0;for(const I of Array.from(d)){const Y=q.find(te=>te.id===I);(Y==null?void 0:Y.status)==="suspended"&&(R(Y),O++)}O>0&&ye.success(`Resuming ${O} monitor(s)`)},ke=()=>{const O=q.filter(te=>d.has(te.id)),I=O.filter(te=>te.status==="active").length,Y=O.filter(te=>te.status==="suspended").length;I>=Y?Pe():(he(),h(new Set))},Me=x.useMemo(()=>{const O=q.filter(te=>d.has(te.id)),I=O.filter(te=>te.status==="active").length,Y=O.filter(te=>te.status==="suspended").length;return I>=Y},[q,d]),Je=async()=>{const O=Array.from(d);for(const I of O)await T(I);h(new Set),ye.success(`Deleted ${O.length} monitor(s)`)},Ke=async O=>{try{await A(O.id),ye.success(`Test initiated for ${O.name}`)}catch{ye.error("Failed to run test")}},E=O=>O&&{21:"FTP",22:"SSH",23:"Telnet",25:"SMTP",53:"DNS",80:"HTTP",110:"POP3",143:"IMAP",443:"HTTPS",465:"SMTPS",587:"SMTP",993:"IMAPS",995:"POP3S",3306:"MySQL",3389:"RDP",5432:"PostgreSQL",8080:"HTTP-Alt",8443:"HTTPS-Alt"}[O]||"";return $?n.jsx("div",{className:"space-y-4",children:[...Array(3)].map((O,I)=>n.jsx(tt,{className:"h-20 w-full"},I))}):n.jsxs(n.Fragment,{children:[n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"TCP/UDP Port Monitors"}),n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[d.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:ke,disabled:d.size===0,children:Me?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:Je,disabled:d.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsx("div",{className:"flex items-center justify-end pt-4",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative w-64",children:[n.jsx(qt,{className:"absolute left-2 top-2.5 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:f,onChange:O=>m(O.target.value),className:"pl-8"})]}),n.jsx(H,{variant:"outline",size:"icon",onClick:()=>w(!_),children:n.jsx(Ui,{className:"h-4 w-4"})})]})}),_&&n.jsxs("div",{className:"flex gap-4 pt-4 border-t",children:[n.jsxs(Fe,{value:g,onValueChange:p,children:[n.jsx(Ie,{className:"w-[180px]",children:n.jsx(Ue,{placeholder:"Filter by status"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Status"}),n.jsx(J,{value:"online",children:"Online"}),n.jsx(J,{value:"offline",children:"Offline"}),n.jsx(J,{value:"warning",children:"Warning"})]})]}),n.jsxs(Fe,{value:y,onValueChange:v,children:[n.jsx(Ie,{className:"w-[180px]",children:n.jsx(Ue,{placeholder:"Filter by tag"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),Q.map(O=>n.jsx(J,{value:O,children:O},O))]})]}),n.jsxs(Fe,{value:j,onValueChange:b,children:[n.jsx(Ie,{className:"w-[180px]",children:n.jsx(Ue,{placeholder:"Sort by"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"name-asc",children:"Name (A-Z)"}),n.jsx(J,{value:"name-desc",children:"Name (Z-A)"}),n.jsx(J,{value:"status-asc",children:"Status (A-Z)"}),n.jsx(J,{value:"status-desc",children:"Status (Z-A)"}),n.jsx(J,{value:"uptime-asc",children:"Uptime (Low-High)"}),n.jsx(J,{value:"uptime-desc",children:"Uptime (High-Low)"}),n.jsx(J,{value:"response-asc",children:"Response (Fast-Slow)"}),n.jsx(J,{value:"response-desc",children:"Response (Slow-Fast)"})]})]}),n.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>{p("all"),v("all"),b("name-asc"),m("")},children:[n.jsx(vn,{className:"h-4 w-4 mr-2"}),"Clear"]})]})]}),n.jsxs(re,{children:[ce.length===0?n.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No TCP/UDP monitors found"}):n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:d.size===ce.length&&ce.length>0,onCheckedChange:se})}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:"Monitor Name"}),n.jsx(Se,{children:"Target / Port"}),n.jsx(Se,{children:"Response Time"}),n.jsx(Se,{children:"History (3h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{children:"24h Uptime"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:ce.map(O=>{const I=W[O.id],Y=E(O.port);return n.jsxs(gt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>oe(O.id),children:[n.jsx(be,{onClick:te=>te.stopPropagation(),children:n.jsx(ct,{checked:d.has(O.id),onCheckedChange:te=>fe(O.id,te)})}),n.jsx(be,{children:n.jsx(gf,{monitoringAgentId:O.id,agentStatus:O.status})}),n.jsx(be,{children:n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:O.name}),O.description&&n.jsx("div",{className:"text-sm text-muted-foreground",children:O.description}),O.tags&&O.tags.length>0&&n.jsx("div",{className:"flex gap-1 mt-1",children:O.tags.map(te=>n.jsx(ve,{variant:"secondary",className:"text-xs",children:te},te))})]})}),n.jsxs(be,{children:[n.jsxs("div",{className:"font-mono text-sm",children:[O.hostname_or_url||"N/A",":",O.port||"N/A"]}),Y&&n.jsx(ve,{variant:"outline",className:"text-xs mt-1",children:Y}),O.protocol&&O.protocol!=="tcp"&&n.jsx(ve,{variant:"outline",className:"text-xs mt-1 ml-1",children:O.protocol.toUpperCase()})]}),n.jsx(be,{children:I!=null&&I.responseTime?`${I.responseTime}ms`:"-"}),n.jsx(be,{children:n.jsx(Ki,{monitoringAgentId:O.id,createdAt:O.created_at})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:I!=null&&I.lastCheckTime?is(I.lastCheckTime,{addSuffix:!0}):"Never"})}),n.jsx(be,{children:(I==null?void 0:I.uptime24h)!==void 0?n.jsxs(ve,{variant:I.uptime24h>=99?"default":I.uptime24h>=95?"secondary":"destructive",children:[I.uptime24h.toFixed(2),"%"]}):"-"}),n.jsx(be,{className:"text-right",onClick:te=>te.stopPropagation(),children:n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>Ke(O),disabled:U,children:n.jsx(sr,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>R(O),children:O.status==="active"?n.jsx(ia,{className:"h-4 w-4"}):n.jsx(qs,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>ne(O),children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>Ce(O),children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},O.id)})})]}),X>1&&n.jsx("div",{className:"mt-4",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>S(O=>Math.max(1,O-1)),className:N===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(X)].map((O,I)=>{const Y=I+1;return Y===1||Y===X||Y>=N-1&&Y<=N+1?n.jsx(wt,{children:n.jsx(ss,{onClick:()=>S(Y),isActive:N===Y,className:"cursor-pointer",children:Y})},Y):Y===N-2||Y===N+2?n.jsx(wt,{children:n.jsx(qo,{})},Y):null}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>S(O=>Math.min(X,O+1)),className:N===X?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]}),n.jsx(Gi,{monitor:C,open:!!C,onOpenChange:O=>!O&&P(null)}),n.jsx(er,{open:!!M,onOpenChange:O=>!O&&D(null),children:n.jsx(Kt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:M&&n.jsx(R2,{clientId:e,open:!!M,onClose:()=>D(null),onBack:()=>D(null),existingAgent:M})})})]})}function RMe(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(!1),[s,a]=x.useState(new Set);return x.useEffect(()=>{const i=o=>{const l=o.target,c=l.closest("[data-monitor-list]"),d=l.closest("[data-monitor-actions]");!c&&!d&&a(new Set)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"TCP/UDP Port Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor TCP and UDP port availability"})]})}),n.jsx(OMe,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>r(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(DMe,{clientId:e,selectedMonitors:s,onSelectionChange:a})}),n.jsx(er,{open:t,onOpenChange:r,children:n.jsx(Kt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:n.jsx(R2,{clientId:e,open:t,onClose:()=>r(!1),onBack:()=>r(!1)})})})]}):n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx("p",{className:"text-muted-foreground",children:"Please select a client to view monitors"})})}function $Me(e){return Ve({queryKey:["keyword-monitor-stats",e],queryFn:async()=>{const{data:t,error:r}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","keyword").eq("status","active");if(r)throw r;if(!t||t.length===0)return{totalMonitors:0,matchingKeywords:0,mismatches:0,averageUptime:0,recentFailures:0};const s=t.map(f=>f.id),a=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:i,error:o}=await B.from("monitor_checks").select("monitor_id, status, error_message").in("monitor_id",s).gte("timestamp",a).order("timestamp",{ascending:!1});if(o)throw o;let l=0,c=0,d=0;const u=new Set;i==null||i.forEach(f=>{c++,f.status==="success"?(d++,l++):f.status==="failure"&&u.add(f.monitor_id)});const h=c>0?Math.round(d/c*100):0;return{totalMonitors:t.length,matchingKeywords:l>0?t.length-u.size:0,mismatches:u.size,averageUptime:h,recentFailures:u.size}},enabled:!!e})}function IMe({clientId:e}){const{data:t,isLoading:r}=$Me(e);if(r)return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-5",children:[...Array(5)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded-full"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-1"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total Keyword Monitors",value:t.totalMonitors,description:"Active monitors",icon:qt,iconColor:"text-blue-500"},{title:"Matching Keywords",value:t.matchingKeywords,description:"Keywords found",icon:zs,iconColor:"text-green-500"},{title:"Mismatches",value:t.mismatches,description:"Keywords not found",icon:sa,iconColor:"text-red-500"},{title:"Average Uptime",value:`${t.averageUptime}%`,description:"Last 24 hours",icon:Bi,iconColor:"text-primary"},{title:"Recent Failures",value:t.recentFailures,description:"In last 24 hours",icon:tn,iconColor:"text-orange-500"}];return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-5",children:s.map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(a.icon,{className:`h-4 w-4 ${a.iconColor}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]},i))})}function LMe(e){return Ve({queryKey:["keyword-monitor-metrics",e],queryFn:async()=>{const{data:t,error:r}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","keyword").eq("status","active");if(r)throw r;if(!t||t.length===0)return[];const s=t.map(u=>u.id),{data:a,error:i}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",s).eq("status","active");if(i)throw i;const o=(a==null?void 0:a.map(u=>u.id))||[],l=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:c,error:d}=await B.from("monitor_checks").select("*").in("monitor_id",o).gte("timestamp",l).order("timestamp",{ascending:!1});if(d)throw d;return t.map(u=>{const h=a==null?void 0:a.find(N=>N.monitoring_agent_id===u.id),f=h?(c==null?void 0:c.filter(N=>N.monitor_id===h.id))||[]:[],m=f[0],g=f.length,p=f.filter(N=>N.status==="success").length,y=g>0?Math.round(p/g*100):0,v=u.monitoring_config,j=(v==null?void 0:v.keywords)||(v!=null&&v.keyword_target?[v.keyword_target]:[]);let b="unknown";m&&(b=m.status==="success"?"matching":"mismatch");const _=f.filter(N=>N.response_time_ms!=null).map(N=>N.response_time_ms),w=_.length>0?Math.round(_.reduce((N,S)=>N+S,0)/_.length):null;return{monitorId:u.id,monitorName:u.name,matchStatus:b,lastCheckTime:(m==null?void 0:m.timestamp)||null,uptime24h:y,responseTimeMs:w,keywords:j,url:u.hostname_or_url}})},enabled:!!e,refetchInterval:6e4})}function FMe({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectedMonitorsChange:a}){const{data:i,isLoading:o}=LMe(e),{agents:l,deleteAgent:c,toggleAgentStatus:d}=Lt(e),{runSingleMonitorCheck:u,isSingleCheckRunning:h}=Ra(),[f,m]=x.useState(""),[g,p]=x.useState("name"),[y,v]=x.useState("asc"),[j,b]=x.use
756State(1),[_,w]=x.useState(!1),[N,S]=x.useState(null),[C,P]=x.useState(null),M=10,D=x.useMemo(()=>new Map((l??[]).map(q=>[q.id,q])),[l]),A=q=>{const Q=new Set(s);Q.has(q)?Q.delete(q):Q.add(q),a(Q)},U=q=>{r(q),A(q)},F=x.useMemo(()=>{if(!i)return[];let q=i.filter(Q=>{var ue;return Q.monitorName.toLowerCase().includes(f.toLowerCase())||((ue=Q.url)==null?void 0:ue.toLowerCase().includes(f.toLowerCase()))||Q.keywords.some(X=>X.toLowerCase().includes(f.toLowerCase()))});return q.sort((Q,ue)=>{let X,le;return g==="name"?(X=Q.monitorName.toLowerCase(),le=ue.monitorName.toLowerCase()):g==="uptime"?(X=Q.uptime24h,le=ue.uptime24h):(X=Q.matchStatus,le=ue.matchStatus),X<le?y==="asc"?-1:1:X>le?y==="asc"?1:-1:0}),q},[i,f,g,y]),L=Math.ceil(F.length/M),$=F.slice((j-1)*M,j*M),R=q=>{g===q?v(y==="asc"?"desc":"asc"):(p(q),v("asc"))},T=()=>{a(new Set(F.map(q=>q.monitorId)))},k=()=>{a(new Set)},W=async()=>{const q=Array.from(s).map(Q=>c(Q));try{await Promise.all(q),ye.success(`Deleted ${s.size} monitor(s)`),a(new Set),w(!1)}catch{ye.error("Failed to delete some monitors")}};return o?n.jsxs("div",{className:"space-y-4",children:[n.jsx(tt,{className:"h-10 w-full"}),n.jsx("div",{className:"space-y-2",children:[...Array(5)].map((q,Q)=>n.jsx(tt,{className:"h-16 w-full"},Q))})]}):!i||i.length===0?n.jsxs("div",{className:"text-center py-12 border rounded-lg",children:[n.jsx(qt,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),n.jsx("p",{className:"text-muted-foreground",children:"No keyword monitors configured"})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-accent rounded-lg border",children:[n.jsx(ve,{variant:"secondary",className:"font-semibold",children:s.size>0?`${s.size} selected`:"Bulk Actions"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",disabled:s.size===0,onClick:k,children:"Deselect All"}),n.jsxs(H,{variant:"destructive",size:"sm",disabled:s.size===0,onClick:()=>w(!0),children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]}),s.size===0&&n.jsx("div",{className:"text-sm text-muted-foreground ml-auto",children:"Select monitors using checkboxes to perform bulk actions"}),s.size>0&&F.length>s.size&&n.jsx(H,{variant:"outline",size:"sm",onClick:T,className:"ml-auto",children:"Select All"})]}),n.jsx("div",{className:"flex items-center justify-end gap-2",children:n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search by name, URL, or keyword...",value:f,onChange:q=>m(q.target.value),className:"pl-10 w-[300px]"})]})}),n.jsx("div",{className:"border rounded-lg",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:s.size===F.length&&F.length>0,onCheckedChange:q=>{q?T():k()}})}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>R("name"),className:"h-8 px-2",children:["Name",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"URL"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>R("uptime"),className:"h-8 px-2",children:["Uptime (24h)",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"History (3h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:$.map(q=>{const Q=s.has(q.monitorId),ue=t===q.monitorId;return n.jsxs(gt,{className:`cursor-pointer transition-colors ${Q?"bg-muted/50":""} ${ue?"border-l-4 border-l-primary":""}`,onClick:()=>U(q.monitorId),children:[n.jsx(be,{onClick:X=>X.stopPropagation(),children:n.jsx(ct,{checked:Q,onCheckedChange:()=>A(q.monitorId)})}),n.jsx(be,{className:"font-medium",children:q.monitorName}),n.jsx(be,{className:"text-sm text-muted-foreground max-w-xs truncate",children:q.url||"N/A"}),n.jsx(be,{children:n.jsxs("span",{className:q.uptime24h>=99?"text-green-600":q.uptime24h>=95?"text-yellow-600":"text-red-600",children:[q.uptime24h,"%"]})}),n.jsx(be,{onClick:X=>X.stopPropagation(),children:(()=>{var le;const X=D.get(q.monitorId);return X?n.jsx(Ki,{monitoringAgentId:q.monitorId,createdAt:X.created_at,checkInterval:((le=X.monitoring_config)==null?void 0:le.checkInterval)||300}):n.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"})})()}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:q.lastCheckTime?is(new Date(q.last
756CheckTime),{addSuffix:!0}):"Never"})}),n.jsx(be,{className:"text-right",onClick:X=>X.stopPropagation(),children:n.jsx("div",{className:"flex items-center justify-end gap-1",children:(()=>{const X=D.get(q.monitorId);return X?n.jsxs(n.Fragment,{children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>{u(q.monitorId),ye.info("Testing monitor...")},disabled:h,title:"Test Monitor",children:n.jsx(sr,{className:`h-4 w-4 ${h?"animate-spin":""}`})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>S(X),title:"Edit",children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>P(X),className:"text-destructive hover:text-destructive",title:"Delete",children:n.jsx(Vt,{className:"h-4 w-4"})})]}):null})()})})]},q.monitorId)})})]})}),F.length>0&&n.jsxs("div",{className:"flex items-center justify-between mt-4 p-3 bg-muted/50 rounded-lg border",children:[n.jsxs("div",{className:"text-sm font-medium",children:["Showing ",(j-1)*M+1," to ",Math.min(j*M,F.length)," of ",F.length," monitors"]}),L>1&&n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>b(q=>Math.max(1,q-1)),disabled:j===1,children:[n.jsx(zh,{className:"h-4 w-4"}),"Previous"]}),n.jsxs("div",{className:"text-sm font-medium",children:["Page ",j," of ",L]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>b(q=>Math.min(L,q+1)),disabled:j===L,children:["Next",n.jsx(Yo,{className:"h-4 w-4"})]})]})]}),n.jsx(jg,{open:_,onOpenChange:w,count:s.size,onConfirm:W}),n.jsx(er,{open:!!N,onOpenChange:q=>!q&&S(null),children:n.jsx(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:n.jsx(Yq,{open:!!N,onClose:()=>S(null),onBack:()=>S(null),clientId:e,existingAgent:N})})}),n.jsx(Gi,{open:!!C,onOpenChange:q=>!q&&P(null),monitor:C})]})}function UMe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{data:i}=Ve({queryKey:["keyword-agents",e],queryFn:async()=>{const{data:d,error:u}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","keyword").eq("status","active");if(u)throw u;return d||[]}}),o=x.useMemo(()=>!i||i.length===0?null:t&&i.find(d=>d.id===t)||i[0],[i,t]),{data:l}=Ve({queryKey:["keyword-chart-data",o==null?void 0:o.id],queryFn:async()=>{if(!o)return null;const d=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:u,error:h}=await B.from("monitor_checks").select("*").eq("monitor_id",o.id).gte("timestamp",d).order("timestamp",{ascending:!0});if(h)throw h;const f={};u==null||u.forEach(y=>{const v=new Date(y.timestamp).toISOString().slice(0,13);f[v]||(f[v]={success:0,failure:0,responseTime:[]}),y.status==="success"?f[v].success++:f[v].failure++,y.response_time_ms&&f[v].responseTime.push(y.response_time_ms)});const m=Object.entries(f).map(([y,v])=>({time:new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),matching:v.success,mismatches:v.failure})),g=Object.entries(f).filter(([,y])=>y.responseTime.length>0).map(([y,v])=>({time:new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),avgResponseTime:Math.round(v.responseTime.reduce((j,b)=>j+b,0)/v.responseTime.length)})),p=Object.entries(f).map(([y,v])=>{const j=v.success+v.failure;return{time:new Date(y).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),matchRate:j>0?Math.round(v.success/j*100):0}});return{matchStatusData:m,responseTimeData:g,matchRateData:p}},enabled:!!o,refetchInterval:6e4}),c=()=>{a.invalidateQueries({queryKey:["keyword-chart-data",o==null?void 0:o.id]})};return!i||i.length===0?null:n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"Keyword Match Monitoring"}),o&&n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Viewing: ",o.name]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:c,children:n.jsx(sr,{className:"h-4 w-4"})}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>s(!r),children:r?n.jsx(L7,{className:"h-4 w-4"}):n.jsx($7,{className:"h-4 w-4"})})]})]}),r&&l&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"match-status",className:"w-full",children:[n.jsxs(nn,{className:"grid w-full grid-cols-3",children:[n.jsx(at,{value:"match-status",children:"Match Status"}),n.jsx(at,{value:"response-time",children:"Response Time"}),n.jsx(at,{value:"match-rate",children:"Match Rate"})]}),n.jsx(it,{value:"match-status",className:"h-[300px] mt-4",children:n.jsx(gr,{width:"100%",height:"100%",children:n.jsxs(Bp,{data:l.matchStatusData,children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"time"}),n.jsx(Jt,{}),n.jsx(Ot,{}),n.jsx(ko,{}),n.jsx(js,{dataKey:"matching",fill:"hsl(var(--chart-1))",name:"Matching"}),n.jsx(js,{dataKey:"mismatches",fill:"hsl(var(--destructive))",name:"Mismatches"})]})})}),n.jsx(it,{value:"response-time",className:"h-[300px] mt-4",children:n.jsx(gr,{width:"100%",height:"100%",children:n.jsxs(Yr,{data:l.responseTimeData,children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"time"}),n.jsx(Jt,{}),n.jsx(Ot,{}),n.jsx(ko,{}),n.jsx(Qt,{type:"monotone",dataKey:"avgResponseTime",stroke:"hsl(var(--chart-2))",name:"Avg Response Time (ms)",strokeWidth:2})]})})}),n.jsx(it,{value:"match-rate",className:"h-[300px] mt-4",children:n.jsx(gr,{width:"100%",height:"100%",children:n.jsxs(Yr,{data:l.matchRateData,children:[n.jsx(hr,{strokeDasharray:"3 3"}),n.jsx(Zt,{dataKey:"time"}),n.jsx(Jt,{domain:[0,100]}),n.jsx(Ot,{}),n.jsx(ko,{}),n.jsx(Qt,{type:"monotone",dataKey:"matchRate",stroke:"hsl(var(--chart-3))",name:"Match Rate (%)",strokeWidth:2})]})})})]})})]})}function zMe(){var d;const{selectedClientId:e,clientMemberships:t}=Mt(),r=(d=t.find(u=>u.client_id===e))==null?void 0:d.client,[s,a]=x.useState(null),[i,o]=x.useState(new Set),[l,c]=x.useState(!1);return x.useEffect(()=>{const u=h=>{const f=h.target,m=f.closest("[data-monitor-list]"),g=f.closest("[data-monitor-actions]");!m&&!g&&o(new Set)};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[]),r?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Keyword Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor websites for specific keywords and content changes"})]}),n.jsx(IMe,{clientId:r.id}),n.jsx(eo,{clientId:r.id,selectedMonitors:i,onAddMonitor:()=>c(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(FMe,{clientId:r.id,activeMonitorId:s,onActiveMonitorChange:a,selectedMonitors:i,onSelectedMonitorsChange:o})}),n.jsx(UMe,{clientId:r.id,activeMonitorId:s}),l&&n.jsx(jc,{open:l,onClose:()=>c(!1),clientId:r.id,preSelectedType:"keyword"})]}):n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx("p",{className:"text-muted-foreground",children:"Please select a client to view monitors"})})}function i9(e){const{data:t={},isLoading:r}=Ve({queryKey:["smtp-monitor-metrics",e],queryFn:async()=>
756{if(!e)return{};const{data:s}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","smtp").eq("status","active");if(!s||s.length===0)return{};const a=s.map(c=>c.id),i=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:o}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",a).gte("timestamp",i).order("timestamp",{ascending:!1}),l={};return s.forEach(c=>{const d=(o==null?void 0:o.filter(y=>y.monitor_id===c.id))||[];if(d.length===0){l[c.id]={responseTime:null,uptime24h:0,lastCheckTime:null,status:"warning"};return}const u=d[0],h=d.slice(0,10),f=h.filter(y=>y.response_time_ms!==null).reduce((y,v)=>y+(v.response_time_ms||0),0)/(h.filter(y=>y.response_time_ms!==null).length||1),g=d.filter(y=>y.status==="success").length/d.length*100;let p="warning";u.status==="success"?p="online":u.status==="failure"&&(p="offline"),l[c.id]={responseTime:Math.round(f),uptime24h:Math.round(g*100)/100,lastCheckTime:new Date(u.timestamp),status:p}}),l},enabled:!!e,refetchInterval:3e4});return{metrics:t,isLoading:r}}function BMe({clientId:e}){const{agents:t,isLoading:r}=Lt(e),{metrics:s}=i9(e),a=(t==null?void 0:t.filter(o=>o.asset_type==="smtp"))||[],i={total:a.length,online:a.filter(o=>{const l=s[o.id];return o.status==="active"&&(l==null?void 0:l.status)==="online"}).length,offline:a.filter(o=>{const l=s[o.id];return o.status==="active"&&(l==null?void 0:l.status)==="offline"}).length,avgResponseTime:Object.values(s).filter(o=>o.responseTime!==null).reduce((o,l)=>o+(l.responseTime||0),0)/(Object.values(s).filter(o=>o.responseTime!==null).length||1)};return r?n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[...Array(4)].map((o,l)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16"}),n.jsx(tt,{className:"h-3 w-32 mt-2"})]})]},l))}):n.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Total SMTP Monitors"}),n.jsx(Wr,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:i.total}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Active monitors"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Online"}),n.jsx(Tt,{className:"h-4 w-4 text-green-500"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold text-green-500",children:i.online}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.total>0?Math.round(i.online/i.total*100):0,"% of total"]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Offline"}),n.jsx(kn,{className:"h-4 w-4 text-red-500"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold text-red-500",children:i.offline}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[i.total>0?Math.round(i.offline/i.total*100):0,"% of total"]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Avg Response Time"}),n.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsxs("div",{className:"text-2xl font-bold",children:[isNaN(i.avgResponseTime)?"-":Math.round(i.avgResponseTime),!isNaN(i.avgResponseTime)&&n.jsx("span",{className:"text-sm font-normal",children:"ms"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all monitors"})]})]})]})}function qMe({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const[i,o]=x.useState(null),[l,c]=x.useState(new Set),d=t!==void 0?t:i,u=s!==void 0?s:l,h=I=>{r?r(I):o(I)},f=I=>{a?a(I):c(I)}
756,[m,g]=x.useState(""),[p,y]=x.useState("all"),[v,j]=x.useState("all"),[b,_]=x.useState("name-asc"),[w,N]=x.useState(!1),[S,C]=x.useState(1),[P,M]=x.useState(null),[D,A]=x.useState(null),{runSingleMonitorCheck:U,isSingleCheckRunning:F}=Ra(),L=p!=="all"||v!=="all",$=()=>{g(""),y("all"),j("all")},R=5,{agents:T,isLoading:k,toggleAgentStatus:W,deleteAgent:q,isDeleting:Q}=Lt(e),{metrics:ue}=i9(e),X=(T==null?void 0:T.filter(I=>I.asset_type==="smtp"))||[],le=x.useMemo(()=>{const I=new Set;return X.forEach(Y=>{var te;(te=Y.tags)==null||te.forEach(K=>I.add(K))}),Array.from(I).sort()},[X]),pe=x.useMemo(()=>{let I=[...X];return m&&(I=I.filter(Y=>{var te,K;return Y.name.toLowerCase().includes(m.toLowerCase())||((te=Y.description)==null?void 0:te.toLowerCase().includes(m.toLowerCase()))||((K=Y.hostname_or_url)==null?void 0:K.toLowerCase().includes(m.toLowerCase()))})),p!=="all"&&(I=I.filter(Y=>{const te=ue[Y.id];return p==="online"?(te==null?void 0:te.status)==="online":p==="offline"?(te==null?void 0:te.status)==="offline":p==="warning"?(te==null?void 0:te.status)==="warning":!0})),v!=="all"&&(I=I.filter(Y=>{var te;return(te=Y.tags)==null?void 0:te.includes(v)})),I.sort((Y,te)=>{const K=ue[Y.id],Z=ue[te.id];switch(b){case"name-asc":return Y.name.localeCompare(te.name);case"name-desc":return te.name.localeCompare(Y.name);case"status-asc":return((K==null?void 0:K.status)||"warning").localeCompare((Z==null?void 0:Z.status)||"warning");case"status-desc":return((Z==null?void 0:Z.status)||"warning").localeCompare((K==null?void 0:K.status)||"warning");case"uptime-asc":return((K==null?void 0:K.uptime24h)||0)-((Z==null?void 0:Z.uptime24h)||0);case"uptime-desc":return((Z==null?void 0:Z.uptime24h)||0)-((K==null?void 0:K.uptime24h)||0);case"response-asc":return((K==null?void 0:K.responseTime)||0)-((Z==null?void 0:Z.responseTime)||0);case"response-desc":return((Z==null?void 0:Z.responseTime)||0)-((K==null?void 0:K.responseTime)||0);default:return 0}}),I},[X,m,p,v,b,ue]),ce=Math.ceil(pe.length/R),se=(S-1)*R,oe=se+R,V=pe.slice(se,oe);x.useEffect(()=>{C(1)},[m,p,v,b]);const fe=I=>{h(I),ne(I)},ne=I=>{const Y=new Set(u);Y.has(I)?Y.delete(I):Y.add(I),f(Y)},Ce=I=>{f(I?new Set(V.map(Y=>Y.id)):new Set)},Pe=I=>{A(I)},he=I=>{M(I)},ke=()=>{let I=0;for(const Y of Array.from(u)){const te=X.find(K=>K.id===Y);(te==null?void 0:te.status)==="active"&&(W(te),I++)}I>0&&ye.success(`Pausing ${I} monitor(s)`)},Me=()=>{let I=0;for(const Y of Array.from(u)){const te=X.find(K=>K.id===Y);(te==null?void 0:te.status)==="suspended"&&(W(te),I++)}I>0&&ye.success(`Resuming ${I} monitor(s)`)},Je=()=>{const I=X.filter(K=>u.has(K.id)),Y=I.filter(K=>K.status==="active").length,te=I.filter(K=>K.status==="suspended").length;Y>=te?ke():(Me(),f(new Set))},Ke=x.useMemo(()=>{const I=X.filter(K=>u.has(K.id)),Y=I.filter(K=>K.status==="active").length,te=I.filter(K=>K.status==="suspended").length;return Y>=te},[X,u]),E=async()=>{const I=Array.from(u);for(const Y of I)await q(Y);f(new Set),ye.success(`Deleted ${I.length} monitor(s)`)},O=async I=>{try{await U(I.id),ye.success(`Test initiated for ${I.name}`)}catch{ye.error("Failed to run test")}};return k?n.jsx("div",{className:"space-y-4",children:[...Array(3)].map((I,Y)=>n.jsx(tt,{className:"h-20 w-full"},Y))}):n.jsxs("div",{"data-monitor-list":!0,children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[u.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:Je,disabled:u.size===0,children:Ke?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:E,disabled:u.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:m,onChange:I=>g(I.target.value),className:"pl-8"})]}),n.jsx(ur,{open:w,onOpenChange:N,children:n.jsx(Jr,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"icon",children:n.jsx(Ui,{className:"h-4 w-4"})})})}),L&&n.jsxs(H,{variant:"ghost",size:"sm",onClick:$,children:[n.jsx(vn,{className:"h-4 w-4 mr-1"}),"Clear"]})]}),n.jsx(ur,{open:w,children:n.jsx(Er,{className:"space-y-3",children:n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Status"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Statuses"}),n.jsx(J,{value:"online",children:"Online"}),n.jsx(J,{value:"offline",children:"Offline"}),n.jsx(J,{value:"warning",children:"Warning"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Tags"}),n.jsxs(Fe,{value:v,onValueChange:j,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),le.map(I=>n.jsx(J,{value:I,children:I},I))]})]})]})]})})})]})}),n.jsxs(re,{children:[n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:u.size===V.length&&V.length>0,onCheckedChange:Ce})}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="name-asc"?"name-desc":"name-asc"),children:["Monitor / Domain",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"Connection"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="response-asc"?"response-desc":"response-asc"),children:["Response Time",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="uptime-desc"?"uptime-asc":"uptime-desc"),children:["Uptime (24h)",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"History (3h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:V.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No SMTP monitors found"})}):V.map(I=>{const Y=ue[I.id],te=I.id===d,K=u.has(I.id);
756return n.jsxs(gt,{className:`cursor-pointer hover:bg-muted/50 ${te?"bg-muted":""} ${K?"bg-primary/5":""}`,onClick:()=>fe(I.id),children:[n.jsx(be,{onClick:Z=>Z.stopPropagation(),children:n.jsx(ct,{checked:K,onCheckedChange:()=>ne(I.id)})}),n.jsx(be,{children:n.jsx(gf,{monitoringAgentId:I.id,agentStatus:I.status})}),n.jsx(be,{children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"font-medium",children:I.name}),n.jsx("div",{className:"text-sm text-muted-foreground",children:I.hostname_or_url||"N/A"}),I.tags&&I.tags.length>0&&n.jsx("div",{className:"flex gap-1 flex-wrap",children:I.tags.map(Z=>n.jsx(ve,{variant:"outline",className:"text-xs",children:Z},Z))})]})}),n.jsx(be,{children:(Y==null?void 0:Y.status)==="online"?n.jsx(ve,{variant:"outline",className:"bg-green-500/10 text-green-500 border-green-500/20",children:"Connected"}):(Y==null?void 0:Y.status)==="offline"?n.jsx(ve,{variant:"outline",className:"bg-red-500/10 text-red-500 border-red-500/20",children:"Failed"}):n.jsx(ve,{variant:"outline",children:"Unknown"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm",children:(Y==null?void 0:Y.responseTime)!==null?`${Y==null?void 0:Y.responseTime}ms`:"-"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm font-medium",children:(Y==null?void 0:Y.uptime24h)!==void 0?`${Y.uptime24h.toFixed(2)}%`:"-"})}),n.jsx(be,{children:n.jsx(Ki,{monitoringAgentId:I.id,createdAt:I.created_at})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:Y!=null&&Y.lastCheckTime?is(Y.lastCheckTime,{addSuffix:!0}):"Never"})}),n.jsx(be,{className:"text-right",onClick:Z=>Z.stopPropagation(),children:n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>O(I),disabled:F,children:n.jsx(sr,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>W(I),children:I.status==="active"?n.jsx(ia,{className:"h-4 w-4"}):n.jsx(qs,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>Pe(I),children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>he(I),children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},I.id)})})]}),ce>1&&n.jsx("div",{className:"mt-4",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>C(I=>Math.max(1,I-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(ce)].map((I,Y)=>n.jsx(wt,{children:n.jsx(ss,{onClick:()=>C(Y+1),isActive:S===Y+1,className:"cursor-pointer",children:Y+1})},Y)),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>C(I=>Math.min(ce,I+1)),className:S===ce?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]}),n.jsx(Gi,{monitor:P,open:!!P,onOpenChange:I=>!I&&M(null)}),n.jsx(er,{open:!!D,onOpenChange:I=>!I&&A(null),children:n.jsx(Kt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:n.jsx($2,{clientId:e,open:!!D,onClose:()=>A(null),onBack:()=>A(null),existingAgent:D})})})]})}const Ex=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))"];function WMe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{agents:i}=Lt(e),o=(i==null?void 0:i.filter(g=>g.asset_type==="smtp"))||[],l=x.useMemo(()=>t?o.find(g=>g.id===t):o[0],[o,t]),{checks:c,isLoading:d}=mc(l==null?void 0:l.id,50),u=x.useMemo(()=>!c||c.length===0?[]:c.filter(g=>g.response_time_ms!==null).slice(0,20).reverse().map(g=>({time:new Date(g.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),responseTime:g.response_time_ms})),[c]),h=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length&&p.length<10;v+=g){const j=y.slice(v,v+g),b=j.filter(S=>S.status==="success").length,_=j.filter(S=>S.status==="failed"||S.status==="error").length,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,success:b,failed:_})}return p},[c]),f=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length;v+=g){const j=y.slice(v,v+g),_=j.filter(S=>S.status==="success").length/j.length*100,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,uptime:parseFloat(_.toFixed(2))})}return p},[c]),m=()=>{l&&a.invalidateQueries({queryKey:["monitor-checks",l.id]})};return!l||!c||c.length===0?null:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"SMTP Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:l.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:m,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),n.jsx(re,{children:n.jsxs(cn,{defaultValue:"response-time",className:"w-full",children:[n.jsxs(nn,{className:"grid w-full grid-cols-3",children:[n.jsx(at,{value:"response-time",children:"Response Time"}),n.jsx(at,{value:"status",children:"Check Status"}),n.jsx(at,{value:"uptime",children:"Uptime %"})]}),n.jsx(it,{value:"response-time",className:"space-y-4",children:n.jsx("div",{style:{height:r?"400px":"250px"},children:n.jsx(gr,{width:"100%",height:"100%",children:n.jsxs(Yr,{data:u,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"ms",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}}),n.jsx(Qt,{type:"monotone",dataKey:"responseTime",stroke:Ex[0],strokeWidth:2,dot:{fill:Ex[0]},name:"Response Time (ms)"})]})})})}),n.jsx(it,{value:"status",className:"space-y-4",children:n.jsx("div",{style:{height:r?"400px":"250px"},children:n.jsx(gr,{width:"100%",height:"100%",children:n.jsxs(Yr,{data:h,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Count",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}}),n.jsx(Qt,{type:"monotone",dataKey:"success",stroke:"hsl(var(--chart-2))",strokeWidth:2,dot:{fill:"hsl(var(--chart-2))"},name:"Successful"}),n.jsx(Qt,{type:"monotone",dataKey:"failed",stroke:"hsl(var(--destructive))",strokeWidth:2,dot:{fill:"hsl(var(--destructive))"},name:"Failed"})]})})})}),n.jsx(it,{value:"uptime",className:"space-y-4",children:n.jsx("div",{style:{height:r?"400px":"250px"},children:n.jsx(gr,{width:"100%",height:"100%",children:n.jsxs(Yr,{data:f,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},domain:[0,100],label:{value:"%",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",borderRadius:"6px"}}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:Ex[1],strokeWidth:2,dot:{fill:Ex[1]},name:"Uptime %"})]})})})})]})})]})}function HMe(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(!1),[s,a]=x.useState(null),[i,o]=x.useState(new Set);return x.useEffect(()=>{const l=c=>{const d=c.target,u=d.closest("[data-monitor-list]"),h=d.closest("[data-monitor-actions]");!u&&!h&&o(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"SMTP Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor SMTP server availability and authentication"})]})}),n.jsx(BMe,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:i,onAddMonitor:()=>r(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(qMe,{clientId:e,activeMonitorId:s,onActiveMonitorChange:a,selectedMonitors:i,onSelectionChange:o})}),n.jsx(WMe,{clientId:e,activeMonitorId:s}),n.jsx(er,{open:t,onOpenChange:r,children:n.jsx(Kt,{className:"max-w-3xl max-h-[90vh] overflow-y-auto",children:n.jsx($2,{clientId:e,open:t,onClose:()=>r(!1),onBack:()=>r(!1)})})})]}):n.jsx("div",{className:"flex items-center justify-center h-64",children:n.jsx("p",{className:"text-muted-foreground",children:"Please select a client to view monitors"})})}function VMe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["ftp-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","ftp").eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const{data:o,error:l}=await B.from("monitors").select("id").in("monitoring_agent_id",a.map($=>$.id));if(l)throw l;if(!o||o.length===0)return{total:a.length,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const c=o.map($=>$.id),d=new Date,u=new Date(d.getTime()-24*60*60*1e3),h=new Date(d.getTime()-7*24*60*60*1e3),f=new Date(d.getTime()-30*24*60*60*1e3),{data:m,error:g}=await B.from("monitor_checks").select("*").in("monitor_id",c).order("timestamp",{ascending:!1}).limit(c.length*5);if(g)throw g;const{data:p,error:y}=await B.from("monitor_checks").select("status, response_time_ms").in("monitor_id",c).gte("timestamp",u.toISOString()),{data:v,error:j}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",h.toISOString()),{data:b,error:_}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",f.toISOString());if(y||j||_)throw y||j||_;const w=new Map;m==null||m.forEach($=>{(!w.has($.monitor_id)||new Date($.timestamp)>new Date(w.get($.monitor_id).timestamp))&&w.set($.monitor_id,$)});let N=0,S=0,C=0,P=0;w.forEach($=>{$.status==="success"?N++:$.status==="failed"||$.status==="error"?S++:C++,$.response_time_ms!==null&&(P+=$.response_time_ms)});const M=(p==null?void 0:p.filter($=>$.response_time_ms!==null))||[],D=M.length>0?Math.round(M.reduce(($,R)=>$+(R.response_time_ms||0),0)/M.length):0,A=p&&p.length>0?p.filter($=>$.status==="success").length/p.length*100:100,U=v&&v.length>0?v.filter($=>$.status==="success").length/v.length*100:100,F=b&&b.length>0?b.filter($=>$.status==="success").length/b.length*100:100,L=(p==null?void 0:p.filter($=>$.status==="failed").length)||0;return{total:a.length,online:N,offline:S,warning:C,avgResponseTime:D,uptime24h:Math.round(A*100)/100,uptime7d:Math.round(U*100)/100,uptime30d:Math.round(F*100)/100,recentIncidents:L}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function KMe({clientId:e}){const{stats:t,isLoading:r}=VMe(e);if(r)return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[...Array(8)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-2"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total FTP Monitors",value:t.total,description:"Active monitors",icon:yt,color:"text-blue-500"},{title:"Online",value:t.online,description:"Connected successfully",icon:Tt,color:"text-green-500"},{title:"Offline",value:t.offline,description:"Connection failed",icon:kn,color:"text-red-500"}
756,{title:"Warning",value:t.warning,description:"Degraded performance",icon:kn,color:"text-yellow-500"},{title:"Avg Response Time",value:`${t.avgResponseTime}ms`,description:"Average connection time",icon:Xt,color:"text-purple-500"},{title:"24h Uptime",value:`${t.uptime24h.toFixed(2)}%`,description:"Last 24 hours",icon:Wr,color:t.uptime24h>=99?"text-green-500":t.uptime24h>=95?"text-yellow-500":"text-red-500"},{title:"7d Uptime",value:`${t.uptime7d.toFixed(2)}%`,description:"Last 7 days",icon:Bi,color:t.uptime7d>=99?"text-green-500":t.uptime7d>=95?"text-yellow-500":"text-red-500"},{title:"Recent Incidents",value:t.recentIncidents,description:"Last 24 hours",icon:S0,color:t.recentIncidents===0?"text-green-500":t.recentIncidents<5?"text-yellow-500":"text-red-500"}];return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:s.map((a,i)=>{const o=a.icon;return n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(o,{className:`h-4 w-4 ${a.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]},i)})})}function GMe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["ftp-monitor-metrics",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","ftp").eq("status","active");if(i)throw i;if(!a||a.length===0)return[];const o=a.map(g=>g.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",o);if(c)throw c;if(!l||l.length===0)return[];const d=l.map(g=>g.id),u=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:h,error:f}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",d).gte("timestamp",u).order("timestamp",{ascending:!1});if(f)throw f;const m=new Map;return l.forEach(g=>{const p=(h==null?void 0:h.filter(N=>N.monitor_id===g.id))||[],y=p.find(N=>N.response_time_ms!==null),v=(y==null?void 0:y.response_time_ms)||null,j=p.filter(N=>N.status==="success").length,b=p.length>0?Math.round(j/p.length*1e4)/100:100,_=p.length>0?p[0].timestamp:null,w=p.length>0?p[0].status:null;m.set(g.monitoring_agent_id,{monitorId:g.id,agentId:g.monitoring_agent_id,responseTime:v,uptime24h:b,lastCheckTime:_,lastStatus:w})}),Array.from(m.values())},enabled:!!e,refetchInterval:6e4});return{metrics:t||[],isLoading:r,error:(s==null?void 0:s.message)||null}}function YMe({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const[i,o]=x.useState(null),[l,c]=x.useState(new Set),d=t!==void 0?t:i,u=s!==void 0?s:l,h=E=>{r?r(E):o(E)},f=E=>{a?a(E):c(E)},[m,g]=x.useState(""),[p,y]=x.useState("all"),[v,j]=x.useState("all"),[b,_]=x.useState("name-asc"),[w,N]=x.useState(!1),[S,C]=x.useState(1),[P,M]=x.useState(null),[D,A]=x.useState(null),{runSingleMonitorCheck:U,isSingleCheckRunning:F}=Ra(),L=5,{agents:$,isLoading:R,toggleAgentStatus:T,deleteAgent:k,isDeleting:W}=Lt(e),{metrics:q}=GMe(e),Q=($==null?void 0:$.filter(E=>E.asset_type==="ftp"))||[],ue=x.useMemo(()=>{const E=new Set;return Q.forEach(O=>{var I;(I=O.tags)==null||I.forEach(Y=>E.add(Y))}),Array.from(E).sort()},[Q]),X=x.useMemo(()=>Q.filter(E=>{var O;if(m){const I=m.toLowerCase(),Y=E.name.toLowerCase().includes(I),te=(O=E.hostname_or_url)==null?void 0:O.toLowerCase().includes(I);if(!Y&&!te)return!1}return!(p!=="all"&&E.status!==p||v!=="all"&&(!E.tags||!E.tags.includes(v)))}),[Q,m,p,v]),le=x.useMemo(()=>{const E=[...X];return E.sort((O,I)=>{var Y,te,K,Z,je,_e,Ee,Ze;switch(b){case"name-asc":return O.name.localeCompare(I.name);case"name-desc":return I.name.localeCompare(O.name);case"response-time-asc":const st=q.find(ze=>ze.agentId===O.id),xt=q.find(ze=>ze.agentId===I.id);return((st==null?void 0:st.responseTime)??999999)-((xt==null?void 0:xt.responseTime)??999999);case"response-time-desc":const Dt=q.find(ze=>ze.agentId===O.id),xe=q.find(ze=>ze.agentId===I.id);return((xe==null?void 0:xe.responseTime)??0)-((Dt==null?void 0:Dt.responseTime)??0);case"uptime-desc":const qe=((Y=q.find(ze=>ze.agentId===O.id))==null?void 0:Y.uptime24h)??100;return(((te=q.find(ze=>ze.agentId===I.id))==null?void 0:te.uptime24h)??100)-qe;case"uptime-asc":const Pr=((K=q.find(ze=>ze.agentId===O.id))==null?void 0:K.uptime24h)??100,wn=((Z=q.find(ze=>ze.agentId===I.id))==null?void 0:Z.uptime24h)??100;return Pr-wn;case"last-check-desc":const An=(je=q.find(ze=>
756ze.agentId===O.id))==null?void 0:je.lastCheckTime,En=(_e=q.find(ze=>ze.agentId===I.id))==null?void 0:_e.lastCheckTime;return An?En?new Date(En).getTime()-new Date(An).getTime():-1:1;case"last-check-asc":const ls=(Ee=q.find(ze=>ze.agentId===O.id))==null?void 0:Ee.lastCheckTime,cs=(Ze=q.find(ze=>ze.agentId===I.id))==null?void 0:Ze.lastCheckTime;return ls?cs?new Date(ls).getTime()-new Date(cs).getTime():-1:1;default:return 0}}),E},[X,b,q]),pe=Math.ceil(le.length/L),ce=(S-1)*L,se=ce+L,oe=le.slice(ce,se);x.useEffect(()=>{C(1)},[m,p,v,b]),x.useEffect(()=>{S>pe&&pe>0&&C(pe)},[S,pe]);const V=p!=="all"||v!=="all",fe=()=>{g(""),y("all"),j("all")};x.useEffect(()=>{const E=O=>{const I=O.target,Y=I.closest("[data-monitor-list]"),te=I.closest("[data-monitor-actions]");!Y&&!te&&f(new Set)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const ne=E=>{h(E),Ce(E)},Ce=E=>{const O=new Set(u);O.has(E)?O.delete(E):O.add(E),f(O)},Pe=()=>{if(u.size===oe.length&&oe.every(E=>u.has(E.id))){const E=new Set(u);oe.forEach(O=>E.delete(O.id)),f(E)}else{const E=new Set(u);oe.forEach(O=>E.add(O.id)),f(E)}},he=()=>{let E=0;for(const O of Array.from(u)){const I=Q.find(Y=>Y.id===O);(I==null?void 0:I.status)==="active"&&(T(I),E++)}E>0&&ye.success(`Pausing ${E} monitor(s)`)},ke=()=>{let E=0;for(const O of Array.from(u)){const I=Q.find(Y=>Y.id===O);(I==null?void 0:I.status)==="suspended"&&(T(I),E++)}E>0&&ye.success(`Resuming ${E} monitor(s)`)},Me=()=>{const E=Q.filter(Y=>u.has(Y.id)),O=E.filter(Y=>Y.status==="active").length,I=E.filter(Y=>Y.status==="suspended").length;O>=I?he():(ke(),f(new Set))},Je=x.useMemo(()=>{const E=Q.filter(Y=>u.has(Y.id)),O=E.filter(Y=>Y.status==="active").length,I=E.filter(Y=>Y.status==="suspended").length;return O>=I},[Q,u]),Ke=async()=>{const E=Array.from(u);for(const O of E)await k(O);f(new Set)};return R?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((E,O)=>n.jsx(tt,{className:"h-16 w-full"},O))})})]}):n.jsxs("div",{"data-monitor-list":!0,children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[u.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:Me,disabled:u.size===0,children:Je?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:Ke,disabled:u.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:m,onChange:E=>g(E.target.value),className:"pl-8"})]}),n.jsx(ur,{open:w,onOpenChange:N,children:n.jsx(Jr,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"icon",children:n.jsx(Ui,{className:"h-4 w-4"})})})}),V&&n.jsxs(H,{variant:"ghost",size:"sm",onClick:fe,children:[n.jsx(vn,{className:"h-4 w-4 mr-1"}),"Clear"]})]}),n.jsx(ur,{open:w,children:n.jsx(Er,{className:"space-y-3",children:n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Status"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Statuses"}),n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"suspended",children:"Suspended"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Tags"}),n.jsxs(Fe,{value:v,onValueChange:j,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),ue.map(E=>n.jsx(J,{value:E,children:E},E))]})]})]})]})})})]})}),n.jsxs(re,{children:[n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:oe.length>0&&oe.every(E=>
756u.has(E.id)),onCheckedChange:Pe})}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="name-asc"?"name-desc":"name-asc"),children:["Monitor / Host",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"Connection"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="response-time-asc"?"response-time-desc":"response-time-asc"),children:["Response Time",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="uptime-desc"?"uptime-asc":"uptime-desc"),children:["Uptime (24h)",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"History (3h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:oe.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No FTP monitors found"})}):oe.map(E=>{const O=q.find(te=>te.agentId===E.id),I=E.id===d,Y=u.has(E.id);return n.jsxs(gt,{className:`cursor-pointer hover:bg-muted/50 ${I?"bg-muted":""} ${Y?"bg-primary/5":""}`,onClick:()=>ne(E.id),children:[n.jsx(be,{onClick:te=>te.stopPropagation(),children:n.jsx(ct,{checked:Y,onCheckedChange:()=>Ce(E.id)})}),n.jsx(be,{children:n.jsx(gf,{monitoringAgentId:E.id,agentStatus:E.status})}),n.jsx(be,{children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"font-medium",children:E.name}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:[E.hostname_or_url,":",E.port||21]}),E.tags&&E.tags.length>0&&n.jsx("div",{className:"flex gap-1 flex-wrap",children:E.tags.map(te=>n.jsx(ve,{variant:"outline",className:"text-xs",children:te},te))})]})}),n.jsx(be,{children:(O==null?void 0:O.lastStatus)==="success"?n.jsx(ve,{variant:"outline",className:"bg-green-500/10 text-green-500 border-green-500/20",children:"Connected"}):(O==null?void 0:O.lastStatus)==="failed"?n.jsx(ve,{variant:"outline",className:"bg-red-500/10 text-red-500 border-red-500/20",children:"Failed"}):n.jsx(ve,{variant:"outline",children:"Unknown"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm",children:(O==null?void 0:O.responseTime)!==null?`${O==null?void 0:O.responseTime}ms`:"-"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm font-medium",children:(O==null?void 0:O.uptime24h)!==void 0?`${O.uptime24h.toFixed(2)}%`:"-"})}),n.jsx(be,{children:O!=null&&O.monitorId?n.jsx(Ki,{monitoringAgentId:E.id,createdAt:E.created_at}):n.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:O!=null&&O.lastCheckTime?is(new Date(O.lastCheckTime),{addSuffix:!0}):"Never"})}),n.jsx(be,{className:"text-right",onClick:te=>te.stopPropagation(),children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>(O==null?void 0:O.monitorId)&&U(O.monitorId),disabled:!(O!=null&&O.monitorId)||F,title:"Test/Refresh",children:n.jsx(sr,{className:`h-4 w-4 ${F?"animate-spin":""}`})}),n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>A(E),title:"Edit",children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>M(E),title:"Delete",children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},E.id)})})]}),pe>1&&n.jsx("div",{className:"mt-4",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>C(E=>Math.max(1,E-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(pe)].map((E,O)=>{const I=O+1;return I===1||I===pe||I>=S-1&&I<=S+1?n.jsx(wt,{children:n.jsx(ss,{onClick:()=>C(I),isActive:S===I,className:"cursor-pointer",children:I})},I):I===S-2||I===S+2?n.jsx(wt,{children:n.jsx(qo,{})},I):null}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>C(E=>Math.min(pe,E+1)),className:S===pe?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]}),n.jsx(Gi,{monitor:P,open:!!P,onOpenChange:E=>!E&&M(null)}),n.jsx(er,{open:!!D,onOpenChange:E=>!E&&A(null),children:n.jsx(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:n.jsx(Qq,{open:!!D,onClose:()=>A(null),onBack:()=>A(null),clientId:e,existingAgent:D})})})]})}const aD=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))"];function QMe({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{agents:i}=Lt(e),o=(i==null?void 0:i.filter(g=>g.asset_type==="ftp"))||[],l=x.useMemo(()=>t?o.find(g=>g.id===t):o[0],[o,t]),{checks:c,isLoading:d}=mc(l==null?void 0:l.id,50),u=x.useMemo(()=>!c||c.length===0?[]:c.filter(g=>g.response_time_ms!==null).slice(0,20).reverse().map(g=>({time:new Date(g.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),responseTime:g.response_time_ms})),[c]),h=x.useMemo(()=>
756{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length&&p.length<10;v+=g){const j=y.slice(v,v+g),b=j.filter(S=>S.status==="success").length,_=j.filter(S=>S.status==="failed"||S.status==="error").length,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,success:b,failed:_})}return p},[c]),f=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length;v+=g){const j=y.slice(v,v+g),_=j.filter(S=>S.status==="success").length/j.length*100,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,uptime:parseFloat(_.toFixed(2))})}return p},[c]),m=()=>{l&&a.invalidateQueries({queryKey:["monitor-checks",l.id]})};return!l||!c||c.length===0?null:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"FTP Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:l.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:m,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"response-time",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsx(at,{value:"response-time",children:"Response Time"}),n.jsx(at,{value:"check-status",children:"Check Status"}),n.jsx(at,{value:"uptime",children:"Uptime"})]}),n.jsx(it,{value:"response-time",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:u,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Response Time (ms)",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"responseTime",stroke:aD[0],strokeWidth:2,dot:{fill:aD[0]},name:"Response Time"})]})})}),n.jsxs(it,{value:"check-status",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"FTP check status over time (grouped by 5 checks)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:h,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Check Count",angle:-90,position:"insideLeft"},allowDecimals:!1}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"success",stroke:"hsl(var(--green))",strokeWidth:2,dot:{fill:"hsl(var(--green))"},name:"Successful Checks"}),n.jsx(Qt,{type:"monotone",dataKey:"failed",stroke:"hsl(var(--destructive))",strokeWidth:2,dot:{fill:"hsl(var(--destructive))"},name:"Failed Checks"})]})})]}),n.jsxs(it,{value:"uptime",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Check success rate trend based on last 50 checks (grouped)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:f,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Uptime (%)",angle:-90,position:"insideLeft"},domain:[0,100]}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:g=>`${g}%`}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"},name:"Uptime"})]})})]})]})})]})}function XMe(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(null),[s,a]=x.useState(new Set),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=c=>{const d=c.target,u=d.closest("[data-monitor-list]"),h=d.closest("[data-monitor-actions]");!u&&!h&&a(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"FTP Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor FTP server availability and authentication"})]}),n.jsx(KMe,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(YMe,{clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a})}),n.jsx(QMe,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"ftp"})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"FTP Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor FTP server availability and authentication"})]}),n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Please select a client to view FTP monitors"})]})}function ZMe(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["sftp-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","sftp").eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const{data:o,error:l}=await B.from("monitors").select("id").in("monitoring_agent_id",a.map(L=>L.id));if(l)throw l;if(!o||o.length===0)return{total:a.length,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const c=o.map(L=>L.id),d=new Date,u=new Date(d.getTime()-24*60*60*1e3),h=new Date(d.getTime()-7*24*60*60*1e3),f=new Date(d.getTime()-30*24*60*60*1e3),{data:m,error:g}=await B.from("monitor_checks").select("*").in("monitor_id",c).order("timestamp",{ascending:!1}).limit(c.length*5);if(g)throw g;const{data:p,error:y}=await B.from("monitor_checks").select("status, response_time_ms").in("monitor_id",c).gte("timestamp",u.toISOString()),{data:v,error:j}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",h.toISOString()),{data:b,error:_}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",f.toISOString());if(y||j||_)throw y||j||_;const w=new Map;m==null||m.forEach(L=>{(!w.has(L.monitor_id)||new Date(L.timestamp)>new Date(w.get(L.monitor_id).timestamp))&&w.set(L.monitor_id,L)});let N=0,S=0,C=0;w.forEach(L=>{L.status==="success"?N++:L.status==="failed"||L.status==="error"?S++:C++});const P=(p==null?void 0:p.filter(L=>L.response_time_ms!==null))||[],M=P.length>0?Math.round(P.reduce((L,$)=>L+($.response_time_ms||0),0)/P.length):0,D=p&&p.length>0?p.filter(L=>L.status==="success").length/p.length*100:100,A=v&&v.length>0?v.filter(L=>L.status==="success").length/v.length*100:100,U=b&&b.length>0?b.filter(L=>L.status==="success").length/b.length*100:100,F=(p==null?void 0:p.filter(L=>L.status==="failed").length)||0;return{total:a.length,online:N,offline:S,warning:C,avgResponseTime:M,uptime24h:Math.round(D*100)/100,uptime7d:Math.round(A*100)/100,uptime30d:Math.round(U*100)/100,recentIncidents:F}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function JMe({clientId:e}){const{stats:t,isLoading:r}=ZMe(e);if(r)return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[...Array(8)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-2"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total SFTP Monitors",value:t.total,description:"Active monitors",icon:yt,color:"text-blue-500"},{title:"Online",value:t.online,description:"Connected successfully",icon:Tt,color:"text-green-500"},{title:"Offline",value:t.offline,description:"Connection failed",icon:kn,color:"text-red-500"}
756,{title:"Warning",value:t.warning,description:"Degraded performance",icon:kn,color:"text-yellow-500"},{title:"Avg Response Time",value:`${t.avgResponseTime}ms`,description:"Average connection time",icon:Xt,color:"text-purple-500"},{title:"24h Uptime",value:`${t.uptime24h.toFixed(2)}%`,description:"Last 24 hours",icon:Wr,color:t.uptime24h>=99?"text-green-500":t.uptime24h>=95?"text-yellow-500":"text-red-500"},{title:"7d Uptime",value:`${t.uptime7d.toFixed(2)}%`,description:"Last 7 days",icon:Bi,color:t.uptime7d>=99?"text-green-500":t.uptime7d>=95?"text-yellow-500":"text-red-500"},{title:"Recent Incidents",value:t.recentIncidents,description:"Last 24 hours",icon:S0,color:t.recentIncidents===0?"text-green-500":t.recentIncidents<5?"text-yellow-500":"text-red-500"}];return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:s.map((a,i)=>{const o=a.icon;return n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(o,{className:`h-4 w-4 ${a.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]},i)})})}function e4e(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["sftp-monitor-metrics",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","sftp").eq("status","active");if(i)throw i;if(!a||a.length===0)return[];const o=a.map(g=>g.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",o);if(c)throw c;if(!l||l.length===0)return[];const d=l.map(g=>g.id),u=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:h,error:f}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",d).gte("timestamp",u).order("timestamp",{ascending:!1});if(f)throw f;const m=new Map;return l.forEach(g=>{const p=(h==null?void 0:h.filter(N=>N.monitor_id===g.id))||[],y=p.find(N=>N.response_time_ms!==null),v=(y==null?void 0:y.response_time_ms)||null,j=p.filter(N=>N.status==="success").length,b=p.length>0?Math.round(j/p.length*1e4)/100:100,_=p.length>0?p[0].timestamp:null,w=p.length>0?p[0].status:null;m.set(g.monitoring_agent_id,{monitorId:g.id,agentId:g.monitoring_agent_id,responseTime:v,uptime24h:b,lastCheckTime:_,lastStatus:w})}),Array.from(m.values())},enabled:!!e,refetchInterval:6e4});return{metrics:t||[],isLoading:r,error:(s==null?void 0:s.message)||null}}function t4e({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const[i,o]=x.useState(null),[l,c]=x.useState(new Set),d=t!==void 0?t:i,u=s!==void 0?s:l,h=E=>{r?r(E):o(E)},f=E=>{a?a(E):c(E)},[m,g]=x.useState(""),[p,y]=x.useState("all"),[v,j]=x.useState("all"),[b,_]=x.useState("name-asc"),[w,N]=x.useState(!1),[S,C]=x.useState(1),[P,M]=x.useState(null),[D,A]=x.useState(null),{runSingleMonitorCheck:U,isSingleCheckRunning:F}=Ra(),L=5,{agents:$,isLoading:R,toggleAgentStatus:T,deleteAgent:k,isDeleting:W}=Lt(e),{metrics:q}=e4e(e),Q=($==null?void 0:$.filter(E=>E.asset_type==="sftp"))||[],ue=x.useMemo(()=>{const E=new Set;return Q.forEach(O=>{var I;(I=O.tags)==null||I.forEach(Y=>E.add(Y))}),Array.from(E).sort()},[Q]),X=x.useMemo(()=>Q.filter(E=>{var O;if(m){const I=m.toLowerCase(),Y=E.name.toLowerCase().includes(I),te=(O=E.hostname_or_url)==null?void 0:O.toLowerCase().includes(I);if(!Y&&!te)return!1}return!(p!=="all"&&E.status!==p||v!=="all"&&(!E.tags||!E.tags.includes(v)))}),[Q,m,p,v]),le=x.useMemo(()=>{const E=[...X];return E.sort((O,I)=>{var Y,te,K,Z,je,_e,Ee,Ze;switch(b){case"name-asc":return O.name.localeCompare(I.name);case"name-desc":return I.name.localeCompare(O.name);case"response-time-asc":const st=q.find(ze=>ze.agentId===O.id),xt=q.find(ze=>ze.agentId===I.id);return((st==null?void 0:st.responseTime)??999999)-((xt==null?void 0:xt.responseTime)??999999);case"response-time-desc":const Dt=q.find(ze=>ze.agentId===O.id),xe=q.find(ze=>ze.agentId===I.id);return((xe==null?void 0:xe.responseTime)??0)-((Dt==null?void 0:Dt.responseTime)??0);case"uptime-desc":const qe=((Y=q.find(ze=>ze.agentId===O.id))==null?void 0:Y.uptime24h)??100;return(((te=q.find(ze=>ze.agentId===I.id))==null?void 0:te.uptime24h)??100)-qe;case"uptime-asc":const Pr=((K=q.find(ze=>ze.agentId===O.id))==null?void 0:K.uptime24h)??100,wn=((Z=q.find(ze=>ze.agentId===I.id))==null?void 0:Z.uptime24h)??100;return Pr-wn;case"last-check-desc":const An=(je=q.find(ze=>
756ze.agentId===O.id))==null?void 0:je.lastCheckTime,En=(_e=q.find(ze=>ze.agentId===I.id))==null?void 0:_e.lastCheckTime;return An?En?new Date(En).getTime()-new Date(An).getTime():-1:1;case"last-check-asc":const ls=(Ee=q.find(ze=>ze.agentId===O.id))==null?void 0:Ee.lastCheckTime,cs=(Ze=q.find(ze=>ze.agentId===I.id))==null?void 0:Ze.lastCheckTime;return ls?cs?new Date(ls).getTime()-new Date(cs).getTime():-1:1;default:return 0}}),E},[X,b,q]),pe=Math.ceil(le.length/L),ce=(S-1)*L,se=ce+L,oe=le.slice(ce,se);x.useEffect(()=>{C(1)},[m,p,v,b]),x.useEffect(()=>{S>pe&&pe>0&&C(pe)},[S,pe]);const V=p!=="all"||v!=="all",fe=()=>{g(""),y("all"),j("all")};x.useEffect(()=>{const E=O=>{const I=O.target,Y=I.closest("[data-monitor-list]"),te=I.closest("[data-monitor-actions]");!Y&&!te&&f(new Set)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const ne=E=>{h(E),Ce(E)},Ce=E=>{const O=new Set(u);O.has(E)?O.delete(E):O.add(E),f(O)},Pe=()=>{if(u.size===oe.length&&oe.every(E=>u.has(E.id))){const E=new Set(u);oe.forEach(O=>E.delete(O.id)),f(E)}else{const E=new Set(u);oe.forEach(O=>E.add(O.id)),f(E)}},he=()=>{let E=0;for(const O of Array.from(u)){const I=Q.find(Y=>Y.id===O);(I==null?void 0:I.status)==="active"&&(T(I),E++)}E>0&&ye.success(`Pausing ${E} monitor(s)`)},ke=()=>{let E=0;for(const O of Array.from(u)){const I=Q.find(Y=>Y.id===O);(I==null?void 0:I.status)==="suspended"&&(T(I),E++)}E>0&&ye.success(`Resuming ${E} monitor(s)`)},Me=()=>{const E=Q.filter(Y=>u.has(Y.id)),O=E.filter(Y=>Y.status==="active").length,I=E.filter(Y=>Y.status==="suspended").length;O>=I?he():(ke(),f(new Set))},Je=x.useMemo(()=>{const E=Q.filter(Y=>u.has(Y.id)),O=E.filter(Y=>Y.status==="active").length,I=E.filter(Y=>Y.status==="suspended").length;return O>=I},[Q,u]),Ke=async()=>{const E=Array.from(u);for(const O of E)await k(O);f(new Set)};return R?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((E,O)=>n.jsx(tt,{className:"h-16 w-full"},O))})})]}):n.jsxs("div",{"data-monitor-list":!0,children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[u.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:Me,disabled:u.size===0,children:Je?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:Ke,disabled:u.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:m,onChange:E=>g(E.target.value),className:"pl-8"})]}),n.jsx(ur,{open:w,onOpenChange:N,children:n.jsx(Jr,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"icon",children:n.jsx(Ui,{className:"h-4 w-4"})})})}),V&&n.jsxs(H,{variant:"ghost",size:"sm",onClick:fe,children:[n.jsx(vn,{className:"h-4 w-4 mr-1"}),"Clear"]})]}),n.jsx(ur,{open:w,children:n.jsx(Er,{className:"space-y-3",children:n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Status"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Statuses"}),n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"suspended",children:"Suspended"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Tags"}),n.jsxs(Fe,{value:v,onValueChange:j,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),ue.map(E=>n.jsx(J,{value:E,children:E},E))]})]})]})]})})})]})}),n.jsxs(re,{children:[n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:oe.length>0&&oe.every(E=>
756u.has(E.id)),onCheckedChange:Pe})}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="name-asc"?"name-desc":"name-asc"),children:["Monitor / Host",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"Connection"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="response-time-asc"?"response-time-desc":"response-time-asc"),children:["Response Time",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="uptime-desc"?"uptime-asc":"uptime-desc"),children:["Uptime (24h)",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"History (3h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:oe.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No SFTP monitors found"})}):oe.map(E=>{const O=q.find(te=>te.agentId===E.id),I=E.id===d,Y=u.has(E.id);return n.jsxs(gt,{className:`cursor-pointer hover:bg-muted/50 ${I?"bg-muted":""} ${Y?"bg-primary/5":""}`,onClick:()=>ne(E.id),children:[n.jsx(be,{onClick:te=>te.stopPropagation(),children:n.jsx(ct,{checked:Y,onCheckedChange:()=>Ce(E.id)})}),n.jsx(be,{children:n.jsx(gf,{monitoringAgentId:E.id,agentStatus:E.status})}),n.jsx(be,{children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"font-medium",children:E.name}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:[E.hostname_or_url,":",E.port||22]}),E.tags&&E.tags.length>0&&n.jsx("div",{className:"flex gap-1 flex-wrap",children:E.tags.map(te=>n.jsx(ve,{variant:"outline",className:"text-xs",children:te},te))})]})}),n.jsx(be,{children:(O==null?void 0:O.lastStatus)==="success"?n.jsx(ve,{variant:"outline",className:"bg-green-500/10 text-green-500 border-green-500/20",children:"Connected"}):(O==null?void 0:O.lastStatus)==="failed"?n.jsx(ve,{variant:"outline",className:"bg-red-500/10 text-red-500 border-red-500/20",children:"Failed"}):n.jsx(ve,{variant:"outline",children:"Unknown"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm",children:(O==null?void 0:O.responseTime)!==null?`${O==null?void 0:O.responseTime}ms`:"-"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm font-medium",children:(O==null?void 0:O.uptime24h)!==void 0?`${O.uptime24h.toFixed(2)}%`:"-"})}),n.jsx(be,{children:O!=null&&O.monitorId?n.jsx(Ki,{monitoringAgentId:E.id,createdAt:E.created_at}):n.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:O!=null&&O.lastCheckTime?is(new Date(O.lastCheckTime),{addSuffix:!0}):"Never"})}),n.jsx(be,{className:"text-right",onClick:te=>te.stopPropagation(),children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>(O==null?void 0:O.monitorId)&&U(O.monitorId),disabled:!(O!=null&&O.monitorId)||F,title:"Test/Refresh",children:n.jsx(sr,{className:`h-4 w-4 ${F?"animate-spin":""}`})}),n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>A(E),title:"Edit",children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>M(E),title:"Delete",children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},E.id)})})]}),pe>1&&n.jsx("div",{className:"mt-4",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>C(E=>Math.max(1,E-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(pe)].map((E,O)=>{const I=O+1;return I===1||I===pe||I>=S-1&&I<=S+1?n.jsx(wt,{children:n.jsx(ss,{onClick:()=>C(I),isActive:S===I,className:"cursor-pointer",children:I})},I):I===S-2||I===S+2?n.jsx(wt,{children:n.jsx(qo,{})},I):null}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>C(E=>Math.min(pe,E+1)),className:S===pe?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]}),n.jsx(Gi,{monitor:P,open:!!P,onOpenChange:E=>!E&&M(null)}),n.jsx(er,{open:!!D,onOpenChange:E=>!E&&A(null),children:n.jsx(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:n.jsx(Xq,{open:!!D,onClose:()=>A(null),onBack:()=>A(null),clientId:e,existingAgent:D})})})]})}const iD=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))"];function r4e({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{agents:i}=Lt(e),o=(i==null?void 0:i.filter(g=>g.asset_type==="sftp"))||[],l=x.useMemo(()=>t?o.find(g=>g.id===t):o[0],[o,t]),{checks:c,isLoading:d}=mc(l==null?void 0:l.id,50),u=x.useMemo(()=>!c||c.length===0?[]:c.filter(g=>g.response_time_ms!==null).slice(0,20).reverse().map(g=>({time:new Date(g.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),responseTime:g.response_time_ms})),[c]),h=x.useMemo(()=>
756{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length&&p.length<10;v+=g){const j=y.slice(v,v+g),b=j.filter(S=>S.status==="success").length,_=j.filter(S=>S.status==="failed"||S.status==="error").length,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,success:b,failed:_})}return p},[c]),f=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length;v+=g){const j=y.slice(v,v+g),_=j.filter(S=>S.status==="success").length/j.length*100,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,uptime:parseFloat(_.toFixed(2))})}return p},[c]),m=()=>{l&&a.invalidateQueries({queryKey:["monitor-checks",l.id]})};return!l||!c||c.length===0?null:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"SFTP Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:l.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:m,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"response-time",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsx(at,{value:"response-time",children:"Response Time"}),n.jsx(at,{value:"check-status",children:"Check Status"}),n.jsx(at,{value:"uptime",children:"Uptime"})]}),n.jsx(it,{value:"response-time",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:u,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Response Time (ms)",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"responseTime",stroke:iD[0],strokeWidth:2,dot:{fill:iD[0]},name:"Response Time"})]})})}),n.jsxs(it,{value:"check-status",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"SFTP check status over time (grouped by 5 checks)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:h,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Check Count",angle:-90,position:"insideLeft"},allowDecimals:!1}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"success",stroke:"hsl(var(--green))",strokeWidth:2,dot:{fill:"hsl(var(--green))"},name:"Successful Checks"}),n.jsx(Qt,{type:"monotone",dataKey:"failed",stroke:"hsl(var(--destructive))",strokeWidth:2,dot:{fill:"hsl(var(--destructive))"},name:"Failed Checks"})]})})]}),n.jsxs(it,{value:"uptime",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Check success rate trend based on last 50 checks (grouped)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:f,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Uptime (%)",angle:-90,position:"insideLeft"},domain:[0,100]}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:g=>`${g}%`}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"},name:"Uptime"})]})})]})]})})]})}function n4e(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(null),[s,a]=x.useState(new Set),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=c=>{const d=c.target,u=d.closest("[data-monitor-list]"),h=d.closest("[data-monitor-actions]");!u&&!h&&a(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"SFTP Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor SFTP server availability and authentication"})]}),n.jsx(JMe,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(t4e,{clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a})}),n.jsx(r4e,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"sftp"})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"SFTP Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor SFTP server availability and authentication"})]}),n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Please select a client to view SFTP monitors"})]})}function s4e(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["ftps-monitor-stats",e],queryFn:async()=>{if(!e)return null;const{data:a,error:i}=await B.from("monitoring_agents").select("*").eq("client_id",e).eq("asset_type","ftps").eq("status","active");if(i)throw i;if(!a||a.length===0)return{total:0,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const{data:o,error:l}=await B.from("monitors").select("id").in("monitoring_agent_id",a.map(L=>L.id));if(l)throw l;if(!o||o.length===0)return{total:a.length,online:0,offline:0,warning:0,avgResponseTime:0,uptime24h:100,uptime7d:100,uptime30d:100,recentIncidents:0};const c=o.map(L=>L.id),d=new Date,u=new Date(d.getTime()-24*60*60*1e3),h=new Date(d.getTime()-7*24*60*60*1e3),f=new Date(d.getTime()-30*24*60*60*1e3),{data:m,error:g}=await B.from("monitor_checks").select("*").in("monitor_id",c).order("timestamp",{ascending:!1}).limit(c.length*5);if(g)throw g;const{data:p,error:y}=await B.from("monitor_checks").select("status, response_time_ms").in("monitor_id",c).gte("timestamp",u.toISOString()),{data:v,error:j}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",h.toISOString()),{data:b,error:_}=await B.from("monitor_checks").select("status").in("monitor_id",c).gte("timestamp",f.toISOString());if(y||j||_)throw y||j||_;const w=new Map;m==null||m.forEach(L=>{(!w.has(L.monitor_id)||new Date(L.timestamp)>new Date(w.get(L.monitor_id).timestamp))&&w.set(L.monitor_id,L)});let N=0,S=0,C=0;w.forEach(L=>{L.status==="success"?N++:L.status==="failed"||L.status==="error"?S++:C++});const P=(p==null?void 0:p.filter(L=>L.response_time_ms!==null))||[],M=P.length>0?Math.round(P.reduce((L,$)=>L+($.response_time_ms||0),0)/P.length):0,D=p&&p.length>0?p.filter(L=>L.status==="success").length/p.length*100:100,A=v&&v.length>0?v.filter(L=>L.status==="success").length/v.length*100:100,U=b&&b.length>0?b.filter(L=>L.status==="success").length/b.length*100:100,F=(p==null?void 0:p.filter(L=>L.status==="failed").length)||0;return{total:a.length,online:N,offline:S,warning:C,avgResponseTime:M,uptime24h:Math.round(D*100)/100,uptime7d:Math.round(A*100)/100,uptime30d:Math.round(U*100)/100,recentIncidents:F}},enabled:!!e,refetchInterval:3e4});return{stats:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function a4e({clientId:e}){const{stats:t,isLoading:r}=s4e(e);if(r)return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:[...Array(8)].map((a,i)=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(tt,{className:"h-4 w-24"}),n.jsx(tt,{className:"h-4 w-4 rounded"})]}),n.jsxs(re,{children:[n.jsx(tt,{className:"h-8 w-16 mb-2"}),n.jsx(tt,{className:"h-3 w-32"})]})]},i))});if(!t)return null;const s=[{title:"Total FTPS Monitors",value:t.total,description:"Active monitors",icon:yt,color:"text-blue-500"},{title:"Online",value:t.online,description:"Connected successfully",icon:Tt,color:"text-green-500"},{title:"Offline",value:t.offline,description:"Connection failed",icon:kn,color:"text-red-500"}
756,{title:"Warning",value:t.warning,description:"Degraded performance",icon:kn,color:"text-yellow-500"},{title:"Avg Response Time",value:`${t.avgResponseTime}ms`,description:"Average connection time",icon:Xt,color:"text-purple-500"},{title:"24h Uptime",value:`${t.uptime24h.toFixed(2)}%`,description:"Last 24 hours",icon:Wr,color:t.uptime24h>=99?"text-green-500":t.uptime24h>=95?"text-yellow-500":"text-red-500"},{title:"7d Uptime",value:`${t.uptime7d.toFixed(2)}%`,description:"Last 7 days",icon:Bi,color:t.uptime7d>=99?"text-green-500":t.uptime7d>=95?"text-yellow-500":"text-red-500"},{title:"Recent Incidents",value:t.recentIncidents,description:"Last 24 hours",icon:S0,color:t.recentIncidents===0?"text-green-500":t.recentIncidents<5?"text-yellow-500":"text-red-500"}];return n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:s.map((a,i)=>{const o=a.icon;return n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:a.title}),n.jsx(o,{className:`h-4 w-4 ${a.color}`})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:a.value}),n.jsx("p",{className:"text-xs text-muted-foreground",children:a.description})]})]},i)})})}function i4e(e){const{data:t,isLoading:r,error:s}=Ve({queryKey:["ftps-monitor-metrics",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("monitoring_agents").select("id").eq("client_id",e).eq("asset_type","ftps").eq("status","active");if(i)throw i;if(!a||a.length===0)return[];const o=a.map(g=>g.id),{data:l,error:c}=await B.from("monitors").select("id, monitoring_agent_id").in("monitoring_agent_id",o);if(c)throw c;if(!l||l.length===0)return[];const d=l.map(g=>g.id),u=new Date(Date.now()-24*60*60*1e3).toISOString(),{data:h,error:f}=await B.from("monitor_checks").select("monitor_id, status, response_time_ms, timestamp").in("monitor_id",d).gte("timestamp",u).order("timestamp",{ascending:!1});if(f)throw f;const m=new Map;return l.forEach(g=>{const p=(h==null?void 0:h.filter(N=>N.monitor_id===g.id))||[],y=p.find(N=>N.response_time_ms!==null),v=(y==null?void 0:y.response_time_ms)||null,j=p.filter(N=>N.status==="success").length,b=p.length>0?Math.round(j/p.length*1e4)/100:100,_=p.length>0?p[0].timestamp:null,w=p.length>0?p[0].status:null;m.set(g.monitoring_agent_id,{monitorId:g.id,agentId:g.monitoring_agent_id,responseTime:v,uptime24h:b,lastCheckTime:_,lastStatus:w})}),Array.from(m.values())},enabled:!!e,refetchInterval:6e4});return{metrics:t||[],isLoading:r,error:(s==null?void 0:s.message)||null}}function o4e({clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a}){const[i,o]=x.useState(null),[l,c]=x.useState(new Set),d=t!==void 0?t:i,u=s!==void 0?s:l,h=E=>{r?r(E):o(E)},f=E=>{a?a(E):c(E)},[m,g]=x.useState(""),[p,y]=x.useState("all"),[v,j]=x.useState("all"),[b,_]=x.useState("name-asc"),[w,N]=x.useState(!1),[S,C]=x.useState(1),[P,M]=x.useState(null),[D,A]=x.useState(null),{runSingleMonitorCheck:U,isSingleCheckRunning:F}=Ra(),L=5,{agents:$,isLoading:R,toggleAgentStatus:T,deleteAgent:k,isDeleting:W}=Lt(e),{metrics:q}=i4e(e),Q=($==null?void 0:$.filter(E=>E.asset_type==="ftps"))||[],ue=x.useMemo(()=>{const E=new Set;return Q.forEach(O=>{var I;(I=O.tags)==null||I.forEach(Y=>E.add(Y))}),Array.from(E).sort()},[Q]),X=x.useMemo(()=>Q.filter(E=>{var O;if(m){const I=m.toLowerCase(),Y=E.name.toLowerCase().includes(I),te=(O=E.hostname_or_url)==null?void 0:O.toLowerCase().includes(I);if(!Y&&!te)return!1}return!(p!=="all"&&E.status!==p||v!=="all"&&(!E.tags||!E.tags.includes(v)))}),[Q,m,p,v]),le=x.useMemo(()=>{const E=[...X];return E.sort((O,I)=>{var Y,te,K,Z,je,_e,Ee,Ze;switch(b){case"name-asc":return O.name.localeCompare(I.name);case"name-desc":return I.name.localeCompare(O.name);case"response-time-asc":const st=q.find(ze=>ze.agentId===O.id),xt=q.find(ze=>ze.agentId===I.id);return((st==null?void 0:st.responseTime)??999999)-((xt==null?void 0:xt.responseTime)??999999);case"response-time-desc":const Dt=q.find(ze=>ze.agentId===O.id),xe=q.find(ze=>ze.agentId===I.id);return((xe==null?void 0:xe.responseTime)??0)-((Dt==null?void 0:Dt.responseTime)??0);case"uptime-desc":const qe=((Y=q.find(ze=>ze.agentId===O.id))==null?void 0:Y.uptime24h)??100;return(((te=q.find(ze=>ze.agentId===I.id))==null?void 0:te.uptime24h)??100)-qe;case"uptime-asc":const Pr=((K=q.find(ze=>ze.agentId===O.id))==null?void 0:K.uptime24h)??100,wn=((Z=q.find(ze=>ze.agentId===I.id))==null?void 0:Z.uptime24h)??100;return Pr-wn;case"last-check-desc":const An=(je=q.find(ze=>
756ze.agentId===O.id))==null?void 0:je.lastCheckTime,En=(_e=q.find(ze=>ze.agentId===I.id))==null?void 0:_e.lastCheckTime;return An?En?new Date(En).getTime()-new Date(An).getTime():-1:1;case"last-check-asc":const ls=(Ee=q.find(ze=>ze.agentId===O.id))==null?void 0:Ee.lastCheckTime,cs=(Ze=q.find(ze=>ze.agentId===I.id))==null?void 0:Ze.lastCheckTime;return ls?cs?new Date(ls).getTime()-new Date(cs).getTime():-1:1;default:return 0}}),E},[X,b,q]),pe=Math.ceil(le.length/L),ce=(S-1)*L,se=ce+L,oe=le.slice(ce,se);x.useEffect(()=>{C(1)},[m,p,v,b]),x.useEffect(()=>{S>pe&&pe>0&&C(pe)},[S,pe]);const V=p!=="all"||v!=="all",fe=()=>{g(""),y("all"),j("all")};x.useEffect(()=>{const E=O=>{const I=O.target,Y=I.closest("[data-monitor-list]"),te=I.closest("[data-monitor-actions]");!Y&&!te&&f(new Set)};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[]);const ne=E=>{h(E),Ce(E)},Ce=E=>{const O=new Set(u);O.has(E)?O.delete(E):O.add(E),f(O)},Pe=()=>{if(u.size===oe.length&&oe.every(E=>u.has(E.id))){const E=new Set(u);oe.forEach(O=>E.delete(O.id)),f(E)}else{const E=new Set(u);oe.forEach(O=>E.add(O.id)),f(E)}},he=()=>{let E=0;for(const O of Array.from(u)){const I=Q.find(Y=>Y.id===O);(I==null?void 0:I.status)==="active"&&(T(I),E++)}E>0&&ye.success(`Pausing ${E} monitor(s)`)},ke=()=>{let E=0;for(const O of Array.from(u)){const I=Q.find(Y=>Y.id===O);(I==null?void 0:I.status)==="suspended"&&(T(I),E++)}E>0&&ye.success(`Resuming ${E} monitor(s)`)},Me=()=>{const E=Q.filter(Y=>u.has(Y.id)),O=E.filter(Y=>Y.status==="active").length,I=E.filter(Y=>Y.status==="suspended").length;O>=I?he():(ke(),f(new Set))},Je=x.useMemo(()=>{const E=Q.filter(Y=>u.has(Y.id)),O=E.filter(Y=>Y.status==="active").length,I=E.filter(Y=>Y.status==="suspended").length;return O>=I},[Q,u]),Ke=async()=>{const E=Array.from(u);for(const O of E)await k(O);f(new Set)};return R?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(tt,{className:"h-6 w-48"})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:[...Array(5)].map((E,O)=>n.jsx(tt,{className:"h-16 w-full"},O))})})]}):n.jsxs("div",{"data-monitor-list":!0,children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex flex-col gap-4",children:[n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg border",children:[n.jsxs(ve,{variant:"secondary",children:[u.size," selected"]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:Me,disabled:u.size===0,children:Je?n.jsxs(n.Fragment,{children:[n.jsx(ia,{className:"h-4 w-4 mr-2"}),"Pause Selected"]}):n.jsxs(n.Fragment,{children:[n.jsx(qs,{className:"h-4 w-4 mr-2"}),"Resume Selected"]})}),n.jsxs(H,{variant:"destructive",size:"sm",onClick:Ke,disabled:u.size===0,children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete Selected"]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search monitors...",value:m,onChange:E=>g(E.target.value),className:"pl-8"})]}),n.jsx(ur,{open:w,onOpenChange:N,children:n.jsx(Jr,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"icon",children:n.jsx(Ui,{className:"h-4 w-4"})})})}),V&&n.jsxs(H,{variant:"ghost",size:"sm",onClick:fe,children:[n.jsx(vn,{className:"h-4 w-4 mr-1"}),"Clear"]})]}),n.jsx(ur,{open:w,children:n.jsx(Er,{className:"space-y-3",children:n.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Status"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Statuses"}),n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"suspended",children:"Suspended"})]})]})]}),n.jsxs("div",{children:[n.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Tags"}),n.jsxs(Fe,{value:v,onValueChange:j,children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Tags"}),ue.map(E=>n.jsx(J,{value:E,children:E},E))]})]})]})]})})})]})}),n.jsxs(re,{children:[n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-12",children:n.jsx(ct,{checked:oe.length>0&&oe.every(E=>
756u.has(E.id)),onCheckedChange:Pe})}),n.jsx(Se,{children:"Status"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="name-asc"?"name-desc":"name-asc"),children:["Monitor / Host",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"Connection"}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="response-time-asc"?"response-time-desc":"response-time-asc"),children:["Response Time",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:n.jsxs(H,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:()=>_(b==="uptime-desc"?"uptime-asc":"uptime-desc"),children:["Uptime (24h)",n.jsx(ns,{className:"ml-2 h-4 w-4"})]})}),n.jsx(Se,{children:"History (3h)"}),n.jsx(Se,{children:"Last Check"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:oe.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No FTPS monitors found"})}):oe.map(E=>{const O=q.find(te=>te.agentId===E.id),I=E.id===d,Y=u.has(E.id);return n.jsxs(gt,{className:`cursor-pointer hover:bg-muted/50 ${I?"bg-muted":""} ${Y?"bg-primary/5":""}`,onClick:()=>ne(E.id),children:[n.jsx(be,{onClick:te=>te.stopPropagation(),children:n.jsx(ct,{checked:Y,onCheckedChange:()=>Ce(E.id)})}),n.jsx(be,{children:n.jsx(gf,{monitoringAgentId:E.id,agentStatus:E.status})}),n.jsx(be,{children:n.jsxs("div",{className:"space-y-1",children:[n.jsx("div",{className:"font-medium",children:E.name}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:[E.hostname_or_url,":",E.port||990]}),E.tags&&E.tags.length>0&&n.jsx("div",{className:"flex gap-1 flex-wrap",children:E.tags.map(te=>n.jsx(ve,{variant:"outline",className:"text-xs",children:te},te))})]})}),n.jsx(be,{children:(O==null?void 0:O.lastStatus)==="success"?n.jsx(ve,{variant:"outline",className:"bg-green-500/10 text-green-500 border-green-500/20",children:"Connected"}):(O==null?void 0:O.lastStatus)==="failed"?n.jsx(ve,{variant:"outline",className:"bg-red-500/10 text-red-500 border-red-500/20",children:"Failed"}):n.jsx(ve,{variant:"outline",children:"Unknown"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm",children:(O==null?void 0:O.responseTime)!==null?`${O==null?void 0:O.responseTime}ms`:"-"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm font-medium",children:(O==null?void 0:O.uptime24h)!==void 0?`${O.uptime24h.toFixed(2)}%`:"-"})}),n.jsx(be,{children:O!=null&&O.monitorId?n.jsx(Ki,{monitoringAgentId:E.id,createdAt:E.created_at}):n.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"})}),n.jsx(be,{children:n.jsx("span",{className:"text-sm text-muted-foreground",children:O!=null&&O.lastCheckTime?is(new Date(O.lastCheckTime),{addSuffix:!0}):"Never"})}),n.jsx(be,{className:"text-right",onClick:te=>te.stopPropagation(),children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>(O==null?void 0:O.monitorId)&&U(O.monitorId),disabled:!(O!=null&&O.monitorId)||F,title:"Test/Refresh",children:n.jsx(sr,{className:`h-4 w-4 ${F?"animate-spin":""}`})}),n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>A(E),title:"Edit",children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>M(E),title:"Delete",children:n.jsx(Vt,{className:"h-4 w-4"})})]})})]},E.id)})})]}),pe>1&&n.jsx("div",{className:"mt-4",children:n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>C(E=>Math.max(1,E-1)),className:S===1?"pointer-events-none opacity-50":"cursor-pointer"})}),[...Array(pe)].map((E,O)=>{const I=O+1;return I===1||I===pe||I>=S-1&&I<=S+1?n.jsx(wt,{children:n.jsx(ss,{onClick:()=>C(I),isActive:S===I,className:"cursor-pointer",children:I})},I):I===S-2||I===S+2?n.jsx(wt,{children:n.jsx(qo,{})},I):null}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>C(E=>Math.min(pe,E+1)),className:S===pe?"pointer-events-none opacity-50":"cursor-pointer"})})]})})})]})]}),n.jsx(Gi,{monitor:P,open:!!P,onOpenChange:E=>!E&&M(null)}),n.jsx(er,{open:!!D,onOpenChange:E=>!E&&A(null),children:n.jsx(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:n.jsx(Zq,{open:!!D,onClose:()=>A(null),onBack:()=>A(null),clientId:e,existingAgent:D})})})]})}const oD=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))"];function l4e({clientId:e,activeMonitorId:t}){const[r,s]=x.useState(!1),a=Et(),{agents:i}=Lt(e),o=(i==null?void 0:i.filter(g=>g.asset_type==="ftps"))||[],l=x.useMemo(()=>t?o.find(g=>g.id===t):o[0],[o,t]),{checks:c,isLoading:d}=mc(l==null?void 0:l.id,50),u=x.useMemo(()=>!c||c.length===0?[]:c.filter(g=>g.response_time_ms!==null).slice(0,20).reverse().map(g=>({time:new Date(g.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),responseTime:g.response_time_ms})),[c]),h=x.useMemo(()=>
756{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length&&p.length<10;v+=g){const j=y.slice(v,v+g),b=j.filter(S=>S.status==="success").length,_=j.filter(S=>S.status==="failed"||S.status==="error").length,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,success:b,failed:_})}return p},[c]),f=x.useMemo(()=>{if(!c||c.length===0)return[];const g=5,p=[],y=[...c].reverse();for(let v=0;v<y.length;v+=g){const j=y.slice(v,v+g),_=j.filter(S=>S.status==="success").length/j.length*100,w=j[j.length-1],N=new Date(w.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});p.push({time:N,uptime:parseFloat(_.toFixed(2))})}return p},[c]),m=()=>{l&&a.invalidateQueries({queryKey:["monitor-checks",l.id]})};return!l||!c||c.length===0?null:n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(me,{children:"FTPS Analytics"}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing data for: ",n.jsx("span",{className:"font-medium text-foreground",children:l.name})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:m,children:[n.jsx(sr,{className:"h-4 w-4 mr-1"}),"Refresh"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!r),children:r?n.jsxs(n.Fragment,{children:[n.jsx(Ar,{className:"h-4 w-4 mr-1"}),"Collapse"]}):n.jsxs(n.Fragment,{children:[n.jsx(dr,{className:"h-4 w-4 mr-1"}),"Expand"]})})]})]})}),r&&n.jsx(re,{children:n.jsxs(cn,{defaultValue:"response-time",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsx(at,{value:"response-time",children:"Response Time"}),n.jsx(at,{value:"check-status",children:"Check Status"}),n.jsx(at,{value:"uptime",children:"Uptime"})]}),n.jsx(it,{value:"response-time",className:"space-y-4",children:n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:u,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Response Time (ms)",angle:-90,position:"insideLeft"}}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"responseTime",stroke:oD[0],strokeWidth:2,dot:{fill:oD[0]},name:"Response Time"})]})})}),n.jsxs(it,{value:"check-status",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"FTPS check status over time (grouped by 5 checks)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:h,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Check Count",angle:-90,position:"insideLeft"},allowDecimals:!1}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"}}),n.jsx(Qt,{type:"monotone",dataKey:"success",stroke:"hsl(var(--green))",strokeWidth:2,dot:{fill:"hsl(var(--green))"},name:"Successful Checks"}),n.jsx(Qt,{type:"monotone",dataKey:"failed",stroke:"hsl(var(--destructive))",strokeWidth:2,dot:{fill:"hsl(var(--destructive))"},name:"Failed Checks"})]})})]}),n.jsxs(it,{value:"uptime",className:"space-y-4",children:[n.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Check success rate trend based on last 50 checks (grouped)"}),n.jsx(gr,{width:"100%",height:300,children:n.jsxs(Yr,{data:f,children:[n.jsx(hr,{strokeDasharray:"3 3",className:"stroke-muted"}),n.jsx(Zt,{dataKey:"time",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),n.jsx(Jt,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"},label:{value:"Uptime (%)",angle:-90,position:"insideLeft"},domain:[0,100]}),n.jsx(Ot,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px"},formatter:g=>`${g}%`}),n.jsx(Qt,{type:"monotone",dataKey:"uptime",stroke:"hsl(var(--primary))",strokeWidth:2,dot:{fill:"hsl(var(--primary))"},name:"Uptime"})]})})]})]})})]})}function c4e(){const{selectedClientId:e}
756=Mt(),[t,r]=x.useState(null),[s,a]=x.useState(new Set),[i,o]=x.useState(!1);return x.useEffect(()=>{const l=c=>{const d=c.target,u=d.closest("[data-monitor-list]"),h=d.closest("[data-monitor-actions]");!u&&!h&&a(new Set)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[]),e?n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"FTPS Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor FTPS server availability and authentication"})]}),n.jsx(a4e,{clientId:e}),n.jsx(eo,{clientId:e,selectedMonitors:s,onAddMonitor:()=>o(!0)}),n.jsx("div",{"data-monitor-list":!0,children:n.jsx(o4e,{clientId:e,activeMonitorId:t,onActiveMonitorChange:r,selectedMonitors:s,onSelectionChange:a})}),n.jsx(l4e,{clientId:e,activeMonitorId:t}),n.jsx(jc,{open:i,onClose:()=>o(!1),clientId:e,preSelectedType:"ftps"})]}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"FTPS Monitors"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor FTPS server availability and authentication"})]}),n.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Please select a client to view FTPS monitors"})]})}function V2(){const{selectedClientId:e}=Mt(),{toast:t}=qr(),r=Et(),{data:s}=Ve({queryKey:["agent-alert-configs",e],queryFn:async()=>{if(!e)return[];const{data:v,error:j}=await B.from("monitoring_agents").select("id, name, monitoring_config").eq("client_id",e).eq("asset_type","local_device");if(j)throw j;return v},enabled:!!e}),a=(s==null?void 0:s.reduce((v,j)=>{var _;const b=(_=j.monitoring_config)==null?void 0:_.agent_alert_configuration;return b&&(v[j.id]=b),v},{}))||{},{data:i,isLoading:o}=Ve({queryKey:["agent-alerts",e],queryFn:async()=>{if(!e)return[];const{data:v,error:j}=await B.from("agent_monitor_state").select(`
757          id,
758          agent_id,
759          monitor_type,
760          state,
761          severity,
762          state_since,
763          details,
764          created_at,
765          updated_at
766        `).eq("client_id",e).eq("monitor_type","agent_heartbeat").order("state_since",{ascending:!1});if(j)throw j;if(!v||v.length===0)return[];const b=[...new Set(v.map(C=>C.agent_id))],{data:_,error:w}=await B.from("monitoring_agents").select("id, name, hostname_or_url").in("id",b);w&&console.error("Failed to fetch agent details for alerts:",w);const N=new Map((_||[]).map(C=>[C.id,C]));return v.filter(C=>{const P=C.details;return!(P!=null&&P.is_tracking_record)}).map(C=>{const P=N.get(C.agent_id),M=C.details,D=C.state==="offline"?"agent_offline":"agent_online",A=C.state==="offline"?"sent":"resolved";return{id:C.id,agent_id:C.agent_id,alert_type:D,status:A,triggered_at:(M==null?void 0:M.triggered_at)||C.state_since||new Date().toISOString(),resolved_at:C.state==="online"?C.state_since:null,error_message:(M==null?void 0:M.message)||null,agent_name:(P==null?void 0:P.name)||"Unknown Agent",hostname:(P==null?void 0:P.hostname_or_url)||"Unknown",created_at:C.created_at,updated_at:C.updated_at}})},enabled:!!e}),{mutate:l,isPending:c}=mt({mutationFn:async({agentId:v,config:j,sendImmediateAlert:b,agentName:_,agentStatus:w,lastSeen:N})=>{console.log("Fetching current config for agent:",v);const{data:S,error:C}=await B.from("monitoring_agents").select("monitoring_config, hostname_or_url").eq("id",v).single();if(C)throw console.error("Failed to fetch agent:",C),C;const P={...S.monitoring_config||{},agent_alert_configuration:j};console.log("Saving alert config:",P);const{data:M,error:D}=await B.from("monitoring_agents").update({monitoring_config:P}).eq("id",v).select().single();if(D)throw console.error("Failed to update monitoring_config:",D),D;if(console.log("Alert config saved successfully:",M==null?void 0:M.monitoring_config),b&&_&&w&&N)try{const A=w==="online"?"recovery":"incident_start",{error:U}=await B.from("alerts").insert({client_id:e,monitor_id:v,alert_type:A,status:"sent",triggered_at:new Date().toISOString(),last_error_message:null});U&&console.error("Failed to create alert record:",U);const F=new Date(N),L=Math.floor((Date.now()-F.getTime())/(1e3*60)),{error:$}=await B.functions.invoke("send-agent-alert-email",{body:{agentName:_,alertType:w==="offline"?"agent_offline":"agent_online",status:w,lastSeen:N,minutesOffline:L,agentId:v,clientId:e,subject:`Agent Alert: ${_} is ${w.toUpperCase()}`}});$&&console.error("Failed to send immediate alert email:",$)}catch(A){console.error("Error sending immediate alert:",A)}return{...S,monitoring_config:P}},onSuccess:(v,{agentId:j,config:b,sendImmediateAlert:_,agentName:w})=>{r.invalidateQueries({queryKey:["agent-alert-configs",e]}),r.invalidateQueries({queryKey:["agent-alerts",e]}
766),t({title:"Alert Settings Updated",description:_?`Agent alert configuration saved and immediate offline alert sent for ${w}.`:"Agent alert configuration has been saved successfully."})},onError:v=>{console.error("Failed to update agent alert config:",v),t({title:"Update Failed",description:"Failed to update alert settings. Please try again.",variant:"destructive"})}}),{mutate:d,isPending:u}=mt({mutationFn:async v=>{const{error:j}=await B.from("alerts").update({status:"acknowledged"}).eq("id",v);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["agent-alerts",e]}),t({title:"Alert Acknowledged",description:"The alert has been acknowledged."})},onError:()=>{t({title:"Error",description:"Failed to acknowledge alert. Please try again.",variant:"destructive"})}}),{mutate:h,isPending:f}=mt({mutationFn:async v=>{const{error:j}=await B.from("agent_monitor_state").delete().in("id",v);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["agent-alerts",e]}),t({title:"Alerts Deleted",description:"Selected agent alerts have been deleted."})},onError:()=>{t({title:"Error",description:"Failed to delete alerts. Please try again.",variant:"destructive"})}}),{mutate:m,isPending:g}=mt({mutationFn:async({agentId:v,agentName:j,alertType:b,lastSeen:_})=>{const w=new Date(_),N=Math.max(1,Math.floor((Date.now()-w.getTime())/(1e3*60))),S=b==="agent_offline"?"offline":"online",{data:C,error:P}=await B.functions.invoke("send-agent-alert-email",{body:{agentName:`[TEST] ${j}`,alertType:b,status:S,lastSeen:_,minutesOffline:N,agentId:v,clientId:e,subject:`[TEST ALERT] Agent ${j} - ${S.toUpperCase()} Alert Test`}});if(P)throw P;return C},onSuccess:(v,{alertType:j})=>{t({title:"Test Alert Sent",description:`A test ${j==="agent_offline"?"offline":"online"} alert email has been sent to configured recipients.`})},onError:v=>{console.error("Failed to send test alert:",v),t({title:"Test Alert Failed",description:v.message||"Failed to send test alert. Make sure email recipients are configured in Alert Management.",variant:"destructive"})}}),p=x.useCallback(v=>a[v]||null,[a]),y=x.useCallback(v=>{const j=a[v];return(j==null?void 0:j.enabled)&&!(j!=null&&j.maintenance_mode)||!1},[a]);return x.useEffect(()=>{if(!e)return;console.log("Setting up real-time agent monitor state subscription for client:",e);const v=B.channel(`agent-monitor-state-realtime-${e}`).on("postgres_changes",{event:"*",schema:"public",table:"agent_monitor_state",filter:`client_id=eq.${e}`},j=>{console.log("Real-time agent monitor state update received:",j),r.invalidateQueries({queryKey:["agent-alerts",e]})}).subscribe(j=>{console.log("Agent monitor state subscription status:",j)});return()=>{console.log("Cleaning up agent monitor state subscription"),B.removeChannel(v)}},[e,r]),{agentAlerts:i,isLoadingAlerts:o,getAgentAlertConfig:p,isAgentAlertsEnabled:y,updateAgentAlertConfig:l,acknowledgeAlert:d,deleteAlerts:h,sendTestAlert:m,isUpdating:c,isAcknowledging:u,isDeleting:f,isSendingTest:g}}const o9=x.forwardRef(({...e},t)=>n.jsx("nav",{ref:t,"aria-label":"breadcrumb",...e}));o9.displayName="Breadcrumb";const l9=x.forwardRef(({className:e,...t},r)=>n.jsx("ol",{ref:r,className:we("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",e),...t}));l9.displayName="BreadcrumbList";const fS=x.forwardRef(({className:e,...t},r)=>n.jsx("li",{ref:r,className:we("inline-flex items-center gap-1.5",e),...t}));fS.displayName="BreadcrumbItem";const c9=x.forwardRef(({asChild:e,className:t,...r},s)=>{const a=e?oc:"a";return n.jsx(a,{ref:s,className:we("transition-colors hover:text-foreground",t),...r})});c9.displayName="BreadcrumbLink";const d9=x.forwardRef(({className:e,...t},r)=>n.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:we("font-normal text-foreground",e),...t}));d9.displayName="BreadcrumbPage";const u9=({children:e,className:t,...r})=>n.jsx("li",{role:"presentation","aria-hidden":"true",className:we("[&>svg]:size-3.5",t),...r,children:e??n.jsx(Yo,{})});u9.displayName="BreadcrumbSeparator";function h9({open:e,onOpenChange:t,clientId:r,initialGroupId:s}){const{isProviderAdmin:a}=Mt(),{agentStatuses:i}=dc(),{toast:o}
766=qr(),[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,f]=x.useState(null),[m,g]=x.useState({name:"",description:"",notes:""}),[p,y]=x.useState(new Set),[v,j]=x.useState(r),[b,_]=x.useState(!1),{data:w=[]}=Ve({queryKey:["all-clients-for-groups"],queryFn:async()=>{const{data:le,error:pe}=await B.from("clients").select("id, name, slug").eq("status","active").order("name");if(pe)throw pe;return le},enabled:a&&!r}),N=r||v,{groups:S,createGroup:C,updateGroup:P,deleteGroup:M,assignAgentToGroup:D,removeAgentFromGroup:A,currentGroupMembers:U,isCreating:F,isUpdating:L,isDeleting:$}=Vi(N,d==null?void 0:d.id),R=U||[],{data:T={}}=Ve({queryKey:["group-member-counts",N],queryFn:async()=>{if(!N)return{};const{data:le,error:pe}=await B.from("agent_groups").select("group_id").eq("client_id",N);if(pe)throw pe;const ce={};return le.forEach(se=>{ce[se.group_id]=(ce[se.group_id]||0)+1}),ce},enabled:!!N});x.useEffect(()=>{if(e&&s&&S.length>0&&!b){const le=S.find(pe=>pe.id===s);le&&(Q(le),_(!0))}},[e,s,S,b]),x.useEffect(()=>{e||_(!1)},[e]);const k=()=>{g({name:"",description:"",notes:""}),c(!1),u(null),y(new Set)},W=()=>{m.name.trim()&&(C(m),k())},q=()=>{!d||!m.name.trim()||(P({id:d.id,...m}),k())},Q=le=>{g({name:le.name,description:le.description||"",notes:le.notes||""}),u(le),c(!0)},ue=()=>{h&&(M(h.id),f(null))},X=async(le,pe)=>{if(d){y(ce=>new Set(ce).add(le));try{pe?await A({agentId:le,groupId:d.id}):await D({agentId:le,groupId:d.id}),o({title:"Success",description:`Agent ${pe?"removed from":"added to"} group`})}catch{o({title:"Error",description:"Failed to update group membership",variant:"destructive"})}finally{y(ce=>{const se=new Set(ce);return se.delete(le),se})}}};return n.jsxs(n.Fragment,{children:[n.jsx(er,{open:e,onOpenChange:t,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[n.jsx(zr,{children:n.jsxs("div",{className:"space-y-3",children:[n.jsx(o9,{children:n.jsxs(l9,{children:[n.jsx(fS,{children:n.jsxs(c9,{href:"#",onClick:le=>{le.preventDefault(),t(!1)},className:"flex items-center gap-1 hover:text-primary",children:[n.jsx(zh,{className:"h-4 w-4"}),"Dashboard"]})}),n.jsx(u9,{}),n.jsx(fS,{children:n.jsxs(d9,{className:"flex items-center gap-2",children:[n.jsx(Rr,{className:"h-4 w-4"}),"Groups"]})})]})}),n.jsx(Br,{children:"Manage Groups"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage agent groups and view group members"})]})}),n.jsxs("div",{className:"space-y-6",children:[a&&!r&&n.jsxs(ee,{children:[n.jsxs(de,{className:"pb-3",children:[n.jsxs(me,{className:"text-base flex items-center gap-2",children:[n.jsx(Ea,{className:"h-4 w-4"}),"Select Client"]}),n.jsx(De,{children:"As a platform admin, select a client to manage their groups"})]}),n.jsx(re,{children:n.jsxs(Fe,{value:v||"",onValueChange:le=>j(le),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select a client..."})}),n.jsx(Le,{children:w.map(le=>n.jsxs(J,{value:le.id,children:[le.name," (",le.slug,")"]},le.id))})]})})]}),!N&&n.jsxs(Xh,{children:[n.jsx(kn,{className:"h-4 w-4"}),n.jsx(Zh,{children:"Please select a client to manage groups."})]}),N&&l&&n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:d?"Edit Group":"Create New Group"}),n.jsx(De,{children:d?"Update the group details and manage members below.":"Create a new group to organize your monitors and agents."})]}),n.jsx(re,{children:n.jsxs(cn,{defaultValue:"details",className:"w-full",children:[n.jsxs(nn,{className:"grid w-full grid-cols-2",children:[n.jsx(at,{value:"details",children:"Group Details"}),n.jsxs(at,{value:"members",disabled:!d,children:["Members (",R.length,")"]})]}),n.jsxs(it,{value:"details",className:"space-y-4 mt-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Group Name *"}),n.jsx(ie,{id:"name",value:m.name,onChange:le=>g({...m,name:le.target.value}),placeholder:"Enter group name"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(ie,{id:"description",value:m.description,onChange:le=>g({...m,description:le.target.value}),placeholder:"Brief description of the group"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"notes",children:"Notes"}),n.jsx(kr,{id:"notes",value:m.notes,onChange:le=>g({...m,notes:le.target.value}),placeholder:"Additional notes or details",rows:3})]}),n.jsxs("div",{className:"flex gap-2 pt-4",children:[n.jsx(H,{onClick:d?q:W,disabled:!m.name.trim()||F||L,children:d?"Update Group":"Create Group"}),n.jsx(H,{variant:"outline",onClick:k,children:"Cancel"})]})]}
766),n.jsx(it,{value:"members",className:"space-y-4 mt-4",children:d&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium",children:"Group Members"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Changes are saved automatically"})]}),n.jsxs(ve,{variant:"secondary",children:[R.length," member",R.length!==1?"s":""]})]}),n.jsx(yd,{className:"h-[300px] w-full border rounded-md p-4",children:n.jsx("div",{className:"space-y-2",children:i&&i.length>0?i.map(le=>{const pe=R.includes(le.agent_id),ce=p.has(le.agent_id);return n.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${le.status==="online"?"bg-green-500":"bg-red-500"}`}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:le.agent_name}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[le.hostname," • ",le.local_ip]})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[ce&&n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),n.jsx(H,{variant:pe?"destructive":"outline",size:"sm",onClick:()=>X(le.agent_id,pe),disabled:ce,className:"flex items-center gap-1",children:pe?n.jsxs(n.Fragment,{children:[n.jsx(jI,{className:"h-3 w-3"}),"Remove"]}):n.jsxs(n.Fragment,{children:[n.jsx(xo,{className:"h-3 w-3"}),"Add"]})})]})]},le.agent_id)}):n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(Rr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:"No agents available"})]})})})]})})]})})]}),N&&n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("h3",{className:"text-lg font-semibold",children:["Groups (",S.length,")"]}),!l&&n.jsxs(H,{onClick:()=>c(!0),children:[n.jsx(Ws,{className:"h-4 w-4 mr-2"}),"Create Group"]})]}),S.length===0?n.jsx(ee,{children:n.jsxs(re,{className:"flex flex-col items-center justify-center py-8 text-center",children:[n.jsx(Rr,{className:"h-12 w-12 text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Groups Created"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"Create your first group to organize your monitors and agents."}),n.jsxs(H,{onClick:()=>c(!0),children:[n.jsx(Ws,{className:"h-4 w-4 mr-2"}),"Create First Group"]})]})}):n.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:S.map(le=>n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsxs("div",{children:[n.jsx(me,{className:"text-base",children:le.name}),le.description&&n.jsx(De,{className:"mt-1",children:le.description})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>Q(le),children:n.jsx(zi,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>f(le),children:n.jsx(Vt,{className:"h-4 w-4"})})]})]})}),n.jsx(re,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Rr,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("span",{className:"text-sm text-muted-foreground",children:[T[le.id]||0," members"]})]}),le.notes&&n.jsx("p",{className:"text-xs text-muted-foreground",children:le.notes})]})})]},le.id))})]})]})]})}),n.jsx(os,{open:!!h,onOpenChange:()=>f(null),children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete Group"}),n.jsxs(Bn,{children:['Are you sure you want to delete the group "',h==null?void 0:h.name,'"? This action cannot be undone. Any monitors or agents assigned to this group will be unassigned.']})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:ue,disabled:$,children:"Delete Group"})]})]})})]})}const d4e=({commandId:e,agentName:t,open:r,onOpenChange:s,onRunAnother:a})=>{const[i,o]=x.useState(null),[l,c]=x.useState(!0),[d,u]=x.useState(!1),[h,f]=x.use
766State(!1),[m,g]=x.useState(""),[p,y]=x.useState(!1),{toast:v}=qr();x.useEffect(()=>{if(!e||!r){o(null),c(!0);return}console.log("Setting up live command tracking for:",e),(async()=>{c(!0);const{data:D,error:A}=await B.from("agent_commands").select("*").eq("id",e).single();A?(console.error("Error fetching command:",A),v({title:"Error",description:"Failed to fetch command details",variant:"destructive"})):(console.log("Initial command data:",D),o(D)),c(!1)})();const M=B.channel(`live-command-${e}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"agent_commands",filter:`id=eq.${e}`},D=>{console.log("Live command update received:",D);const A=D.new;o(A),A.status==="completed"?v({title:"Command Completed",description:`Command "${A.op}" finished successfully`}):A.status==="failed"&&v({title:"Command Failed",description:`Command "${A.op}" encountered an error`,variant:"destructive"})}).subscribe();return()=>{console.log("Cleaning up live command subscription"),B.removeChannel(M)}},[e,r,v]);const j=P=>{switch(P){case"completed":return n.jsx(Tt,{className:"h-5 w-5 text-green-500"});case"failed":return n.jsx(sa,{className:"h-5 w-5 text-red-500"});case"pending":return n.jsx(mr,{className:"h-5 w-5 text-yellow-500 animate-spin"});case"cancelled":case"expired":return n.jsx(kn,{className:"h-5 w-5 text-gray-500"});default:return n.jsx(Xt,{className:"h-5 w-5"})}},b=P=>{switch(P){case"completed":return"default";case"pending":return"secondary";case"failed":return"destructive";default:return"outline"}},_=P=>P==null?"":P===""?n.jsx("div",{className:"text-muted-foreground italic",children:"No output produced"}):P.replace(/\r\n/g,`
767`).replace(/\r/g,`
768`).split(`
769`).map((M,D)=>n.jsx("div",{style:{fontFamily:'Consolas, Monaco, "Courier New", monospace'},children:M||" "},D)),w=P=>{navigator.clipboard.writeText(P).then(()=>{v({title:"Copied",description:"Output copied to clipboard"})}).catch(()=>{v({title:"Error",description:"Failed to copy to clipboard",variant:"destructive"})})},N=P=>P<1e3?`${P}ms`:`${(P/1e3).toFixed(2)}s`,S=()=>{if(!i)return null;const P=new Date(i.created_at).getTime(),M=i.finished_at?new Date(i.finished_at).getTime():Date.now();return N(M-P)},C=async()=>{var M;if(!i||!m)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m)){v({title:"Invalid Email",description:"Please enter a valid email address",variant:"destructive"});return}y(!0);try{const D=i.result_details&&i.result_details.output||"",A=i.result_details?i.result_details.error_message:void 0,U=((M=i.args)==null?void 0:M.script_name)||i.op.replace(/_/g," ").replace(/\b\w/g,$=>$.toUpperCase()),{data:F,error:L}=await B.functions.invoke("send-command-results-email",{body:{recipientEmail:m,agentName:t,commandName:U,commandOp:i.op,status:i.status,executionTime:S()||"N/A",output:D,error:A,timestamp:$r(new Date(i.created_at),"MMM dd, yyyy HH:mm:ss")}});if(L)throw L;v({title:"Email Sent",description:`Results sent to ${m}`}),f(!1),g("")}catch(D){console.error("Error sending email:",D),v({title:"Failed to Send Email",description:D.message||"An error occurred",variant:"destructive"})}finally{y(!1)}};return r?n.jsx(er,{open:r,onOpenChange:s,children:n.jsxs(Kt,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[n.jsxs(zr,{children:[n.jsxs(Br,{className:"flex items-center gap-2",children:[n.jsx(ws,{className:"h-5 w-5"}),"Live Command Execution"]}),n.jsxs(_s,{children:["Real-time results for ",t]})]}),l?n.jsxs("div",{className:"flex items-center justify-center py-12",children:[n.jsx(mr,{className:"h-8 w-8 animate-spin text-muted-foreground"}),n.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading command details..."})]}):i?n.jsx(yd,{className:"flex-1 pr-4",children:n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[j(i.status),n.jsxs("div",{children:[n.jsx("div",{className:"font-semibold text-lg",children:i.op}),n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Started ",$r(new Date(i.created_at),"MMM dd, yyyy HH:mm:ss")]})]})]}),n.jsxs("div",{className:"flex flex-col items-end gap-2",children:[n.jsx(ve,{variant:b(i.status),className:"text-sm px-3 py-1",children:i.status}),i.status==="pending"&&n.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[n.jsx(mr,{className:"h-3 w-3 animate-spin"}),"Executing..."]})]})]}),i.status!=="pending"&&n.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"}),n.jsx("span",{className:"text-muted-foreground",children:"Execution Time:"}),n.jsx("span",{className:"font-medium",children:S()})]}),n.jsx(ja,{}),i.args&&Object.keys(i.args).length>0&&n.jsxs(ur,{open:d,onOpenChange:u,children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",size:"sm",className:"w-full justify-between",children:[n.jsx("span",{className:"text-sm font-medium",children:"Command Arguments"}),d?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})}),n.jsx(Er,{className:"pt-2",children:n.jsx("div",{className:"bg-muted/50 p-3 rounded-lg",children:n.jsx("pre",{className:"text-xs whitespace-pre-wrap break-all",children:JSON.stringify(i.args,null,2)})})})]}),i.status==="pending"&&n.jsxs("div",{className:"space-y-3 p-4 border border-blue-200 bg-blue-50/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(mr,{className:"h-4 w-4 animate-spin text-blue-600"}),n.jsx("span",{className:"font-medium text-blue-900",children:"Command is being executed..."})]}),n.jsx("p",{className:"text-sm text-blue-700",children:"The agent is processing this command. Results will appear here as soon as they're available."})]}),i.result_details&&i.result_details.output!==void 0&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("h4",{className:"font-medium flex items-center gap-2",children:[n.jsx(ws,{className:"h-4 w-4"}),"Output"]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>w(i.result_details.output),className:"flex items-center gap-2",children:[n.jsx(rg,{className:"h-3 w-3"}),"Copy"]})]}),n.jsx("div",{className:"bg-black text-green-400 p-4 rounded-lg border",children:n.jsx(yd,{className:"max-h-96",children:n.jsx("div",{className:"text-sm leading-relaxed font-mono",children:_(i.result_details.output)})})})]}),i.status==="failed"&&i.result_details&&i.result_details.error_message&&n.jsxs("div",{className:"space-y-2",children:[n.jsxs("h4",{className:"font-medium text-red-600 flex items-center gap-2",children:[n.jsx(sa,{className:"h-4 w-4"}),"Error Details"]}
769),n.jsx("div",{className:"bg-red-50 border border-red-200 text-red-800 p-4 rounded-lg",children:n.jsx("code",{className:"text-sm break-all",children:i.result_details.error_message})})]}),i.status==="completed"&&n.jsx("div",{className:"p-4 bg-green-50 border border-green-200 rounded-lg",children:n.jsxs("div",{className:"flex items-center gap-2 text-green-800",children:[n.jsx(Tt,{className:"h-5 w-5"}),n.jsx("span",{className:"font-medium",children:"Command completed successfully"})]})}),n.jsx(ja,{}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 text-xs",children:[n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Command ID:"}),n.jsx("p",{className:"font-mono text-xs break-all mt-1",children:i.id})]}),n.jsxs("div",{children:[n.jsx("span",{className:"text-muted-foreground",children:"Cursor:"}),n.jsx("p",{className:"font-mono text-xs break-all mt-1",children:i.cursor})]})]})]})}):n.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[n.jsx(kn,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),n.jsx("p",{children:"Command not found"})]}),n.jsxs(xg,{className:"flex gap-2 pt-4",children:[i&&(i.status==="completed"||i.status==="failed")&&n.jsxs(gk,{open:h,onOpenChange:f,children:[n.jsx(xk,{asChild:!0,children:n.jsxs(H,{variant:"outline",children:[n.jsx(aa,{className:"h-4 w-4 mr-2"}),"Email Results"]})}),n.jsx(sj,{className:"w-80",align:"start",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"email",children:"Recipient Email"}),n.jsx(ie,{id:"email",type:"email",placeholder:"[email protected]",value:m,onChange:P=>g(P.target.value),onKeyDown:P=>P.key==="Enter"&&C()})]}),n.jsx(H,{onClick:C,disabled:p||!m,className:"w-full",children:p?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Send Email"]})})]})})]}),a&&n.jsxs(H,{variant:"outline",onClick:()=>{s(!1),a()},children:[n.jsx(mI,{className:"h-4 w-4 mr-2"}),"Run Another Command"]}),n.jsx(H,{onClick:()=>s(!1),children:"Close"})]})]})}):null};function u4e({config:e,onConfigChange:t,isOpen:r,onToggle:s}){const a=e.heartbeat_interval_seconds||60,i=e.command_poll_interval_seconds||10,o=e.command_timeout_seconds||300,l=c=>{if(c>=60){const d=Math.floor(c/60),u=c%60;return u>0?`${d}m ${u}s`:`${d} min`}return`${c}s`};return n.jsx(ee,{children:n.jsxs(ur,{open:r,onOpenChange:s,children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(me,{className:"text-lg flex items-center gap-2",children:[n.jsx(Xt,{className:"h-5 w-5"}),"Agent Timing Settings"]}),r?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]}),n.jsx(De,{children:"Control how often the agent communicates with the server"})]})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xC,{className:"h-4 w-4 text-muted-foreground"}),n.jsx(z,{htmlFor:"heartbeat_interval",className:"font-medium",children:"Heartbeat Interval"})]}),n.jsx("span",{className:"text-sm font-mono bg-muted px-2 py-1 rounded",children:l(a)})]}),n.jsx(sd,{id:"heartbeat_interval",min:5,max:300,step:5,value:[a],onValueChange:([c])=>t("heartbeat_interval_seconds",c),className:"w-full"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the agent reports its status to the server (5s - 5min)"})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"}),n.jsx(z,{htmlFor:"command_poll",className:"font-medium",children:"Command Poll Interval"})]}),n.jsx("span",{className:"text-sm font-mono bg-muted px-2 py-1 rounded",children:l(i)})]}),n.jsx(sd,{id:"command_poll",min:5,max:60,step:5,value:[i],onValueChange:([c])=>t("command_poll_interval_seconds",c),className:"w-full"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the agent checks for new commands (5s - 60s)"})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yI,{className:"h-4 w-4 text-muted-foreground"}),n.jsx(z,{htmlFor:"command_timeout",className:"font-medium",children:"Command Timeout"})]}),n.jsx("span",{className:"text-sm font-mono bg-muted px-2 py-1 rounded",children:l(o
769)})]}),n.jsx(sd,{id:"command_timeout",min:30,max:1800,step:30,value:[o],onValueChange:([c])=>t("command_timeout_seconds",c),className:"w-full"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Maximum time a command can run before timing out (30s - 30min)"})]}),n.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:n.jsxs("p",{className:"text-muted-foreground",children:[n.jsx("strong",{children:"Note:"})," Changes take effect on the agent's next heartbeat. Lower intervals provide faster responses but increase server load."]})})]})})]})})}const h4e=[{value:"website",label:"Website"},{value:"server",label:"Server"},{value:"database",label:"Database"},{value:"saas",label:"SaaS Service"},{value:"ssl",label:"SSL Certificate"},{value:"ping",label:"Ping Monitor"},{value:"tcp",label:"TCP/UDP Monitor"},{value:"dns",label:"DNS Monitor"}],f4e=["http","https","tcp","udp","icmp"];function m4e({agent:e,isOpen:t,onClose:r,onUpdate:s,clientId:a}){var q,Q,ue,X,le,pe,ce;const[i,o]=x.useState(e),[l,c]=x.useState({basic:!0,status:!1,network:!1,timing:!1,monitoring:!1,groups:!1,metadata:!1}),[d,u]=x.useState(new Set),{updateAgent:h,isUpdating:f}=Lt(),{groups:m,assignAgentToGroup:g,removeAgentFromGroup:p,currentGroupMembers:y}=Vi(a,null),{agentStatuses:v}=dc(),{toast:j}=qr(),{popupEnabled:b}=zC(),_=v.find(se=>se.agent_id===e.id),w=e.monitoring_config,N=w==null?void 0:w.agent_alert_configuration,S=(N==null?void 0:N.popup_notifications)!==!1,C=()=>{if(!(_!=null&&_.last_seen))return"Never";const se=new Date(_.last_seen),V=new Date().getTime()-se.getTime(),fe=Math.floor(V/1e3);if(fe<60)return`${fe} seconds ago`;const ne=Math.floor(fe/60);if(ne<60)return`${ne} minute${ne!==1?"s":""} ago`;const Ce=Math.floor(ne/60);if(Ce<24)return`${Ce} hour${Ce!==1?"s":""} ago`;const Pe=Math.floor(Ce/24);return`${Pe} day${Pe!==1?"s":""} ago`};x.useEffect(()=>{o(e)},[e]);const P=se=>{switch(se){case"server":return ht;case"website":return Pn;case"database":return ng;case"saas":return P7;case"ssl":return yt;default:return Pn}},M=se=>{switch(se){case"active":return"default";case"suspended":return"secondary";default:return"outline"}},D=se=>se.charAt(0).toUpperCase()+se.slice(1),A=se=>new Date(se).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),U=async()=>{try{await h({id:i.id,...i}),s(i)}catch(se){console.error("Error updating agent:",se)}},F=(se,oe)=>{o(V=>({...V,[se]:oe}))},L=(se,oe)=>{const fe={...i.monitoring_config||{},[se]:oe};F("monitoring_config",fe)},$=se=>{c(oe=>({...oe,[se]:!oe[se]}))},R=P(e.asset_type),T=i.monitoring_config||{},k=m.filter(se=>y&&y.includes(e.id)),W=async(se,oe)=>{u(V=>new Set(V).add(se));try{oe?await p({agentId:e.id,groupId:se}):await g({agentId:e.id,groupId:se}),j({title:"Success",description:`Agent ${oe?"removed from":"added to"} group`})}catch{j({title:"Error",description:"Failed to update group membership",variant:"destructive"})}finally{u(V=>{const fe=new Set(V);return fe.delete(se),fe})}};return n.jsx(er,{open:t,onOpenChange:r,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[n.jsx(zr,{className:"space-y-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsx(R,{className:"h-8 w-8 text-primary"}),n.jsxs("div",{children:[n.jsx(Br,{className:"text-xl",children:e.name}),n.jsxs("div",{className:"flex items-center space-x-2 mt-1",children:[n.jsx(ve,{variant:M(e.status),children:D(e.status)}),n.jsx(ve,{variant:"outline",children:(q=h4e.find(se=>se.value===e.asset_type))==null?void 0:q.label})]})]})]}),n.jsxs(H,{onClick:U,disabled:f,children:[n.jsx(Lo,{className:"h-4 w-4 mr-2"}),f?"Saving...":"Save Changes"]})]})}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(ee,{children:n.jsxs(ur,{open:l.basic,onOpenChange:()=>$("basic"),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(me,{className:"text-lg",children:"Basic Information"}),l.basic?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Agent Name"}),n.jsx(ie,{id:"name",value:i.name,onChange:se=>F("name",se.target.value)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:i.description||"",onChange:se=>F("description",se.target.value)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"status",children:"Status"}),n.jsxs(Fe,{value:i.status,onValueChange:se=>F("status",se),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"suspended",children:"Suspended"})]})]})]})]})})]})}),e.asset_type==="local_device"&&n.jsx(ee,{children:n.jsxs(ur,{open:l.status,onOpenChange:()=>$("status"),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ii,{className:"h-5 w-5 text-primary"}),n.jsx(me,{className:"text-lg",children:"Agent Status & Notifications"})]}),l.status?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-3",children:[n.jsxs("h4",{className:"font-medium text-sm flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4"}),"Current Status"]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 p-4 bg-muted/50 rounded-lg",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Connection Status"}),n.jsx("div",{className:"flex items-center gap-2",children:(_==null?void 0:_.status)==="online"?n.jsxs(n.Fragment,{children:[n.jsx(wI,{className:"h-4 w-4 text-green-500"}),n.jsx(ve,{variant:"default",className:"bg-green-500/10 text-green-500 border-green-500/20",children:"Online"})]}):n.jsxs(n.Fragment,{children:[n.jsx(bI,{className:"h-4 w-4 text-red-500"}),n.jsx(ve,{variant:"destructive",children:"Offline"})]})})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Last Seen"}),n.jsx("p",{className:"text-sm font-medium",children:C()}),(_==null?void 0:_.last_seen)&&n.jsx("p",{className:"text-xs text-muted-foreground",children:new Date(_.last_seen).toLocaleStr
769ing()})]})]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("h4",{className:"font-medium text-sm flex items-center gap-2",children:[n.jsx(ii,{className:"h-4 w-4"}),"Popup Notification Settings"]}),n.jsxs("div",{className:"space-y-3 p-4 bg-muted/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Global Popup Notifications"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Master setting from Settings page"})]}),n.jsx(ve,{variant:b?"default":"secondary",children:b?"Enabled":"Disabled"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Agent-Specific Popups"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Setting for this agent only"})]}),n.jsx(ve,{variant:S?"default":"secondary",children:S?"Enabled":"Disabled"})]}),n.jsx("div",{className:"pt-2 border-t",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:"Effective Status"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Will you receive popup notifications?"})]}),b&&S?n.jsx(ve,{className:"bg-green-500/10 text-green-500 border-green-500/20",children:"✓ Active"}):n.jsx(ve,{variant:"secondary",children:"✗ Inactive"})]})})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure agent-specific popup notifications in the Alert Settings dialog. Global settings can be changed in the Settings page."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h4",{className:"font-medium text-sm",children:"Notification Duration"}),n.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[n.jsxs("div",{className:"p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:[n.jsx("p",{className:"font-medium text-red-500",children:"Offline Alert"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Displays for 10 seconds"})]}),n.jsxs("div",{className:"p-3 bg-green-500/10 border border-green-500/20 rounded-lg",children:[n.jsx("p",{className:"font-medium text-green-500",children:"Online Alert"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Displays for 5 seconds"})]})]})]})]})})]})}),n.jsx(ee,{children:n.jsxs(ur,{open:l.network,onOpenChange:()=>$("network"),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(me,{className:"text-lg",children:"Network Configuration"}),l.network?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"hostname_or_url",children:"Hostname or URL"}),n.jsx(ie,{id:"hostname_or_url",value:i.hostname_or_url||"",onChange:se=>F("hostname_or_url",se.target.value)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"ip_address",children:"IP Address"}),n.jsx(ie,{id:"ip_address",value:i.ip_address||"",onChange:se=>F("ip_address",se.target.value)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"protocol",children:"Protocol"}),n.jsxs(Fe,{value:i.protocol||"https",onValueChange:se=>F("protocol",se),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsx(Le,{children:f4e.map(se=>n.jsx(J,{value:se,children:se.toUpperCase()},se))})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"port",children:"Port"}),n.jsx(ie,{id:"port",type:"number",value:((Q=i.port)==null?void 0:Q.toString())||"",onChange:se=>F("port",se.target.value?parseInt(se.target.value):null)})]})]})})]})}),n.jsx(u4e,{config:T,onConfigChange:L,isOpen:l.timing,onToggle:()=>$("timing")}),n.jsx(ee,{children:n.jsxs(ur,{open:l.monitoring,onOpenChange:()=>$("monitoring"),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(me,{className:"text-lg",children:"Monitoring Configuration"}),l.monitoring?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"check_interval",children:"Check Interval (seconds)"}),n.jsx(ie,{id:"check_interval",type:"number",value:((ue=T.check_interval)==null?void 0:ue.toString())||"300",onChange:se=>L("check_interval",parseInt(se.target.value)||300)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"timeout_seconds",children:"Timeout (seconds)"}),n.jsx(ie,{id:"timeout_seconds",type:"number",value:((X=T.timeout_seconds)==null?void 0:X.toString())||"30",onChange:se=>L("timeout_seconds",parseInt(se.target.value)||30)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert_threshold",children:"Alert Threshold"}),n.jsx(ie,{id:"alert_threshold",type:"number",value:((le=T.alert_threshold)==null?void 0:le.toString())||"3",onChange:se=>L("alert_threshold",parseInt(se.target.value)||3)})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"escalation_enabled",children:"Escalation Enabled"}),n.jsxs(Fe,{value:T.escalation_enabled?"Yes":"No",onValueChange:se=>L("escalation_enabled",se==="Yes"),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"Yes",children:"Yes"}),n.jsx(J,{value:"No",children:"No"})]})]})]}),(i.asset_type==="website"||i.asset_type==="saas")&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"status_monitoring_strategy",children:"Status Monitoring Strategy"}),n.jsxs(Fe,{value:T.status_monitoring_strategy||"standard",onValueChange:se=>L("status_monitoring_strategy",se),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"standard",children:n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:"Standard"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"UP: 2xx, 3xx | DOWN: 4xx, 5xx, errors"})]})}),n.jsx(J,{value:"restricted",children:n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:"Restricted Access"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"UP: 2xx, 3xx, 401, 403, 404 | DOWN: 5xx, errors"})]})}),n.jsx(J,{value:"custom",children:n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:"Custom"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"Define specific status codes below"})]})})]})]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Choose how HTTP status codes are interpreted for UP/DOWN status"})]}),T.status_monitoring_strategy==="custom"&&n.jsxs("div",{children:[n.jsx(z,{htmlFor:"expected_status_codes",children:"Expected HTTP Status Codes"}),n.jsx(ie,{id:"expected_status_codes",value:T.expected_status_codes||"200,201,202,204",onCh
769ange:se=>L("expected_status_codes",se.target.value),placeholder:"200,201,202,204,301,302"}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Comma-separated list of HTTP status codes that indicate UP status"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"follow_redirects",checked:T.follow_redirects!==void 0?T.follow_redirects:!0,onChange:se=>L("follow_redirects",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"follow_redirects",className:"text-sm",children:"Follow HTTP redirects (3xx responses)"})]})]}),i.asset_type==="ssl"&&n.jsx(n.Fragment,{children:n.jsxs("div",{className:"border-t pt-4",children:[n.jsx("h4",{className:"font-medium mb-4",children:"SSL Certificate Configuration"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"sni_host_override",children:"SNI Host Override"}),n.jsx(ie,{id:"sni_host_override",value:T.sni_host_override||"",onChange:se=>L("sni_host_override",se.target.value),placeholder:"Optional SNI hostname override"})]}),n.jsxs("div",{children:[n.jsx(z,{children:"Monitoring Regions"}),n.jsx("div",{className:"grid grid-cols-3 gap-2 mt-2",children:["US","EU","APAC"].map(se=>n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:`region-${se}`,checked:(T.regions||["US"]).includes(se),onChange:oe=>{const V=T.regions||["US"],fe=oe.target.checked?[...V,se]:V.filter(ne=>ne!==se);L("regions",fe)},className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:`region-${se}`,className:"text-sm",children:se})]},se))})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"regional_failure_threshold",children:"Regional Failure Handling"}),n.jsxs(Fe,{value:T.regional_failure_threshold||"warning",onValueChange:se=>L("regional_failure_threshold",se),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"warning",children:"Warning (one region having issues)"}),n.jsx(J,{value:"down",children:"Down (treat any region failure as down)"})]})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"cert_expiration_days",children:"Certificate Expiration Alert (days)"}),n.jsx(ie,{id:"cert_expiration_days",type:"number",value:((pe=T.cert_expiration_days)==null?void 0:pe.toString())||"30",onChange:se=>L("cert_expiration_days",parseInt(se.target.value)||30),min:"1",max:"365"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"min_key_size",children:"Minimum Key Size (RSA)"}),n.jsx(ie,{id:"min_key_size",type:"number",value:((ce=T.min_key_size)==null?void 0:ce.toString())||"2048",onChange:se=>L("min_key_size",parseInt(se.target.value)||2048)})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"min_tls_version",children:"Minimum TLS Version"}),n.jsxs(Fe,{value:T.min_tls_version||"TLS 1.2",onValueChange:se=>L("min_tls_version",se),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"TLS 1.2",children:"TLS 1.2"}),n.jsx(J,{value:"TLS 1.3",children:"TLS 1.3"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("h5",{className:"font-medium text-sm",children:"SSL Certificate Checks"}),n.jsxs("div",{className:"grid grid-cols-1 gap-2",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_future_cert",checked:T.check_future_cert||!1,onChange:se=>L("check_future_cert",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_future_cert",className:"text-sm",children:"Check for future-dated certificates"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_hostname_match",checked:T.check_hostname_match!==void 0?T.check_hostname_match:!0,onChange:se=>L("check_hostname_match",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_hostname_match",className:"text-sm",children:"Verify hostname match (CN/SANs)"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_weak_signature",checked:T.check_weak_signature!==void 0?T.check_weak_signature:!0,onChange:se=>L("check_weak_signature",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_weak_signature",className:"text-sm",children:"Check for weak signature algorithms"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_chain_complete",checked:T.check_chain_complete!==void 0?T.check_chain_complete:!0,onChange:se=>L("check_chain_complete",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_chain_complete",className:"text-sm",children:"Verify complete certificate chain"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_revocation",checked:T.check_revocation||!1,onChange:se=>L("check_revocation",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_revocation",className:"text-sm",children:"Check certificate revocation (OCSP/CRL)"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"check_weak_ciphers",checked:T.check_weak_ciphers!==void 0?T.check_weak_ciphers:!0,onChange:se=>L("check_weak_ciphers",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"check_weak_ciphers",className:"text-sm",children:"Check for weak ciphers"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"checkbox",id:"require_perfect_forward_secrecy",checked:T.require_perfect_forward_secrecy||!1,onChange:se=>L("require_perfect_forward_secrecy",se.target.checked),className:"rounded border border-input bg-background"}),n.jsx(z,{htmlFor:"require_perfect_forward_secrecy",className:"text-sm",children:"Require Perfect Forward Secrecy"})]})]})]})]})]})})]})})]})}),n.jsx(ee,{children:n.jsxs(ur,{open:l.groups,onOpenChange:()=>$("groups"),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs(me,{className:"text-lg flex items-center gap-2",children:[n.jsx(Rr,{className:"h-5 w-5"}),"Groups (",k.length,")"]}),l.groups?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-4",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsxs("div",{children:[n.jsx("h4",{className:"text-sm font-medium",children:"Group Membership"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Manage which groups this agent belongs to"})]})}),n.jsx("div",{className:"space-y-2",children:m&&m.length>0?m.map(se=>{const oe=k.some(fe=>fe.id===se.id),V=d.has(se.id);return n.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg hover:bg-muted/50 transition-colors",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("p",{className:"text-sm font-medium",children:se.name}),se.description&&n.jsx("p",{className:"text-xs text-muted-foreground",children:se.description})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[V&&n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),n.jsx(H,{variant:oe?"destructive":"outline",size:"sm",onClick:()=>W(se.id,oe),disabled:V,className:"flex items-center gap-1",children:oe?n.jsxs(n.Fragment,{children:[n.jsx(jI,{className:"h-3 w-3"}),"Remove"]}):n.jsxs(n.Fragment,{children:[n.jsx(xo,{className:"h-3 w-3"}),"Add"]})})]})]},se.id)}):n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx(Rr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:"No groups available"})]})})]})})]})}),n.jsx(ee,{children:n.jsxs(ur,{open:l.metadata,onOpenChange:()=>$("metadata"),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(me,{className:"text-lg",children:"Metadata"}),l.metadata?n.jsx(Ar,{className:"h-4 w-4"}):n.jsx(dr,{className:"h-4 w-4"})]})})}),n.jsx(Er,{children:n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium text-sm text-muted-foreground",children:"Created At"}),n.jsx("p",{children:A(e.created_at)})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium text-sm text-muted-foreground",children:"Last Updated"}),n.jsx("p",{children:A(e.updated_at)})]})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium text-sm text-muted-foreground",children:"Agent ID"}),n.jsx("p",{className:"font-mono text-xs",children:e.id})]})]})})]})})]})]})})}function lD(e){const t=new Date,r=new Date(e),s=t.getTime()-r.getTime(),a=Math.floor(s/(1e3*60*60*24)),i=Math.floor(s%(1e3*60*60*24)/(1e3*60*60)),o=Math.floor(s%(1e3*60*60)/(1e3*60));return a>0?`${a}d ${i}h`:i>0?`${i}h ${o}m`:`${o}m`}function p4e({agentId:e,createdAt:t,className:r,refreshTrigger:s}){const a=Et(),{getAgentHeartbeatHistory:i}=dc(),{data:o,isLoading:l}=i(e),[c,d]=x.useState(lD(t));if(x.useEffect(()=>{const p=setInterval(()=>{d(lD(t))},6e4);return()=>clearInterval(p)},[t]),x.useEffect(()=>{s&&a.invalidateQueries({queryKey:["agent-heartbeat-history",e]})},[s,e,a]),l)return n.jsxs("div",{className:"flex items-center gap-5",children:[n.jsx("div",{className:we("flex items-center gap-0.5 shrink-0 ml-[5px]",r),children:Array.from({length:36}).map((p,y)=>n.jsx("div",{className:"w-1.5 h-8 bg-muted/40 rounded-sm animate-pulse flex-none"}
769,y))}),n.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[n.jsx("span",{className:"whitespace-nowrap",children:"Up: Loading..."}),n.jsx("span",{className:"whitespace-nowrap",children:"History: 3h"})]})]});const u=o||[],h=new Date,f=5,g=Array.from({length:36},(p,y)=>{const v=new Date(h.getTime()-y*f*60*1e3),j=new Date(v.getTime()-f*60*1e3),b=u.find(w=>{const N=new Date(w.created_at);return N>=j&&N<=v});if(!b)return{status:"offline",tooltip:`${j.toLocaleTimeString()} - ${v.toLocaleTimeString()}: No heartbeat (OFFLINE)`,time:j};const _=new Date(b.created_at);return{status:b.status,tooltip:`${_.toLocaleTimeString()}: ${b.status.toUpperCase()}${b.error_message?` - ${b.error_message}`:""}`,time:_}});return n.jsxs("div",{className:"flex items-center gap-5",children:[n.jsx("div",{className:we("flex items-center gap-0.5 shrink-0 ml-[5px]",r),children:g.map((p,y)=>{const v=p.status==="online",j=p.status==="offline"||p.status==="error",b=p.status==="empty";return n.jsx("div",{className:we("w-1.5 h-8 rounded-sm transition-colors duration-200 cursor-pointer flex-none",v&&"bg-emerald-500 hover:bg-emerald-400 shadow-sm",j&&"bg-destructive hover:bg-destructive/80 shadow-sm",b&&"bg-muted/40"),title:p.tooltip},y)})}),n.jsxs("div",{className:"flex flex-col text-xs text-muted-foreground",children:[n.jsxs("span",{className:"whitespace-nowrap",children:["Up: ",c]}),n.jsx("span",{className:"whitespace-nowrap",children:"History: 3h"})]})]})}function g4e({agent:e,isOpen:t,onClose:r}){const{toast:s}=qr(),{getAgentAlertConfig:a,updateAgentAlertConfig:i,isUpdating:o,sendTestAlert:l,isSendingTest:c}=V2(),d={enabled:!1,conditions:{alert_on_offline:!0,alert_on_online:!1,offline_threshold_minutes:1},cooldown_minutes:15,maintenance_mode:!1,popup_notifications:!0},[u,h]=x.useState(d),f=x.useRef(null);x.useEffect(()=>{if(!t){f.current=null;return}if(e&&f.current!==e.agent_id){const y=a(e.agent_id);if(y){console.log("Loading existing alert config for",e.agent_name,y);const v={...d,...y};h(v)}else console.log("No existing alert config for",e.agent_name,"using default"),h(d);f.current=e.agent_id}},[t,e==null?void 0:e.agent_id]);const m=async()=>{console.log("Saving alert config:",u,"for agent:",e.agent_id,e.agent_name);try{const y=u.enabled&&e.status==="offline"&&u.conditions.alert_on_offline;console.log("Will send immediate alert:",y),i({agentId:e.agent_id,config:u,sendImmediateAlert:y,agentName:e.agent_name,agentStatus:e.status,lastSeen:e.last_seen}),r()}catch(y){console.error("Error in handleSave:",y),s({title:"Error",description:"Failed to update alert settings. Please try again.",variant:"destructive"})}},g=()=>{if(u.maintenance_mode)return n.jsx(ve,{variant:"secondary",children:"Maintenance Mode"});if(u.enabled){const y=[];return u.conditions.alert_on_offline&&y.push("Alert on Offline"),u.conditions.alert_on_online&&y.push("Alert on Online"),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(ve,{variant:"default",children:"Alerts Enabled"}),n.jsx(ve,{variant:"outline",children:y.join(", ")})]})}return n.jsx(ve,{variant:"outline",children:"Alerts Disabled"})},p=()=>{const y={online:"bg-green-100 text-green-800 border-green-200",offline:"bg-red-100 text-red-800 border-red-200",error:"bg-yellow-100 text-yellow-800 border-yellow-200"};return n.jsxs(ve,{variant:"outline",className:y[e.status],children:["Agent is ",e.status.charAt(0).toUpperCase()+e.status.slice(1)]})};return n.jsx(er,{open:t,onOpenChange:r,children:n.jsxs(Kt,{className:"max-w-2xl",children:[n.jsx(zr,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(ii,{className:"h-6 w-6 text-primary"}),n.jsxs("div",{children:[n.jsxs(Br,{children:["Agent Status Alerts - ",e.agent_name]}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Configure alerts for when this agent goes online or offline"})]})]}),n.jsxs("div",{className:"flex flex-col items-end gap-1",children:[n.jsx("span",{className:"text-xs text-muted-foreground",children:"Current Status"}),p()]})]})}),n.jsxs("div",{className:"space-y-6",children:[n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx(me,{className:"text-lg",children:"Alert Configuration Status"}),g()]})}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert-enabled",className:"text-base font-medium",children:"Enable Agent Status Alerts"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Receive notifications when this agent's status changes"})]}),n.jsx(Rs,{id:"alert-enabled",checked:u.enabled,onCheckedChange:y=>h(v=>({...v,enabled:y}))})]})})})]}),u.enabled&&n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"text-lg flex items-center gap-2",children:[n.jsx(Qo,{className:"h-5 w-5"}),"Alert Conditions"]})}),n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(tn,{className:"h-5 w-5 text-red-500"}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert-offline",className:"text-base font-medium",children:"Alert when Agent goes Offline"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Receive alerts when this agent stops responding"})]})]}),n.jsx(Rs,{id:"alert-offline",checked:u.conditions.alert_on_offline,onCheckedChange:y=>h(v=>({...v,conditions:{...v.conditions,alert_on_offline:y}}
769))})]}),u.conditions.alert_on_offline&&n.jsxs("div",{className:"ml-8 space-y-2",children:[n.jsx(z,{htmlFor:"offline-threshold",children:"Offline Threshold (minutes)"}),n.jsx(ie,{id:"offline-threshold",type:"number",min:"1",max:"60",value:u.conditions.offline_threshold_minutes,onChange:y=>h(v=>({...v,conditions:{...v.conditions,offline_threshold_minutes:parseInt(y.target.value)||1}})),className:"w-32"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Alert after agent is offline for this many minutes (agents are considered offline after 30 seconds without heartbeat)"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Tt,{className:"h-5 w-5 text-green-500"}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"alert-online",className:"text-base font-medium",children:"Alert when Agent comes Online"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Receive recovery alerts when this agent comes back online"})]})]}),n.jsx(Rs,{id:"alert-online",checked:u.conditions.alert_on_online,onCheckedChange:y=>h(v=>({...v,conditions:{...v.conditions,alert_on_online:y}}))})]}),n.jsxs("div",{className:"space-y-2 border-t pt-4",children:[n.jsx(z,{htmlFor:"cooldown",className:"text-base font-medium",children:"Alert Cooldown (minutes)"}),n.jsx(ie,{id:"cooldown",type:"number",min:"0",max:"120",value:u.cooldown_minutes||0,onChange:y=>h(v=>({...v,cooldown_minutes:parseInt(y.target.value)||0})),className:"w-32"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Minimum time between alerts for this agent. Set to 0 to disable cooldown."})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(ii,{className:"h-5 w-5 text-primary"}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"popup-notifications",className:"text-base font-medium",children:"Show Popup Notifications"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Display an in-app popup when this agent's status changes"})]})]}),n.jsx(Rs,{id:"popup-notifications",checked:u.popup_notifications,onCheckedChange:y=>h(v=>({...v,popup_notifications:y}))})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs(z,{className:"text-base font-medium flex items-center gap-2",children:[n.jsx(aa,{className:"h-4 w-4"}),"Email Recipients"]}),n.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[n.jsx("p",{className:"text-sm text-blue-800 mb-2",children:n.jsx("strong",{children:"📧 Email recipients are managed globally"})}),n.jsxs("p",{className:"text-xs text-blue-700",children:["To configure email notifications for all alerts (including agent alerts), go to the ",n.jsx("strong",{children:"Alert Management"})," section in your dashboard. This ensures all your monitoring alerts use the same email recipients."]})]})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"maintenance-mode",className:"text-base font-medium",children:"Maintenance Mode"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Temporarily disable all alerts for this agent"})]}),n.jsx(Rs,{id:"maintenance-mode",checked:u.maintenance_mode,onCheckedChange:y=>h(v=>({...v,maintenance_mode:y}))})]}),n.jsx("div",{className:"border-t pt-4 mt-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs(z,{className:"text-base font-medium flex items-center gap-2",children:[n.jsx(Ii,{className:"h-4 w-4"}),"Test Alert Email"]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Send a test alert email to verify your configuration"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>l({agentId:e.agent_id,agentName:e.agent_name,alertType:"agent_offline",lastSeen:e.last_seen}),disabled:c,className:"text-red-600 border-red-200 hover:bg-red-50",children:[n.jsx(tn,{className:"h-4 w-4 mr-1"}),c?"Sending...":"Test Offline"]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>l({agentId:e.agent_id,agentName:e.agent_name,alertType:"agent_online",lastSeen:e.last_seen}
769),disabled:c,className:"text-green-600 border-green-200 hover:bg-green-50",children:[n.jsx(Tt,{className:"h-4 w-4 mr-1"}),c?"Sending...":"Test Online"]})]})]})})]})]}),n.jsxs("div",{className:"flex justify-end gap-3",children:[n.jsx(H,{variant:"outline",onClick:r,children:"Cancel"}),n.jsxs(H,{onClick:m,disabled:o,children:[n.jsx(Lo,{className:"h-4 w-4 mr-2"}),o?"Saving...":"Save Settings"]})]})]})]})})}function x4e({open:e,onOpenChange:t,clientId:r}){var U;const{user:s,isProviderAdmin:a,clientMemberships:i,selectedClientId:o}=Mt(),[l,c]=x.useState("download"),[d,u]=x.useState(null),[h,f]=x.useState([]),[m,g]=x.useState(!1),[p,y]=x.useState(!1),[v,j]=x.useState(null),[b,_]=x.useState(""),[w,N]=x.useState(""),S=(U=i.find(F=>F.client_id===o))==null?void 0:U.client,C=async()=>{try{const{data:F,error:L}=await B.from("agent_versions").select("*").eq("status","active").order("created_at",{ascending:!1});if(L)throw L;f(F||[]);const $=(F==null?void 0:F.find(R=>R.is_latest))||(F==null?void 0:F[0])||null;u($)}catch(F){console.error("Failed to fetch agent versions:",F),ye.error("Failed to load agent versions")}};x.useEffect(()=>{e&&C()},[e]);const P=async()=>{if(!d){ye.error("No agent version available for download");return}g(!0);try{const{data:F,error:L}=await B.storage.from("agent-installers").download(d.file_path);if(L)throw L;const $=URL.createObjectURL(F),R=document.createElement("a");R.href=$,R.download=`MonitoringAgentInstaller-v${d.version}.msi`,document.body.appendChild(R),R.click(),document.body.removeChild(R),URL.revokeObjectURL($),ye.success(`Downloaded agent v${d.version}`)}catch(F){console.error("Download failed:",F),ye.error("Failed to download agent")}finally{g(!1)}},M=async()=>{if(!v||!b.trim()){ye.error("Please select a file and enter a version number");return}y(!0);try{const F=`agent-v${b}-${Date.now()}.msi`,{error:L}=await B.storage.from("agent-installers").upload(F,v);if(L)throw L;const{error:$}=await B.from("agent_versions").insert({version:b.trim(),file_path:F,is_latest:!0,status:"active",release_notes:w.trim()||null,created_by_user_id:s==null?void 0:s.id});if($)throw $;await B.from("agent_versions").update({is_latest:!1}).neq("version",b.trim()),ye.success(`Agent v${b} uploaded successfully`),j(null),_(""),N(""),await C()}catch(F){console.error("Upload failed:",F),ye.error("Failed to upload agent")}finally{y(!1)}},D=F=>{navigator.clipboard.writeText(F).then(()=>{ye.success("Copied to clipboard")}).catch(()=>{ye.error("Failed to copy to clipboard")})},A=[{step:1,title:"Download the MSI Installer",description:"Click the download button below to get the latest agent installer."},{step:2,title:"Run as Administrator",description:"Right-click the downloaded MSI file and select 'Run as administrator'."},{step:3,title:"Enter Tenant ID",description:"When prompted, enter your 24-character tenant ID:",highlight:S==null?void 0:S.tenant_id},{step:4,title:"Configure Agent",description:"Enter a name for your monitoring agent and the local hostname."},{step:5,title:"Automatic Registration",description:"The installer will automatically register your agent with the platform."},{step:6,title:"Verify Installation",description:"Check your dashboard - the agent will appear once it's online and sending heartbeats."}];return n.jsx(er,{open:e,onOpenChange:t,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[85vh] overflow-y-auto",children:[n.jsxs(zr,{children:[n.jsxs(Br,{className:"flex items-center gap-2",children:[n.jsx(wa,{className:"h-5 w-5"}),"Download Local Monitoring Agent"]}),n.jsx(_s,{children:"Download and install the smart Windows monitoring agent with automatic registration."})]}),n.jsxs(cn,{value:l,onValueChange:c,className:"mt-4",children:[n.jsxs(nn,{className:"grid w-full grid-cols-2",children:[n.jsxs(at,{value:"download",className:"flex items-center gap-2",children:[n.jsx(wa,{className:"h-4 w-4"}),"Download & Install"]}),a&&n.jsxs(at,{value:"admin",className:"flex items-center gap-2",children:[n.jsx(A7,{className:"h-4 w-4"}),"Admin Upload"]})]}),n.jsxs(it,{value:"download",className:"space-y-6 mt-6",children:[S&&n.jsxs(ee,{className:"border-primary/20 bg-gradient-to-r from-primary/5 to-primary/10",children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2 text-lg",children:[n.jsx(Km,{className:"h-5 w-5"}),"Your Tenant ID"]}),n.jsx(De,{children:"You'll need this ID during installation"})]}),n.jsx(re,{children:n.jsxs("div",{className:"flex items-center justify-between p-4 bg-background/80 rounded-lg border",children:[n.jsx("code",{className:"text-lg font-mono tracking-wider text-primary",children:S.tenant_id}),n.jsxs(H,{size:"sm",variant:"outline",onClick:()=>D(S.tenant_id),className:"hover:bg-primary/10",children:[n.jsx(rg,{className:"w-4 h-4 mr-2"}),"Copy"]})]})})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(wa,{className:"h-5 w-5"}
769),"Download Latest Agent"]}),n.jsx(De,{children:"Get the latest version of the Windows monitoring agent"})]}),n.jsx(re,{className:"space-y-4",children:d?n.jsx(n.Fragment,{children:n.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg bg-muted/50",children:[n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(ve,{variant:"default",className:"bg-gradient-primary",children:["v",d.version]}),n.jsx("span",{className:"font-medium",children:"Latest Version"})]}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Released ",is(new Date(d.created_at),{addSuffix:!0})]}),d.release_notes&&n.jsx("p",{className:"text-sm mt-2",children:d.release_notes})]}),n.jsxs(H,{onClick:P,disabled:m,className:"bg-gradient-primary",size:"lg",children:[m?n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}):n.jsx(wa,{className:"w-4 h-4 mr-2"}),"Download MSI"]})]})}):n.jsxs("div",{className:"text-center py-8",children:[n.jsx(kn,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-medium mb-2",children:"No Agent Available"}),n.jsxs("p",{className:"text-muted-foreground",children:["No agent version is currently available for download.",a&&" Please upload an agent version in the Admin tab."]})]})})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Qo,{className:"h-5 w-5"}),"Installation Instructions"]}),n.jsx(De,{children:"Follow these steps to install and configure your monitoring agent"})]}),n.jsx(re,{children:n.jsx("div",{className:"space-y-4",children:A.map(F=>n.jsxs("div",{className:"flex gap-4",children:[n.jsx("div",{className:"flex-shrink-0",children:n.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center text-sm font-medium",children:F.step})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h4",{className:"font-medium",children:F.title}),n.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:F.description}),F.highlight&&n.jsx("div",{className:"mt-2 p-2 bg-muted rounded border",children:n.jsx("code",{className:"text-sm font-mono",children:F.highlight})})]})]},F.step))})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Smart Installer Benefits"]})}),n.jsx(re,{children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx(Tt,{className:"w-8 h-8 mx-auto text-green-500"}),n.jsx("h5",{className:"font-medium",children:"Zero Configuration"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"No manual token generation or config files needed"})]}),n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx(Tt,{className:"w-8 h-8 mx-auto text-green-500"}),n.jsx("h5",{className:"font-medium",children:"Automatic Registration"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Agent registers itself using your tenant ID"})]}),n.jsxs("div",{className:"text-center space-y-2",children:[n.jsx(Tt,{className:"w-8 h-8 mx-auto text-green-500"}),n.jsx("h5",{className:"font-medium",children:"Instant Monitoring"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Appears in dashboard immediately when online"})]})]})})]})]}),a&&n.jsxs(it,{value:"admin",className:"space-y-6 mt-6",children:[n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Db,{className:"h-5 w-5"}),"Upload New Agent Version"]}),n.jsx(De,{children:"Upload a new MSI installer to make it available for download"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"version",children:"Version Number"}),n.jsx(ie,{id:"version",value:b,onChange:F=>_(F.target.value),placeholder:"e.g., 2.1.0"})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"file",children:"MSI File"}),n.jsx(ie,{id:"file",type:"file",accept:".msi",onChange:F=>{var L;return j(((L=F.target.files)==null?void 0:L[0])||null)}})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"notes",children:"Release Notes (Optional)"}),n.jsx(ie,{id:"notes",value:w,onChange:F=>N(F.target.value),placeholder:"Brief description of changes in this version"})]}),n.jsxs(H,{onClick:M,disabled:p||!v||!b.trim(),className:"w-full bg-gradient-primary",children:[p?n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}):n.jsx(Db,{className:"w-4 h-4 mr-2"}),"Upload Agent Version"]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(gC,{className:"h-5 w-5"}),"Version History"]}),n.jsx(De,{children:"All uploaded agent versions"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"space-y-3",children:h.map(F=>n.jsxs("div",{className:"flex items-center justify-between p-3 border rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs(ve,{variant:F.is_latest?"default":"outline",className:F.is_latest?"bg-gradient-primary":"",children:["v",F.version]}),n.jsxs("div",{children:[n.jsxs("p",{className:"text-sm font-medium",children:[F.is_latest&&"Latest • ",is(new Date(F.created_at),{addSuffix:!0})]}),F.release_notes&&n.jsx("p",{className:"text-xs text-muted-foreground",children:F.release_notes})]})]}),n.jsx(ve,{variant:"outline",className:F.status==="active"?"text-green-600":"text-muted-foreground",children:F.status})]},F.id))}),h.length===0&&n.jsxs("div",{className:"text-center py-6 text-muted-foreground",children:[n.jsx(Db,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),n.jsx("p",{children:"No agent versions uploaded yet."})]})]})]})]})]})]})})}var K2="ContextMenu",[v4e,xRe]=Qr(K2,[Xj]),ks=Xj(),[y4e,f9]=v4e(K2),m9=e=>{const{__scopeContextMenu:t,children:r,onOpenChange:s,dir:a,modal:i=!0}=e,[o,l]=x.useState(!1),c=ks(t),d=Sr(s),u=x.useCallback(h=>
769{l(h),d(h)},[d]);return n.jsx(y4e,{scope:t,open:o,onOpenChange:u,modal:i,children:n.jsx(b8,{...c,dir:a,open:o,onOpenChange:u,modal:i,children:r})})};m9.displayName=K2;var p9="ContextMenuTrigger",g9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,disabled:s=!1,...a}=e,i=f9(p9,r),o=ks(r),l=x.useRef({x:0,y:0}),c=x.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=x.useRef(0),u=x.useCallback(()=>window.clearTimeout(d.current),[]),h=f=>{l.current={x:f.clientX,y:f.clientY},i.onOpenChange(!0)};return x.useEffect(()=>u,[u]),x.useEffect(()=>void(s&&u()),[s,u]),n.jsxs(n.Fragment,{children:[n.jsx(w8,{...o,virtualRef:c}),n.jsx(We.span,{"data-state":i.open?"open":"closed","data-disabled":s?"":void 0,...a,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:s?e.onContextMenu:Te(e.onContextMenu,f=>{u(),h(f),f.preventDefault()}),onPointerDown:s?e.onPointerDown:Te(e.onPointerDown,Ox(f=>{u(),d.current=window.setTimeout(()=>h(f),700)})),onPointerMove:s?e.onPointerMove:Te(e.onPointerMove,Ox(u)),onPointerCancel:s?e.onPointerCancel:Te(e.onPointerCancel,Ox(u)),onPointerUp:s?e.onPointerUp:Te(e.onPointerUp,Ox(u))})]})});g9.displayName=p9;var j4e="ContextMenuPortal",x9=e=>{const{__scopeContextMenu:t,...r}=e,s=ks(t);return n.jsx(_8,{...s,...r})};x9.displayName=j4e;var v9="ContextMenuContent",y9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=f9(v9,r),i=ks(r),o=x.useRef(!1);return n.jsx(N8,{...i,...s,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:l=>{var c;(c=e.onCloseAutoFocus)==null||c.call(e,l),!l.defaultPrevented&&o.current&&l.preventDefault(),o.current=!1},onInteractOutside:l=>{var c;(c=e.onInteractOutside)==null||c.call(e,l),!l.defaultPrevented&&!a.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});y9.displayName=v9;var b4e="ContextMenuGroup",w4e=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(S8,{...a,...s,ref:t})});w4e.displayName=b4e;var _4e="ContextMenuLabel",j9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(C8,{...a,...s,ref:t})});j9.displayName=_4e;var N4e="ContextMenuItem",b9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(k8,{...a,...s,ref:t})});b9.displayName=N4e;var S4e="ContextMenuCheckboxItem",w9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(P8,{...a,...s,ref:t})});w9.displayName=S4e;var C4e="ContextMenuRadioGroup",k4e=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(T8,{...a,...s,ref:t})});k4e.displayName=C4e;var P4e="ContextMenuRadioItem",_9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(A8,{...a,...s,ref:t})});_9.displayName=P4e;var T4e="ContextMenuItemIndicator",N9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(E8,{...a,...s,ref:t})});N9.displayName=T4e;var A4e="ContextMenuSeparator",S9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(O8,{...a,...s,ref:t})});S9.displayName=A4e;var E4e="ContextMenuArrow",O4e=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(M8,{...a,...s,ref:t})});O4e.displayName=E4e;var M4e="ContextMenuSubTrigger",C9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(D8,{...a,...s,ref:t})});C9.displayName=M4e;var D4e="ContextMenuSubContent",k9=x.forwardRef((e,t)=>{const{__scopeContextMenu:r,...s}=e,a=ks(r);return n.jsx(R8,{...a,...s,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});k9.displayName=D4e;function Ox(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var R4e=m9,$4e=g9,I4e=x9,P9=y9,T9=j9,A9=b9,E9=w9,O9=_9,M9=N9,D9=S9,R9=C9,$9=k9;
769const L4e=R4e,F4e=$4e,U4e=x.forwardRef(({className:e,inset:t,children:r,...s},a)=>n.jsxs(R9,{ref:a,className:we("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent data-[state=open]:text-accent-foreground focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...s,children:[r,n.jsx(Yo,{className:"ml-auto h-4 w-4"})]}));U4e.displayName=R9.displayName;const z4e=x.forwardRef(({className:e,...t},r)=>n.jsx($9,{ref:r,className:we("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));z4e.displayName=$9.displayName;const I9=x.forwardRef(({className:e,...t},r)=>n.jsx(I4e,{children:n.jsx(P9,{ref:r,className:we("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t})}));I9.displayName=P9.displayName;const om=x.forwardRef(({className:e,inset:t,...r},s)=>n.jsx(A9,{ref:s,className:we("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...r}));om.displayName=A9.displayName;const B4e=x.forwardRef(({className:e,children:t,checked:r,...s},a)=>n.jsxs(E9,{ref:a,className:we("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:r,...s,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(M9,{children:n.jsx(oi,{className:"h-4 w-4"})})}),t]}));B4e.displayName=E9.displayName;const q4e=x.forwardRef(({className:e,children:t,...r},s)=>n.jsxs(O9,{ref:s,className:we("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...r,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(M9,{children:n.jsx(ku,{className:"h-2 w-2 fill-current"})})}),t]}));q4e.displayName=O9.displayName;const W4e=x.forwardRef(({className:e,inset:t,...r},s)=>n.jsx(T9,{ref:s,className:we("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...r}));W4e.displayName=T9.displayName;const mS=x.forwardRef(({className:e,...t},r)=>n.jsx(D9,{ref:r,className:we("-mx-1 my-1 h-px bg-border",e),...t}));mS.displayName=D9.displayName;const H4e=[{value:"tcp",label:"TCP Port Monitoring",icon:ht},{value:"udp",label:"UDP Port Monitoring",icon:ht},{value:"http",label:"HTTP/HTTPS Monitoring",icon:Pn},{value:"smtp",label:"SMTP Monitoring",icon:aa},{value:"ftp",label:"FTP Monitoring",icon:ng},{value:"sftp",label:"SFTP Monitoring",icon:yt}];function V4e({agent:e,onUpdate:t}){const[r,s]=x.useState(!1),[a,i]=x.useState([]),[o,l]=x.useState(""),[c,d]=x.useState(!1),u=e.is_probe_agent||!1,h=e.probe_capabilities||[],f=async()=>{if(t){d(!0);try{await t(e.id,{is_probe_agent:!0,probe_capabilities:a,probe_location:o.trim()||null}),ye.success("Probe agent enabled successfully"),s(!1)}catch(p){console.error("Error enabling probe agent:",p),ye.error("Failed to enable probe agent")}finally{d(!1)}}},m=async()=>{if(t){d(!0);try{await t(e.id,{is_probe_agent:!1,probe_capabilities:[],probe_location:null}),ye.success("Probe agent disabled successfully")}catch(p){console.error("Error disabling probe agent:",p),ye.error("Failed to disable probe agent")}finally{d(!1)}}},g=(p,y)=>{i(v=>y?[...v,p]:v.filter(j=>j!==p))};return u?n.jsxs(L4e,{children:[n.jsx(F4e,{asChild:!0,children:n.jsxs(H,{variant:"ghost",size:"sm",title:`Probe agent (${h.length} capabilities)`,className:"relative",children:[n.jsx("div",{className:"absolute -top-1 -left-1 h-2 w-2 bg-green-500 rounded-full border border-background"}),n.jsx(Cn,{className:"h-4 w-4 text-primary"}),h.length>0&&n.jsx(ve,{variant:"secondary",className:"absolute -top-1 -right-1 h-4 w-4 p-0 flex items-center justify-center text-xs bg-primary/10 text-primary",children:h.length})]})}),n.jsxs(I9,{children:[n.jsx(om,{disabled:!0,className:"text-sm font-medium",children:"Probe Agent Active"}),e.probe_location&&n.jsxs(om,{disabled:!0,className:"text-xs text-muted-foreground",children:["📍 ",e.probe_location]}),n.jsx(mS,{}),h.length>0&&n.jsxs(n.Fragment,{children:[n.jsxs(om,{disabled:!0,className:"text-xs text-muted-foreground",children:["Capabilities: ",h.join(", ")
769]}),n.jsx(mS,{})]}),n.jsx(om,{onClick:m,className:"text-destructive",disabled:c,children:"Disable Probe"})]})]}):n.jsxs(n.Fragment,{children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>s(!0),title:"Enable as probe agent",className:"relative",children:n.jsx(Cn,{className:"h-4 w-4 text-muted-foreground"})}),n.jsx(er,{open:r,onOpenChange:s,children:n.jsxs(Kt,{className:"max-w-md",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Enable Probe Agent"}),n.jsx(_s,{children:"Enable this agent to act as a probe for monitoring other network resources."})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"probe-location",children:"Probe Location (Optional)"}),n.jsx(ie,{id:"probe-location",value:o,onChange:p=>l(p.target.value),placeholder:"e.g., Data Center A, Office NYC",className:"mt-1"})]}),n.jsxs("div",{children:[n.jsx(z,{children:"Monitoring Capabilities"}),n.jsx("div",{className:"grid grid-cols-1 gap-2 mt-2",children:H4e.map(p=>{const y=p.icon;return n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:p.value,checked:a.includes(p.value),onCheckedChange:v=>g(p.value,v)}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(y,{className:"h-4 w-4"}),n.jsx(z,{htmlFor:p.value,className:"text-sm",children:p.label})]})]},p.value)})})]}),n.jsxs("div",{className:"flex justify-end space-x-2 pt-4",children:[n.jsx(H,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),n.jsx(H,{onClick:f,disabled:c||a.length===0,children:"Enable Probe"})]})]})]})})]})}function L9({selectedClientId:e,tenantCustomerId:t,context:r}){const[s,a]=x.useState(new Set),{openHelpModal:i}=_ae(),{helpRequests:o,isLoading:l,refetch:c}=h6(e);G.useEffect(()=>{c()},[c]);const d=g=>{const p=new Set(s);p.has(g)?p.delete(g):p.add(g),a(p)},u=g=>{switch(g){case"bug_report":return n.jsx(S7,{className:"h-4 w-4"});case"feature_request":return n.jsx(D7,{className:"h-4 w-4"});default:return n.jsx(Hm,{className:"h-4 w-4"})}},h=g=>{switch(g){case"bug_report":return"Bug Report";case"feature_request":return"Feature Request";default:return"General Help"}},f=g=>{switch(g){case"reported":return"secondary";case"in_progress":return"default";case"resolved":return"outline";default:return"secondary"}},m=g=>{switch(g){case"high":return"destructive";case"medium":return"default";case"low":return"secondary";default:return"secondary"}};return l?n.jsx("div",{className:"flex items-center justify-center p-8",children:n.jsx("div",{className:"text-muted-foreground",children:"Loading help requests..."})}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-semibold",children:"Get Help"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Submit bug reports, feature requests, or ask for general help"})]}),n.jsxs(H,{onClick:()=>i(r,t),className:"gap-2",children:[n.jsx(Ws,{className:"h-4 w-4"}),"New Request"]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h4",{className:"text-md font-medium",children:"Your Help Requests"}),o.length===0?n.jsx(ee,{children:n.jsxs(re,{className:"p-6 text-center",children:[n.jsx(Hm,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),n.jsx("p",{className:"text-muted-foreground",children:"No help requests yet"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Submit your first request using the button above"})]})}):o.map(g=>n.jsx(ee,{children:n.jsxs(ur,{open:s.has(g.id),onOpenChange:()=>d(g.id),children:[n.jsx(Jr,{asChild:!0,children:n.jsx(de,{className:"cursor-pointer hover:bg-muted/50 transition-colors",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[u(g.type),n.jsxs("div",{children:[n.jsx(me,{className:"text-base",children:g.title}),n.jsxs(De,{children:[$r(new Date(g.reported_date),"MMM d, yyyy")," • ",h(g.type)]})]})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ve,{variant:m(g.priority),children:g.priority}),n.jsx(ve,{variant:f(g.status),children:g.status.replace("_"," ")}),s.has(g.id)?n.jsx(dr,{className:"h-4 w-4"}):n.jsx(Yo,{className:"h-4 w-4"})]})]})})}),n.jsx(Er,{children:n.jsx(re,{className:"pt-0",children:n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h5",{className:"font-medium mb-2",children:"Description"}),n.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:g.description})]}),g.response_notes&&n.jsxs("div",{children:[n.jsx("h5",{className:"font-medium mb-2",children:"Response"}),n.jsxs("div",{className:"bg-muted/50 p-3 rounded-md",children:[n.jsx("p",{className:"text-sm whitespace-pre-wrap",children:g.response_notes}),g.resolved_date&&n.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Resolved on ",$r(new Date(g.resolved_date),"MMM d, yyyy")]})]})]})]})})})]})},g.id))]})]})}function K4e(){var Y2,Q2,X2,Z2,J2;const e=di(),[t,r]=RC(),{toast:s}=qr(),{selectedClientId:a}=Mt(),{agents:i,isLoading:o,updateAgent:l,deleteAgent:c}
769=Lt(a),{recentHeartbeats:d,agentStatuses:u}=dc(),{agentAlerts:h,isLoadingAlerts:f,acknowledgeAlert:m,deleteAlerts:g,isAcknowledging:p,isDeleting:y,isAgentAlertsEnabled:v}=V2(),{groups:j,assignAgentToGroup:b,removeAgentFromGroup:_}=Vi(a),[w,N]=x.useState(""),[S,C]=x.useState(()=>{const ge=t.get("group");return ge||"all"});x.useEffect(()=>{const ge=t.get("group");ge&&C(ge)},[t]);const[P,M]=x.useState("all"),[D,A]=x.useState(""),[U,F]=x.useState(""),[L,$]=x.useState(!1),[R,T]=x.useState(!1),[k,W]=x.useState(null),[q,Q]=x.useState(!1),[ue,X]=x.useState(null),[le,pe]=x.useState(!1),[ce,se]=x.useState(null),[oe,V]=x.useState(!1),[fe,ne]=x.useState(!1),[Ce,Pe]=x.useState(1),[he,ke]=x.useState("agents"),[Me,Je]=x.useState(new Set),[Ke,E]=x.useState(null),[O,I]=x.useState("all"),Y=5,te=x.useRef(null),K=(i==null?void 0:i.filter(ge=>ge.asset_type==="local_device"))||[],{data:Z=[],refetch:je}=Ve({queryKey:["probe-agents",a],enabled:!!a,queryFn:async()=>{if(!a)return[];const{data:ge,error:Re}=await B.from("monitoring_agents").select("id, is_probe_agent, probe_capabilities, probe_location").eq("client_id",a).in("asset_type",["local_device"]);if(Re)throw Re;return ge}}),_e=x.useMemo(()=>{const ge={};return(Z||[]).forEach(Re=>{ge[Re.id]=Re}),ge},[Z]),{data:Ee,refetch:Ze}=Ve({queryKey:["agent-groups",a],enabled:!!a,queryFn:async()=>{const{data:ge,error:Re}=await B.from("agent_groups").select("agent_id, group_id").eq("client_id",a);if(Re)throw Re;return ge||[]}}),st=x.useMemo(()=>{const ge={};return(Ee||[]).forEach(Re=>{ge[Re.agent_id]||(ge[Re.agent_id]=[]),ge[Re.agent_id].push(Re.group_id)}),ge},[Ee]),xt=ge=>{const Re=st[ge]||[];return(j==null?void 0:j.filter(ut=>Re.includes(ut.id)))||[]},Dt=x.useMemo(()=>{const ge={};ge.all={total:K.length,online:K.filter(ut=>{const Yt=u==null?void 0:u.find(Mr=>Mr.agent_id===ut.id);return(Yt==null?void 0:Yt.status)==="online"}).length,offline:K.filter(ut=>{const Yt=u==null?void 0:u.find(Mr=>Mr.agent_id===ut.id);return(Yt==null?void 0:Yt.status)!=="online"}).length};const Re=K.filter(ut=>!(st[ut.id]&&st[ut.id].length>0));return ge.ungrouped={total:Re.length,online:Re.filter(ut=>{const Yt=u==null?void 0:u.find(Mr=>Mr.agent_id===ut.id);return(Yt==null?void 0:Yt.status)==="online"}).length,offline:Re.filter(ut=>{const Yt=u==null?void 0:u.find(Mr=>Mr.agent_id===ut.id);return(Yt==null?void 0:Yt.status)!=="online"}).length},j==null||j.forEach(ut=>{const Yt=Object.entries(st).filter(([On,Ps])=>Ps.includes(ut.id)).map(([On])=>On),Mr=K.filter(On=>Yt.includes(On.id));ge[ut.id]={total:Mr.length,online:Mr.filter(On=>{const Ps=u==null?void 0:u.find(zd=>zd.agent_id===On.id);return(Ps==null?void 0:Ps.status)==="online"}).length,offline:Mr.filter(On=>{const Ps=u==null?void 0:u.find(zd=>zd.agent_id===On.id);return(Ps==null?void 0:Ps.status)!=="online"}).length}}),ge},[K,u,j,st]),xe=x.useMemo(()=>{const ge=K.length;let Re=0,ut=0,Yt=0;return K.forEach(Mr=>{const On=u==null?void 0:u.find(Ps=>Ps.agent_id===Mr.id);(On==null?void 0:On.status)==="online"?Re++:ut++,v(Mr.id)&&Yt++}),{total:ge,online:Re,offline:ut,withAlerts:Yt}},[K,u,v]),qe=x.useMemo(()=>{let ge=K;return w&&(ge=ge.filter(Re=>{var ut;return Re.name.toLowerCase().includes(w.toLowerCase())||((ut=Re.hostname_or_url)==null?void 0:ut.toLowerCase().includes(w.toLowerCase()))})),S!=="all"&&(ge=ge.filter(Re=>S==="ungrouped"?(st[Re.id]||[]).length===0:(st[Re.id]||[]).includes(S))),P!=="all"&&(ge=ge.filter(Re=>{const ut=u==null?void 0:u.find(Yt=>Yt.agent_id===Re.id);return(ut==null?void 0:ut.status)===P})),ge},[K,w,S,P,st,u]),St=Math.ceil(qe.length/Y),Pr=x.useMemo(()=>{const ge=(Ce-1)*Y,Re=ge+Y;return qe.slice(ge,Re)},[qe,Ce,Y]);x.useEffect(()=>{Pe(1)},[w,S,P]);const wn=ge=>{const Re=u==null?void 0:u.find(ut=>ut.agent_id===ge);return Re?{status:Re.status,lastSeen:Re.last_seen,hostname:Re.hostname,localIp:Re.local_ip,osType:Re.os_type}:{status:"unknown",lastSeen:null,hostname:null,localIp:null,osType:null}},An=ge=>(h==null?void 0:h.filter(Re=>Re.agent_id===ge&&Re.status==="sent"))||[],En=ge=>{C(ge),ge==="all"?t.delete("group"):t.set("group",ge),r(t),Pe(1)},ls=async(ge,Re)=>{var ut;if(a)try{const Yt=st[ge]||[];for(const Mr of Yt)await _({agentId:ge,groupId:Mr});if(Re!=="remove"){await b({agentId:ge,groupId:Re});const Mr=(ut=j==null?void 0:j.find(On=>On.id===Re))==null?void 0:ut.name;s({title:"Success",description:`Agent assigned to group "${Mr}"`})}else s({title:"Success",description:"Agent removed from all groups"});Ze()}catch(Yt){console.error("Error changing agent group:",Yt),s({title:"Error",description:"Failed to change agent group",variant:"destructive"})}},cs=ge=>{Je(Re=>{const ut=new Set(Re);return ut.has(ge)?ut.delete(ge):ut.add(ge),ut})},ze=()=>{const ge=(h==null?void 0:h.filter(Re=>Re.status==="sent"))||[];Me.size===ge.length?Je(new Set):Je(new Set(ge.map(Re=>Re.id)))},xf=async()=>{try{await g(Array.from(Me)),Je(new Set),s({title:"Success",description:`Deleted ${Me.size} alert(s)`})}catch(ge){console.error("Error deleting alerts:",ge),s({title:"Error",description:"Failed to delete alerts",variant:"destructive"})}},{createCommand:dt,isCreating:zt}
769=zv(D||void 0,a),{commands:Ft,activeCommands:ds,cancelCommand:Ct,deleteCommand:fi,isCancelling:nl,isDeleting:ua}=zv(void 0,a),ha=x.useMemo(()=>O==="all"?Ft:Ft.filter(ge=>ge.agent_id===O),[Ft,O]),eW=x.useMemo(()=>ha.filter(ge=>ge.status==="pending"),[ha]),tW=ge=>{console.log("Sending command for agent:",ge.agent_id),te.current={agentId:ge.agent_id,timestamp:Date.now()},dt(ge),T(!1)};x.useEffect(()=>{if(!a)return;const ge=B.channel("new-commands-listener").on("postgres_changes",{event:"INSERT",schema:"public",table:"agent_commands",filter:`client_id=eq.${a}`},Re=>{const ut=Re.new;if(te.current){const Yt=Date.now()-te.current.timestamp;ut.agent_id===te.current.agentId&&Yt<5e3&&(W(ut.id),Q(!0),te.current=null)}}).subscribe();return()=>{B.removeChannel(ge)}},[a]);const Ud=(h==null?void 0:h.filter(ge=>ge.status==="sent"))||[];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Private LAN Agents"}),n.jsx("p",{className:"text-muted-foreground",children:"Monitor and manage your private network infrastructure agents"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(H,{onClick:()=>ne(!0),variant:"outline",children:[n.jsx(wa,{className:"h-4 w-4 mr-2"}),"Download Agent"]}),n.jsxs(H,{onClick:()=>$(!0),variant:"outline",children:[n.jsx(Rr,{className:"h-4 w-4 mr-2"}),"Manage Groups"]})]})]}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[n.jsxs(ee,{className:`cursor-pointer transition-all ${P==="all"?"ring-2 ring-primary":"hover:shadow-md"}`,onClick:()=>M("all"),children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Total Agents"}),n.jsx(ht,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:xe.total}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Private LAN monitoring agents"})]})]}),n.jsxs(ee,{className:`cursor-pointer transition-all ${P==="online"?"ring-2 ring-success":"hover:shadow-md"}`,onClick:()=>M("online"),children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Online"}),n.jsx(zs,{className:"h-4 w-4 text-success"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:xe.online}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Currently active agents"})]})]}),n.jsxs(ee,{className:`cursor-pointer transition-all ${P==="offline"?"ring-2 ring-destructive":"hover:shadow-md"}`,onClick:()=>M("offline"),children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Offline"}),n.jsx(sa,{className:"h-4 w-4 text-destructive"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:xe.offline}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents not responding"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"With Alerts Enabled"}),n.jsx(tn,{className:"h-4 w-4 text-warning"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:xe.withAlerts}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Agents with alert monitoring enabled"})]})]})]}),n.jsxs(cn,{value:he,onValueChange:ke,className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsxs(at,{value:"agents",children:[n.jsx(ht,{className:"h-4 w-4 mr-2"}),"Agents (",qe.length,")"]}),n.jsxs(at,{value:"alerts",children:[n.jsx(tn,{className:"h-4 w-4 mr-2"}),"Active Alerts (",Ud.length,")"]}),n.jsxs(at,{value:"commands",children:[n.jsx(ws,{className:"h-4 w-4 mr-2"}),"Commands (",Ft.length,")"]}),n.jsxs(at,{value:"get-help",children:[n.jsx(Hm,{className:"h-4 w-4 mr-2"}),"Get Help"]})]}),n.jsxs(it,{value:"agents",className:"space-y-4",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"flex items-center justify-between",children:n.jsx("div",{className:"flex-1 overflow-hidden",children:n.jsx(cn,{value:S,onValueChange:En,children:n.jsx("div",{className:"overflow-x-auto pb-2",children:n.jsxs(nn,{className:"inline-flex h-auto p-1 bg-muted/50 gap-1 flex-nowrap",children:[n.jsxs(at,{value:"all",className:"flex items-center gap-2 px-3 py-2 whitespace-nowrap data-[state=active]:bg-background",children:[n.jsx(ht,{className:"h-4 w-4"}),n.jsx("span",{children:"All"}),n.jsx(ve,{variant:"secondary",className:"ml-1",children:((Y2=Dt.all)==null?void 0:Y2.total)||0})]}),n.jsxs(at,{value:"ungrouped",className:"flex items-center gap-2 px-3 py-2 whitespace-nowrap data-[state=active]:bg-background",disabled:(((Q2=Dt.ungrouped)==null?void 0:Q2.total)||0)===0,children:[n.jsx(Vm,{className:"h-4 w-4"}),n.jsx("span",{children:"Ungrouped"}),n.jsxs("div",{className:"flex items-center gap-1",children:[(((X2=Dt.ungrouped)==null?void 0:X2.online)||0)>0&&n.jsx("div",{className:"w-2 h-2 rounded-full bg-success"}),(((Z2=Dt.ungrouped)==null?void 0:Z2.offline)||0)>0&&n.jsx("div",{className:"w-2 h-2 rounded-full bg-destructive"}),n.jsx(ve,{variant:"secondary",children:((J2=Dt.ungrouped)==null?void 0:J2.total)||0})]})]}),j&&j.length>0&&n.jsx("div",{className:"w-px h-6 bg-border mx-1 self-center"}),j==null?void 0:j.filter(ge=>ge.is_critical).map(ge=>{const Re=Dt[ge.id];return n.jsxs(at,{value:ge.id,className:"flex items-center gap-2 px-3 py-2 whitespace-nowrap data-[state=active]:bg-background",children:[n.jsx(Sv,{className:"h-4 w-4 text-warning fill-warning"}),n.jsx("span",{children:ge.name}),n.jsxs("div",{className:"flex items-center gap-1",children:[((Re==null?void 0:Re.online)||0)>0&&n.jsx("div",{className:"w-2 h-2 rounded-full bg-success"}),((Re==null?void 0:Re.offline)||0)>0&&n.jsx("div",{className:"w-2 h-2 rounded-full bg-destructive"}),n.jsx(ve,{variant:"secondary",children:(Re==null?void 0:Re.total)||0})]})]},ge.id)}),(j==null?void 0:j.some(ge=>ge.is_critical))&&(j==null?void 0:j.some(ge=>!ge.is_critical))&&n.jsx("div",{className:"w-px h-6 bg-border mx-1 self-center"}),j==null?void 0:j.filter(ge=>!ge.is_critical).map(ge=>{const Re=Dt[ge.id];return n.jsxs(at,{value:ge.id,className:"flex items-center gap-2 px-3 py-2 whitespace-nowrap data-[state=active]:bg-background",children:[n.jsx(Rr,{className:"h-4 w-4"}),n.jsx("span",{children:ge.name}),n.jsxs("div",{className:"flex items-center gap-1",children:[((Re==null?void 0:Re.online)||0)>0&&n.jsx("div",{className:"w-2 h-2 rounded-full bg-success"}),((Re==null?void 0:Re.offline)||0)>0&&n.jsx("div",{className:"w-2 h-2 rounded-full bg-destructive"}),n.jsx(ve,{variant:"secondary",children:(Re==null?void 0:Re.total)||0})]})]},ge.id)})]})})})})}),n.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search by name or hostname...",value:w,onChange:ge=>N(ge.target.value),className:"pl-8"})]}),n.jsxs("select",{value:P,onChange:ge=>M(ge.target.value),className:"h-10 px-3 rounded-md border bg-background text-sm",children:[n.jsx("option",{value:"all",children:"All Status"}),n.jsx("option",{value:"online",children:"Online Only"}),n.jsx("option",{value:"offline",children:"Offline Only"})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"grid grid-cols-1 gap-4",children:o?n.jsx(ee,{children:n.jsx(re,{className:"py-12 text-center text-muted-foreground",children:"Loading agents..."})}):qe.length===0?n.jsx(ee,{children:n.jsxs(re,{className:"py-12 text-center",children:[n.jsx(ht,{className:"h-12 w-12 mx-auto mb-4 opacity-50 text-muted-foreground"}),n.jsx("p",{className:"text-lg font-medium",children:"No agents found"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:w?"Try adjusting your search":"Add your first private LAN agent"})]})}):Pr.map(ge=>{var On,Ps,zd;const Re=wn(ge.id),ut=An(ge.id),Yt=xt(ge.id),Mr=v(ge.id);return n.jsx(ee,{className:"hover:shadow-md transition-shadow",children:n.jsx(re,{className:"p-6",children:n.jsxs("div",{className:"flex items-center gap-4",children:[n.jsx("div",{className:"flex items-center",children:n.jsx("div",{className:`w-3 h-3 rounded-full ${Re.status==="online"?"bg-success shadow-lg shadow-success/50":"bg-destructive shadow-lg shadow-destructive/50"}`,title:Re.status==="online"?"Online":"Offline"})}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[n.jsx("h3",{className:"text-lg font-semibold",children:ge.name}),Mr&&n.jsxs(ve,{variant:"secondary",className:"bg-primary/10 text-primary",children:[n.jsx(ii,{className:"h-3 w-3 mr-1"}),"Alerts On"]}),ut.length>0&&n.jsxs(ve,{variant:"destructive",children:[n.jsx(tn,{className:"h-3 w-3 mr-1"}),ut.length," Alert",ut.length>
7691?"s":""]})]}),n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[n.jsxs("div",{children:[n.jsx("p",{className:"text-muted-foreground",children:"Last Seen"}),n.jsx("p",{className:"font-medium",children:Re.lastSeen&&!isNaN(new Date(Re.lastSeen).getTime())?$r(new Date(Re.lastSeen),"MMM dd, HH:mm"):"Never"})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-muted-foreground",children:"Group"}),n.jsx("div",{className:"flex flex-wrap gap-1",children:Yt.length>0?Yt.map(mi=>n.jsx(ve,{variant:"outline",className:"text-xs",children:mi.name},mi.id)):n.jsx("span",{className:"font-medium text-muted-foreground",children:"No group"})})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-muted-foreground",children:"Hostname"}),n.jsx("p",{className:"font-medium",children:Re.hostname||ge.hostname_or_url||"N/A"})]}),n.jsxs("div",{children:[n.jsx("p",{className:"text-muted-foreground",children:"OS Type"}),n.jsx("p",{className:"font-medium",children:Re.osType||"Unknown"})]})]}),ge.description&&n.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:ge.description})]}),n.jsx("div",{className:"flex-1 flex items-center justify-center",children:n.jsx(p4e,{agentId:ge.id,createdAt:ge.created_at||new Date().toISOString()})}),n.jsxs("div",{className:"flex gap-2 shrink-0 flex-wrap",children:[n.jsx(V4e,{agent:{id:ge.id,name:ge.name,is_probe_agent:!!((On=_e[ge.id])!=null&&On.is_probe_agent),probe_capabilities:((Ps=_e[ge.id])==null?void 0:Ps.probe_capabilities)||[],probe_location:((zd=_e[ge.id])==null?void 0:zd.probe_location)||null},onUpdate:async(mi,nb)=>{const{error:vf}=await B.from("monitoring_agents").update(nb).eq("id",mi);vf?s({title:"Error",description:vf.message,variant:"destructive"}):(s({title:"Probe updated",description:"Probe settings saved."}),je())}}),n.jsx(Eu,{children:n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",onClick:()=>e(`/dashboard/agent/${ge.id}/monitors`),children:n.jsx($o,{className:"h-4 w-4"})})}),n.jsx(Pi,{children:"View Agent Details"})]})}),n.jsx(Eu,{children:n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",onClick:()=>{X(ge),pe(!0)},children:n.jsx(B7,{className:"h-4 w-4"})})}),n.jsx(Pi,{children:"Edit Agent"})]})}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>{A(ge.id),F(ge.name),T(!0)},children:[n.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Command"]}),n.jsx(Eu,{children:n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsxs(H,{variant:"outline",size:"sm",className:"relative",onClick:()=>{se(ge),V(!0)},children:[n.jsx(ii,{className:"h-4 w-4"}),Mr&&n.jsx("span",{className:"absolute -top-1 -right-1 h-2.5 w-2.5 rounded-full bg-success border-2 border-background"})]})}),n.jsx(Pi,{children:Mr?"Alerts enabled - Click to configure":"Configure Alerts"})]})}),n.jsxs(gk,{children:[n.jsx(xk,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",title:"Change group",children:n.jsx(Vm,{className:"h-4 w-4"})})}),n.jsxs(sj,{className:"w-56 p-1",align:"end",children:[n.jsx("div",{className:"px-2 py-1.5 text-sm font-medium text-muted-foreground",children:"Change Group"}),n.jsx(H,{variant:"ghost",size:"sm",className:"w-full justify-start text-destructive hover:text-destructive",onClick:()=>ls(ge.id,"remove"),children:"Remove from all groups"}),n.jsx("div",{className:"h-px bg-border my-1"}),j==null?void 0:j.map(mi=>{var vf;const nb=(vf=st[ge.id])==null?void 0:vf.includes(mi.id);return n.jsxs(H,{variant:"ghost",size:"sm",className:"w-full justify-start",onClick:()=>ls(ge.id,mi.id),children:[nb?n.jsx(oi,{className:"h-4 w-4 mr-2 text-primary"}):n.jsx("span",{className:"w-4 mr-2"}),mi.name,mi.is_critical&&n.jsx("span",{className:"ml-auto text-xs text-destructive",children:"Critical"})]},mi.id)}),(!j||j.length===0)&&n.jsx("div",{className:"px-2 py-3 text-sm text-muted-foreground text-center",children:"No groups available"})]})]}),n.jsxs(os,{children:[n.jsx(lh,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",title:"Delete agent",children:n.jsx(Vt,{className:"h-4 w-4 text-destructive"})})}),n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete Agent"}),n.jsxs(Bn,{children:['This will permanently delete the agent "',ge.name,'" and all its associated monitors and data. This action cannot be undone.']})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:()=>c(ge.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Agent"})]})]})]})]})]})})},ge.id)})}),!o&&qe.length>0&&n.jsxs("div",{className:"flex items-center justify-between pt-4",children:[n.jsxs("div",{className:"text-sm text-muted-foreground",children:["Showing ",(Ce-1)*Y+1," to ",Math.min(Ce*Y,qe.length)," of ",qe.length," agents"]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>Pe(ge=>Math.max(1,ge-1)),disabled:Ce===1,children:[n.jsx(zh,{className:"h-4 w-4 mr-1"}),"Previous"]}),n.jsxs("div",{className:"flex items-center gap-1",children:[Array.from({length:Math.min(St,5)},(ge,Re)=>Re+1).map(ge=>n.jsx(H,{variant:Ce===ge?"default":"outline",size:"sm",onClick:()=>Pe(ge),className:"w-8 h-8 p-0",children:ge},ge)),St>5&&n.jsx("span",{className:"px-2 text-muted-foreground",children:"..."})]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>Pe(ge=>Math.min(St,ge+1)),disabled:Ce===St,children:["Next",n.jsx(Yo,{className:"h-4 w-4 ml-1"})]})]})]})]})]}),n.jsx(it,{value:"alerts",className:"space-y-4",children:n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"Active Agent Alerts"}),n.jsx(De,{children:"Current alerts from your private LAN monitoring agents"})]}),n.jsx(re,{children:Ud.length===0?n.jsxs("div",{className:"text-center py-12",children:[n.jsx(zs,{className:"h-12 w-12 mx-auto mb-4 text-success opacity-50"}),n.jsx("p",{className:"text-lg font-medium",children:"No active alerts"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"All your agents are running smoothly"})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ct,{checked:Me.size===Ud.length&&Ud.length>0,onCheckedChange:ze}),n.jsxs("span",{className:"text-sm",children:["Select All (",Me.size," of ",Ud.length," selected)"]})]}),n.jsx("div",{className:"flex gap-2",children:n.jsxs(H,{size:"sm",variant:"destructive",onClick:xf,disabled:Me.size===0||y,className:"flex items-center gap-2",children:[n.jsx(Vt,{className:"h-4 w-4"}),y?"Deleting...":`Delete Selected (${Me.size})`]})})]}),n.jsx("div",{className:"space-y-3",children:Ud.map(ge=>n.jsx(ee,{children:n.jsx(re,{className:"p-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ct,{checked:Me.has(ge.id),onCheckedChange:()=>cs(ge.id)}),n.jsxs("div",{className:"flex-1",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.jsx(tn,{className:"h-4 w-4 text-destructive"}),n.jsx("h4",{className:"font-semibold",children:ge.agent_name||"Unknown Agent"}),n.jsx(ve,{variant:"destructive",children:ge.alert_type})]}),n.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:ge.error_message||"Alert triggered"}),n.jsxs("div",{className:"text-xs text-muted-foreground",children:["Triggered: ",ge.triggered_at&&!isNaN(new Date(ge.triggered_at).getTime())?$r(new Date(ge.triggered_at),"MMM dd, yyyy HH:mm:ss"):"Unknown"]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:()=>m(ge.id),disabled:p,children:p?"Acknowledging...":"Acknowledge"}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>e(`/dashboard/agent/${ge.agent_id}/monitors`),children:"View Details"})]})]})})},ge.id))})]})})]})}),n.jsxs(it,{value:"commands",className:"space-y-4",children:[n.jsx(ee,{children:n.jsx(re,{className:"pt-6",children:n.jsxs("div",{className:"flex flex-col md:flex-row gap-4 items-start md:items-center",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx(z,{children:"Filter by Agent"}),n.jsxs(Fe,{value:O,onValueChange:I,children:[n.jsx(Ie,{className:"w-full md:w-64",children:n.jsx(Ue,{placeholder:"All Agents"})}),n.jsxs(Le,{children:[n.jsxs(J,{value:"all",children:["All Agents (",Ft.length," commands)"]}),K.map(ge=>{const Re=Ft.filter(ut=>ut.agent_id===ge.id).length;return n.jsxs(J,{value:ge.id,children:[ge.name," (",Re," commands)"]},ge.id)})]})]})]}),O!=="all"&&n.jsxs(H,{onClick:()=>{A(O);const ge=K.find(Re=>Re.id===O);ge&&F(ge.name),T(!0)},children:[n.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Send Command"]})]})})}
769),n.jsx(Z5,{commands:eW,onViewDetails:E,onCancelCommand:ge=>Ct(ge)}),n.jsx(nk,{commands:ha,onViewDetails:E,onDeleteCommand:ge=>fi(ge)})]}),n.jsx(it,{value:"get-help",className:"space-y-4",children:n.jsx(ee,{children:n.jsx(re,{className:"p-0",children:n.jsx(L9,{selectedClientId:a||"",context:"agents"})})})})]}),n.jsx(lk,{command:Ke,open:!!Ke,onOpenChange:ge=>!ge&&E(null)}),n.jsx(x4e,{open:fe,onOpenChange:ne,clientId:a||void 0}),L&&n.jsx(h9,{open:L,onOpenChange:$,clientId:a}),D&&n.jsx(uk,{agentId:D,clientId:a,onTriggerCommand:tW,isLoading:zt,open:R,onOpenChange:ge=>{T(ge),ge||(A(""),F(""))}}),n.jsx(d4e,{commandId:k,agentName:U,open:q,onOpenChange:ge=>{Q(ge),ge||W(null)},onRunAnother:()=>{T(!0)}}),ue&&n.jsx(m4e,{agent:ue,isOpen:le,onClose:()=>{pe(!1),X(null)},onUpdate:()=>{pe(!1),X(null)},clientId:a}),ce&&u&&n.jsx(g4e,{agent:u.find(ge=>ge.agent_id===ce.id)||{agent_id:ce.id,agent_name:ce.name,hostname:ce.hostname_or_url||"",status:"offline",last_seen:new Date().toISOString()},isOpen:oe,onClose:()=>{V(!1),se(null)}})]})}function G4e(e){const{data:t=[],isLoading:r,error:s}=Ve({queryKey:["alerts",e],queryFn:async()=>{if(!e)return[];const{data:a,error:i}=await B.from("alerts").select("*, monitors(name, monitoring_agent_id)").eq("client_id",e).order("triggered_at",{ascending:!1}).limit(50);if(i)throw i;return a||[]},enabled:!!e});return{alerts:t,isLoading:r,error:(s==null?void 0:s.message)||null}}function Y4e(e){const{toast:t}=qr(),r=Et(),{data:s=[],isLoading:a,error:i}=Ve({queryKey:["alert-channels",e],queryFn:async()=>{if(!e)return[];const{data:u,error:h}=await B.from("alert_channels").select("*").eq("client_id",e).order("created_at",{ascending:!1});if(h)throw h;return u||[]},enabled:!!e}),o=mt({mutationFn:async({clientId:u,name:h,emailAddresses:f,alertTypes:m=["incident_start","recovery"]})=>{const{data:g,error:p}=await B.from("alert_channels").select("id").eq("client_id",u).eq("type","email").maybeSingle();if(p)throw p;const y={client_id:u,type:"email",name:h,email_addresses:f,alert_types:m,enabled:!0,configuration:{}};if(g){const{data:v,error:j}=await B.from("alert_channels").update(y).eq("id",g.id).select().single();if(j)throw j;return v}else{const{data:v,error:j}=await B.from("alert_channels").insert(y).select().single();if(j)throw j;return v}},onSuccess:(u,h)=>{r.invalidateQueries({queryKey:["alert-channels",h.clientId]}),t({title:"Email Recipients Saved",description:`${h.emailAddresses.length} recipient(s) configured for alert notifications`})},onError:u=>{t({title:"Failed to Update Alert Settings",description:u.message,variant:"destructive"})}}),l=mt({mutationFn:async u=>{const{data:h,error:f}=await B.functions.invoke("send-alert-email",{body:{alertType:"incident_start",monitorName:"Test Monitor",monitorType:"website",targetUrl:"https://example.com",errorMessage:"This is a test alert email",consecutiveFailures:1,timestamp:new Date().toISOString(),recipients:u,clientName:"Test Client"}});if(f)throw f;return h},onSuccess:()=>{t({title:"Test Email Sent",description:"A test alert email has been sent successfully"})},onError:u=>{t({title:"Failed to Send Test Email",description:u.message,variant:"destructive"})}}),c=mt({mutationFn:async u=>{const{data:h,error:f}=await B.from("alerts").update({status:"acknowledged"}).eq("id",u).select().single();if(f)throw f;return h},onSuccess:()=>{r.invalidateQueries({queryKey:["alerts"]}),t({title:"Alert Acknowledged",description:"The alert has been marked as acknowledged"})},onError:u=>{t({title:"Failed to Acknowledge Alert",description:u.message,variant:"destructive"})}}),d=mt({mutationFn:async u=>{const{data:h,error:f}=await B.from("alerts").delete().in("id",u).select();if(f)throw f;return h},onSuccess:(u,h)=>{r.invalidateQueries({queryKey:["alerts"]}),t({title:"Alerts Deleted",description:`${h.length} alert${h.length>1?"s":""} deleted successfully`})},onError:u=>{t({title:"Failed to Delete Alerts",description:u.message,variant:"destructive"})}});return{alertChannels:s,isLoading:a,error:(i==null?void 0:i.message)||null,createOrUpdateEmailChannel:o.mutate,testAlertEmail:l.mutate,acknowledgeAlert:c.mutate,deleteAlerts:d.mutate,isCreating:o.isPending,isTesting:l.isPending,isAcknowledging:c.isPending,isDeleting:d.isPending}}function Q4e({clientId:e}
769){const[t,r]=x.useState(""),[s,a]=x.useState([]),[i,o]=x.useState("Email Notifications"),[l,c]=x.useState([]),{alerts:d}=G4e(e),{agentAlerts:u,deleteAlerts:h}=V2(),{alertChannels:f,createOrUpdateEmailChannel:m,testAlertEmail:g,acknowledgeAlert:p,deleteAlerts:y,isCreating:v,isTesting:j,isDeleting:b}=Y4e(e),_=x.useMemo(()=>{const k=d.map(q=>{var Q;return{id:q.id,type:"monitor",alert_type:q.alert_type,status:q.status,triggered_at:q.triggered_at,resolved_at:q.resolved_at,error_message:q.last_error_message,name:((Q=q.monitors)==null?void 0:Q.name)||"Unknown Monitor",consecutive_failures:q.consecutive_failures}}),W=(u||[]).map(q=>({id:q.id,type:"agent",alert_type:q.alert_type==="agent_offline"?"incident_start":"recovery",status:q.status,triggered_at:q.triggered_at,resolved_at:q.resolved_at,error_message:q.error_message||`Agent ${q.agent_name} went ${q.alert_type==="agent_offline"?"offline":"online"}`,name:q.agent_name,hostname:q.hostname,consecutive_failures:0}));return[...k,...W].sort((q,Q)=>new Date(Q.triggered_at).getTime()-new Date(q.triggered_at).getTime())},[d,u]),w=f.find(k=>k.type==="email"),N=w==null?void 0:w.id,S=w==null?void 0:w.email_addresses,C=w==null?void 0:w.name;x.useEffect(()=>{S&&S.length>0&&a(S),C&&o(C)},[N,JSON.stringify(S),C]);const P=()=>{const k=t.trim();k&&!s.includes(k)&&(a([...s,k]),r(""))},M=k=>{a(s.filter(W=>W!==k))},D=()=>{!e||s.length===0||m({clientId:e,name:i,emailAddresses:s})},A=()=>{s.length!==0&&g(s)},U=k=>{switch(k){case"sent":return n.jsx(kn,{className:"h-4 w-4 text-amber-500"});case"acknowledged":return n.jsx(Xt,{className:"h-4 w-4 text-blue-500"});case"resolved":return n.jsx(Tt,{className:"h-4 w-4 text-green-500"});default:return n.jsx(kn,{className:"h-4 w-4 text-gray-500"})}},F=k=>{switch(k){case"sent":return"bg-amber-100 text-amber-800 border-amber-200";case"acknowledged":return"bg-blue-100 text-blue-800 border-blue-200";case"resolved":return"bg-green-100 text-green-800 border-green-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},L=k=>{switch(k){case"incident_start":return"bg-red-100 text-red-800 border-red-200";case"recovery":return"bg-green-100 text-green-800 border-green-200";default:return"bg-gray-100 text-gray-800 border-gray-200"}},$=k=>{c(W=>W.includes(k)?W.filter(q=>q!==k):[...W,k])},R=()=>{l.length===_.length?c([]):c(_.map(k=>k.id))},T=async()=>{if(l.length===0)return;const k=_.filter(q=>l.includes(q.id)&&q.type==="monitor").map(q=>q.id),W=_.filter(q=>l.includes(q.id)&&q.type==="agent").map(q=>q.id);k.length>0&&y(k),W.length>0&&h(W),c([])};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Qo,{className:"h-6 w-6 text-primary"}),n.jsxs("div",{children:[n.jsx("h2",{className:"text-2xl font-bold text-foreground",children:"Alert Management"}),n.jsx("p",{className:"text-muted-foreground",children:"Configure email notifications for monitor alerts"})]})]}),n.jsxs(cn,{defaultValue:"email-settings",className:"w-full",children:[n.jsxs(nn,{className:"grid w-full grid-cols-3",children:[n.jsx(at,{value:"email-settings",children:"Email Settings"}),n.jsx(at,{value:"alert-history",children:"Alert History"}),n.jsx(at,{value:"test-alerts",children:"Test Alerts"})]}),n.jsx(it,{value:"email-settings",className:"space-y-6",children:n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(aa,{className:"h-5 w-5"}),"Email Recipients"]}),n.jsx(De,{children:"Configure email addresses to receive monitor alert notifications"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"channel-name",children:"Channel Name"}),n.jsx(ie,{id:"channel-name",value:i,onChange:k=>o(k.target.value),placeholder:"Enter channel name"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"email-input",children:"Add Email Address"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(ie,{id:"email-input",type:"email",value:t,onChange:k=>r(k.target.value),placeholder:"Enter email address",onKeyDown:k=>k.key==="Enter"&&P()}),n.jsx(H,{onClick:P,variant:"outline",children:"Add"})]})]}),s.length>0&&n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{children:"Current Recipients"}),n.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((k,W)=>n.jsxs(ve,{variant:"secondary",className:"flex items-center gap-2",children:[k,n.jsx("button",{onClick:()=>M(k),className:"ml-1 text-xs hover:text-destructive",children:"×"})]},W))})]}),n.jsx("div",{className:"flex gap-2 pt-4",children:n.jsx(H,{onClick:D,disabled:v||s.length===0,children:v?"Saving...":"Save Settings"})})]})]})}),n.jsx(it,{value:"alert-history",className:"space-y-6",children:n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(O7,{className:"h-5 w-5"}),"Recent Alerts"]}),n.jsx(De,{children:"View and manage your monitor alerts"})]}),n.jsx(re,{children:_.length===0?n.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No alerts found. Alerts will appear here when monitors or agents detect issues."}):n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ct,{checked:l.length===_.length&&_.length>0,onCheckedChange:R}),n.jsxs(z,{className:"text-sm",children:["Select All (",l.length," of ",_.length," selected)"]})]}),n.jsxs(H,{size:"sm",variant:"destructive",onClick:T,disabled:l.length===0||b,className:"flex items-center gap-2",children:[n.jsx(Vt,{className:"h-4 w-4"}),b?"Deleting...":`Delete Selected (${l.length})`]})]}),_.map(k=>n.jsxs("div",{className:"flex items-start gap-3 p-4 border rounded-lg",children:[n.jsx(ct,{checked:l.includes(k.id),onCheckedChange:()=>$(k.id)}),n.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[k.type==="agent"?n.jsx(ht,{className:"h-4 w-4 text-purple-500"}):U(k.status),n.jsxs("div",{className:"space-y-1 flex-1",children:[n.jsx("div",{className:"flex items-center gap-2",children:k.type==="agent"?n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:"bg-purple-100 text-purple-800 border-purple-200",children:"Agent"}),n.jsx(ve,{className:k.alert_type==="incident_start"?"bg-red-100 text-red-800 border-red-200":"bg-green-100 text-green-800 border-green-200",children:k.alert_type==="incident_start"?"Agent Offline":"Agent Online"})]}):n.jsxs(n.Fragment,{children:[n.jsx(ve,{className:L(k.alert_type),children:k.alert_type==="incident_start"?"Incident":"Recovery"}),n.jsx(ve,{className:F(k.status),children:k.status})]})}),n.jsxs("p",{className:"font-medium",children:[k.name,"hostname"in k&&k.hostname&&n.jsxs("span",{className:"text-muted-foreground text-sm ml-2",children:["(",k.hostname,")"]})]}),k.error_message&&n.jsx("p",{className:"text-sm text-muted-foreground",children:k.error_message}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:[$r(new Date(k.triggered_at),"MMM d, yyyy h:mm a"),k.consecutive_failures>0&&n.jsxs("span",{className:"ml-2",children:["• ",k.consecutive_failures," consecutive failures"]})]})]})]}),k.status==="sent"&&k.type==="monitor"&&n.jsx(H,{size:"sm",variant:"outline",onClick:()=>p(k.id),children:"Acknowledge"})]},k.id))]})})]})}),n.jsx(it,{value:"test-alerts",className:"space-y-6",children:n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Ii,{className:"h-5 w-5"}),"Test Email Alerts"]}),n.jsx(De,{children:"Send a test alert email to verify your configuration"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg",children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"Test email will be sent to:"}),s.length>0?n.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((k,W)=>n.jsx(ve,{variant:"secondary",children:k},W))}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"No email recipients configured. Add recipients in the Email Settings tab."})]}),n.jsx(H,{onClick:A,disabled:j||s.length===0,className:"w-full",children:j?"Sending Test Email...":"Send Test Alert Email"})]})]})})]})]})}function X4e(){const{selectedClientId:e}=Mt();return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Alert Management"}),n.jsx("p",{className:"text-muted-foreground",children:"Configure and manage alert notifications for your monitors"})]}),n.jsx(Q4e,{clientId:e||void 0})]})}function Z4e(){const{selectedClientId:e,isProviderAdmin:t}=Mt(),[r,s]=x.useState(null),{data:a=[]}=Ve({queryKey:["all-clients-for-groups-page"],queryFn:async()=>{const{data:b,error:_}=await B.from("clients").select("id, name, slug").eq("status","active").order("name");if(_)throw _;return b},enabled:t}),i=e||r,{groups:o,updateGroup:l}=Vi(i),{agentStatuses:c}
769=dc(),[d,u]=x.useState(""),[h,f]=x.useState(!1),[m,g]=x.useState(null),{data:p=[]}=Ve({queryKey:["agent-groups",i],queryFn:async()=>{if(!i)return[];const{data:b,error:_}=await B.from("agent_groups").select("agent_id, group_id").eq("client_id",i);if(_)throw _;return b},enabled:!!i}),y=x.useMemo(()=>o?o.filter(b=>b.name.toLowerCase().includes(d.toLowerCase())||(b.description||"").toLowerCase().includes(d.toLowerCase())):[],[o,d]),v=x.useMemo(()=>{const b={};return!c||!o||o.forEach(_=>{const w=c.filter(N=>p.some(S=>S.agent_id===N.agent_id&&S.group_id===_.id));b[_.id]={total:w.length,online:w.filter(N=>N.status==="online").length,offline:w.filter(N=>N.status==="offline").length}}),b},[o,c,p]),j=async b=>{await l({id:b.id,is_critical:!b.is_critical})};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Group Management"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage agent groups and view group members"})]}),i&&n.jsxs(H,{onClick:()=>f(!0),children:[n.jsx(Ws,{className:"h-4 w-4 mr-2"}),"Manage Groups"]})]}),t&&!e&&n.jsxs(ee,{children:[n.jsxs(de,{className:"pb-3",children:[n.jsxs(me,{className:"text-base flex items-center gap-2",children:[n.jsx(Ea,{className:"h-4 w-4"}),"Select Client"]}),n.jsx(De,{children:"As a platform admin, select a client to view and manage their groups"})]}),n.jsx(re,{children:n.jsxs(Fe,{value:r||"",onValueChange:b=>s(b),children:[n.jsx(Ie,{className:"max-w-md",children:n.jsx(Ue,{placeholder:"Select a client..."})}),n.jsx(Le,{children:a.map(b=>n.jsxs(J,{value:b.id,children:[b.name," (",b.slug,")"]},b.id))})]})})]}),!i&&n.jsxs(Xh,{children:[n.jsx(kn,{className:"h-4 w-4"}),n.jsx(Zh,{children:"Please select a client to view and manage groups."})]}),i&&n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),n.jsx(ie,{placeholder:"Search groups by name or description...",value:d,onChange:b=>u(b.target.value),className:"pl-10"})]}),n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:y.map(b=>{const _=v[b.id]||{total:0,online:0,offline:0};return n.jsxs(ee,{className:"hover:shadow-md transition-shadow",children:[n.jsxs(de,{className:"pb-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(me,{className:"text-lg",children:b.name}),b.is_critical&&n.jsxs(ve,{variant:"secondary",className:"bg-primary/10 text-primary",children:[n.jsx(Sv,{className:"h-3 w-3 mr-1"}),"Critical"]})]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:w=>{w.stopPropagation(),j(b)},title:b.is_critical?"Remove from critical groups":"Mark as critical group",children:n.jsx(Sv,{className:`h-4 w-4 ${b.is_critical?"fill-current text-primary":""}`})})]}),b.description&&n.jsx(De,{children:b.description})]}),n.jsxs(re,{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center justify-between text-sm",children:[n.jsx("div",{className:"flex items-center gap-4",children:n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(Rr,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("span",{children:[_.total," agents"]})]})}),n.jsxs("div",{className:"flex gap-2",children:[n.jsxs(ve,{variant:"secondary",className:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",children:[_.online," online"]}),n.jsxs(ve,{variant:"secondary",className:"bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-400",children:[_.offline," offline"]})]})]}),n.jsxs(H,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{g(b.id),f(!0)},children:[n.jsx($o,{className:"h-4 w-4 mr-2"}),"View Details"]})]})]},b.id)})}),y.length===0&&n.jsxs("div",{className:"text-center py-12",children:[n.jsx("div",{className:"text-muted-foreground mb-4",children:d?"No groups match your search":"No groups created yet"}),n.jsxs(H,{onClick:()=>f(!0),children:[n.jsx(Ws,{className:"h-4 w-4 mr-2"}),"Create First Group"]})]})]}),n.jsx(h9,{open:h,onOpenChange:b=>{f(b),b||g(null)},clientId:i,initialGroupId:m})]})}const qw=[{value:"powershell",label:"PowerShell",icon:ws},{value:"batch",label:"Batch/DOS",icon:pI}],cD=["general","system","network","security","monitoring","maintenance","custom"],Vf=10,J4e=({clientId:e})=>
769{const[t,r]=x.useState(!1),[s,a]=x.useState(null),[i,o]=x.useState(""),[l,c]=x.useState("all"),[d,u]=x.useState("all"),[h,f]=x.useState(1),[m,g]=x.useState(new Set),[p,y]=x.useState(!1),[v,j]=x.useState({name:"",description:"",script_type:"",script_content:"",category:"general",tags:[]}),{templates:b,isLoading:_,refetch:w,createTemplate:N,updateTemplate:S,deleteTemplate:C,isCreating:P,isUpdating:M,isDeleting:D}=MN(e),A=()=>{j({name:"",description:"",script_type:"",script_content:"",category:"general",tags:[]}),a(null)},U=()=>{if(!v.name.trim()||!v.script_type||!v.script_content.trim())return;const V={...v,client_id:e,created_by_user_id:void 0,is_active:!0,is_system_template:!1};s?S({id:s.id,...V}):N(V),r(!1),A()},F=V=>{j({name:V.name,description:V.description||"",script_type:V.script_type,script_content:V.script_content,category:V.category,tags:V.tags||[]}),a(V),r(!0)},L=V=>{C(V)},$=V=>{const fe=V.script_type==="powershell"?".ps1":V.script_type==="batch"?".cmd":".txt",ne=`${V.name.replace(/[^a-zA-Z0-9-_]/g,"_")}${fe}`,Ce=new Blob([V.script_content],{type:"text/plain"}),Pe=URL.createObjectURL(Ce),he=document.createElement("a");he.href=Pe,he.download=ne,document.body.appendChild(he),he.click(),document.body.removeChild(he),URL.revokeObjectURL(Pe)},R=x.useMemo(()=>b.filter(V=>{var Pe;const fe=!i||V.name.toLowerCase().includes(i.toLowerCase())||((Pe=V.description)==null?void 0:Pe.toLowerCase().includes(i.toLowerCase())),ne=l==="all"||V.script_type===l,Ce=d==="all"||V.category===d;return fe&&ne&&Ce}),[b,i,l,d]),T=Math.ceil(R.length/Vf),k=x.useMemo(()=>{const V=(h-1)*Vf;return R.slice(V,V+Vf)},[R,h]);x.useMemo(()=>{f(1)},[i,l,d]);const W=V=>{var fe;return((fe=qw.find(ne=>ne.value===V))==null?void 0:fe.label)||V},q=()=>{const V=k.map(ne=>ne.id);if(V.every(ne=>m.has(ne))){const ne=new Set(m);
769V.forEach(Ce=>ne.delete(Ce)),g(ne)}else{const ne=new Set(m);V.forEach(Ce=>ne.add(Ce)),g(ne)}},Q=V=>{const fe=new Set(m);fe.has(V)?fe.delete(V):fe.add(V),g(fe)},ue=()=>{g(new Set)},X=()=>{const V=b.filter(fe=>m.has(fe.id));V.forEach(fe=>{$(fe)}),ye.success(`Downloaded ${V.length} script(s)`)},le=async()=>{const V=b.filter(ne=>m.has(ne.id)&&!ne.is_system_template);let fe=0;for(const ne of V)try{await C(ne.id),fe++}catch(Ce){console.error(`Failed to delete ${ne.name}:`,Ce)}ye.success(`Deleted ${fe} script(s)`),g(new Set),y(!1)},pe=m.size,ce=b.filter(V=>m.has(V.id)&&!V.is_system_template).length,se=k.length>0&&k.every(V=>m.has(V.id)),oe=k.some(V=>m.has(V.id));return n.jsx(ee,{children:n.jsxs(re,{className:"space-y-4 pt-6",children:[n.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between",children:[n.jsxs("div",{className:"flex flex-1 gap-2 flex-wrap",children:[n.jsxs("div",{className:"relative flex-1 min-w-[200px] max-w-sm",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search templates...",value:i,onChange:V=>o(V.target.value),className:"pl-8"})]}),n.jsxs(Fe,{value:l,onValueChange:c,children:[n.jsx(Ie,{className:"w-40",children:n.jsx(Ue,{placeholder:"All Types"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Types"}),qw.map(V=>n.jsx(J,{value:V.value,children:V.label},V.value))]})]}),n.jsxs(Fe,{value:d,onValueChange:u,children:[n.jsx(Ie,{className:"w-32",children:n.jsx(Ue,{placeholder:"All Categories"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Categories"}),cD.map(V=>n.jsx(J,{value:V,children:V.charAt(0).toUpperCase()+V.slice(1)},V))]})]})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx(H,{variant:"outline",size:"icon",onClick:()=>w(),title:"Refresh",children:n.jsx(sr,{className:"h-4 w-4"})}),n.jsxs(er,{open:t,onOpenChange:r,children:[n.jsx(Y0,{asChild:!0,children:n.jsxs(H,{onClick:A,children:[n.jsx(Ws,{className:"h-4 w-4 mr-2"}),"+ Create Script"]})}),n.jsxs(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:s?"Edit Template":"Create New Template"}),n.jsx(_s,{children:s?"Update the script template":"Create a reusable script template"})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"name",children:"Template Name *"}),n.jsx(ie,{id:"name",value:v.name,onChange:V=>j({...v,name:V.target.value}),placeholder:"e.g., System Information"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"script-type",children:"Script Type *"}),n.jsxs(Fe,{value:v.script_type,onValueChange:V=>j({...v,script_type:V}),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select script type...",children:v.script_type&&W(v.script_type)})}),n.jsx(Le,{children:qw.map(V=>n.jsx(J,{value:V.value,children:V.label},V.value))})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(ie,{id:"description",value:v.description,onChange:V=>j({...v,description:V.target.value}),placeholder:"Brief description of what this script does"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"category",children:"Category"}),n.jsxs(Fe,{value:v.category,onValueChange:V=>j({...v,category:V}),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsx(Le,{children:cD.map(V=>n.jsx(J,{value:V,children:V.charAt(0).toUpperCase()+V.slice(1)},V))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"script-content",children:"Script Content *"}),n.jsx(kr,{id:"script-content",value:v.script_content,onChange:V=>j({...v,script_content:V.target.value}),placeholder:"Enter your script content here...",rows:12,className:"font-mono text-sm"})]}),n.jsxs("div",{className:"flex gap-2 pt-4",children:[n.jsx(H,{onClick:()=>{r(!1),A()},variant:"outline",className:"flex-1",children:"Cancel"}),n.jsx(H,{onClick:U,disabled:!v.name.trim()||!v.script_type||!v.script_content.trim()||P||M,className:"flex-1",children:P||M?s?"Updating...":"Creating...":s?"Update Template":"Create Template"})]})]})]})]})]})]}),pe>0&&n.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted rounded-lg",children:[n.jsxs(ve,{variant:"secondary",children:[pe," selected"]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:X,children:[n.jsx(wa,{className:"h-4 w-4 mr-2"}),"Download Selected"]}),ce>0&&n.jsxs(os,{open:p,onOpenChange:y,children:[n.jsx(lh,{asChild:!0,children:n.jsxs(H,{variant:"destructive",size:"sm",children:[n.jsx(Vt,{className:"h-4 w-4 mr-2"}),"Delete (",ce,")"]})}),n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete Selected Templates"}),n.jsxs(Bn,{children:["Are you sure you want to delete ",ce," template(s)? This action cannot be undone.",pe!==ce&&n.jsxs("span",{className:"block mt-2 text-amber-600",children:["Note: ",pe-ce," system template(s) will not be deleted."]})]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:ue,children:"Clear Selection"})]}),n.jsx("div",{className:"border rounded-lg",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{className:"w-[50px]",children:n.jsx(ct,{checked:se,onCheckedChange:q,"aria-label":"Select all on this page",className:oe&&!se?"data-[state=checked]:bg-primary/50":""})}),n.jsx(Se,{children:"Name"}),n.jsx(Se,{children:"Type"}),n.jsx(Se,{children:"Category"}),n.jsx(Se,{children:"Description"}),n.jsx(Se,{className:"w-[100px]",children:"Actions"})]})}),n.jsx(Kn,{children:_?n.jsx(gt,{children:n.jsx(be,{colSpan:6,className:"text-center text-muted-foreground",children:"Loading templates..."})}):k.length===0?n.jsx(gt,{children:n.jsx(be,{colSpan:6,className:"text-center text-muted-foreground",children:i||l!=="all"||d!=="all"?"No templates match your filters":"No templates found. Create your first template to get started."})}):k.map(V=>n.jsxs(gt,{className:m.has(V.id)?"bg-muted/50":"",children:[n.jsx(be,{children:n.jsx(ct,{checked:m.has(V.id),onCheckedChange:()=>Q(V.id),"aria-label":`Select ${V.name}`})}),n.jsx(be,{className:"font-medium",children:V.name}),n.jsx(be,{children:n.jsx("span",{className:"text-sm",children:W(V.script_type)})}),n.jsx(be,{children:n.jsx(ve,{variant:"outline",className:"capitalize",children:V.category})}),n.jsx(be,{className:"max-w-xs truncate",children:V.description||"No description"}),n.jsx(be,{children:n.jsxs("div",{className:"flex items-center gap-1",children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>$(V),title:"Download script",children:n.jsx(wa,{className:"h-4 w-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>F(V),disabled:M,title:"Edit template",children:n.jsx(U7,{className:"h-4 w-4"})}),!V.is_system_template&&n.jsxs(os,{children:[n.jsx(lh,{asChild:!0,children:n.jsx(H,{variant:"ghost",size:"sm",disabled:D,children:n.jsx(Vt,{className:"h-4 w-4"})})}),n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete Template"}),n.jsxs(Bn,{children:['Are you sure you want to delete "',V.name,'"? This action cannot be undone.']})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:()=>L(V.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})})]},V.id))})]})}),R.length>0&&n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",(h-1)*Vf+1," to ",Math.min(h*Vf,R.length)," of ",R.length," templates"]}),n.jsx(Yi,{children:n.jsxs(Qi,{children:[n.jsx(wt,{children:n.jsx(Xi,{onClick:()=>f(V=>Math.max(1,V-1)),className:h===1?"pointer-events-none opacity-50":"cursor-pointer"})}),Array.from({length:Math.min(5,T)},(V,fe)=>{let ne;return T<=5||h<=3?ne=fe+1:h>=T-2?ne=T-4+fe:ne=h-2+fe,n.jsx(wt,{children:n.jsx(ss,{onClick:()=>f(ne),isActive:h===ne,className:"cursor-pointer",children:ne})},ne)}),n.jsx(wt,{children:n.jsx(Zi,{onClick:()=>f(V=>Math.min(T,V+1)),className:h===T?"pointer-events-none opacity-50":"cursor-pointer"})})]})})]})]})})},dD=[{value:"powershell",label:"PowerShell",icon:ws},{value:"batch",label:"Windows CMD",icon:hd}],eDe=["general","diagnostics","maintenance","security","reporting","network","system"];function tDe({clientId:e}){const t=Et(),[r,s]=x.useState(""),[a,i]=x.useState("all"),[o,l]=x.useState("all"),[c,d]=x.useState(new Set),{data:u=[],isLoading:h}=Ve({queryKey:["platform-scripts-for-import"],queryFn:async()=>{const{data:w,error:N}=await B.from("system_script_templates").select("*").eq("is_active",!0).eq("is_internal",!1).order("name");if(N)throw N;return w}}),{data:f=[]}=Ve({queryKey:["client-templates-names",e],queryFn:async()=>{const{data:w,error:N}=await B.from("script_templates").select("name, script_type").eq("client_id",e).eq("is_active",!0);if(N)throw N;return w},enabled:!!e}),m=mt({mutationFn:async w=>{const{data:N,error:S}=await B.rpc("import_system_template_to_client",{p_template_id:w,p_client_id:e});if(S)throw S;return N}}),g=w=>f.some(N=>N.name===w.name&&N.script_type===w.script_type),p=x.useMemo(()=>u.filter(w=>{var P;const N=!r||w.name.toLowerCase().includes(r.toLowerCase())||((P=w.description)==null?void 0:P.toLowerCase().includes(r.toLowerCase())),S=a==="all"||w.script_type===a,C=o==="all"||w.category===o;return N&&S&&C}),[u,r,a,o]),y=w=>{const N=new Set(c);N.has(w)?N.delete(w):N.add(w),d(N)},v=async()=>{const w=Array.from(c);let N=0,S=0;const C=[];console.log(`Importing ${w.length} templates to client ${e}`);for(const P of w)try{const M=await m.mutateAsync(P);console.log(`Successfully imported template ${P}, new ID: ${M}`),N++}catch(M){const D=(M==null?void 0:M.message)||"";console.error(`Import error for ${P}:`,D),D.includes("already exists")?S++:C.push(D)}console.log("Invalidating script-templates queries..."),await t.invalidateQueries({queryKey:["script-templates",e]}),await t.invalidateQueries({queryKey:["script-templates"]}),await t.invalidateQueries({queryKey:["client-templates-names",e]}),N>0&&ye.success(`Successfully imported ${N} script(s) - check Your Script Library tab`),S>0&&ye.info(`${S} script(s) already in your library`),C.length>0&&ye.error(`Failed to import ${C.length} script(s): ${C.join(", ")}`),d(new Set)},j=w=>{const N=dD.find(S=>S.value===w);return(N==null?void 0:N.icon)||hd},b=u.filter(w=>!g(w)).length,_=u.length-b;return n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Pn,{className:"h-5 w-5"}),"Platform Scripts"]}),n.jsx(De,{children:"You must browse and import platform scripts to use them in your own script library"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsxs(ve,{variant:"secondary",children:[b," available"]}),n.jsxs(ve,{variant:"outline",children:[_," imported"]})]})]})}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"flex flex-wrap gap-4",children:[n.jsxs("div",{className:"flex-1 min-w-[200px]",children:[n.jsx(z,{htmlFor:"platform-search",className:"sr-only",children:"Search"}),n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{id:"platform-search",placeholder:"Search scripts...",value:r,onChange:w=>s(w.target.value),className:"pl-8"})]})]}),n.jsx("div",{className:"w-[150px]",children:n.jsxs(Fe,{value:a,onValueChange:i,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Script Type"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Types"}),dD.map(w=>n.jsx(J,{value:w.value,children:w.label},w.value))]})]})}),n.jsx("div",{className:"w-[150px]",children:n.jsxs(Fe,{value:o,onValueChange:l,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Category"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Categories"}),eDe.map(w=>
769n.jsx(J,{value:w,children:w.charAt(0).toUpperCase()+w.slice(1)},w))]})]})}),c.size>0&&n.jsxs(H,{onClick:v,disabled:m.isPending,children:[n.jsx(wa,{className:"h-4 w-4 mr-2"}),m.isPending?"Importing...":`Import Selected (${c.size})`]})]}),n.jsx(yd,{className:"h-[500px] border rounded-md",children:h?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-muted-foreground",children:"Loading platform scripts..."})}):p.length===0?n.jsx("div",{className:"flex items-center justify-center h-full",children:n.jsx("p",{className:"text-muted-foreground",children:"No scripts match your filters"})}):n.jsx("div",{className:"p-4 space-y-2",children:p.map(w=>{const N=g(w),S=c.has(w.id),C=j(w.script_type);return n.jsx(ee,{className:`transition-all ${N?"opacity-60 bg-muted":S?"ring-2 ring-primary":"hover:shadow-sm cursor-pointer"}`,onClick:()=>!N&&y(w.id),children:n.jsx(re,{className:"p-4",children:n.jsxs("div",{className:"flex items-start gap-3",children:[!N&&n.jsx(ct,{checked:S,onCheckedChange:()=>y(w.id),onClick:P=>P.stopPropagation(),className:"mt-1"}),N&&n.jsx(zs,{className:"h-5 w-5 text-green-500 mt-1"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsx("span",{className:"font-medium",children:w.name}),n.jsxs(ve,{variant:"outline",className:"text-xs",children:[n.jsx(C,{className:"h-3 w-3 mr-1"}),w.script_type]}),n.jsx(ve,{variant:"secondary",className:"text-xs",children:w.category}),N&&n.jsx(ve,{variant:"default",className:"text-xs bg-green-500",children:"Already Imported"})]}),w.description&&n.jsx("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:w.description}),w.tags&&w.tags.length>0&&n.jsx("div",{className:"flex gap-1 mt-2 flex-wrap",children:w.tags.map(P=>n.jsx(ve,{variant:"outline",className:"text-xs",children:P},P))})]})]})})},w.id)})})}),n.jsx("div",{className:"text-sm text-muted-foreground",children:c.size>0?`${c.size} script(s) selected for import`:"Click on scripts to select them for import"})]})]})}function rDe(){const{selectedClientId:e}=Mt(),{agents:t,isLoading:r}=Lt(e),{groups:s}=Vi(e),[a,i]=x.useState(""),[o,l]=x.useState("all"),[c,d]=x.useState(""),[u,h]=x.useState(null),[f,m]=x.useState(!1),[g,p]=x.useState("execute"),y=(t==null?void 0:t.filter(D=>D.asset_type==="local_device"))||[],{data:v=[]}=Ve({queryKey:["agent-groups",e],queryFn:async()=>{if(!e)return[];const{data:D,error:A}=await B.from("agent_groups").select("agent_id, group_id").eq("client_id",e);if(A)throw A;return D},enabled:!!e}),j=x.useMemo(()=>{let D=y;return c&&(D=D.filter(A=>{var U;return A.name.toLowerCase().includes(c.toLowerCase())||((U=A.hostname_or_url)==null?void 0:U.toLowerCase().includes(c.toLowerCase()))})),o&&o!=="all"&&(o==="ungrouped"?D=D.filter(A=>!v.some(U=>U.agent_id===A.id)):D=D.filter(A=>v.some(U=>U.agent_id===A.id&&U.group_id===o))),D},[y,c,o,v]),{commands:b,createCommand:_,isCreating:w,cancelCommand:N,deleteCommand:S}=zv(a||void 0,e),C=t==null?void 0:t.find(D=>D.id===a),P=D=>{i(D)},M=D=>{_(D)};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Scripts"}),n.jsx("p",{className:"text-muted-foreground",children:"Execute commands, manage scripts, and import from the platform library"})]}),n.jsxs(cn,{value:g,onValueChange:p,children:[n.jsxs(nn,{className:"grid w-full grid-cols-3 lg:w-auto lg:inline-flex",children:[n.jsxs(at,{value:"execute",className:"gap-2",children:[n.jsx(ws,{className:"h-4 w-4"}),n.jsx("span",{className:"hidden sm:inline",children:"Execute"})]}),n.jsxs(at,{value:"library",className:"gap-2",children:[n.jsx(hd,{className:"h-4 w-4"}),n.jsx("span",{className:"hidden sm:inline",children:"Your Script Library"})]}),n.jsxs(at,{value:"platform",className:"gap-2",children:[n.jsx(Pn,{className:"h-4 w-4"}),n.jsx("span",{className:"hidden sm:inline",children:"Platform Scripts"})]})]}),n.jsx(it,{value:"execute",className:"space-y-6 mt-6",children:n.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[n.jsxs(ee,{className:"lg:col-span-1",children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),"Select Agent"]}),n.jsx(De,{children:"Choose an agent to send commands"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{children:"Search Agents"}),n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search by name or hostname...",value:c,onChange:D=>d(D.target.value),className:"pl-8"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{children:"Filter by Group"}),n.jsxs(Fe,{value:o,onValueChange:l,children:[n.jsxs(Ie,{children:[n.jsx(Rr,{className:"h-4 w-4 mr-2"}),n.jsx(Ue,{placeholder:"All Groups"})]}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Groups"}),n.jsx(J,{value:"ungrouped",children:"Ungrouped"}),s==null?void 0:s.map(D=>n.jsx(J,{value:D.id,children:D.name},D.id))]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs(z,{children:["Available Agents (",j.length,")"]}),n.jsx("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:r?n.jsx("div",{className:"text-sm text-muted-foreground text-center py-4",children:"Loading agents..."}):j.length===0?n.jsx("div",{className:"text-sm text-muted-foreground text-center py-4",children:"No agents found"}):j.map(D=>
769n.jsx(ee,{className:`cursor-pointer transition-all hover:shadow-md ${a===D.id?"ring-2 ring-primary":""}`,onClick:()=>P(D.id),children:n.jsx(re,{className:"p-3",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex-1",children:[n.jsx("div",{className:"font-medium",children:D.name}),n.jsx("div",{className:"text-xs text-muted-foreground",children:D.hostname_or_url||"No hostname"})]}),n.jsx(ve,{variant:D.status==="active"?"default":"secondary",children:D.status})]})})},D.id))})]})]})]}),n.jsx("div",{className:"lg:col-span-2 space-y-6",children:a?n.jsxs(n.Fragment,{children:[n.jsx(ee,{children:n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-5 w-5"}),C==null?void 0:C.name]}),n.jsx(De,{children:(C==null?void 0:C.hostname_or_url)||"No hostname available"})]}),n.jsxs(H,{onClick:()=>m(!0),children:[n.jsx(Ii,{className:"h-4 w-4 mr-2"}),"Send Command"]})]})})}),n.jsxs(cn,{defaultValue:"history",className:"space-y-4",children:[n.jsxs(nn,{children:[n.jsxs(at,{value:"history",children:["Command History (",b.length,")"]}),n.jsxs(at,{value:"active",children:["Active Commands (",b.filter(D=>D.status==="pending").length,")"]})]}),n.jsx(it,{value:"history",children:n.jsx(nk,{commands:b,onViewDetails:h,onDeleteCommand:S})}),n.jsx(it,{value:"active",children:n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"Active Commands"}),n.jsx(De,{children:"Commands currently being processed by the agent"})]}),n.jsx(re,{children:b.filter(D=>D.status==="pending").length===0?n.jsx("div",{className:"text-center text-muted-foreground py-8",children:"No active commands"}):n.jsx("div",{className:"space-y-2",children:b.filter(D=>D.status==="pending").map(D=>n.jsx(ee,{children:n.jsx(re,{className:"p-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("div",{className:"font-medium",children:D.op}),n.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(D.created_at).toLocaleString()})]}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>N(D.id),children:"Cancel"})]})})},D.id))})})]})})]})]}):n.jsx(ee,{children:n.jsx(re,{className:"py-12",children:n.jsxs("div",{className:"text-center text-muted-foreground",children:[n.jsx(ws,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),n.jsx("p",{className:"text-lg font-medium",children:"No Agent Selected"}),n.jsx("p",{className:"text-sm",children:"Select an agent from the list to send commands and view history"})]})})})})]})}),n.jsx(it,{value:"library",className:"mt-6",children:e?n.jsx(J4e,{clientId:e}):n.jsx(ee,{children:n.jsx(re,{className:"py-12",children:n.jsxs("div",{className:"text-center text-muted-foreground",children:[n.jsx(hd,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),n.jsx("p",{className:"text-lg font-medium",children:"No Client Selected"}),n.jsx("p",{className:"text-sm",children:"Please select a client to view your script library"})]})})})}),n.jsx(it,{value:"platform",className:"mt-6",children:e?n.jsx(tDe,{clientId:e}):n.jsx(ee,{children:n.jsx(re,{className:"py-12",children:n.jsxs("div",{className:"text-center text-muted-foreground",children:[n.jsx(Pn,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),n.jsx("p",{className:"text-lg font-medium",children:"No Client Selected"}),n.jsx("p",{className:"text-sm",children:"Please select a client to browse platform scripts"})]})})})})]}),u&&n.jsx(lk,{command:u,open:!!u,onOpenChange:D=>!D&&h(null)}),a&&n.jsx(uk,{agentId:a,clientId:e,onTriggerCommand:M,isLoading:w,open:f,onOpenChange:m})]})}var G2="Radio",[nDe,F9]=Qr(G2),[sDe,aDe]=nDe(G2),U9=x.forwardRef((e,t)=>{const{__scopeRadio:r,name:s,checked:a=!1,required:i,disabled:o,value:l="on",onCheck:c,form:d,...u}=e,[h,f]=x.useState(null),m=nt(t,y=>f(y)),g=x.useRef(!1),p=h?d||!!h.closest("form"):!0;return n.jsxs(sDe,{scope:r,checked:a,disabled:o,children:[n.jsx(We.button,{type:"button",role:"radio","aria-checked":a,"data-state":W9(a),"data-disabled":o?"":void 0,disabled:o,value:l,...u,ref:m,onClick:Te(e.onClick,y=>{a||c==null||c(),p&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})}),p&&n.jsx(q9,{control:h,bubbles:!g.current,name:s,value:l,checked:a,required:i,disabled:o,form:d,style:{transform:"translateX(-100%)"}})]})});U9.displayName=G2;var z9="RadioIndicator",B9=x.forwardRef((e,t)=>
vendor: 2,077 bytes, line 769
769{const{__scopeRadio:r,forceMount:s,...a}=e,i=aDe(z9,r);return n.jsx(jn,{present:s||i.checked,children:n.jsx(We.span,{"data-state":W9(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t})})});B9.displayName=z9;var iDe="RadioBubbleInput",q9=x.forwardRef(({__scopeRadio:e,control:t,checked:r,bubbles:s=!0,...a},i)=>{const o=x.useRef(null),l=nt(o,i),c=dg(r),d=Hh(t);return x.useEffect(()=>{const u=o.current;if(!u)return;const h=window.HTMLInputElement.prototype,m=Object.getOwnPropertyDescriptor(h,"checked").set;if(c!==r&&m){const g=new Event("click",{bubbles:s});m.call(u,r),u.dispatchEvent(g)}},[c,r,s]),n.jsx(We.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...a,tabIndex:-1,ref:l,style:{...a.style,...d,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});q9.displayName=iDe;function W9(e){return e?"checked":"unchecked"}var oDe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],rb="RadioGroup",[lDe,vRe]=Qr(rb,[Jh,F9]),H9=Jh(),V9=F9(),[cDe,dDe]=lDe(rb),K9=x.forwardRef((e,t)=>{const{__scopeRadioGroup:r,name:s,defaultValue:a,value:i,required:o=!1,disabled:l=!1,orientation:c,dir:d,loop:u=!0,onValueChange:h,...f}=e,m=H9(r),g=Md(d),[p,y]=Bs({prop:i,defaultProp:a??null,onChange:h,caller:rb});return n.jsx(cDe,{scope:r,name:s,required:o,disabled:l,value:p,onValueChange:y,children:n.jsx(BC,{asChild:!0,...m,orientation:c,dir:g,loop:u,children:n.jsx(We.div,{role:"radiogroup","aria-required":o,"aria-orientation":c,"data-disabled":l?"":void 0,dir:g,...f,ref:t})})})});K9.displayName=rb;var G9="RadioGroupItem",Y9=x.forwardRef((e,t)=>{const{__scopeRadioGroup:r,disabled:s,...a}=e,i=dDe(G9,r),o=i.disabled||s,l=H9(r),c=V9(r),d=x.useRef(null),u=nt(t,d),h=i.value===a.value,f=x.useRef(!1);return x.useEffect(()=>{const m=p=>{oDe.includes(p.key)&&(f.current=!0)},g=()=>f.current=!1;return document.addEventListener("keydown",m),document.addEventListener("keyup",g),()=>{document.removeEventListener("keydown",m),document.removeEventListener("keyup",g)}},[]),n.jsx(qC,{asChild:!0,...l,focusable:!o,active:h,children:n.jsx(U9,{disabled:o,required:i.required,
769checked:h,...c,...a,name:i.name,ref:u,onCheck:()=>i.onValueChange(a.value),onKeyDown:Te(m=>{m.key==="Enter"&&m.preventDefault()}),onFocus:Te(a.onFocus,()=>{var m;f.current&&((m=d.current)==null||m.click())})})})});Y9.displayName=G9;var uDe="RadioGroupIndicator",Q9=x.forwardRef((e,t)=>{const{__scopeRadioGroup:r,...s}=e,a=V9(r);return n.jsx(B9,{...a,...s,ref:t})});Q9.displayName=uDe;var X9=K9,Z9=Y9,hDe=Q9;const J9=x.forwardRef(({className:e,...t},r)=>n.jsx(X9,{className:we("grid gap-2",e),...t,ref:r}));J9.displayName=X9.displayName;const pS=x.forwardRef(({className:e,...t},r)=>n.jsx(Z9,{ref:r,className:we("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:n.jsx(hDe,{className:"flex items-center justify-center",children:n.jsx(ku,{className:"h-2.5 w-2.5 fill-current text-current"})})}));pS.displayName=Z9.displayName;function fDe(){const[e,t]=x.useState(()=>localStorage.getItem("color-theme")==="true-black"?"true-black":"blue-dark");return x.useEffect(()=>{localStorage.setItem("color-theme",e);const s=document.documentElement;s.classList.remove("theme-black"),s.classList.add("dark"),e==="true-black"&&s.classList.add("theme-black")},[e]),{theme:e,setTheme:t,toggleTheme:()=>{t(s=>s==="blue-dark"?"true-black":"blue-dark")}}}function mDe(){const{selectedClientId:e}=Mt(),{toast:t}=qr(),[r,s]=x.useState(!1),[a,i]=x.useState(!1),[o,l]=x.useState({default_heartbeat_interval_seconds:60,default_command_poll_interval_seconds:10,default_command_timeout_seconds:300});x.useEffect(()=>{e&&c()},[e]);const c=async()=>{if(e){s(!0);try{const{data:h}=await B.from("clients").select("enabled_modules").eq("id",e).single();if(h!=null&&h.enabled_modules)try{const f=typeof h.enabled_modules=="string"?JSON.parse(h.enabled_modules):h.enabled_modules;f.agent_timing_defaults&&l({default_heartbeat_interval_seconds:f.agent_timing_defaults.heartbeat_interval_seconds||60,default_command_poll_interval_seconds:f.agent_timing_defaults.command_poll_interval_seconds||10,default_command_timeout_seconds:f.agent_timing_defaults.command_timeout_seconds||300})}catch{}}catch(h){console.error("Failed to load defaults:",h)}finally{s(!1)}}},d=async()=>{if(e){if(o.default_heartbeat_interval_seconds<5||o.default_heartbeat_interval_seconds>300){t({title:"Invalid value",description:"Heartbeat interval must be between 5 and 300 seconds",variant:"destructive"});return}if(o.default_command_poll_interval_seconds<5||o.default_command_poll_interval_seconds>60){t({title:"Invalid value",description:"Command poll interval must be between 5 and 60 seconds",variant:"destructive"});return}if(o.default_command_timeout_seconds<30||o.default_command_timeout_seconds>1800){t({title:"Invalid value",description:"Command timeout must be between 30 and 1800 seconds",variant:"destructive"});return}i(!0);try{const{data:h}=await B.from("clients").select("enabled_modules").eq("id",e).single();let f={};if(h!=null&&h.enabled_modules)try{f=typeof h.enabled_modules=="string"?JSON.parse(h.enabled_modules):h.enabled_modules}catch{f={}}const m={...f,agent_timing_defaults:{heartbeat_interval_seconds:o.default_heartbeat_interval_seconds,command_poll_interval_seconds:o.default_command_poll_interval_seconds,command_timeout_seconds:o.default_command_timeout_seconds}},{error:g}=await B.from("clients").update({enabled_modules:JSON.stringify(m)}).eq("id",e);if(g)throw g;t({title:"Defaults saved",description:"Agents will receive these settings on next heartbeat"})}catch(h){console.error("Failed to save defaults:",h),t({title:"Error",description:"Failed to save default settings",variant:"destructive"})}finally{i(!1)}}},u=(h,f)=>{const m=parseInt(f,10);!isNaN(m)&&m>=0&&l(g=>({...g,[h]:m}))};return r?n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-5 w-5"}),"Default Agent Timing"]})}),n.jsx(re,{children:n.jsxs("div",{className:"animate-pulse space-y-4",children:[n.jsx("div",{className:"h-12 bg-muted rounded"}),n.jsx("div",{className:"h-12 bg-muted rounded"}),n.jsx("div",{className:"h-12 bg-muted rounded"})]})})]}):n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-5 w-5"}),"Default Agent Timing"]}),n.jsx(De,{children:"Set default timing values. Agents receive updated settings on their next heartbeat."})]}),n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(xC,{className:"h-4 w-4 text-muted-foreground"}),n.jsx(z,{htmlFor:"heartbeat",className:"font-medium",children:"Heartbeat Interval (seconds)"})]}),n.jsx(ie,{id:"heartbeat",type:"number",min:5,max:300,value:o.default_heartbeat_interval_seconds,onChange:h=>u("default_heartbeat_interval_seconds",h.target.value),className:"w-full"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"How often agents report status (5-300 seconds)"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"}),n.jsx(z,{htmlFor:"poll",className:"font-medium",children:"Command Poll Interval (seconds)"})]}),n.jsx(ie,{id:"poll",type:"number",min:5,max:60,value:o.default_command_poll_interval_seconds,onChange:h=>u("default_command_poll_interval_seconds",h.target.value),className:"w-full"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"How often agents check for c
769ommands (5-60 seconds)"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yI,{className:"h-4 w-4 text-muted-foreground"}),n.jsx(z,{htmlFor:"timeout",className:"font-medium",children:"Command Timeout (seconds)"})]}),n.jsx(ie,{id:"timeout",type:"number",min:30,max:1800,value:o.default_command_timeout_seconds,onChange:h=>u("default_command_timeout_seconds",h.target.value),className:"w-full"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Max command execution time (30-1800 seconds)"})]}),n.jsxs(H,{onClick:d,disabled:a,className:"w-full",children:[n.jsx(Lo,{className:"h-4 w-4 mr-2"}),a?"Saving...":"Save Defaults"]})]})]})}const uD={max_alerts_per_hour:20,flapping_window_minutes:30,flapping_threshold:5,default_cooldown_minutes:15};function pDe(){const{toast:e}=qr(),t=Et(),{data:r,isLoading:s}=Ve({queryKey:["platform-settings"],queryFn:async()=>{const{data:l,error:c}=await B.from("platform_settings").select("*");if(c)throw c;return l}}),a=(()=>{const l=r==null?void 0:r.find(c=>c.setting_key==="alert_rate_limits");return l!=null&&l.setting_value?{...uD,...l.setting_value}:uD})(),{mutate:i,isPending:o}=mt({mutationFn:async l=>{const c={...a,...l},{error:d}=await B.from("platform_settings").update({setting_value:c}).eq("setting_key","alert_rate_limits");if(d)throw d;return c},onSuccess:()=>{t.invalidateQueries({queryKey:["platform-settings"]}),e({title:"Settings Updated",description:"Alert rate limit settings have been saved."})},onError:l=>{console.error("Failed to update platform settings:",l),e({title:"Update Failed",description:"Failed to save settings. Please try again.",variant:"destructive"})}});return{settings:r,isLoading:s,alertRateLimits:a,updateAlertRateLimits:i,isUpdating:o}}function gDe(){const{alertRateLimits:e,updateAlertRateLimits:t,isLoading:r,isUpdating:s}=pDe(),[a,i]=x.useState({max_alerts_per_hour:20,flapping_window_minutes:30,flapping_threshold:5,default_cooldown_minutes:15});x.useEffect(()=>{e&&i(e)},[e]);const o=()=>{t(a)},l=JSON.stringify(a)!==JSON.stringify(e);return r?n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(tt,{className:"h-6 w-48"}),n.jsx(tt,{className:"h-4 w-72 mt-2"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsx(tt,{className:"h-20 w-full"}),n.jsx(tt,{className:"h-20 w-full"})]})]}):n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5"}),"Platform Alert Rate Limits"]}),n.jsx(De,{children:"Configure global rate limiting to prevent alert fatigue across all clients"})]}),n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(vI,{className:"h-4 w-4 text-primary"}),n.jsx(z,{className:"text-base font-medium",children:"Global Alert Cap"})]}),n.jsx("div",{className:"flex items-center gap-4",children:n.jsxs("div",{className:"space-y-1 flex-1",children:[n.jsx(z,{htmlFor:"max-alerts",className:"text-sm text-muted-foreground",children:"Max alerts per client per hour"}),n.jsx(ie,{id:"max-alerts",type:"number",min:"5",max:"100",value:a.max_alerts_per_hour,onChange:c=>i(d=>({...d,max_alerts_per_hour:parseInt(c.target.value)||20})),className:"w-32"})]})}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Prevents email flooding when many agents go offline simultaneously."})]}),n.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Wr,{className:"h-4 w-4 text-orange-500"}),n.jsx(z,{className:"text-base font-medium",children:"Flapping Protection"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx(z,{htmlFor:"flapping-threshold",className:"text-sm text-muted-foreground",children:"State changes threshold"}),n.jsx(ie,{id:"flapping-threshold",type:"number",min:"3",max:"20",value:a.flapping_threshold,onChange:c=>i(d=>({...d,flapping_threshold:parseInt(c.target.value)||5})),className:"w-full"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(z,{htmlFor:"flapping-window",className:"text-sm text-muted-foreground",children:"Within minutes"}),n.jsx(ie,{id:"flapping-window",type:"number",min:"5",max:"120",value:a.flapping_window_minutes,onChange:c=>i(d=>({...d,flapping_window_minutes:parseInt(c.target.value)||30})),className:"w-full"})]})]}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["Suppresses alerts if an agent toggles online/offline more than ",a.flapping_threshold," times in ",a.flapping_window_minutes," minutes."]})]}),n.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4 text-blue-500"}),n.jsx(z,{className:"text-base font-medium",children:"Default Cooldown Period"})]}),n.jsxs("div",{className:"space-y-1",children:[n.jsx(z,{htmlFor:"default-cooldown",className:"text-sm text-muted-foreground",children:"Default minutes between alerts (per agent)"}),n.jsx(ie,{id:"default-cooldown",type:"number",min:"0",max:"120",value:a.default_cooldown_minutes,onChange:c=>i(d=>({...d,default_cooldown_minutes:parseInt(c.target.value)||15})),className:"w-32"})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Default cooldown for new agents. Individual agents can override this in their alert settings."})]}),n.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-4",children:n.jsxs("div",{className:"flex items-start gap-2",children:[n.jsx(tn,{className:"h-4 w-4 text-amber-600 dar
769k:text-amber-500 mt-0.5"}),n.jsxs("div",{className:"text-sm text-amber-800 dark:text-amber-200",children:[n.jsx("p",{className:"font-medium",children:"Rate Limiting Flow"}),n.jsxs("ol",{className:"mt-1 list-decimal list-inside text-xs space-y-1 text-amber-700 dark:text-amber-300",children:[n.jsx("li",{children:"Check per-agent cooldown period"}),n.jsx("li",{children:"Check for flapping (rapid state changes)"}),n.jsx("li",{children:"Check global alert cap for the client"}),n.jsx("li",{children:"If all checks pass → send alert"})]})]})]})}),n.jsx("div",{className:"flex justify-end pt-2",children:n.jsxs(H,{onClick:o,disabled:s||!l,children:[n.jsx(Lo,{className:"h-4 w-4 mr-2"}),s?"Saving...":"Save Settings"]})})]})]})}function xDe(){const{theme:e,setTheme:t}=fDe(),{showMonitoringMenu:r,setShowMonitoringMenu:s}=o6(),{popupEnabled:a,setPopupEnabled:i,popupDuration:o,setPopupDuration:l,minDuration:c,maxDuration:d}=zC(),{user:u,isProviderAdmin:h,clientMemberships:f,selectedClientId:m}=Mt(),g=f.find(v=>v.client_id===m),p=h||(g==null?void 0:g.role)==="client_admin"||(g==null?void 0:g.role)==="provider_admin"||(g==null?void 0:g.role)==="org_admin",y=async(v,j)=>{try{const b=await fetch(`/scripts/${v}`);if(!b.ok)throw new Error("Failed to fetch script");const _=await b.blob(),w=window.URL.createObjectURL(_),N=document.createElement("a");N.href=w,N.download=v,document.body.appendChild(N),N.click(),window.URL.revokeObjectURL(w),document.body.removeChild(N),ye.success(`Downloaded ${j}`)}catch(b){ye.error("Failed to download script"),console.error("Download error:",b)}};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Settings"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage your application preferences and configuration"})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"Color Theme"}),n.jsx(De,{children:"Choose your preferred dark theme"})]}),n.jsx(re,{className:"space-y-4",children:n.jsxs(J9,{value:e,onValueChange:v=>t(v),children:[n.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-4 hover:bg-accent/50 transition-colors",children:[n.jsx(pS,{value:"blue-dark",id:"blue-dark"}),n.jsxs(z,{htmlFor:"blue-dark",className:"flex-1 cursor-pointer",children:[n.jsx("div",{className:"font-medium",children:"Blue Dark"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"Professional blue-tinted dark theme"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("div",{className:"w-6 h-6 rounded-full",style:{background:"hsl(217 91% 60%)"}}),n.jsx("div",{className:"w-6 h-6 rounded-full",style:{background:"hsl(222.2 84% 4.9%)"}})]})]}),n.jsxs("div",{className:"flex items-center space-x-3 rounded-lg border p-4 hover:bg-accent/50 transition-colors",children:[n.jsx(pS,{value:"true-black",id:"true-black"}),n.jsxs(z,{htmlFor:"true-black",className:"flex-1 cursor-pointer",children:[n.jsx("div",{className:"font-medium",children:"True Black"}),n.jsx("div",{className:"text-sm text-muted-foreground",children:"Pure black theme with neutral colors"})]}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("div",{className:"w-6 h-6 rounded-full border",style:{background:"hsl(0 0% 98%)"}}),n.jsx("div",{className:"w-6 h-6 rounded-full border",style:{background:"hsl(0 0% 0%)"}})]})]})]})})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(ii,{className:"h-5 w-5"}),"Notification Preferences"]}),n.jsx(De,{children:"Control how you receive alerts in the application"})]}),n.jsxs(re,{className:"space-y-6",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:"Popup Notifications"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Show popup notifications in the app when monitors or agents change status"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:a?"Enabled":"Disabled"}),n.jsx(Rs,{checked:a,onCheckedChange:i})]})]}),a&&n.jsxs("div",{className:"space-y-3 pt-2 border-t",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsxs("p",{className:"text-sm font-medium flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4"}),"Popup Duration"]}),n.jsxs("p",{className:"text-sm text-muted-foreground",children:["How long popup notifications stay visible (",c,"-",d," seconds)"]})]}),n.jsxs("span",{className:"text-sm font-medium tabular-nums w-16 text-right",children:[o,"s"]})]}),n.jsx(sd,{value:[o],onValueChange:v=>l(v[0]),min:c,max:d,step:1,className:"w-full"}),n.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[n.jsxs("span",{children:[c,"s"]}),n.jsxs("span",{children:[d,"s"]})]})]})]})]}),h&&n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"Menu Visibility"}),n.jsx(De,{children:"Control which menu sections are visible in the sidebar"})]}),n.jsx(re,{className:"space-y-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{className:"text-sm font-medium",children:"Monitoring Menu"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Show Internet Monitors and Private LAN Agents in the sidebar"})]}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("span",{className:"text-sm text-muted-foreground",children:r?"Visible":"Hidden"}),n.jsx(Rs,{checked:r,onCheckedChange:s})]})]})})]}),h&&n.jsx(gDe,{}),p&&n.jsx(mDe,{}),p&&n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(wa,{className:"h-5 w-5"}),"Agent Downloads"]}),n.jsx(De,{children:"Download the latest PowerShell agent script for Windows servers"})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between p-4 border rounded-lg",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(hd,{className:"h-8 w-8 text-primary"}),n.jsxs("div",{children:[n.jsx("p",{className:"font-medium",children:"Minimal Agent v8.0.0"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"~250 lines • Server-controlled intervals • No local config files"})]})]}),n.jsxs(H,{onClick:()=>y("agent-v8-minimal.ps1","Minimal Agent v8.0.0"),children:[n.jsx(wa,{className:"h-4 w-4 mr-2"}),"Download"]})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"This agent registers automatically using your Tenant ID from the Windows Registry (HKLM:\\Software\\IsItUp\\Id) and receives timing configuration from the server."})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"Account Settings"}),n.jsx(De,{children:"Manage your account preferences"})]}),n.jsx(re,{children:n.jsx("p",{className:"text-sm text-muted-foreground",children:"Additional settings coming soon"})})]})]})}function vDe(){const{selectedClientId:e}=Mt();return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Help & Support"}),n.jsx("p",{className:"text-muted-foreground",children:"Get assistance and learn more about using the platform"})]}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Hm,{className:"h-5 w-5 text-primary"}),n.jsx(me,{children:"Documentation"})]}),n.jsx(De,{children:"Browse our comprehensive documentation"})]}),n.jsxs(re,{children:[n.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Learn how to set up monitors, configure alerts, and manage your infrastru
769cture."}),n.jsxs("a",{href:"#",className:"text-sm text-primary hover:underline inline-flex items-center gap-1",children:["View Documentation",n.jsx(_0,{className:"h-3 w-3"})]})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(aa,{className:"h-5 w-5 text-primary"}),n.jsx(me,{children:"Contact Support"})]}),n.jsx(De,{children:"Get in touch with our support team"})]}),n.jsx(re,{children:n.jsx(L9,{selectedClientId:e||"",context:"internet"})})]})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Dl,{className:"h-5 w-5 text-primary"}),n.jsx(me,{children:"Frequently Asked Questions"})]})}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium mb-1",children:"How do I add a new monitor?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:'Navigate to the specific monitor type page and click the "Add Monitor" button.'})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium mb-1",children:"How do I configure alerts?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Go to the Alerts page from the sidebar navigation to configure notification settings."})]}),n.jsxs("div",{children:[n.jsx("h4",{className:"font-medium mb-1",children:"How do I change the color theme?"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Go to Settings and choose between Blue Dark and True Black themes."})]})]})]})]})}const yDe=e=>{const{toast:t}=qr(),r=Et(),{data:s,isLoading:a,error:i}=Ve({queryKey:["watchlist-tokens",e],queryFn:async()=>{if(!e)return[];const{data:h,error:f}=await B.from("watchlist_tokens").select("*").eq("client_id",e).order("created_at",{ascending:!1});if(f)throw f;return h},enabled:!!e}),o=mt({mutationFn:async h=>{var p;const{data:f}=await B.auth.getUser(),{data:m,error:g}=await B.rpc("create_watchlist_token",{p_client_id:h.client_id,p_slug:h.slug,p_name:h.name,p_description:h.description||null,p_password:h.password,p_expires_at:h.expires_at||null,p_created_by_user_id:((p=f.user)==null?void 0:p.id)||null});if(g)throw g;return m},onSuccess:()=>{r.invalidateQueries({queryKey:["watchlist-tokens"]}),t({title:"Watchlist created",description:"Your watchlist dashboard has been created successfully."})},onError:h=>{t({title:"Error creating watchlist",description:h.message,variant:"destructive"})}}),l=mt({mutationFn:async({id:h,updates:f})=>{const{data:m,error:g}=await B.from("watchlist_tokens").update(f).eq("id",h).select().single();if(g)throw g;return m},onSuccess:()=>{r.invalidateQueries({queryKey:["watchlist-tokens"]}),t({title:"Watchlist updated",description:"Your watchlist has been updated successfully."})},onError:h=>{t({title:"Error updating watchlist",description:h.message,variant:"destructive"})}}),c=mt({mutationFn:async h=>{const{error:f}=await B.from("watchlist_tokens").delete().eq("id",h);if(f)throw f},onSuccess:()=>{r.invalidateQueries({queryKey:["watchlist-tokens"]}),t({title:"Watchlist deleted",description:"Your watchlist has been deleted successfully."})},onError:h=>{t({title:"Error deleting watchlist",description:h.message,variant:"destructive"})}}),d=mt({mutationFn:async({id:h,is_active:f})=>{if(!f){const{error:g}
769=await B.rpc("revoke_watchlist_sessions",{p_watchlist_id:h});g&&console.error("Error clearing sessions on deactivation:",g)}const{error:m}=await B.from("watchlist_tokens").update({is_active:f}).eq("id",h);if(m)throw m},onSuccess:(h,f)=>{r.invalidateQueries({queryKey:["watchlist-tokens"]}),f.is_active||r.invalidateQueries({queryKey:["watchlist-session-counts"]})},onError:h=>{t({title:"Error updating watchlist",description:h.message,variant:"destructive"})}}),u=mt({mutationFn:async h=>{const{error:f}=await B.rpc("revoke_watchlist_sessions",{p_watchlist_id:h});f&&console.error("Error revoking sessions from table:",f);const m=crypto.randomUUID(),{error:g}=await B.from("watchlist_tokens").update({token:m}).eq("id",h);if(g)throw g},onSuccess:()=>{r.invalidateQueries({queryKey:["watchlist-tokens"]}),r.invalidateQueries({queryKey:["watchlist-session-counts"]}),t({title:"Sessions revoked",description:"All active watchlist sessions have been disconnected."})},onError:h=>{t({title:"Error revoking sessions",description:h.message,variant:"destructive"})}});return{tokens:s||[],isLoading:a,error:i,createToken:o.mutate,updateToken:l.mutate,deleteToken:c.mutate,toggleActive:d.mutate,revokeSessions:u.mutate}},jDe=e=>{const{data:t,isLoading:r,error:s,refetch:a}=Ve({queryKey:["watchlist-session-counts",e],queryFn:async()=>{if(!e)return[];const{data:o,error:l}=await B.rpc("get_watchlist_session_counts",{p_client_id:e});if(l)throw console.error("Error fetching session counts:",l),l;return o||[]},enabled:!!e,refetchInterval:3e4,staleTime:15e3});return{sessionCounts:t||[],isLoading:r,error:s,refetch:a,getSessionCount:o=>{const l=t==null?void 0:t.find(c=>c.watchlist_id===o);return(l==null?void 0:l.active_count)||0}}};function bDe({watchlistId:e,clientId:t,onClose:r}){const s=Et(),[a,i]=x.useState(new Set),{data:o,isLoading:l}=Ve({queryKey:["client-monitors",t],queryFn:async()=>{const{data:v,error:j}=await B.from("monitoring_agents").select("id, name, asset_type, status, hostname_or_url").eq("client_id",t).eq("status","active").order("name");if(j)throw j;return v}}),{data:c,isLoading:d}=Ve({queryKey:["watchlist-assigned-monitors",e],queryFn:async()=>{const{data:v,error:j}=await B.from("watchlist_monitors").select("monitor_id").eq("watchlist_id",e);if(j)throw j;return new Set(v.map(b=>b.monitor_id))}});x.useEffect(()=>{c&&i(c)},[c]);const u=mt({mutationFn:async v=>{const{error:j}=await B.from("watchlist_monitors").insert(v.map(b=>({watchlist_id:e,monitor_id:b})));if(j)throw j},onSuccess:()=>{s.invalidateQueries({queryKey:["watchlist-assigned-monitors",e]}),s.invalidateQueries({queryKey:["watchlist-monitors"]}),ye.success("Monitors added to watchlist")},onError:v=>{console.error("Error adding monitors:",v),ye.error("Failed to add monitors")}}),h=mt({mutationFn:async v=>{const{error:j}=await B.from("watchlist_monitors").delete().eq("watchlist_id",e).in("monitor_id",v);if(j)throw j},onSuccess:()=>{s.invalidateQueries({queryKey:["watchlist-assigned-monitors",e]}),s.invalidateQueries({queryKey:["watchlist-monitors"]}),ye.success("Monitors removed from watchlist")},onError:v=>{console.error("Error removing monitors:",v),ye.error("Failed to remove monitors")}}),f=v=>{const j=new Set(a);j.has(v)?j.delete(v):j.add(v),i(j)},m=()=>{const v=c||new Set,j=Array.from(a).filter(_=>!v.has(_)),b=Array.from(v).filter(_=>!a.has(_));j.length>0&&u.mutate(j,{onSuccess:()=>{b.length===0&&r&&r()}}),b.length>0&&h.mutate(b,{onSuccess:()=>{j.length===0&&r&&r()}})},g=()=>{const v=c||new Set;return v.size!==a.size?!0:Array.from(a).some(j=>!v.has(j))},p=x.useMemo(()=>{const v=[],j=[];return o==null||o.forEach(b=>{b.asset_type==="local_device"?v.push(b):j.push(b)}),{lanAgents:v,internetMonitors:j}},[o]);if(l||d)return n.jsx("div",{className:"flex items-center justify-center py-8",children:n.jsx(mr,{className:"h-6 w-6 animate-spin"})});const y=v=>!v||v.length===0?n.jsx(ee,{className:"p-8 text-center",children:n.jsx("p",{className:"text-muted-foreground",children:"No monitors available in this category."})}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:v.map(j=>n.jsx(ee,{className:`p-4 cursor-pointer transition-colors ${a.has(j.id)?"border-primary bg-primary/5":"hover:border-muted-foreground
769/50"}`,onClick:()=>f(j.id),children:n.jsxs("div",{className:"flex items-start gap-3",children:[n.jsx(ct,{checked:a.has(j.id),onCheckedChange:()=>f(j.id),className:"mt-1"}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[n.jsx(Wr,{className:"h-4 w-4 flex-shrink-0"}),n.jsx("span",{className:"font-medium truncate",children:j.name})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ve,{variant:"outline",className:"text-xs",children:j.asset_type==="local_device"?"LAN AGENT":j.asset_type.toUpperCase()}),j.hostname_or_url&&n.jsx("span",{className:"text-xs text-muted-foreground truncate",children:j.hostname_or_url})]})]})]})},j.id))});return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"text-lg font-semibold",children:"Select Monitors"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose which monitors to display on this watchlist"})]}),n.jsx(H,{onClick:m,disabled:!g()||u.isPending||h.isPending,children:u.isPending||h.isPending?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]}),o&&o.length===0?n.jsx(ee,{className:"p-8 text-center",children:n.jsx("p",{className:"text-muted-foreground",children:"No monitors available. Create monitors first."})}):n.jsxs(cn,{defaultValue:"lan",className:"w-full",children:[n.jsxs(nn,{className:"grid w-full grid-cols-2",children:[n.jsxs(at,{value:"lan",className:"flex items-center gap-2",children:[n.jsx(ht,{className:"h-4 w-4"}),"Private LAN Agents (",p.lanAgents.length,")"]}),n.jsxs(at,{value:"internet",className:"flex items-center gap-2",children:[n.jsx(Pn,{className:"h-4 w-4"}),"Internet Monitors (",p.internetMonitors.length,")"]})]}),n.jsx(it,{value:"lan",className:"mt-4",children:y(p.lanAgents)}),n.jsx(it,{value:"internet",className:"mt-4",children:y(p.internetMonitors)})]})]})}function wDe(){var C;const{selectedClientId:e,clientMemberships:t}=Mt(),r=(C=t.find(P=>P.client_id===e))==null?void 0:C.client,{tokens:s,isLoading:a,createToken:i,deleteToken:o,toggleActive:l,revokeSessions:c}=yDe(e),{getSessionCount:d,refetch:u}=jDe(e||void 0),{toast:h}=qr(),[f,m]=x.useState(!1),[g,p]=x.useState(null),[y,v]=x.useState({name:"",slug:"",description:"",password:"",confirmPassword:"",expiresAt:""}),j=P=>P.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim(),b=P=>{v(M=>({...M,name:P,slug:M.slug===""?j(P):M.slug}))},_=()=>{if(e){if(y.password!==y.confirmPassword){h({title:"Password mismatch",description:"Passwords do not match",variant:"destructive"});return}if(y.password.length<8){h({title:"Weak password",description:"Password must be at least 8 characters long",variant:"destructive"});return}i({client_id:e,name:y.name,slug:y.slug,description:y.description,password:y.password,expires_at:y.expiresAt||void 0}),v({name:"",slug:"",description:"",password:"",confirmPassword:"",expiresAt:""}),m(!1)}},w=()=>"https://isitup.ai",N=P=>{const M=(r==null?void 0:r.slug)||"client",D=`${w()}/${M}/public/${P}`;navigator.clipboard.writeText(D),h({title:"URL copied",description:"Watchlist URL has been copied to clipboard"})},S=P=>{const M=(r==null?void 0:r.slug)||"client",D=`${w()}/${M}/public/${P}`;window.open(D,"_blank")};return a?n.jsx(ee,{children:n.jsxs(de,{children:[n.jsx(me,{children:"Watchlist Dashboards"}),n.jsx(De,{children:"Loading..."})]})}):n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsx(me,{children:"Watchlist Dashboards"}),n.jsx(De,{children:"Create public watchlist dashboards for monitoring your Private LAN agents. Each watchlist has a unique URL and password protection."})]}),n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"flex justify-between items-center",children:[n.jsxs("p",{className:"text-sm text-muted-foreground",children:[s.length," watchlist",s.length!==1?"s":""," created"]}),n.jsxs(er,{open:f,onOpenChange:m,children:[n.jsx(Y0,{asChild:!0,children:n.jsxs(H,{children:[n.jsx(Ws,{className:"mr-2 h-4 w-4"}),"Create Watchlist"]})}),n.jsxs(Kt,{className:"max-w-2xl",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Create Watchlist Dashboard"}),n.jsx(_s,{children:"Create a public dashboard to monitor your Private LAN agents. The URL will be shareable with password protection."})]}),n.jsxs("div",{className:"grid gap-4 py-4",children:[n.jsxs("div",{className:"grid gap-2",children:[n.jsx(z,{htmlFor:"name",children:"Watchlist Name"}),n.jsx(ie,{id:"name",placeholder:"NOC Dashboard",value:y.name,onChange:P=>b(P.target.value)})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(z,{htmlFor:"slug",children:"URL Slug"}),n.jsx(ie,{id:"slug",placeholder:"noc-dashboard",value:y.slug,onChange:P=>v(M=>({...M,slug:j(P.target.value)}))}),n.jsxs("p",{className:"text-xs text-muted-foreground",children:["URL: https://isitup.ai/",(r==null?void 0:r.slug)||"client","/public/",y.slug||"slug"]})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(z,{htmlFor:"description",children:"Description (Optional)"}),n.jsx(kr,{id:"description",placeholder:"Dashboard for monitoring production servers",value:y.description,onChange:P=>v(M=>({...M,description:P.target.value}))})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(z,{htmlFor:"password",children:"Password"}),n.jsx(ie,{id:"password",type:"password",placeholder:"Enter a strong password",value:y.password,onChange:P=>v(M=>({...M,password:P.target.value}))})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(z,{htmlFor:"confirmPassword",children:"Confirm Password"}),n.jsx(ie,{id:"confirmPassword",type:"password",placeholder:"Confirm password",value:y.confirmPassword,onChange:P=>v(M=>({...M,confirmPassword:P.target.value}))})]}),n.jsxs("div",{className:"grid gap-2",children:[n.jsx(z,{htmlFor:"expiresAt",children:"Expiry Date (Optional)"}),n.jsx(ie,{id:"expiresAt",type:"datetime-local",value:y.expiresAt,onChange:P=>v(M=>({...M,expiresAt:P.target.value}))})]})]}),n.jsxs(xg,{children:[n.jsx(H,{variant:"outline",onClick:()=>m(!1),children:"Cancel"}),n.jsx(H,{onClick:_,children:"Create Watchlist"})]})]})]})]}),s.length===0?n.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[n.jsx("p",{children:"No watchlist dashboards created yet."}),n.jsx("p",{className:"text-sm",children:"Create your first watchlist to get started."})]}):n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-5 ga
769p-4",children:s.map(P=>n.jsx(_De,{token:P,selectedClient:r,selectedClientId:e,openMonitorDialogId:g,setOpenMonitorDialogId:p,copyWatchlistUrl:N,openWatchlist:S,toggleActive:l,deleteToken:o,revokeSessions:c,activeSessionCount:d(P.id),refetchSessions:u},P.id))})]})]})}function _De({token:e,selectedClient:t,selectedClientId:r,openMonitorDialogId:s,setOpenMonitorDialogId:a,copyWatchlistUrl:i,openWatchlist:o,toggleActive:l,deleteToken:c,revokeSessions:d,activeSessionCount:u,refetchSessions:h}){const{monitors:f}=qse(r||void 0,e.id),m=(f==null?void 0:f.length)||0,g=()=>{d(e.id),setTimeout(()=>h(),500)};return n.jsx(ee,{className:"flex flex-col h-full",children:n.jsxs(re,{className:"pt-6 flex-1 flex flex-col",children:[n.jsxs("div",{className:"flex items-start justify-between mb-3",children:[n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("h4",{className:"font-semibold text-sm truncate mb-1",children:e.name}),n.jsxs("div",{className:"flex flex-wrap gap-1",children:[n.jsxs(ve,{variant:"secondary",className:"text-xs",children:[n.jsx(Rr,{className:"h-3 w-3 mr-1"}),m," ",m===1?"monitor":"monitors"]}),u>0&&n.jsxs(ve,{variant:"default",className:"text-xs bg-success hover:bg-success/90",children:[n.jsx($o,{className:"h-3 w-3 mr-1"}),u," viewing"]})]})]}),n.jsx(Rs,{checked:e.is_active,onCheckedChange:p=>l({id:e.id,is_active:p}),className:"ml-2"})]}),e.description&&n.jsx("p",{className:"text-xs text-muted-foreground mb-3 line-clamp-2",children:e.description}),n.jsxs("div",{className:"mt-auto space-y-2",children:[n.jsxs(er,{open:s===e.id,onOpenChange:p=>a(p?e.id:null),children:[n.jsx(Y0,{asChild:!0,children:n.jsxs(H,{variant:"outline",size:"sm",className:"w-full",children:[n.jsx(Qo,{className:"h-3 w-3 mr-1"}),"Manage"]})}),n.jsxs(Kt,{className:"max-w-4xl max-h-[80vh] overflow-y-auto",children:[n.jsxs(zr,{children:[n.jsxs(Br,{children:["Manage Monitors - ",e.name]}),n.jsx(_s,{children:"Select which monitors to display on this watchlist dashboard"})]}),r&&n.jsx(bDe,{watchlistId:e.id,clientId:r,onClose:()=>a(null)})]})]}),n.jsxs("div",{className:"flex gap-1",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:()=>i(e.slug),className:"flex-1",title:"Copy URL",children:n.jsx(rg,{className:"h-3 w-3"})}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>o(e.slug),className:"flex-1",title:"Open Watchlist",children:n.jsx(_0,{className:"h-3 w-3"})}),n.jsxs(os,{children:[n.jsx(lh,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",className:"flex-1",title:"Revoke Sessions",children:n.jsx(Gm,{className:"h-3 w-3"})})}),n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Revoke All Sessions?"}),n.jsxs(Bn,{children:['This will disconnect all users currently viewing "',e.name,'" (',u," active). They will need to re-enter the password to access the watchlist again."]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:g,children:"Revoke Sessions"})]})]})]}),n.jsxs(os,{children:[n.jsx(lh,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",className:"flex-1",title:"Delete Watchlist",children:n.jsx(Vt,{className:"h-3 w-3"})})}),n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete Watchlist?"}),n.jsxs(Bn,{children:['This will permanently delete "',e.name,'" and its public URL will no longer work.']})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:()=>c(e.id),children:"Delete"})]})]})]})]})]})]})})}function NDe(){return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Watchlist Dashboards"}),n.jsx("p",{className:"text-muted-foreground",children:"Create and manage public watchlist dashboards for monitoring your Private LAN agents"})]}),n.jsx(wDe,{})]})}function SDe(){const[e,t]=x.useState([]),[r,s]=x.useState(!0),[a,i]=x.useState(null),o=async()=>{try{s(!0),i(null),t([]);const{data:d,error:u}=await B.from("clients").select("*").order("created_at",{ascending:!1});if(u)throw u;if(!d||d.length===0){t([]);return}const h=[];for(const f of d){const{data:m}=await B.from("client_members").select("user_id, role, status").eq("client_id",f.id).eq("status","active"),g=[];if(m&&m.length>0){const{data:v}=await B.from("user_profiles").select("user_id, email, first_name, last_name, display_name").in("user_id",m.map(j=>
769j.user_id));for(const j of m){const b=v==null?void 0:v.find(_=>_.user_id===j.user_id);g.push({user_id:j.user_id,role:j.role,status:j.status,email:b==null?void 0:b.email,first_name:b==null?void 0:b.first_name,last_name:b==null?void 0:b.last_name,display_name:b==null?void 0:b.display_name})}}const{count:p}=await B.from("monitoring_agents").select("*",{count:"exact",head:!0}).eq("client_id",f.id).eq("status","active"),{count:y}=await B.from("monitors").select("*",{count:"exact",head:!0}).eq("client_id",f.id).eq("status","active");h.push({...f,user_count:g.length,active_monitor_count:p||0,monitor_count:y||0,members:g})}t(h)}catch(d){console.error("Error fetching clients:",d),i(d instanceof Error?d.message:"Failed to fetch clients")}finally{s(!1)}};return x.useEffect(()=>{o();const d=B.channel("clients-changes").on("postgres_changes",{event:"*",schema:"public",table:"clients"},()=>{console.log("Clients table changed, refetching..."),o()}).subscribe(),u=B.channel("client-members-changes").on("postgres_changes",{event:"*",schema:"public",table:"client_members"},()=>{console.log("Client members changed, refetching..."),o()}).subscribe(),h=B.channel("monitoring-agents-changes").on("postgres_changes",{event:"*",schema:"public",table:"monitoring_agents"},()=>{console.log("Monitoring agents changed, refetching..."),o()}).subscribe(),f=B.channel("monitors-changes").on("postgres_changes",{event:"*",schema:"public",table:"monitors"},()=>{console.log("Monitors changed, refetching..."),o()}).subscribe();return()=>{B.removeChannel(d),B.removeChannel(u),B.removeChannel(h),B.removeChannel(f)}},[]),{clients:e,isLoading:r,error:a,refetch:o,updateClient:async(d,u)=>{try{const{data:h,error:f}=await B.from("clients").update(u).eq("id",d).select().single();if(f)throw f;return t(m=>m.map(g=>g.id===d?{...g,...u}:g)),{success:!0,data:h}}catch(h){return console.error("Error updating client:",h),{success:!1,error:h instanceof Error?h.message:"Failed to update client"}}},deleteClient:async d=>{try{const{data:u,error:h}=await B.functions.invoke("delete-client",{body:{clientId:d}});if(h)throw h;if(!u.success)throw new Error(u.error||"Failed to delete client");return t(f=>f.filter(m=>m.id!==d)),{success:!0}}catch(u){return console.error("Error deleting client:",u),{success:!1,error:u instanceof Error?u.message:"Failed to delete client"}}}}}const Kf=[{icon:Ea,title:"Company Details",description:"Basic company information"},{icon:Rr,title:"People & Address",description:"Contacts and addresses"},{icon:yt,title:"Security Settings",description:"Security configuration"},{icon:oi,title:"Verify & Create",description:"Review and confirm details"}];function CDe({open:e,onOpenChange:t,onSuccess:r,existingClient:s}){const[a,i]=x.useState(0),[o,l]=x.useState(!1),[c,d]=x.useState(""),{toast:u}=qr(),[h,f]=x.useState({displayName:(s==null?void 0:s.name)||"",legalName:(s==null?void 0:s.legal_name)||"",slug:(s==null?void 0:s.slug)||"",primaryTimezone:(s==null?void 0:s.primary_timezone)||"UTC",dataResidencyRegion:(s==null?void 0:s.data_residency_region)||"us-east",planCode:(s==null?void 0:s.plan_code)||"free"}),[m,g]=x.useState({primaryContactName:"",primaryContactEmail:"",primaryContactPhone:"",invoiceEmail:"",useCustomPassword:!1,customPassword:"",registeredAddress:{line1:"",line2:"",city:"",region:"",postalCode:"",countryCode:"US"},billingAddressSame:!0,billingAddress:{line1:"",line2:"",city:"",region:"",postalCode:"",countryCode:"US"}}),[p,y]=x.useState(!1),[v,j]=x.useState({mfaRequired:!0,supportImpersonationAllowed:!1,sessionIdleTimeoutMinutes:30});x.useEffect(()=>{s?(f({displayName:s.name||"",legalName:s.legal_name||"",slug:s.slug||"",primaryTimezone:s.primary_timezone||"UTC",dataResidencyRegion:s.data_residency_region||"us-east",planCode:s.plan_code||"free"}),j({mfaRequired:s.mfa_required??!0,supportImpersonationAllowed:s.support_impersonation_allowed??!1,sessionIdleTimeoutMinutes:s.session_idle_timeout_minutes||30})):(f({displayName:"",legalName:"",slug:"",primaryTimezone:"UTC",dataResidencyRegion:"us-east",planCode:"free"}),g({primaryContactName:"",primaryContactEmail:"",primaryContactPhone:"",invoiceEmail:"",useCustomPassword:!1,customPassword:"",registeredAddress:{line1:"",line2:"",city:"",region:"",postalCode:"",countryCode:"US"},billingAddressSame:!0,billingAddress:{line1:"",line2:"",city:"",region:"",postalCode:"",countryCode:"US"}}),j({mfaRequired:!0,supportImpersonationAllowed:!1,sessionIdleTimeoutMinutes:30}),i(0))},[s]);const b=A=>A.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),_=A=>{f(U=>({...U,displayName:A,slug:b(A)}))},w=A=>A.length<8?{isValid:!1,message:"At least 8 characters"}:/[A-Z]/.test(A)?/[a-z]/.test(A)?/[0-9]/.test(A)?/[!@#$%^&*(),.?":{}|<>]/.test(A)?{isValid:!0,message:"Password meets all requirements"}:{isValid:!1,message:"At least one special character"}:{isValid:!1,message:"At least one number"}:{isValid:!1,message:"At least one lowercase letter"}:{isValid:!1,message:"At least one uppercase letter"},N=()=>{const A="ABCDEFGHIJKLMNOPQRSTUVWXYZ",U="abcdefghijklmnopqrstuvwxyz",F="0123456789",L='!@#$%^&*(),.?":{}|<>',$=A+U+F+L;let R="";R+=A[Math.floor(Math.random()*A.length)],R+=U[Math.floor(Math.random()*U.length)],R+=F[Math.floor(Math.random()*F.length)],R+=L[Math.floor(Math.random()*L.length)];for(let T=0;T<12;T++)R+=$[Math.floor(Math.random()*$.length)];return R.split("").sort(()=>Math.random()-.5).join("")},S=A=>{switch(A){case 0:return!!(h.displayName&&h.legalName&&h.slug);case 1:const U=!!(m.primaryContactName&&m.primaryContactEmail&&m.registeredAddress.line1&&m.registeredAddress.city&&m.registeredAddress.region&&m.registeredAddress.postalCode);return m.useCustomPassword?U&&w(m.customPassword).isValid:U;case 2:return!0;case 3:return!0;default:return!1}},C=()=>{S(a)&&i(A=>Math.min(A+1,3))},P=()=>{i(A=>Math.max(A-1,0))},M=async()=>
769{if(S(3)){l(!0);try{let A;if(s){const{data:U,error:F}=await B.from("clients").update({name:h.displayName,legal_name:h.legalName,slug:h.slug,primary_timezone:h.primaryTimezone,data_residency_region:h.dataResidencyRegion,plan_code:h.planCode,invoice_email:m.invoiceEmail||m.primaryContactEmail,mfa_required:v.mfaRequired,support_impersonation_allowed:v.supportImpersonationAllowed}).eq("id",s.id).select().single();if(F)throw F;A=U}else{const{data:U,error:F}=await B.rpc("generate_tenant_id");if(F||!U)throw new Error("Failed to generate tenant ID");const{data:L,error:$}=await B.from("clients").insert({name:h.displayName,legal_name:h.legalName,slug:h.slug,primary_timezone:h.primaryTimezone,data_residency_region:h.dataResidencyRegion,plan_code:h.planCode,invoice_email:m.invoiceEmail||m.primaryContactEmail,mfa_required:v.mfaRequired,support_impersonation_allowed:v.supportImpersonationAllowed,status:"active",enabled_modules:"core",tenant_id:U}).select().single();if($)throw $;A=L}if(s)u({title:"Client Updated Successfully",description:`${A.name} has been updated.`});else{const{data:U,error:F}=await B.from("client_contacts").insert({client_id:A.id,type:"primary",name:m.primaryContactName,email:m.primaryContactEmail,phone:m.primaryContactPhone||null}).select().single();if(F)throw F;const{data:L,error:$}=await B.from("client_addresses").insert({client_id:A.id,type:"registered",line1:m.registeredAddress.line1,line2:m.registeredAddress.line2||null,city:m.registeredAddress.city,region:m.registeredAddress.region,postal_code:m.registeredAddress.postalCode,country_code:m.registeredAddress.countryCode}).select().single();if($)throw $;let R=L;if(!m.billingAddressSame){const{data:k,error:W}=await B.from("client_addresses").insert({client_id:A.id,type:"billing",line1:m.billingAddress.line1,line2:m.billingAddress.line2||null,city:m.billingAddress.city,region:m.billingAddress.region,postal_code:m.billingAddress.postalCode,country_code:m.billingAddress.countryCode}).select().single();if(W)throw W;R=k}const{error:T}=await B.from("clients").update({primary_contact_id:U.id,registered_address_id:L.id,billing_address_id:R.id}).eq("id",A.id);if(T)throw T;console.log("Creating admin user with edge function...");try{const{data:k,error:W}=await B.functions.invoke("create-client-admin",{body:{email:m.primaryContactEmail,userData:{first_name:m.primaryContactName.split(" ")[0]||"Admin",last_name:m.primaryContactName.split(" ").slice(1).join(" ")||"User",is_new_client_admin:!0,client_id:A.id,display_name:m.primaryContactName},clientId:A.id,customPassword:m.useCustomPassword?m.customPassword:void 0}});if(console.log("Edge function response:",{adminResult:k,adminError:W}),W)throw console.error("Edge function error:",W),new Error(`Edge function failed: ${W.message||W}`);if(!(k!=null&&k.success))throw console.error("Admin creation failed:",k),new Error((k==null?void 0:k.error)||"Failed to create admin user - unknown error");console.log("Client admin created successfully:",k);const q=k.generatedPassword;d(q),u({title:"Client Created Successfully",description:`${A.name} created with admin login: ${m.primaryContactEmail} / ${q}`})}catch(k){console.error("Error creating client admin:",k),u({title:"Client Created",description:`${A.name} was created, but admin user creation failed: ${k.message}. Please create the admin user manually.`,variant:"destructive"})}await B.rpc("create_audit_log",{p_event_type:s?"client_update":"client_create",p_client_id:A.id,p_metadata:{client_name:A.name,action:s?"client_updated":"client_created",actor_context:"provider",client_slug:A.slug,created_by_wizard:!0,admin_email:m.primaryContactEmail,default_password_generated:!s}})}console.log(s?"Client updated successfully":"Client and admin creation completed successfully"),r(),t(!1),i(0),d(""),f({displayName:"",legalName:"",slug:"",primaryTimezone:"UTC",dataResidencyRegion:"us-east",planCode:"free"}),g({primaryContactName:"",primaryContactEmail:"",primaryContactPhone:"",invoiceEmail:"",useCustomPassword:!1,customPassword:"",registeredAddress:{line1:"",line2:"",city:"",region:"",postalCode:"",countryCode:"US"},billingAddressSame:!0,billingAddress:{line1:"",line2:"",city:"",region:"",postalCode:"",countryCode:"US"}}),j({mfaRequired:!0,supportImpersonationAllowed:!1,sessionIdleTimeoutMinutes:30})}catch(A){console.error("Error creating client:",A),u({title:"Error Creating Client",description:A.message||"An unexpected error occurred",variant:"destructive"})}finally{l(!1)}}},D=()=>{switch(a){case 0:return n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"displayName",children:"Display Name *"}),n.jsx(ie,{id:"displayName",value:h.displayName,onChange:A=>_(A.target.value),placeholder:"Acme Corporation"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"legalName",children:"Legal Name *"}),n.jsx(ie,{id:"legalName",value:h.legalName,onChange:A=>f(U=>({...U,legalName:A.target.value})),placeholder:"Acme Corporation Inc."})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"slug",children:"Slug *"}),n.jsx(ie,{id:"slug",value:h.slug,onChange:A=>f(U=>({...U,slug:A.target.value})),placeholder:"acme-corp"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"URL-friendly identifier (auto-generated from display name)"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"timezone",children:"Primary Timezone"}),n.jsxs(Fe,{value:h.primaryTimezone,onValueChange:A=>f(U=>({...U,primaryTimezone:A})),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"UTC",children:"UTC"}
769),n.jsx(J,{value:"America/New_York",children:"Eastern Time"}),n.jsx(J,{value:"America/Chicago",children:"Central Time"}),n.jsx(J,{value:"America/Denver",children:"Mountain Time"}),n.jsx(J,{value:"America/Los_Angeles",children:"Pacific Time"})]})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"region",children:"Data Residency"}),n.jsxs(Fe,{value:h.dataResidencyRegion,onValueChange:A=>f(U=>({...U,dataResidencyRegion:A})),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"us-east",children:"US East"}),n.jsx(J,{value:"us-west",children:"US West"}),n.jsx(J,{value:"eu-central",children:"EU Central"}),n.jsx(J,{value:"ap-southeast",children:"Asia Pacific"})]})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx(z,{htmlFor:"plan",children:"Subscription Plan"}),n.jsxs("div",{className:"grid gap-3",children:[n.jsx("div",{className:`p-4 border-2 rounded-lg cursor-pointer transition-colors ${h.planCode==="free"?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onClick:()=>f(A=>({...A,planCode:"free"})),children:n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"font-semibold",children:"Free"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Perfect for getting started"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Up to 10 monitors • Basic alerts"})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"font-bold text-lg",children:"$0"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"/month"})]})]})}),n.jsx("div",{className:`p-4 border-2 rounded-lg cursor-pointer transition-colors ${h.planCode==="professional"?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onClick:()=>f(A=>({...A,planCode:"professional"})),children:n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"font-semibold",children:"Professional"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"Most popular choice"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Up to 600 monitors • Advanced alerts • API access"})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"font-bold text-lg",children:"$35"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"/month"})]})]})}),n.jsx("div",{className:`p-4 border-2 rounded-lg cursor-pointer transition-colors ${h.planCode==="enterprise"?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,onClick:()=>f(A=>({...A,planCode:"enterprise"})),children:n.jsxs("div",{className:"flex justify-between items-start",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"font-semibold",children:"Enterprise"}),n.jsx("p",{className:"text-sm text-muted-foreground",children:"For large organizations"}),n.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Up to 6,000 monitors • SLA • White-label • SSO"})]}),n.jsxs("div",{className:"text-right",children:[n.jsx("p",{className:"font-bold text-lg",children:"$89"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"/month"})]})]})})]})]})]});case 1:return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h4",{className:"font-medium",children:"Primary Admin Contact"}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"contactName",children:"Full Name *"}),n.jsx(ie,{id:"contactName",value:m.primaryContactName,onChange:A=>g(U=>({...U,primaryContactName:A.target.value})),placeholder:"John Doe"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"contactEmail",children:"Email *"}),n.jsx(ie,{id:"contactEmail",type:"email",value:m.primaryContactEmail,onChange:A=>g(U=>({...U,primaryContactEmail:A.target.value})),placeholder:"[email protected]"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"contactPhone",children:"Phone"}),n.jsx(ie,{id:"contactPhone",value:m.primaryContactPhone,onChange:A=>g(U=>({...U,primaryContactPhone:A.target.value})),placeholder:"+1 (555) 123-4567"})]})]}),n.jsxs("div",{className:"space-y-3",children:[n.jsx(z,{children:"Initial Admin Password"}),n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex items-center space-x-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"radio",id:"autoPassword",name:"passwordOption",checked:!m.useCustomPassword,onChange:()=>g(A=>({...A,useCustomPassword:!1,customPassword:""})),className:"h-4 w-4 text-primary"}),n.jsx(z,{htmlFor:"autoPassword",className:"font-normal cursor-pointer",children:"Auto-generate secure password"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("input",{type:"radio",id:"customPassword",name:"passwordOption",checked:m.useCustomPassword,onChange:()=>g(A=>({...A,useCustomPassword:!0})),className:"h-4 w-4 text-primary"}),n.jsx(z,{htmlFor:"customPassword",className:"font-normal cursor-pointer",children:"Set custom password"})]})]}),m.useCustomPassword?n.jsxs("div",{className:"space-y-2",children:[n.jsxs("div",{className:"flex gap-2",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(ie,{type:p?"text":"password",value:m.customPassword,onChange:A=>g(U=>({...U,customPassword:A.target.value})),placeholder:"Enter custom password",className:"pr-10"}),n.jsx(H,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>y(!p),children:p?n.jsx(U_,{className:"h-4 w-4"}):n.jsx($o,{className:"h-4 w-4"})})]}),n.jsxs(H,{type:"button",variant:"outline",size:"sm",onClick:()=>g(A=>({...A,customPassword:N()})),className:"flex items-center gap-1",children:[n.jsx(sr,{className:"h-3 w-3"}),"Generate"]})]}),n.jsxs("div",{className:"text-xs space-y-1",children:[n.jsxs("p",{className:`${m.customPassword.length>=8?"text-green-600":"text-muted-foreground"}`,children:["• Min 8 characters ",m.customPassword.length>=8&&"✓"]}),n.jsxs("p",{className:`${/[A-Z]/.test(m.customPassword)?"text-green-600":"text-muted-foreground"}`,children:["• Uppercase letter ",/[A-Z]/.test(m.customPassword)&&"✓"]}),n.jsxs("p",{className:`${/[a-z]/.test(m.customPassword)?"text-green-600":"text-muted-foreground"}`,children:["• Lowercase letter ",/[a-z]/.test(m.customPassword)&&"✓"]}),n.jsxs("p",{className:`${/[0-9]/.test(m.customPassword)?"text-green-600":"text-muted-foreground"}`,children:["• Number ",/[0-9]/.test(m.customPassword)&&"✓"]}),n.jsxs("p",{className:`${/[!@#$%^&*(),.?":{}|<>]/.test(m.customPassword)?"text-green-600":"text-muted-foreground"}`,children:["• Special character ",/[!@#$%^&*(),.?":{}|<>]/.test(m.customPassword)&&"✓"]})]})]}):n.jsx("div",{className:"p-3 bg-muted/30 border border-border rounded-md",children:n.jsx("div",{className:"text-sm text-muted-foreground",children:c?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"font-mono text-foreground mb-1",children:c}),n.jsx("p",{className:"text-xs",children:"Secure password generated successfully - save this password!"})]}):n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"text-sm",children:"A secure password will be generated automatically during account creation"}),n.jsx("p",{className:"text-xs mt-1",children:"The password will be displayed after successful client creation"})]})})})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"invoiceEmail",children:"Invoice Email"}),n.jsx(ie,{id:"invoiceEmail",type:"email",value:m.invoiceEmail,onChange:A=>g(U=>({...U,invoiceEmail:A.target.value})),placeholder:"[email protected] (leave blank to use primary contact email)"})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h4",{className:"font-medium",children:"Registered Address"}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"regLine1",children:"Address Line 1 *"}),n.jsx(ie,{id:"regLine1",value:m.registeredAddress.line1,onChange:A=>g(U=>({...U,registeredAddress:{...U.registeredAddress,line1:A.target.value}})),placeholder:"123 Main Street"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"regLine2",children:"Address Line 2"}),n.jsx(ie,{id:"regLine2",value:m.registeredAddress.line2,onChange:A=>g(U=>({...U,registeredAddress:{...U.registeredAddress,line2:A.target.value}})),placeholder:"Suite 100"})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"regCity",children:"City *"}),n.jsx(ie,{id:"regCity",value:m.registeredAddress.city,onChange:A=>g(U=>({...U,registeredAddress:{...U.registeredAddress,city:A.target.value}})),placeholder:"New York"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"regRegion",children:"State/Region *"}),n.jsx(ie,{id:"regRegion",value:m.registeredAddress.region,onChange:A=>g(U=>({...U,registeredAddress:{...U.registeredAddress,region:A.target.value}})),placeholder:"NY"})]})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"regPostal",children:"Postal Code *"}),n.jsx(ie,{id:"regPostal",value:m.registeredAddress.postalCode,onChange:A=>g(U=>({...U,registeredAddress:{...U.registeredAddress,postalCode:A.target.value}})),placeholder:"10001"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"regCountry",children:"Country"}),n.jsxs(Fe,{value:m.registeredAddress.countryCode,onValueChange:A=>g(U=>({...U,registeredAddress:{...U.registeredAddress,countryCode:A}})),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsxs(Le,{children:[n.jsx(J,{value:"US",children:"United States"}),n.jsx(J,{value:"CA",children:"Canada"}),n.jsx(J,{value:"GB",children:"United Kingdom"}),n.jsx(J,{value:"DE",children:"Germany"}),n.jsx(J,{value:"FR",children:"France"})]})]})]})]})]}),n.jsx("div",{className:"space-y-2",children:n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"billingSame",checked:m.b
769illingAddressSame,onCheckedChange:A=>g(U=>({...U,billingAddressSame:!!A}))}),n.jsx(z,{htmlFor:"billingSame",children:"Billing address same as registered address"})]})})]});case 2:return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{className:"space-y-4",children:[n.jsx("h4",{className:"font-medium",children:"Security Settings"}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"mfaRequired",checked:v.mfaRequired,onCheckedChange:A=>j(U=>({...U,mfaRequired:!!A}))}),n.jsx(z,{htmlFor:"mfaRequired",children:"Require Multi-Factor Authentication (Recommended)"})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ct,{id:"supportImpersonation",checked:v.supportImpersonationAllowed,onCheckedChange:A=>j(U=>({...U,supportImpersonationAllowed:!!A}))}),n.jsx(z,{htmlFor:"supportImpersonation",children:"Allow support impersonation"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"sessionTimeout",children:"Session Idle Timeout (minutes)"}),n.jsx(ie,{id:"sessionTimeout",type:"number",min:"5",max:"480",value:v.sessionIdleTimeoutMinutes,onChange:A=>j(U=>({...U,sessionIdleTimeoutMinutes:parseInt(A.target.value)||30}))})]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsx("h4",{className:"font-medium",children:"Review & Create"}),n.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[n.jsxs("p",{children:[n.jsx("strong",{children:"Company:"})," ",h.displayName]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Slug:"})," ",h.slug]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Plan:"})," ",h.planCode]}),n.jsxs("p",{children:[n.jsx("strong",{children:"Primary Contact:"})," ",m.primaryContactName," (",m.primaryContactEmail,")"]}),n.jsxs("p",{children:[n.jsx("strong",{children:"MFA Required:"})," ",v.mfaRequired?"Yes":"No"]})]})]})]});default:return null}};return n.jsx(er,{open:e,onOpenChange:t,children:n.jsxs(Kt,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[n.jsx(zr,{children:n.jsx(Br,{children:s?"Edit Client":"Add New Client"})}),n.jsx("div",{className:"flex items-center justify-between mb-6",children:Kf.map((A,U)=>{const F=A.icon,L=U===a,$=U<a;return n.jsxs("div",{className:"flex items-center",children:[n.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full border-2 ${$?"bg-primary border-primary text-primary-foreground":L?"border-primary text-primary":"border-muted text-muted-foreground"}`,children:$?n.jsx(oi,{className:"w-4 h-4"}):n.jsx(F,{className:"w-4 h-4"})}),U<Kf.length-1&&n.jsx("div",{className:`w-16 h-0.5 mx-2 ${$?"bg-primary":"bg-muted"}`})]},U)})}),n.jsxs(ee,{children:[n.jsxs(de,{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[G.createElement(Kf[a].icon,{className:"w-5 h-5"}),Kf[a].title]}),n.jsx("p",{className:"text-sm text-muted-foreground",children:Kf[a].description})]}),n.jsx(re,{children:D()})]}),n.jsxs("div",{className:"flex justify-between",children:[n.jsxs(H,{variant:"outline",onClick:P,disabled:a===0,children:[n.jsx(zh,{className:"w-4 h-4 mr-2"}),"Previous"]}),a<3?n.jsxs(H,{onClick:C,disabled:!S(a),children:["Next",n.jsx(Yo,{className:"w-4 h-4 ml-2"})]}):n.jsx(H,{onClick:M,disabled:!S(a)||o,className:"bg-gradient-primary",children:o?n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"animate-spin mr-2",children:"⏳"}),s?"Updating Client...":"Creating Client..."]}):n.jsxs(n.Fragment,{children:[n.jsx(oi,{className:"w-4 h-4 mr-2"}),s?"Update Client":"Create Client"]})})]})]})})}function wr({label:e,value:t,fieldName:r,isEditing:s,onEdit:a,onSave:i,onCancel:o,onChange:l,type:c="text",placeholder:d,options:u=[],readOnly:h=!1,description:f}){const m=x.useRef(null),[g,p]=x.useState(t);x.useEffect(()=>{p(t)},[t]),x.useEffect(()=>{s&&m.current&&m.current.focus()},[s]);const y=()=>{h||a()},v=w=>{w.key==="Enter"?(l(g),i()):w.key==="Escape"&&(p(t),o())},j=()=>{l(g),i()},b=()=>{p(t),o()},_=t||"Not specified";return n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:r,children:e}),f&&n.jsx("p",{className:"text-xs text-muted-foreground",children:f}),s?n.jsxs("div",{className:"flex items-center space-x-2",children:[c==="select"?n.jsxs(Fe,{value:(g==null?void 0:g.toString())||"",onValueChange:p,children:[n.jsx(Ie,{className:"flex-1",children:n.jsx(Ue,{placeholder:d})}),n.jsx(Le,{children:u.map(w=>n.jsx(J,{value:w.value,children:w.label},w.value))})]}):n.jsx(ie,{ref:m,id:r,type:c,value:(g==null?void 0:g.toString())||"",onChange:w=>p(c==="number"?parseInt(w.target.value)||null:w.target.value),onKeyDown:v,placeholder:d,className:"flex-1"}),n.jsx(H,{size:"sm",variant:"outline",onClick:j,children:n.jsx(oi,{className:"w-3 h-3"})}),n.jsx(H,{size:"sm",variant:"outline",onClick:b,children:n.jsx(vn,{className:"w-3 h-3"})})]}):n.jsx("p",{className:`text-sm p-2 bg-muted rounded cursor-pointer hover:bg-muted/80 transition-colors ${h?"cursor-default hover:bg-muted":""}`,onDoubleClick:y,title:h?"":"Double-click to edit",children:_})]})}function kDe({clientId:e,currentLimits:t,onUpdate:r}){const[s,a]=x.useState(t!==null),[i,o]=x.useState({max_alerts_per_hour:(t==null?void 0:t.max_alerts_per_hour)??20,flapping_window_minutes:(t==null?void 0:t.flapping_window_minutes)??30,flapping_threshold:(t==null?void 0:t.flapping_threshold)??5,default_cooldown_minutes:(t==null?void 0:t.default_cooldown_minutes)??15}),[l,c]=x.useState(!1),[d,u]=x.useState(!1);x.useEffect(()=>{a(t!==null),t&&o({max_alerts_per_hour:t.max_alerts_per_hour??20,flapping_window_minutes:t.flapping_window_minutes??30,flapping_threshold:t.flapping_threshold??5,default_cooldown_minutes:t.default_cooldown_minutes??15})},[t]);const h=async()=>{c(!0);try{const g={alert_rate_limits:s?i:null},{error:p}=await B.from("clients").update(g).eq("id",e);if(p)throw p;ye.success(s?"Custom rate limits saved":"Reset to global defaults"),u(!1),r()}catch(g){console.error("Error saving rate limits:",g),ye.error("Failed to save rate limits")}finally{c(!1)}},f=(g,p)=>{o(y=>({...y,[g]:p}
769)),u(!0)},m=g=>{a(g),u(!0)};return n.jsxs(ee,{children:[n.jsxs(de,{className:"pb-3",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(yt,{className:"h-5 w-5 text-primary"}),n.jsx(me,{className:"text-base",children:"Alert Rate Limits"})]}),n.jsx(Rs,{checked:s,onCheckedChange:m})]}),n.jsx(De,{children:s?"Using custom rate limits for this client":"Using global platform defaults"})]}),s&&n.jsxs(re,{className:"space-y-4",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(vI,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm",children:"Max Alerts/Hour"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Per-client cap"})]})]}),n.jsx(ie,{type:"number",min:"5",max:"100",value:i.max_alerts_per_hour??"",onChange:g=>f("max_alerts_per_hour",parseInt(g.target.value)||20),className:"w-20 text-right"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Wr,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm",children:"Flapping Threshold"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"State changes before suppress"})]})]}),n.jsx(ie,{type:"number",min:"3",max:"20",value:i.flapping_threshold??"",onChange:g=>f("flapping_threshold",parseInt(g.target.value)||5),className:"w-20 text-right"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm",children:"Flapping Window"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Minutes to track changes"})]})]}),n.jsx(ie,{type:"number",min:"5",max:"120",value:i.flapping_window_minutes??"",onChange:g=>f("flapping_window_minutes",parseInt(g.target.value)||30),className:"w-20 text-right"})]}),n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ym,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs("div",{children:[n.jsx(z,{className:"text-sm",children:"Default Cooldown"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Minutes between alerts"})]})]}),n.jsx(ie,{type:"number",min:"0",max:"120",value:i.default_cooldown_minutes??"",onChange:g=>f("default_cooldown_minutes",parseInt(g.target.value)||15),className:"w-20 text-right"})]}),d&&n.jsxs(H,{onClick:h,disabled:l,size:"sm",className:"w-full mt-2",children:[n.jsx(Lo,{className:"h-4 w-4 mr-2"}),l?"Saving...":"Save Rate Limits"]})]}),!s&&d&&n.jsx(re,{children:n.jsxs(H,{onClick:h,disabled:l,size:"sm",variant:"outline",className:"w-full",children:[n.jsx(Ym,{className:"h-4 w-4 mr-2"}),l?"Saving...":"Reset to Global Defaults"]})})]})}function PDe({client:e,isOpen:t,onClose:r,onUpdate:s}){var Q,ue,X,le,pe,ce,se,oe;const[a,i]=x.useState(!1),[o,l]=x.useState({}),[c,d]=x.useState([]),[u,h]=x.useState(!1),[f,m]=x.useState({}),[g,p]=x.useState(!1),[y,v]=x.useState(!1),[j,b]=x.useState(null),[_,w]=x.useState({basic:!0,primaryUser:!1,business:!1,settings:!1,alertLimits:!1,security:!1}),[N,S]=x.useState("");x.useEffect(()=>{e&&(l(e),p(!1),m({}),C())},[e]),x.useEffect(()=>{var V,fe,ne,Ce,Pe,he;if(c.length>0){const ke=((fe=(V=c[0])==null?void 0:V.user_profile)==null?void 0:fe.display_name)||`${((Ce=(ne
769=c[0])==null?void 0:ne.user_profile)==null?void 0:Ce.first_name)||""} ${((he=(Pe=c[0])==null?void 0:Pe.user_profile)==null?void 0:he.last_name)||""}`.trim()||"";S(ke)}},[c]);const C=async()=>{if(e){h(!0);try{const{data:V,error:fe}=await B.from("client_members").select("id, user_id, role, status, created_at").eq("client_id",e.id).eq("status","active").eq("role","client_admin").order("created_at",{ascending:!0}).limit(1);if(fe)throw fe;if(!V||V.length===0){d([]);return}const ne=V.map(ke=>ke.user_id),{data:Ce,error:Pe}=await B.from("user_profiles").select("user_id, email, first_name, last_name, display_name").in("user_id",ne);if(Pe)throw Pe;const he=V.map(ke=>{const Me=Ce==null?void 0:Ce.find(Je=>Je.user_id===ke.user_id);return{id:ke.id,user_id:ke.user_id,role:ke.role,status:ke.status,joined_at:ke.created_at,user_profile:Me||{email:"No profile found",first_name:null,last_name:null,display_name:null}}});d(he)}catch(V){console.error("Error fetching primary user:",V),d([])}finally{h(!1)}}};if(!e)return null;const P=async()=>{i(!0);try{const{error:V}=await B.from("clients").update({name:o.name,legal_name:o.legal_name,industry:o.industry,invoice_email:o.invoice_email,plan_code:o.plan_code,max_user_count:o.max_user_count,data_residency_region:o.data_residency_region,primary_timezone:o.primary_timezone}).eq("id",e.id);if(V)throw V;j&&c.length>0&&await M(c[0].user_id,j),N&&c.length>0&&await D(c[0].user_id,N),ye.success("Client details updated successfully"),p(!1),m({}),s()}catch(V){console.error("Error updating client:",V),ye.error("Failed to update client details")}finally{i(!1)}},M=async(V,fe)=>{try{const{error:ne}=await B.functions.invoke("generate-secure-password",{body:{userId:V,clientId:e.id,newPassword:fe}});if(ne)throw ne;ye.success("Password updated successfully")}catch(ne){throw console.error("Error updating password:",ne),ye.error("Failed to update password"),ne}},D=async(V,fe)=>{try{const{error:ne}=await B.from("user_profiles").update({display_name:fe}).eq("user_id",V);if(ne)throw ne;ye.success("Admin name updated successfully"),await C()}catch(ne){throw console.error("Error updating admin name:",ne),ye.error("Failed to update admin name"),ne}},A=V=>{m(fe=>({...fe,[V]:!0}))},U=V=>{m(fe=>({...fe,[V]:!1}))},F=V=>{m(fe=>({...fe,[V]:!1})),e&&l(fe=>({...fe,[V]:e[V]}))},L=V=>{w(fe=>({...fe,[V]:!fe[V]}))},$=(V,fe)=>{l(ne=>({...ne,[V]:fe})),p(!0)},R=async()=>
769{if(!(!e||!c.length)){v(!0);try{const{data:V,error:fe}=await B.functions.invoke("generate-secure-password",{body:{userId:c[0].user_id,clientId:e.id}});if(fe)throw fe;V!=null&&V.password&&(b(V.password),p(!0),ye.success("New password generated successfully"))}catch(V){console.error("Error generating password:",V),ye.error("Failed to generate new password")}finally{v(!1)}}},T=V=>{if(!V)return"Not available";try{const fe=new Date(V);return isNaN(fe.getTime())?"Invalid date":fe.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return"Invalid date"}};if(!t)return null;const k=[{value:"technology",label:"Technology"},{value:"healthcare",label:"Healthcare"},{value:"finance",label:"Finance"},{value:"legal",label:"Legal"},{value:"education",label:"Education"},{value:"manufacturing",label:"Manufacturing"},{value:"retail",label:"Retail"},{value:"other",label:"Other"}],W=[{value:"basic",label:"Basic"},{value:"professional",label:"Professional"},{value:"enterprise",label:"Enterprise"}],q=[{value:"us-east",label:"US East"},{value:"us-west",label:"US West"},{value:"eu-west",label:"EU West"},{value:"asia-pacific",label:"Asia Pacific"}];return!e||!t?null:n.jsx(er,{open:t,onOpenChange:r,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[n.jsx(zr,{children:n.jsxs(Br,{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-10 h-10 rounded-lg bg-gradient-primary flex items-center justify-center",children:n.jsx(Ea,{className:"w-5 h-5 text-primary-foreground"})}),n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx("span",{children:e.name}),n.jsx(ve,{variant:e.status==="active"?"default":"secondary",children:e.status})]}),n.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[e.industry||"No industry specified"," • ",e.user_count||0," users • ID: ",e.tenant_id]})]}),n.jsx("div",{className:"ml-auto flex items-center space-x-2",children:g&&n.jsxs(H,{size:"sm",onClick:P,disabled:a,className:"bg-gradient-primary",children:[a?n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}):n.jsx(Lo,{className:"w-4 h-4 mr-2"}),"Save Changes"]})})]})}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs(ur,{open:_.basic,onOpenChange:()=>L("basic"),children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",className:"w-full justify-between p-0 h-auto",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Cv,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium",children:"Basic Information"})]}),_.basic?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})]})}),n.jsx(Er,{className:"space-y-4 pt-4",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(wr,{label:"Client Name",value:o.name||"",fieldName:"name",isEditing:f.name||!1,onEdit:()=>A("name"),onSave:()=>U("name"),onCancel:()=>F("name"),onChange:V=>$("name",V),type:"text"}),n.jsx(wr,{label:"Client Slug",value:e.slug,fieldName:"slug",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0}),n.jsx(wr,{label:"Tenant ID",value:e.tenant_id,fieldName:"tenant_id",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0,description:"24-character tenant ID for MSI installer"}),n.jsx(wr,{label:"Legal Name",value:o.legal_name||"",fieldName:"legal_name",isEditing:f.legal_name||!1,onEdit:()=>A("legal_name"),onSave:()=>U("legal_name"),onCancel:()=>F("legal_name"),onChange:V=>$("legal_name",V),type:"text",placeholder:"Enter legal name"}),n.jsx(wr,{label:"Industry",value:o.industry||"",fieldName:"industry",isEditing:f.industry||!1,onEdit:()=>A("industry"),onSave:()=>U("industry"),onCancel:()=>F("industry"),onChange:V=>$("industry",V),type:"select",options:k,placeholder:"Select industry"})]})})]}),n.jsx(ja,{}),n.jsxs(ur,{open:_.primaryUser,onOpenChange:()=>L("primaryUser"),children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",className:"w-full justify-between p-0 h-auto",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Km,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium",children:"Primary User Info"})]}),_.primaryUser?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})]})}),n.jsx(Er,{className:"space-y-4 pt-4",children:u?n.jsxs("div",{className:"flex items-center justify-center py-4",children:[n.jsx(mr,{className:"w-4 h-4 animate-spin mr-2"}),n.jsx("span",{children:"Loading user info..."})]}):c.length>0?n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(wr,{label:"Admin Email",value:((ue=(Q=c[0])==null?void 0:Q.user_profile)==null?void 0:ue.email)||"Not available",fieldName:"admin_email",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0}),n.jsx(wr,{label:"Admin Name",value:N,fieldName:"admin_name",isEditing:f.admin_name||!1,onEdit:()=>A("admin_name"),onSave:()=>U("admin_name"),onCancel:()=>{var V,fe,ne,Ce,Pe,he;if(F("admin_name"),c.length>0){const ke=((fe=(V=c[0])==null?void 0:V.user_profile)==null?void 0:fe.display_name)||`${((Ce=(ne
769=c[0])==null?void 0:ne.user_profile)==null?void 0:Ce.first_name)||""} ${((he=(Pe=c[0])==null?void 0:Pe.user_profile)==null?void 0:he.last_name)||""}`.trim()||"";S(ke)}},onChange:V=>{S(V),p(!0)},type:"text",placeholder:"Enter admin display name"}),n.jsx("div",{className:"md:col-span-2",children:n.jsxs("div",{className:"space-y-2",children:[n.jsx(wr,{label:"Admin Password",value:j||"",fieldName:"admin_password",isEditing:f.admin_password||!1,onEdit:()=>A("admin_password"),onSave:()=>U("admin_password"),onCancel:()=>F("admin_password"),onChange:V=>{b(V),p(!0)},type:"password",placeholder:"Enter new password"}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsxs(H,{size:"sm",variant:"outline",onClick:R,disabled:y,className:"hover:bg-primary/10",children:[y?n.jsx(mr,{className:"w-4 h-4 animate-spin mr-2"}):n.jsx(sr,{className:"w-4 h-4 mr-2"}),"Generate New"]}),j&&n.jsxs(H,{size:"sm",onClick:async()=>{try{await M(c[0].user_id,j),b(null),p(!1)}catch{}},disabled:a,className:"bg-gradient-primary",children:[a?n.jsx(mr,{className:"w-4 h-4 animate-spin mr-2"}):n.jsx(Lo,{className:"w-4 h-4 mr-2"}),"Save Password"]})]}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Double-click the password field to edit, or generate a new password"})]})}),n.jsx(wr,{label:"Role",value:((le=(X=c[0])==null?void 0:X.role)==null?void 0:le.replace("_"," ").toUpperCase())||"Not specified",fieldName:"admin_role",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0}),n.jsx(wr,{label:"User Status",value:((ce=(pe=c[0])==null?void 0:pe.status)==null?void 0:ce.charAt(0).toUpperCase())+((oe=(se=c[0])==null?void 0:se.status)==null?void 0:oe.slice(1))||"Not specified",fieldName:"admin_status",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0})]}):n.jsxs("div",{className:"space-y-4",children:[n.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"No primary user found for this client"}),n.jsx(TDe,{clientId:e.id,onUserCreated:C})]})})]}),n.jsx(ja,{}),n.jsxs(ur,{open:_.business,onOpenChange:()=>L("business"),children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",className:"w-full justify-between p-0 h-auto",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(aa,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium",children:"Business Settings"})]}),_.business?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})]})}),n.jsx(Er,{className:"space-y-4 pt-4",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(wr,{label:"Invoice Email",value:o.invoice_email||"",fieldName:"invoice_email",isEditing:f.invoice_email||!1,onEdit:()=>A("invoice_email"),onSave:()=>U("invoice_email"),onCancel:()=>F("invoice_email"),onChange:V=>$("invoice_email",V),type:"email",placeholder:"Enter invoice email"}),n.jsx(wr,{label:"Plan Code",value:o.plan_code||"",fieldName:"plan_code",isEditing:f.plan_code||!1,onEdit:()=>A("plan_code"),onSave:()=>U("plan_code"),onCancel:()=>F("plan_code"),onChange:V=>$("plan_code",V),type:"select",options:W,placeholder:"Select plan code"}),n.jsx(wr,{label:"Data Residency",value:o.data_residency_region||"",fieldName:"data_residency_region",isEditing:f.data_residency_region||!1,onEdit:()=>A("data_residency_region"),onSave:()=>U("data_residency_region"),onCancel:()=>F("data_residency_region"),onChange:V=>$("data_residency_region",V),type:"select",options:q,placeholder:"Select data residency"}),n.jsx(wr,{label:"Primary Timezone",value:o.primary_timezone||"",fieldName:"primary_timezone",isEditing:f.primary_timezone||!1,onEdit:()=>A("primary_timezone"),onSave:()=>U("primary_timezone"),onCancel:()=>F("primary_timezone"),onChange:V=>$("primary_timezone",V),type:"text",placeholder:"UTC"})]})})]}),n.jsx(ja,{}),n.jsxs(ur,{open:_.settings,onOpenChange:()=>L("settings"),children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",className:"w-full justify-between p-0 h-auto",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Qo,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium",children:"Resource Limits"})]}),_.settings?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})]})}),n.jsx(Er,{className:"space-y-4 pt-4",children:n.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:n.jsx(wr,{label:"Max Users",value:o.max_user_count||"",fieldName:"max_user_count",isEditing:f.max_user_count||!1,onEdit:()=>A("max_user_count"),onSave:()=>U("max_user_count"),onCancel:()=>F("max_user_count"),onChange:V=>$("max_user_count",V),type:"number",placeholder:"10"})})})]}),n.jsx(ja,{}),n.jsxs(ur,{open:_.alertLimits,onOpenChange:()=>L("alertLimits"),children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",className:"w-full justify-between p-0 h-auto",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(yt,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium",children:"Alert Rate Limits"})]}),_.alertLimits?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})]})}),n.jsx(Er,{className:"pt-4",children:n.jsx(kDe,{clientId:e.id,currentLimits:e.alert_rate_limits,onUpdate:s})})]}),n.jsx(ja,{}),n.jsxs(ur,{open:_.security,onOpenChange:()=>L("security"),children:[n.jsx(Jr,{asChild:!0,children:n.jsxs(H,{variant:"ghost",className:"w-full justify-between p-0 h-auto",children:[n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(fI,{className:"w-4 h-4"}),n.jsx("span",{className:"font-medium",children:"Metadata"})]}),_.security?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})]})}),n.jsx(Er,{className:"space-y-4 pt-4",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsx(wr,{label:"Created At",value:T(e.created_at),fieldName:"
769created_at",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0}),n.jsx(wr,{label:"Last Updated",value:T(e.updated_at),fieldName:"updated_at",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0}),n.jsx(wr,{label:"Client ID",value:e.id,fieldName:"id",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0}),n.jsx(wr,{label:"Active Users",value:(e.user_count||0).toString(),fieldName:"user_count",isEditing:!1,onEdit:()=>{},onSave:()=>{},onCancel:()=>{},onChange:()=>{},readOnly:!0})]})})]})]})]})})}function TDe({clientId:e,onUserCreated:t}){const[r,s]=x.useState(!1),[a,i]=x.useState({email:"",firstName:"",lastName:"",password:""}),o=()=>{const d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";let u="";for(let h=0;h<16;h++)u+=d.charAt(Math.floor(Math.random()*d.length));i(h=>({...h,password:u}))},l=async()=>{if(!a.email||!a.firstName){ye.error("Email and first name are required");return}s(!0);try{const{data:c,error:d}=await B.functions.invoke("create-client-admin",{body:{email:a.email,userData:{first_name:a.firstName,last_name:a.lastName||"",display_name:`${a.firstName} ${a.lastName||""}`.trim(),client_id:e},clientId:e,customPassword:a.password||void 0}});if(d)throw new Error(`Failed to create admin user: ${d.message}`);if(!(c!=null&&c.success))throw new Error((c==null?void 0:c.error)||"Failed to create admin user");ye.success(`Primary user created successfully! Email: ${a.email}`),i({email:"",firstName:"",lastName:"",password:""}),t()}catch(c){console.error("Error creating primary user:",c),ye.error(c.message||"Failed to create primary user")}finally{s(!1)}};return n.jsxs(ee,{className:"p-4",children:[n.jsxs(de,{className:"px-0 pt-0",children:[n.jsx(me,{className:"text-sm",children:"Create Primary User"}),n.jsx(De,{className:"text-xs",children:"Create an admin user account for this client"})]}),n.jsxs(re,{className:"px-0 pb-0 space-y-3",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-xs font-medium",children:"Email *"}),n.jsx(ie,{type:"email",placeholder:"[email protected]",value:a.email,onChange:c=>i(d=>({...d,email:c.target.value})),className:"h-8 text-sm"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-xs font-medium",children:"First Name *"}),n.jsx(ie,{type:"text",placeholder:"John",value:a.firstName,onChange:c=>i(d=>({...d,firstName:c.target.value})),className:"h-8 text-sm"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-xs font-medium",children:"Last Name"}),n.jsx(ie,{type:"text",placeholder:"Doe",value:a.lastName,onChange:c=>i(d=>({...d,lastName:c.target.value})),className:"h-8 text-sm"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx("label",{className:"text-xs font-medium",children:"Password"}),n.jsxs("div",{className:"flex space-x-2",children:[n.jsx(ie,{type:"password",placeholder:"Leave empty to auto-generate",value:a.password,onChange:c=>i(d=>({...d,password:c.target.value})),className:"h-8 text-sm flex-1"}),n.jsx(H,{size:"sm",variant:"outline",onClick:o,className:"h-8 px-2",children:n.jsx(sr,{className:"w-3 h-3"})})]})]})]}),n.jsx("div",{className:"flex justify-end space-x-2 pt-2",children:n.jsxs(H,{size:"sm",onClick:l,disabled:r||!a.email||!a.firstName,className:"bg-gradient-primary",children:[r?n.jsx(mr,{className:"w-3 h-3 mr-2 animate-spin"}):n.jsx(Cv,{className:"w-3 h-3 mr-2"}),"Create Primary User"]})})]})]})}function ADe({clientId:e,clientName:t,open:r,onOpenChange:s}){const{agents:a,isLoading:i,deleteAgent:o,toggleAgentStatus:l,isDeleting:c,isTogglingStatus:d}=Lt(e||void 0),[u,h]=x.useState(null),[f,m]=x.useState({});x.useEffect(()=>{if(!e||!r||a.length===0)return;const j=async()=>{const _=a.filter(N=>N.asset_type==="local_device");if(_.length===0)return;const{data:w}=await B.from("private_lan_agent_heartbeats").select("agent_id, created_at").in("agent_id",_.map(N=>N.id)).order("created_at",{ascending:!1});if(w){const N=new Date,S={};for(const C of w)if(!S[C.agent_id]){const P=new Date(C.created_at),M=(N.getTime()-P.getTime())/1e3;S[C.agent_id]={lastSeen:C.created_at,isOnline:M<=90}}m(S)}};j();const b=setInterval(j,3e4);return()=>clearInterval(b)}
769,[e,r,a]);const g=j=>{switch(j){case"active":return"default";case"suspended":return"secondary";default:return"outline"}},p=j=>{switch(j){case"active":return"bg-green-500/20 text-green-700 dark:text-green-400 border-green-500/30";case"suspended":return"bg-orange-500/20 text-orange-700 dark:text-orange-400 border-orange-500/30";default:return""}},y=async()=>{u&&(await o(u.id),h(null))},v=async j=>{await l(j)};return n.jsxs(n.Fragment,{children:[n.jsx(er,{open:r,onOpenChange:s,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[80vh] overflow-hidden flex flex-col",children:[n.jsxs(zr,{children:[n.jsxs(Br,{className:"flex items-center gap-2",children:[n.jsx(ht,{className:"w-5 h-5"}),'Agents for "',t,'"']}),n.jsx(_s,{children:"View and manage all monitoring agents for this client."})]}),n.jsx("div",{className:"flex-1 overflow-auto",children:i?n.jsxs("div",{className:"flex items-center justify-center py-12",children:[n.jsx(mr,{className:"h-6 w-6 animate-spin mr-2"}),n.jsx("span",{children:"Loading agents..."})]}):a.length===0?n.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[n.jsx(ht,{className:"h-12 w-12 text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-medium mb-2",children:"No agents found"}),n.jsx("p",{className:"text-muted-foreground",children:"This client doesn't have any monitoring agents configured."})]}):n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{children:"Name"}),n.jsx(Se,{children:"Asset Type"}),n.jsx(Se,{children:"Hostname/URL"}),n.jsx(Se,{children:"Monitoring"}),n.jsx(Se,{children:"Connection"}),n.jsx(Se,{children:"Last Seen"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:a.map(j=>{var w;const b=f[j.id],_=j.asset_type==="local_device";return n.jsxs(gt,{children:[n.jsx(be,{className:"font-medium",children:j.name}),n.jsx(be,{children:n.jsx(ve,{variant:"outline",className:"capitalize",children:((w=j.asset_type)==null?void 0:w.replace(/_/g," "))||"N/A"})}),n.jsx(be,{className:"max-w-[200px] truncate",children:j.hostname_or_url||j.ip_address||"N/A"}),n.jsx(be,{children:n.jsx(ve,{variant:g(j.status),className:p(j.status),children:j.status==="active"?"Enabled":"Paused"})}),n.jsx(be,{children:_?b?n.jsx(ve,{variant:"outline",className:b.isOnline?"bg-green-500/20 text-green-700 dark:text-green-400 border-green-500/30":"bg-red-500/20 text-red-700 dark:text-red-400 border-red-500/30",children:b.isOnline?n.jsxs(n.Fragment,{children:[n.jsx(wI,{className:"w-3 h-3 mr-1"})," Online"]}):n.jsxs(n.Fragment,{children:[n.jsx(bI,{className:"w-3 h-3 mr-1"})," Offline"]})}):n.jsx(ve,{variant:"outline",className:"text-muted-foreground",children:"No heartbeat"}):n.jsx("span",{className:"text-muted-foreground text-sm",children:"N/A"})}),n.jsx(be,{className:"text-muted-foreground text-sm",children:_&&(b!=null&&b.lastSeen)?is(new Date(b.lastSeen),{addSuffix:!0}):j.updated_at?is(new Date(j.updated_at),{addSuffix:!0}):"N/A"}),n.jsx(be,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-1",children:[n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>v(j),disabled:d,title:j.status==="active"?"Suspend Agent":"Activate Agent",className:j.status==="active"?"hover:bg-orange-500/10 text-orange-600":"hover:bg-green-500/10 text-green-600",children:j.status==="active"?n.jsx(ia,{className:"w-4 h-4"}):n.jsx(qs,{className:"w-4 h-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>h({id:j.id,name:j.name}),disabled:c,title:"Delete Agent",className:"hover:bg-destructive/10 text-destructive",children:n.jsx(Vt,{className:"w-4 h-4"})})]})})]},j.id)})})]})}),n.jsxs("div",{className:"flex justify-between items-center pt-4 border-t",children:[n.jsxs("div",{className:"text-sm text-muted-foreground",children:[a.length," agent",a.length!==1?"s":""," total"]}),n.jsx(H,{variant:"outline",onClick:()=>s(!1),children:"Close"})]})]})}),n.jsx(os,{open:!!u,onOpenChange:()=>h(null),children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsxs(zn,{className:"flex items-center gap-2",children:[n.jsx(kn,{className:"w-5 h-5 text-destructive"}),"Delete Agent"]}),n.jsxs(Bn,{children:['Are you sure you want to delete "',u==null?void 0:u.name,'"? This action cannot be undone. All agent data, including heartbeats, events, and configurations will be permanently removed.']})]}
769),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:c,children:"Cancel"}),n.jsx(qn,{onClick:y,disabled:c,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:c?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete Agent"})]})]})})]})}const Mx=[{value:"user",label:"User"},{value:"client_admin",label:"Client Admin"}];function EDe({clientId:e,clientName:t,members:r,onRefresh:s}){const[a,i]=x.useState(!1),[o,l]=x.useState(!1),[c,d]=x.useState(!1),[u,h]=x.useState(!1),[f,m]=x.useState(null),[g,p]=x.useState(null),[y,v]=x.useState(""),[j,b]=x.useState(""),[_,w]=x.useState("user"),[N,S]=x.useState("user"),[C,P]=x.useState(!1),[M,D]=x.useState("add"),[A,U]=x.useState(""),[F,L]=x.useState(""),[$,R]=x.useState(""),[T,k]=x.useState("user"),[W,q]=x.useState(""),[Q,ue]=x.useState(!1),[X,le]=x.useState(""),[pe,ce]=x.useState([]),[se,oe]=x.useState(""),[V,fe]=x.useState(""),[ne,Ce]=x.useState(""),[Pe,he]=x.useState(""),[ke,Me]=x.useState(""),[Je,Ke]=x.useState(""),[E,O]=x.useState(!1);x.useEffect(()=>{(async()=>{const{data:qe,error:St}=await B.from("pending_invitations").select("*").eq("client_id",e).eq("status","pending").order("created_at",{ascending:!1});!St&&qe&&ce(qe)})()},[e,r]);const I=xe=>xe.display_name?xe.display_name:xe.first_name||xe.last_name?`${xe.first_name||""} ${xe.last_name||""}`.trim():"Unknown User",Y=async()=>{if(!y.trim()){ye.error("Please enter an email address");return}P(!0);try{const{data:xe,error:qe}=await B.from("user_profiles").select("user_id").eq("email",y.toLowerCase().trim()).maybeSingle();if(qe)throw qe;if(!xe){ye.error("No user found with that email address. Use 'Invite New User' to send an invitation."),P(!1);return}if(r.find(wn=>wn.user_id===xe.user_id)){ye.error("This user is already a member of this client"),P(!1);return}const{error:Pr}=await B.from("client_members").insert({client_id:e,user_id:xe.user_id,role:_,status:"active"});if(Pr)throw Pr;ye.success(`User added to ${t} successfully`),i(!1),v(""),w("user"),s()}catch(xe){console.error("Error adding user:",xe),ye.error(xe instanceof Error?xe.message:"Failed to add user")}finally{P(!1)}},te=async()=>{if(!j.trim()){ye.error("Please enter an email address");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j.trim())){ye.error("Please enter a valid email address");return}P(!0);try{const{data:qe,error:St}=await B.functions.invoke("invite-user",{body:{email:j.toLowerCase().trim(),clientId:e,clientName:t,role:N}});if(St)throw St;if(qe.error){ye.error(qe.error),P(!1);return}qe.userExists?ye.success(`User already exists and has been added to ${t}`):ye.success(`Invitation sent to ${j}`),i(!1),b(""),S("user"),s()}catch(qe){console.error("Error inviting user:",qe),ye.error(qe instanceof Error?qe.message:"Failed to send invitation")}finally{P(!1)}},K=async()=>{if(!A.trim()){ye.error("Please enter an email address");return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(A.trim())){ye.error("Please enter a valid email address");return}if(!F.trim()){ye.error("Please enter a first name");return}P(!0);try{const{data:qe,error:St}=await B.functions.invoke("create-client-admin",{body:{email:A.toLowerCase().trim(),userData:{first_name:F.trim(),last_name:$.trim(),display_name:`${F.trim()} ${$.trim()}`.trim(),client_id:e},clientId:e,role:T,customPassword:W.trim()||void 0}});if(St)throw St;if(!(qe!=null&&qe.success)){ye.error((qe==null?void 0:qe.error)||"Failed to create user"),P(!1);return}const Pr=qe.generatedPassword;le(Pr),ye.success(n.jsxs("div",{className:"space-y-1",children:[n.jsx("p",{children:"User created successfully!"}),n.jsxs("p",{className:"text-xs font-mono bg-muted p-1 rounded",children:[A," / ",Pr]})]}),{duration:1e4}),U(""),L(""),R(""),k("user"),q(""),s()}catch(qe){console.error("Error creating user:",qe),ye.error(qe instanceof Error?qe.message:"Failed to create user")}finally{P(!1)}},Z=async()=>{if(f){P(!0);try{const xe={};if(se!==(f.first_name||"")&&(xe.firstName=se),V!==(f.last_name||"")&&(xe.lastName=V),ne!==(f.display_name||"")&&(xe.displayName=ne),Pe!==(f.email||"")&&(xe.email=Pe),ke!==f.role&&(xe.role=ke),Je.trim()&&(xe.password=Je),Object.keys(xe).length===0){ye.info("No changes to save"),l(!1);return}const{data:qe,error:St}=await B.functions.invoke("update-client-user",{body:{userId:f.user_id,clientId:e,updates:xe}});if(St)throw St;if(qe.error){ye.error(qe.error),P(!1);return}ye.success("User updated successfully"),l(!1),_e(),s()}catch(xe){console.error("Error updating user:",xe),ye.error(xe instanceof Error?xe.message:"Failed to update user")}finally{P(!1)}}},je=async()=>
769{if(f){P(!0);try{const{error:xe}=await B.from("client_members").delete().eq("client_id",e).eq("user_id",f.user_id);if(xe)throw xe;ye.success(`User removed from ${t}`),d(!1),m(null),s()}catch(xe){console.error("Error removing user:",xe),ye.error(xe instanceof Error?xe.message:"Failed to remove user")}finally{P(!1)}}},_e=()=>{m(null),oe(""),fe(""),Ce(""),he(""),Me(""),Ke(""),O(!1)},Ee=xe=>{m(xe),oe(xe.first_name||""),fe(xe.last_name||""),Ce(xe.display_name||""),he(xe.email||""),Me(xe.role),Ke(""),O(!1),l(!0)},Ze=xe=>{m(xe),d(!0)},st=async()=>{if(g){P(!0);try{const{error:xe}=await B.from("pending_invitations").update({status:"cancelled"}).eq("id",g.id);if(xe)throw xe;ye.success(`Invitation to ${g.email} cancelled`),h(!1),p(null),ce(qe=>qe.filter(St=>St.id!==g.id))}catch(xe){console.error("Error cancelling invitation:",xe),ye.error(xe instanceof Error?xe.message:"Failed to cancel invitation")}finally{P(!1)}}},xt=async xe=>{P(!0);try{const{data:qe,error:St}=await B.functions.invoke("invite-user",{body:{email:xe.email,clientId:e,clientName:t,role:xe.role,resend:!0}});if(St)throw St;if(qe.error){ye.error(qe.error);return}await B.from("pending_invitations").update({created_at:new Date().toISOString(),expires_at:new Date(Date.now()+30*24*60*60*1e3).toISOString()}).eq("id",xe.id),ye.success(`Invitation resent to ${xe.email}`);const{data:Pr}=await B.from("pending_invitations").select("*").eq("client_id",e).eq("status","pending").order("created_at",{ascending:!1});Pr&&ce(Pr)}catch(qe){console.error("Error resending invitation:",qe),ye.error(qe instanceof Error?qe.message:"Failed to resend invitation")}finally{P(!1)}},Dt=xe=>new Date(xe)<new Date;return n.jsxs("div",{className:"mt-4 pt-4 border-t",children:[n.jsxs("div",{className:"flex items-center justify-between mb-3",children:[n.jsxs("h4",{className:"text-sm font-medium flex items-center",children:[n.jsx(Rr,{className:"w-4 h-4 mr-2"}),"Client Users (",r.length,")"]}),n.jsxs(H,{size:"sm",variant:"outline",onClick:()=>i(!0),className:"h-7 text-xs",children:[n.jsx(xo,{className:"w-3 h-3 mr-1"}),"Add User"]})]}),r.length===0?n.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No users assigned to this client."}):n.jsx("div",{className:"space-y-2",children:r.map(xe=>n.jsxs("div",{className:"flex items-center justify-between p-2 rounded-md bg-muted/50 group",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/10 flex items-center justify-center",children:n.jsx(Cv,{className:"w-4 h-4 text-primary"})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:I(xe)}),n.jsxs("p",{className:"text-xs text-muted-foreground flex items-center",children:[n.jsx(aa,{className:"w-3 h-3 mr-1"}),xe.email||"No email"]})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ve,{variant:"outline",className:"text-xs",children:xe.role==="client_admin"?"Client Admin":xe.role==="provider_admin"?"Provider Admin":xe.role==="user"?"User":xe.role}),n.jsxs("div",{className:"opacity-0 group-hover:opacity-100 transition-opacity flex items-center space-x-1",children:[n.jsx(H,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>Ee(xe),title:"Edit User",children:n.jsx(z7,{className:"w-3 h-3"})}),n.jsx(H,{size:"icon",variant:"ghost",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:()=>Ze(xe),title:"Remove User",children:n.jsx(Vt,{className:"w-3 h-3"})})]})]})]},xe.user_id))}),pe.length>0&&n.jsxs("div",{className:"mt-4 pt-4 border-t",children:[n.jsxs("h5",{className:"text-sm font-medium flex items-center mb-3 text-muted-foreground",children:[n.jsx(Xt,{className:"w-4 h-4 mr-2"}),"Pending Invitations (",pe.length,")"]}),n.jsx("div",{className:"space-y-2",children:pe.map(xe=>{const qe=Dt(xe.expires_at);return n.jsxs("div",{className:`flex items-center justify-between p-2 rounded-md group ${qe?"bg-destructive/10":"bg-amber-500/10"}`,children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center ${qe?"bg-destructive/20":"bg-
769amber-500/20"}`,children:n.jsx(aa,{className:`w-4 h-4 ${qe?"text-destructive":"text-amber-600"}`})}),n.jsxs("div",{children:[n.jsx("p",{className:"text-sm font-medium",children:xe.email}),n.jsxs("p",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[n.jsxs("span",{children:["Invited ",$r(new Date(xe.created_at),"MMM d, yyyy")]}),qe?n.jsx(ve,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Expired"}):n.jsxs("span",{className:"text-amber-600",children:["Expires ",$r(new Date(xe.expires_at),"MMM d, yyyy")]})]})]})]}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(ve,{variant:"outline",className:"text-xs",children:xe.role==="client_admin"?"Client Admin":"User"}),n.jsxs("div",{className:"flex items-center space-x-1",children:[n.jsx(H,{size:"icon",variant:"ghost",className:"h-6 w-6",onClick:()=>xt(xe),disabled:C,title:"Resend Invitation",children:n.jsx(sr,{className:`w-3 h-3 ${C?"animate-spin":""}`})}),n.jsx(H,{size:"icon",variant:"ghost",className:"h-6 w-6 text-destructive hover:text-destructive",onClick:()=>{p(xe),h(!0)},disabled:C,title:"Cancel Invitation",children:n.jsx(R7,{className:"w-3 h-3"})})]})]})]},xe.id)})})]}),n.jsx(er,{open:a,onOpenChange:xe=>{i(xe),xe||(D("add"),v(""),b(""),w("user"),S("user"),U(""),L(""),R(""),k("user"),q(""),ue(!1),le(""))},children:n.jsxs(Kt,{className:"sm:max-w-[500px]",children:[n.jsxs(zr,{children:[n.jsxs(Br,{children:["Add User to ",t]}),n.jsx(_s,{children:"Add an existing user or invite someone new to join this client."})]}),n.jsxs(cn,{value:M,onValueChange:D,className:"mt-2",children:[n.jsxs(nn,{className:"grid w-full grid-cols-3",children:[n.jsxs(at,{value:"add",className:"flex items-center gap-1 text-xs",children:[n.jsx(xo,{className:"w-3 h-3"}),"Add Existing"]}),n.jsxs(at,{value:"create",className:"flex items-center gap-1 text-xs",children:[n.jsx(Cv,{className:"w-3 h-3"}),"Create New"]}),n.jsxs(at,{value:"invite",className:"flex items-center gap-1 text-xs",children:[n.jsx(Ii,{className:"w-3 h-3"}),"Invite"]})]}),n.jsxs(it,{value:"add",className:"space-y-4 mt-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Add a user who already has an account on the platform."}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"email",children:"User Email"}),n.jsx(ie,{id:"email",type:"email",placeholder:"[email protected]",value:y,onChange:xe=>v(xe.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"role",children:"Role"}),n.jsxs(Fe,{value:_,onValueChange:w,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select a role"})}),n.jsx(Le,{children:Mx.map(xe=>n.jsx(J,{value:xe.value,children:xe.label},xe.value))})]})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(H,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(H,{onClick:Y,disabled:C,children:C?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Adding..."]}):n.jsxs(n.Fragment,{children:[n.jsx(xo,{className:"w-4 h-4 mr-2"}),"Add User"]})})]})]}),n.jsxs(it,{value:"create",className:"space-y-4 mt-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Create a brand new user account with login credentials."}),n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"create-first-name",children:"First Name *"}),n.jsx(ie,{id:"create-first-name",placeholder:"John",value:F,onChange:xe=>L(xe.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"create-last-name",children:"Last Name"}),n.jsx(ie,{id:"create-last-name",placeholder:"Doe",value:$,onChange:xe=>R(xe.target.value)})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"create-email",children:"Email *"}),n.jsx(ie,{id:"create-email",type:"email",placeholder:"[email protected]",value:A,onChange:xe=>U(xe.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"create-role",children:"Role"}),n.jsxs(Fe,{value:T,onValueChange:k,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select a role"})}),n.jsx(Le,{children:Mx.map(xe=>n.jsx(J,{value:xe.value,children:xe.label},xe.value))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs(z,{htmlFor:"create-password",className:"flex items-center gap-2",children:[n.jsx(Km,{className:"w-3 h-3"}),"Password (leave blank to auto-generate)"]}),n.jsxs("div",{className:"relative",children:[n.jsx(ie,{id:"create-password",type:Q?"text":"password",value:W,onChange:xe=>q(xe.target.value),placeholder:"Auto-generate secure password",className:"pr-10"}),n.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>ue(!Q),children:Q?n.jsx(U_,{className:"h-4 w-4 text-muted-foreground"}):n.jsx($o,{className:"h-4 w-4 text-muted-foreground"})})]})]}),X&&n.jsxs("div",{className:"p-3 bg-green-500/10 border border-green-500/20 rounded-md",children:[n.jsx("p",{className:"text-sm font-medium text-green-600 mb-1",children:"User Created!"}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Save these credentials:"}),n.jsxs("div",{className:"mt-2 p-2 bg-muted rounded font-mono text-xs",children:[n.jsxs("p",{children:["Email: ",A||"See toast notification"]}),n.jsxs("p",{children:["Password: ",X]})]})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(H,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(H,{onClick:K,disabled:C,children:C?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Creating..."]}):n.jsxs(n.Fragment,{children:[n.jsx(xo,{className:"w-4 h-4 mr-2"}),"Create User"]})})]})]}
769),n.jsxs(it,{value:"invite",className:"space-y-4 mt-4",children:[n.jsx("p",{className:"text-sm text-muted-foreground",children:"Send an invitation email to someone who doesn't have an account yet."}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"invite-email",children:"Email Address"}),n.jsx(ie,{id:"invite-email",type:"email",placeholder:"[email protected]",value:j,onChange:xe=>b(xe.target.value)})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"invite-role",children:"Role"}),n.jsxs(Fe,{value:N,onValueChange:S,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select a role"})}),n.jsx(Le,{children:Mx.map(xe=>n.jsx(J,{value:xe.value,children:xe.label},xe.value))})]})]}),n.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[n.jsx(H,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),n.jsx(H,{onClick:te,disabled:C,children:C?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Sending..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Ii,{className:"w-4 h-4 mr-2"}),"Send Invitation"]})})]})]})]})]})}),n.jsx(er,{open:o,onOpenChange:xe=>{l(xe),xe||_e()},children:n.jsxs(Kt,{className:"sm:max-w-[500px]",children:[n.jsxs(zr,{children:[n.jsx(Br,{children:"Edit User"}),n.jsxs(_s,{children:["Update user details for ",f?I(f):"this user","."]})]}),n.jsxs("div",{className:"space-y-4 py-4",children:[n.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"edit-first-name",children:"First Name"}),n.jsx(ie,{id:"edit-first-name",value:se,onChange:xe=>oe(xe.target.value),placeholder:"First name"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"edit-last-name",children:"Last Name"}),n.jsx(ie,{id:"edit-last-name",value:V,onChange:xe=>fe(xe.target.value),placeholder:"Last name"})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"edit-display-name",children:"Display Name"}),n.jsx(ie,{id:"edit-display-name",value:ne,onChange:xe=>Ce(xe.target.value),placeholder:"Display name"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"edit-email",children:"Email"}),n.jsx(ie,{id:"edit-email",type:"email",value:Pe,onChange:xe=>he(xe.target.value),placeholder:"[email protected]"})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsx(z,{htmlFor:"edit-role",children:"Role"}),n.jsxs(Fe,{value:ke,onValueChange:Me,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select a role"})}),n.jsx(Le,{children:Mx.map(xe=>n.jsx(J,{value:xe.value,children:xe.label},xe.value))})]})]}),n.jsxs("div",{className:"space-y-2",children:[n.jsxs(z,{htmlFor:"edit-password",className:"flex items-center gap-2",children:[n.jsx(Km,{className:"w-3 h-3"}),"New Password (leave blank to keep current)"]}),n.jsxs("div",{className:"relative",children:[n.jsx(ie,{id:"edit-password",type:E?"text":"password",value:Je,onChange:xe=>Ke(xe.target.value),placeholder:"Enter new password",className:"pr-10"}),n.jsx(H,{type:"button",variant:"ghost",size:"icon",className:"absolute right-0 top-0 h-full px-3 hover:bg-transparent",onClick:()=>O(!E),children:E?n.jsx(U_,{className:"h-4 w-4 text-muted-foreground"}):n.jsx($o,{className:"h-4 w-4 text-muted-foreground"})})]}),Je&&n.jsx("p",{className:"text-xs text-muted-foreground",children:"The user will receive an email notification about the password change."})]})]}),n.jsxs(xg,{children:[n.jsx(H,{variant:"outline",onClick:()=>l(!1),disabled:C,children:"Cancel"}),n.jsx(H,{onClick:Z,disabled:C,children:C?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})}),n.jsx(os,{open:c,onOpenChange:d,children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Remove User"}),n.jsxs(Bn,{children:["Are you sure you want to remove"," ",n.jsx("strong",{children:f?I(f):"this user"})," ","from ",t,"? They will lose access to this client's resources."]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:C,children:"Cancel"}),n.jsx(qn,{onClick:je,disabled:C,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:C?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Removing..."]}):"Remove User"})]})]})}),n.jsx(os,{open:u,onOpenChange:h,children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Cancel Invitation"}),n.jsxs(Bn,{children:["Are you sure you want to cancel the invitation to"," ",n.jsx("strong",{children:g==null?void 0:g.email}),"? They will no longer be able to join ",t," using this invitation."]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:C,children:"Keep Invitation"}),n.jsx(qn,{onClick:st,disabled:C,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:C?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Cancelling..."]}):"Cancel Invitation"})]})]})})]})}function ODe(){const{clients:e,isLoading:t,error:r,refetch:s,updateClient:a,deleteClient:i}=SDe(),[o,l]=x.useState(!1),[c,d]=x.useState(null),[u,h]=x.useState(null),[f,m]=x.useState(!1),[g,p]=x.useState({}),[y,v]=x.useState({}
769),[j,b]=x.useState({}),[_,w]=x.useState({}),[N,S]=x.useState(null),[C,P]=x.useState(null),[M,D]=x.useState(!1),[A,U]=x.useState(""),[F,L]=x.useState("all"),[$,R]=x.useState("all"),[T,k]=x.useState(null),W=x.useMemo(()=>{const he=new Set;return e.forEach(ke=>{ke.industry&&he.add(ke.industry)}),Array.from(he).sort()},[e]),q=x.useMemo(()=>e.filter(he=>{const ke=A===""||he.name.toLowerCase().includes(A.toLowerCase())||he.legal_name&&he.legal_name.toLowerCase().includes(A.toLowerCase()),Me=F==="all"||he.status===F,Je=$==="all"||he.industry===$;return ke&&Me&&Je}),[e,A,F,$]),Q=x.useMemo(()=>{const he=e.length,ke=e.filter(E=>E.status==="active").length,Me=e.filter(E=>E.status==="inactive").length,Je=e.reduce((E,O)=>E+(O.user_count||0),0),Ke=e.reduce((E,O)=>E+(O.active_monitor_count||0)+(O.monitor_count||0),0);return{totalClients:he,activeClients:ke,inactiveClients:Me,totalUsers:Je,totalMonitors:Ke}},[e]),ue=he=>{w(ke=>({...ke,[he]:!ke[he]}))},X=he=>he==="active"?"default":"secondary",le=he=>he.charAt(0).toUpperCase()+he.slice(1),pe=(he,ke)=>{const Me=`${he}-${ke}`;p(Je=>({...Je,[Me]:ke}))},ce=async(he,ke)=>{const Me=`${he}-${ke}`,Je=y[Me];if(Je!==void 0){const Ke=await a(he,{[ke]:Je});Ke.success?ye.success(`${ke} updated successfully`):ye.error(Ke.error||"Failed to update client")}p(Ke=>{const E={...Ke};return delete E[Me],E}),v(Ke=>{const E={...Ke};return delete E[Me],E})},se=(he,ke)=>{const Me=`${he}-${ke}`;p(Je=>{const Ke={...Je};return delete Ke[Me],Ke}),v(Je=>{const Ke={...Je};return delete Ke[Me],Ke})},oe=(he,ke,Me)=>{const Je=`${he}-${ke}`;v(Ke=>({...Ke,[Je]:Me})),b(Ke=>({...Ke,[he]:{...Ke[he],[ke]:Me}}))},V=async he=>{const ke=j[he];if(!ke||Object.keys(ke).length===0)return;const Me=await a(he,ke);Me.success?(ye.success("All changes saved successfully"),b(Je=>{const Ke={...Je};return delete Ke[he],Ke}),v(Je=>{const Ke={...Je};return Object.keys(ke).forEach(E=>{delete Ke[`${he}-${E}`]}),Ke}),p(Je=>{const Ke={...Je};return Object.keys(ke).forEach(E=>{delete Ke[`${he}-${E}`]}),Ke})):ye.error(Me.error||"Failed to save changes")},fe=he=>{const ke=j[he];return ke&&Object.keys(ke).length>0},ne=async()=>{if(!c)return;m(!0);const he=await i(c.id);he.success?(ye.success(`Client "${c.name}" has been deleted successfully`),d(null)):ye.error(he.error||"Failed to delete client"),m(!1)},Ce=async(he,ke,Me)=>{P({id:he,name:ke,currentStatus:Me})},Pe=async()=>{if(!C)return;D(!0);const he=C.currentStatus==="active"?"inactive":"active",ke=await a(C.id,{status:he});ke.success?(ye.success(`Client "${C.name}" has been ${he==="active"?"enabled":"disabled"}`),P(null)):ye.error(ke.error||"Failed to update client status"),D(!1)};return n.jsxs(ee,{className:"shadow-card-custom",children:[n.jsx(de,{className:"pb-4",children:n.jsx("div",{className:"flex items-center justify-end",children:n.jsxs(H,{className:"bg-gradient-primary",onClick:()=>l(!0),children:[n.jsx(Ws,{className:"w-4 h-4 mr-2"}),"Add Client"]})})}),n.jsxs(re,{className:"space-y-4",children:[!t&&!r&&e.length>0&&n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[n.jsxs("div",{className:"rounded-lg border bg-muted/30 p-3 text-center",children:[n.jsx("p",{className:"text-2xl font-bold",children:Q.totalClients}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Clients"})]}),n.jsxs("div",{className:"rounded-lg border bg-green-500/10 p-3 text-center",children:[n.jsx("p",{className:"text-2xl font-bold text-green-600",children:Q.activeClients}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]}),n.jsxs("div",{className:"rounded-lg border bg-orange-500/10 p-3 text-center",children:[n.jsx("p",{className:"text-2xl font-bold text-orange-600",children:Q.inactiveClients}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive"})]}),n.jsxs("div",{className:"rounded-lg border bg-blue-500/10 p-3 text-center",children:[n.jsx("p",{className:"text-2xl font-bold text-blue-600",children:Q.totalUsers}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Users"})]}),n.jsxs("div",{className:"rounded-lg border bg-purple-500/10 p-3 text-center",children:[n.jsx("p",{className:"text-2xl font-bold text-purple-600",children:Q.totalMonitors}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Total Monitors"})]})]}),n.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-3",children:[n.jsxs("div",{className:"relative flex-1 w-full",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4"}),n.jsx(ie,{placeholder:"Search clients...",className:"pl-9",value:A,onChange:he=>U(he.target.value)})]}),n.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto",children:[n.jsxs(Fe,{value:F,onValueChange:L,children:[n.jsx(Ie,{className:"w-[130px]",children:n.jsx(Ue,{placeholder:"Status"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Status"}),n.jsx(J,{value:"active",children:"Active"}),n.jsx(J,{value:"inactive",children:"Inactive"})]})]}),n.jsxs(Fe,{value:$,onValueChange:R,children:[n.jsx(Ie,{className:"w-[150px]",children:n.jsx(Ue,{placeholder:"Industry"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Industries"}),W.map(he=>n.jsx(J,{value:he,children:he},he))]})]}),(F!=="all"||$!=="all"||A)&&n.jsx(H,{variant:"ghost",size:"icon",onClick:()=>{L("all"),R("all"),U("")},title:"Clear filters",children:n.jsx(vn,{className:"w-4 h-4"})})]})]}),(F!=="all"||$!=="all"||A)&&n.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[n.jsxs("span",{className:"text-xs text-muted-foreground",children:["Showing ",q.length," of ",e.length," clients"]}),F!=="all"&&n.jsxs(ve,{variant:"secondary",className:"text-xs",children:["Status: ",F,n.jsx("button",{className:"ml-1 hover:text-destructive",onClick:()=>L("all"),children:n.jsx(vn,{className:"w-3 h-3"})})]}),$!=="all"&&n.jsxs(ve,{variant:"secondary",className:"text-xs",children:["Industry: ",$,n.jsx("button",{className:"ml-1 hover:text-destructive",onClick:()=>R("all"),children:n.jsx(vn,{className:"w-3 h-3"})})]}),A&&n.jsxs(ve,{variant:"secondary",className:"text-xs",children:['Search: "',A,'"',n.jsx("button",{className:"ml-1 hover:text-destructive",onClick:()=>U(""),children:n.jsx(vn,{className:"w-3 h-3"})})]})]}),r&&n.jsxs(Xh,{variant:"destructive",children:[n.jsx(kn,{className:"h-4 w-4"}),n.jsx(Zh,{children:r})]}),t&&n.jsxs("div",{className:"flex items-center justify-center py-8",children:[n.jsx(mr,{className:"h-6 w-6 animate-spin mr-2"}),n.jsx("span",{children:"Loading clients..."})]}),!t&&!r&&n.jsx("div",{className:"space-y-3",children:e.length===0?n.jsxs("div",{className:"text-center py-8",children:[n.jsx(Ea,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-medium mb-2",children:"No clients yet"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"Get started by adding your first client to the platform."}
769),n.jsxs(H,{className:"bg-gradient-primary",onClick:()=>l(!0),children:[n.jsx(Ws,{className:"w-4 h-4 mr-2"}),"Add First Client"]})]}):q.length===0?n.jsxs("div",{className:"text-center py-8",children:[n.jsx(qt,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-medium mb-2",children:"No clients match your filters"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:"Try adjusting your search or filter criteria."}),n.jsx(H,{variant:"outline",onClick:()=>{L("all"),R("all"),U("")},children:"Clear Filters"})]}):q.map(he=>{const ke=Me=>`${he.id}-${Me}`;return n.jsxs("div",{className:"rounded-lg border bg-card hover:shadow-md transition-shadow",children:[n.jsx("div",{className:"p-4",children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{className:"flex items-center space-x-4 flex-1 cursor-pointer",onClick:()=>ue(he.id),children:[n.jsx("div",{className:"w-8 h-8 rounded-lg bg-gradient-primary flex items-center justify-center",children:n.jsx(Ea,{className:"w-4 h-4 text-primary-foreground"})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center space-x-3",children:[n.jsx("h3",{className:"text-sm font-medium truncate",children:he.name}),n.jsx(ve,{variant:X(he.status),className:`text-xs ${he.status==="active"?"bg-gradient-primary":""}`,children:le(he.status)})]}),n.jsxs("div",{className:"flex items-center space-x-4 mt-1 text-xs text-muted-foreground",children:[n.jsxs("span",{className:"flex items-center",children:[n.jsx(Rr,{className:"w-3 h-3 mr-1"}),he.user_count," users"]}),n.jsxs("span",{className:"flex items-center",children:[n.jsx(gC,{className:"w-3 h-3 mr-1"}),(he.active_monitor_count||0)+(he.monitor_count||0)," monitors"]}),he.industry&&n.jsx("span",{children:he.industry})]})]})]}),n.jsxs("div",{className:"flex items-center space-x-2 ml-4",children:[fe(he.id)&&n.jsxs(H,{onClick:()=>V(he.id),className:"bg-gradient-primary",size:"sm",children:[n.jsx(Lo,{className:"w-3 h-3 mr-1"}),"Save"]}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>h(he),className:"hover:bg-primary/10",children:n.jsx($o,{className:"w-4 h-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>k({id:he.id,name:he.name}),className:"hover:bg-green-500/10",title:"View Client Health",children:n.jsx(Wr,{className:"w-4 h-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>S({id:he.id,name:he.name}),className:"hover:bg-blue-500/10",title:"View Client Agents",children:n.jsx(ht,{className:"w-4 h-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>Ce(he.id,he.name,he.status),className:he.status==="active"?"hover:bg-orange-500/10":"hover:bg-green-500/10",title:he.status==="active"?"Disable Client":"Enable Client",children:he.status==="active"?n.jsx(K7,{className:"w-4 h-4 text-green-500"}):n.jsx(V7,{className:"w-4 h-4 text-muted-foreground"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>d({id:he.id,name:he.name}),className:"hover:bg-destructive/10 text-destructive",children:n.jsx(Vt,{className:"w-4 h-4"})}),n.jsx(H,{variant:"ghost",size:"sm",onClick:()=>ue(he.id),className:"hover:bg-muted",children:_[he.id]?n.jsx(Ar,{className:"w-4 h-4"}):n.jsx(dr,{className:"w-4 h-4"})})]})]})}),_[he.id]&&n.jsxs("div",{className:"px-4 pb-4 border-t bg-muted/20 animate-fade-in",children:[n.jsxs("div",{className:"pt-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[n.jsx(wr,{label:"Client Name",value:he.name,fieldName:"name",isEditing:g[ke("name")]==="name",onEdit:()=>pe(he.id,"name"),onSave:()=>ce(he.id,"name"),onCancel:()=>se(he.id,"name"),onChange:Me=>oe(he.id,"name",Me),type:"text",placeholder:"Enter client name"}),n.jsx(wr,{label:"Legal Name",value:he.legal_name,fieldName:"legal_name",isEditing:g[ke("legal_name")]==="legal_name",onEdit:()=>pe(he.id,"legal_name"),onSave:()=>ce(he.id,"legal_name"),onCancel:()=>se(he.id,"legal_name"),onChange:Me=>oe(he.id,"legal_name",Me),type:"text",placeholder:"Enter legal name"}),n.jsx(wr,{label:"Industry",value:he.industry,fieldName:"industry",isEditing:g[ke("industry")]==="industry",onEdit:()=>pe(he.id,"industry"),onSave:()=>ce(he.id,"industry"),onCancel:()=>se(he.id,"industry"),onChange:Me=>oe(he.id,"industry",Me),type:"text",placeholder:"Enter industry"}),n.jsx(wr,{label:"Plan",value:he.plan_code,fieldName:"plan_code",isEditing:g[ke("plan_code")]==="plan_code",onEdit:()=>pe(he.id,"plan_code"),onSave:()=>ce(he.id,"plan_code"),onCancel:()=>se(he.id,"plan_code"),onChange:Me=>oe(he.id,"plan_code",Me),type:"select",options:[{value:"free",label:"Free Plan"},{value:"professional",label:"Professional Plan"},{value:"enterprise",label:"Enterprise Plan"}]}),n.jsx(wr,{label:"Max Users",value:he.max_user_count,fieldName:"max_user_count",isEditing:g[ke("max_user_count")]==="max_user_count",onEdit:()=>pe(he.id,"max_user_count"),onSave:()=>ce(he.id,"max_user_count"),onCancel:()=>se(he.id,"max_user_count"),onChange:Me=>oe(he.id,"max_user_count",Me),type:"number",placeholder:"Enter max user count"}),n.jsx(wr,{label:"Status",value:he.status,fieldName:"status",isEditing:g[ke("status")]==="status",onEdit:()=>pe(he.id,"status"),onSave:()=>ce(he.id,"status"),onCancel:()=>se(he.id,"status"),onChange:Me=>oe(he.id,"status",Me),type:"select",options:[{value:"active",label:"Active"},{value:"suspended",label:"Suspended"},{value:"inactive",label:"Inactive"}]})]}),n.jsx(EDe,{clientId:he.id,clientName:he.name,members:he.members||[],onRefresh:s})]})]},he.id)})}),n.jsx(PDe,{client:u,isOpen:!!u,onClose:()=>h(null),onUpdate:()=>{s(),h(null)}})]}),n.jsx(CDe,{open:o,onOpenChange:l,onSuccess:()=>{s()}}),n.jsx(os,{open:!!c,onOpenChange:()=>d(null),children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Delete Client"}),n.jsxs(Bn,{children:['Are you sure you want to delete "',c==null?void 0:c.name,'"? This action cannot be undone. All client data, including users, addresses, and contacts will be permanently removed.']})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:f,children:"Cancel"}),n.jsx(qn,{onClick:ne,disabled:f,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:f?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete Client"})]})]})}),n.jsx(os,{open:!!C,onOpenChange:()=>P(null),children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsxs(zn,{children:[(C==null?void 0:C.currentStatus)==="active"?"Disable":"Enable"," Client"]}),n.jsx(Bn,{children:(C==null?void 0:C.currentStatus)==="active"?`Are you sure you want to disable "${C==null?void 0:C.name}"? Users will not be able to access this client's resources.`:`Are you sure you want to enable "${C==null?void 0:C.name}"? Users will regain access to this client's resources.`})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:M,children:"Cancel"}),n.jsx(qn,{onClick:Pe,disabled:M,className:(C==null?void 0:C.currentStatus)==="active"?"bg-orange-500 text-white hover:bg-orange-600":"bg-green-500 text-white hover:bg-green-600",children:M?n.jsxs(n.Fragment,{children:[n.jsx(mr,{className:"w-4 h-4 mr-2 animate-spin"}),(C==null?void 0:C.currentStatus)==="active"?"Disabling...":"Enabling..."]}):(C==null?void 0:C.currentStatus)==="active"?"Disable Client":"Enable Client"})]})]})}),n.jsx(ADe,{clientId:(N==null?void 0:N.id)||null,clientName:(N==null?void 0:N.name)||"",open:!!N,onOpenChange:he=>!he&&S(null)}),n.jsx(m6,{clientId:(T==null?void 0:T.id)||"",clientName:(T==null?void 0:T.name)||"",open:!!T,onOpenChange:he=>!he&&k(null)})]})}function MDe(){const{isProviderAdmin:e,isLoading:t}=Mt();return!t&&!e?n.jsx(lc,{to:"/dashboard/overview",replace:!0}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Client Management"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage all clients on the platform"})]}),n.jsx(ODe,{})]})}const Dx=[{value:"powershell",label:"PowerShell",icon:ws},{value:"batch",label:"Batch/DOS",icon:ws}],hD=["general","monitoring","maintenance","security","backup","deployment","diagnostics"];function DDe(){const{isProviderAdmin:e}
769=Mt(),[t,r]=x.useState(!1),{systemTemplates:s,isLoading:a,createSystemTemplate:i,updateSystemTemplate:o,deleteSystemTemplate:l,isCreating:c,isUpdating:d,isDeleting:u}=A5(void 0,t),[h,f]=x.useState(""),[m,g]=x.useState("all"),[p,y]=x.useState("all"),[v,j]=x.useState(!1),[b,_]=x.useState(null),[w,N]=x.useState({name:"",description:"",script_type:"",script_content:"",category:"general",tags:[]});if(!e)return n.jsx("div",{className:"flex items-center justify-center p-8",children:n.jsx(ee,{children:n.jsxs(re,{className:"p-6 text-center",children:[n.jsx("div",{className:"mb-4",children:n.jsx(Dl,{className:"w-16 h-16 mx-auto text-muted-foreground"})}),n.jsx("h3",{className:"text-lg font-semibold text-foreground mb-2",children:"Access Denied"}),n.jsx("p",{className:"text-muted-foreground",children:"You need platform administrator privileges to access system templates."})]})})});const S=s.filter(R=>{var q;const T=R.name.toLowerCase().includes(h.toLowerCase())||((q=R.description)==null?void 0:q.toLowerCase().includes(h.toLowerCase()))||R.tags.some(Q=>Q.toLowerCase().includes(h.toLowerCase())),k=m==="all"||R.script_type===m,W=p==="all"||R.category===p;return T&&k&&W}),C=R=>{const T=Dx.find(k=>k.value===R);return(T==null?void 0:T.icon)||Dl},P=R=>{const T=Dx.find(k=>k.value===R);return(T==null?void 0:T.label)||R},M=()=>{N({name:"",description:"",script_type:"",script_content:"",category:"general",tags:[]}),_(null)},D=()=>{M(),j(!0)},A=R=>{N({name:R.name,description:R.description||"",script_type:R.script_type,script_content:R.script_content,category:R.category,tags:R.tags||[]}),_(R),j(!0)},U=async R=>{if(R.preventDefault(),!w.name.trim()||!w.script_type||!w.script_content.trim()){ye.error("Please fill in all required fields");return}const T={...w,is_active:!0};try{b?await o({...T,id:b.id}):await i(T),j(!1),M()}catch(k){console.error("Error saving template:",k)}},F=async R=>{try{await l(R.id)}catch(T){console.error("Error deleting template:",T)}},L=R=>{const T=R.split(",").map(k=>k.trim()).filter(k=>k.length>0);N(k=>({...k,tags:T}))},$=R=>{const k=(X=>{switch(X){case"powershell":return".ps1";case"batch":return".bat";case"bash":return".sh";case"python":return".py";case"javascript":return".js";case"sql":return".sql";case"registry":return".reg";case"configuration":return".conf";default:return".txt"}})(R.script_type),W=`${R.name.replace(/[^a-zA-Z0-9-_]/g,"_")}${k}`,q=new Blob([R.script_content],{type:"text/plain"}),Q=URL.createObjectURL(q),ue=document.createElement("a");ue.href=Q,ue.download=W,document.body.appendChild(ue),ue.click(),document.body.removeChild(ue),URL.revokeObjectURL(Q),ye.success(`Downloaded ${W}`)};return n.jsxs("div",{className:"space-y-6",children:[n.jsx("div",{className:"flex justify-end",children:n.jsxs(H,{onClick:D,disabled:c,children:[n.jsx(Ws,{className:"w-4 h-4 mr-2"}),"Create Template"]})}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsx(me,{className:"text-lg",children:"Filters"})}),n.jsx(re,{className:"space-y-4",children:n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"search",children:"Search Templates"}),n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-muted-foreground"}),n.jsx(ie,{id:"search",placeholder:"Search by name, description, or tags...",value:h,onChange:R=>f(R.target.value),className:"pl-10"})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"script-type-filter",children:"Script Type"}),n.jsxs(Fe,{value:m,onValueChange:g,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"All types"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Types"}),Dx.map(R=>n.jsx(J,{value:R.value,children:R.label},R.value))]})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"category-filter",children:"Category"}),n.jsxs(Fe,{value:p,onValueChange:y,children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"All categories"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Categories"}),hD.map(R=>n.jsx(J,{value:R,children:R.charAt(0).toUpperCase()+R.slice(1)},R))]})]})]}),n.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[n.jsx(Rs,{id:"show-internal",checked:t,onCheckedChange:r}),n.jsxs(z,{htmlFor:"show-internal",className:"flex items-center gap-2 cursor-pointer",children:[n.jsx(Io,{className:"w-4 h-4 text-muted-foreground"}),"Show Internal Scripts"]})]})]})})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs(me,{className:"text-lg flex items-center gap-2",children:[n.jsx(Dl,{className:"w-5 h-5"}),"System Templates (",S.length,")"]})}),n.jsx(re,{children:a?n.jsxs("div",{className:"text-center py-8",children:[n.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary mx-auto"}),n.jsx("p",{className:"text-muted-foreground mt-2",children:"Loading system templates..."})]}):S.length===0?n.jsxs("div",{className:"text-center py-8",children:[n.jsx(Dl,{className:"w-16 h-16 mx-auto text-muted-foreground mb-4"}),n.jsx("h3",{className:"text-lg font-medium text-foreground mb-2",children:"No System Templates Found"}),n.jsx("p",{className:"text-muted-foreground mb-4",children:s.length===0?"Create your first system template to get started.":"No templates match your current filters."}),s.length===0&&n.jsxs(H,{onClick:D,children:[n.jsx(Ws,{className:"w-4 h-4 mr-2"}),"Create First Template"]})]}):n.jsx("div",{className:"overflow-x-auto",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{children:"Template Name"}),n.jsx(Se,{children:"Type"}),n.jsx(Se,{children:"Category"}),n.jsx(Se,{children:"Description"}),n.jsx(Se,{children:"Tags"}),n.jsx(Se,{children:"Created"}),n.jsx(Se,{className:"text-right",children:"Actions"})]})}),n.jsx(Kn,{children:S.map(R=>{var k,W;const T=C(R.script_type);return n.jsxs(gt,{children:[n.jsx(be,{className:"font-medium",children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(T,{className:"w-4 h-4 text-muted-foreground"}),R.name,R.is_internal&&n.jsxs(ve,{variant:"secondary",className:"text-xs",children:[n.jsx(Io,{className:"w-3 h-3 mr-1"}),"Internal"]}
769)]})}),n.jsx(be,{children:n.jsx(ve,{variant:"outline",children:P(R.script_type)})}),n.jsx(be,{children:n.jsx(ve,{variant:"secondary",children:R.category.charAt(0).toUpperCase()+R.category.slice(1)})}),n.jsx(be,{className:"max-w-xs",children:n.jsx("p",{className:"truncate text-sm text-muted-foreground",children:R.description||"No description"})}),n.jsx(be,{children:n.jsxs("div",{className:"flex flex-wrap gap-1",children:[(k=R.tags)==null?void 0:k.slice(0,2).map((q,Q)=>n.jsx(ve,{variant:"outline",className:"text-xs",children:q},Q)),((W=R.tags)==null?void 0:W.length)>2&&n.jsxs(ve,{variant:"outline",className:"text-xs",children:["+",R.tags.length-2]})]})}),n.jsx(be,{className:"text-sm text-muted-foreground",children:new Date(R.created_at).toLocaleDateString()}),n.jsx(be,{className:"text-right",children:n.jsxs("div",{className:"flex items-center justify-end gap-2",children:[n.jsx(H,{variant:"outline",size:"sm",onClick:()=>A(R),disabled:d,children:n.jsx(zi,{className:"w-3 h-3"})}),n.jsx(H,{variant:"outline",size:"sm",onClick:()=>$(R),children:n.jsx(wa,{className:"w-3 h-3"})}),n.jsxs(os,{children:[n.jsx(lh,{asChild:!0,children:n.jsx(H,{variant:"outline",size:"sm",disabled:u,children:n.jsx(Vt,{className:"w-3 h-3"})})}),n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{children:"Deactivate System Template"}),n.jsxs(Bn,{children:['Are you sure you want to deactivate "',R.name,'"? This will remove it from the system template library but preserve the data.']})]}),n.jsxs(Un,{children:[n.jsx(Wn,{children:"Cancel"}),n.jsx(qn,{onClick:()=>F(R),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Deactivate"})]})]})]})]})})]},R.id)})})]})})})]}),n.jsx(er,{open:v,onOpenChange:j,children:n.jsxs(Kt,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[n.jsx(zr,{children:n.jsx(Br,{children:b?"Edit System Template":"Create System Template"})}),n.jsxs("form",{onSubmit:U,className:"space-y-4",children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[n.jsxs("div",{children:[n.jsx(z,{htmlFor:"name",children:"Template Name *"}),n.jsx(ie,{id:"name",value:w.name,onChange:R=>N(T=>({...T,name:R.target.value})),placeholder:"Enter template name...",required:!0})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"script_type",children:"Script Type *"}),n.jsxs(Fe,{value:w.script_type,onValueChange:R=>N(T=>({...T,script_type:R})),children:[n.jsx(Ie,{children:n.jsx(Ue,{placeholder:"Select script type..."})}),n.jsx(Le,{children:Dx.map(R=>n.jsx(J,{value:R.value,children:R.label},R.value))})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"category",children:"Category"}),n.jsxs(Fe,{value:w.category,onValueChange:R=>N(T=>({...T,category:R})),children:[n.jsx(Ie,{children:n.jsx(Ue,{})}),n.jsx(Le,{children:hD.map(R=>n.jsx(J,{value:R,children:R.charAt(0).toUpperCase()+R.slice(1)},R))})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"tags",children:"Tags (comma-separated)"}),n.jsx(ie,{id:"tags",value:w.tags.join(", "),onChange:R=>L(R.target.value),placeholder:"monitoring, security, maintenance..."})]})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"description",children:"Description"}),n.jsx(kr,{id:"description",value:w.description,onChange:R=>N(T=>({...T,description:R.target.value})),placeholder:"Describe what this template does...",rows:3})]}),n.jsxs("div",{children:[n.jsx(z,{htmlFor:"script_content",children:"Script Content *"}),n.jsx(kr,{id:"script_content",value:w.script_content,onChange:R=>N(T=>({...T,script_content:R.target.value})),placeholder:"Enter your script content here...",rows:12,className:"font-mono text-sm",required:!0})]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx(H,{type:"button",variant:"outline",onClick:()=>j(!1),children:"Cancel"}),n.jsx(H,{type:"submit",disabled:c||d,children:c||d?"Saving...":b?"Update Template":"Create Template"})]})]})]})})]})}function RDe(){const{isProviderAdmin:e,isLoading:t}=Mt();return!t&&!e?n.jsx(lc,{to:"/dashboard/overview",replace:!0}):n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Platform Scripts"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage platform-wide script templates available to all clients"})]}),n.jsx(DDe,{})]})}const $De=()=>
769{const[e,t]=x.useState({totalClients:0,totalUsers:0,activeUsers:0,onlineUsers:0,totalMonitors:0,totalAgents:0,onlineAgents:0,totalScripts:0}),[r,s]=x.useState(!0),a=async()=>{try{s(!0);const{count:i}=await B.from("clients").select("id",{count:"exact",head:!0}),{count:o}=await B.from("user_profiles").select("id",{count:"exact",head:!0}).eq("is_provider_admin",!0),{data:l}=await B.from("client_members").select("user_id").eq("status","active"),c=(l==null?void 0:l.map(S=>S.user_id))||[],{count:d}=await B.from("user_profiles").select("id",{count:"exact",head:!0}).in("user_id",c),u=(o||0)+(d||0),{count:h}=await B.from("client_members").select("user_id",{count:"exact",head:!0}).eq("status","active"),f=new Date;f.setDate(f.getDate()-1);const{data:m}=await B.from("audit_logs").select("user_id").gte("created_at",f.toISOString()).not("user_id","is",null),p=new Set((m==null?void 0:m.map(S=>S.user_id))||[]).size,{count:y}=await B.from("monitors").select("id",{count:"exact",head:!0}),{count:v}=await B.from("monitoring_agents").select("id",{count:"exact",head:!0}).eq("asset_type","local_device"),{data:j}=await B.from("agent_current_status").select("agent_id, last_seen, status"),b=new Date,_=90*1e3;let w=0;j==null||j.forEach(S=>{if(S.last_seen){const C=new Date(S.last_seen);b.getTime()-C.getTime()<=_&&S.status==="online"&&w++}});let N=0;try{const{data:S,error:C}=await B.rpc("get_platform_script_counts");if(!C&&S&&Array.isArray(S)&&S[0])N=S[0].total_scripts||0;else{console.log("RPC failed, using fallback queries:",C);const{count:P}=await B.from("script_templates").select("id",{count:"exact",head:!0}),{count:M}=await B.from("system_script_templates").select("id",{count:"exact",head:!0});N=(P||0)+(M||0)}}catch(S){console.error("Error getting script counts:",S);const{count:C}=await B.from("script_templates").select("id",{count:"exact",head:!0}),{count:P}=await B.from("system_script_templates").select("id",{count:"exact",head:!0});N=(C||0)+(P||0)}t({totalClients:i||0,totalUsers:u,activeUsers:h||0,onlineUsers:p||0,totalMonitors:y||0,totalAgents:v||0,onlineAgents:w,totalScripts:N})}catch(i){console.error("Error fetching platform stats:",i)}finally{s(!1)}};return x.useEffect(()=>{a();const i=B.channel("clients-changes").on("postgres_changes",{event:"*",schema:"public",table:"clients"},a).subscribe(),o=B.channel("users-changes").on("postgres_changes",{event:"*",schema:"public",table:"user_profiles"},a).subscribe(),l=B.channel("members-changes").on("postgres_changes",{event:"*",schema:"public",table:"client_members"},a).subscribe(),c=B.channel("monitors-changes").on("postgres_changes",{event:"*",schema:"public",table:"monitors"},a).subscribe(),d=B.channel("scripts-changes").on("postgres_changes",{event:"*",schema:"public",table:"script_templates"},a).on("postgres_changes",{event:"*",schema:"public",table:"system_script_templates"},a).subscribe();return()=>{B.removeChannel(i),B.removeChannel(o),B.removeChannel(l),B.removeChannel(c),B.removeChannel(d)}},[]),{stats:e,isLoading:r,refetch:a}};function IDe(){const{isProviderAdmin:e,isLoading:t}=Mt(),{stats:r,isLoading:s}=$De();if(!t&&!e)return n.jsx(lc,{to:"/dashboard/overview",replace:!0});const a=t||s,i=[{title:"Total Clients",value:(r==null?void 0:r.totalClients)??0,description:"Active client accounts",icon:Ea},{title:"Total Users",value:(r==null?void 0:r.totalUsers)??0,description:"Registered user accounts",icon:Rr},{title:"Active Users",value:(r==null?void 0:r.activeUsers)??0,description:"Users with active memberships",icon:Rr},{title:"Total Agents",value:(r==null?void 0:r.totalAgents)??0,description:`${(r==null?void 0:r.onlineAgents)??0} online`,icon:ht},{title:"Total Monitors",value:(r==null?void 0:r.totalMonitors)??0,description:"Active monitor checks",icon:Pn},{title:"Total Scripts",value:(r==null?void 0:r.totalScripts)??0,description:"Script templates",icon:hd},{title:"Online Users",value:(r==null?void 0:r.onlineUsers)??0,description:"Active in last 24 hours",icon:Wr}];return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Platform Statistics"}),n.jsx("p",{className:"text-muted-foreground",children:"Overview of platform-wide metrics and usage"})]}),n.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:i.map(o=>n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:o.title}),n.jsx(o.icon,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[a?n.jsx("div",{className:"h-8 w-20 animate-pulse bg-muted rounded"}):n.jsx("div",{className:"text-2xl font-bold",children:o.value.toLocaleStr
769ing()}),n.jsx("p",{className:"text-xs text-muted-foreground",children:o.description})]})]},o.title))})]})}function LDe(){const{isProviderAdmin:e,isLoading:t}=Mt(),[r,s]=x.useState(""),[a,i]=x.useState("all"),{data:o,isLoading:l,refetch:c,isRefetching:d}=Ve({queryKey:["audit-logs"],queryFn:async()=>{const{data:m,error:g}=await B.from("audit_logs").select(`
770          *,
771          client:clients(name, slug)
772        `).order("created_at",{ascending:!1}).limit(500);if(g)throw g;return m},enabled:e});if(!t&&!e)return n.jsx(lc,{to:"/dashboard/overview",replace:!0});const u=[...new Set((o==null?void 0:o.map(m=>m.event_type))||[])],h=o==null?void 0:o.filter(m=>{var y,v;const g=r===""||m.event_type.toLowerCase().includes(r.toLowerCase())||JSON.stringify(m.metadata).toLowerCase().includes(r.toLowerCase())||((v=(y=m.client)==null?void 0:y.name)==null?void 0:v.toLowerCase().includes(r.toLowerCase())),p=a==="all"||m.event_type===a;return g&&p}),f=m=>m.includes("delete")||m.includes("revoke")?"destructive":m.includes("create")||m.includes("add")?"default":m.includes("update")||m.includes("modify")?"secondary":"outline";return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"Audit Logs"}),n.jsx("p",{className:"text-muted-foreground",children:"View all platform activity and security events"})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(Dl,{className:"h-5 w-5"}),"Activity Log"]}),n.jsxs(De,{children:[(h==null?void 0:h.length)||0," events recorded"]})]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>c(),disabled:d,children:[n.jsx(sr,{className:`h-4 w-4 mr-2 ${d?"animate-spin":""}`}),"Refresh"]})]})}),n.jsxs(re,{children:[n.jsxs("div",{className:"flex flex-col sm:flex-row gap-4 mb-4",children:[n.jsxs("div",{className:"relative flex-1",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search logs...",value:r,onChange:m=>s(m.target.value),className:"pl-10"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Ui,{className:"h-4 w-4 text-muted-foreground"}),n.jsxs(Fe,{value:a,onValueChange:i,children:[n.jsx(Ie,{className:"w-[180px]",children:n.jsx(Ue,{placeholder:"Filter by type"})}),n.jsxs(Le,{children:[n.jsx(J,{value:"all",children:"All Events"}),u.map(m=>n.jsx(J,{value:m,children:m},m))]})]})]})]}),l?n.jsx("div",{className:"space-y-3",children:[...Array(5)].map((m,g)=>n.jsx(tt,{className:"h-12 w-full"},g))}):n.jsx("div",{className:"rounded-md border",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{children:"Timestamp"}),n.jsx(Se,{children:"Event Type"}),n.jsx(Se,{children:"Client"}),n.jsx(Se,{children:"Details"})]})}),n.jsx(Kn,{children:h&&h.length>0?h.map(m=>{var g;return n.jsxs(gt,{children:[n.jsx(be,{className:"font-mono text-sm",children:$r(new Date(m.created_at),"yyyy-MM-dd HH:mm:ss")}),n.jsx(be,{children:n.jsx(ve,{variant:f(m.event_type),children:m.event_type})}),n.jsx(be,{children:((g=m.client)==null?void 0:g.name)||n.jsx("span",{className:"text-muted-foreground",children:"-"})}),n.jsx(be,{className:"max-w-md truncate",children:n.jsx("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:m.metadata?JSON.stringify(m.metadata).substring(0,100):"-"})})]},m.id)}):n.jsx(gt,{children:n.jsx(be,{colSpan:4,className:"text-center text-muted-foreground py-8",children:"No audit logs found"})})})]})})]})]})]})}function FDe(){const{isProviderAdmin:e,isLoading:t,user:r}=Mt(),[s,a]=x.useState(""),[i,o]=x.useState(!1),[l,c]=x.useState(!1),[d,u]=x.useState(null),[h,f]=x.useState(new Map),[m,g]=x.useState(new Set),p=Et(),y=new Set(Array.from(h.entries()).filter(([$,R])=>R.isOnline).map(([$])=>$));x.useEffect(()=>{if(!e)return;const $=B.channel("user-presence-admin");return $.on("presence",{event:"sync"},()=>{const R=$.presenceState(),T=new Map;
772Object.values(R).forEach(k=>{k.forEach(W=>{T.set(W.user_id,{isOnline:!0,isIdle:W.status==="idle"})})}),f(T)}).on("presence",{event:"join"},({newPresences:R})=>{f(T=>{const k=new Map(T);return R.forEach(W=>{k.set(W.user_id,{isOnline:!0,isIdle:W.status==="idle"})}),k})}).on("presence",{event:"leave"},({leftPresences:R})=>{f(T=>{const k=new Map(T);return R.forEach(W=>{k.delete(W.user_id)}),k})}).subscribe(),()=>{B.removeChannel($)}},[e]),x.useEffect(()=>{if(!e)return;const $=B.channel("user-profiles-changes").on("postgres_changes",{event:"UPDATE",schema:"public",table:"user_profiles"},()=>{p.invalidateQueries({queryKey:["user-profiles-admin"]})}).subscribe();return()=>{B.removeChannel($)}},[e,p]);const{data:v,isLoading:j,refetch:b,isRefetching:_}=Ve({queryKey:["user-profiles-admin"],queryFn:async()=>{const{data:$,error:R}=await B.from("user_profiles").select("*").order("updated_at",{ascending:!1});if(R)throw R;return $},enabled:e}),{data:w}=Ve({queryKey:["client-members-admin"],queryFn:async()=>{const{data:$,error:R}=await B.from("client_members").select(`
773          id,
774          user_id,
775          client_id,
776          role,
777          status,
778          created_at
779        `).order("created_at",{ascending:!1});if(R)throw R;const T=[...new Set(($==null?void 0:$.map(q=>q.client_id))||[])],{data:k}=await B.from("clients").select("id, name, slug").in("id",T),W=new Map((k==null?void 0:k.map(q=>[q.id,q]))||[]);return($==null?void 0:$.map(q=>({...q,client:W.get(q.client_id)})))||[]},enabled:e}),N=mt({mutationFn:async $=>{const{data:R,error:T}=await B.functions.invoke("revoke-user-session",{body:{userId:$,action:"revoke_sessions"}});if(T)throw T;if(R!=null&&R.error)throw new Error(R.error);return R},onSuccess:()=>{ye.success("All sessions revoked successfully",{description:`User ${d==null?void 0:d.email} has been logged out from all devices.`}),o(!1),u(null),p.invalidateQueries({queryKey:["audit-logs"]})},onError:$=>{ye.error("Failed to revoke sessions",{description:$.message})}}),S=mt({mutationFn:async({userId:$,action:R})=>{const{data:T,error:k}=await B.functions.invoke("manage-user-account",{body:{userId:$,action:R}});if(k)throw k;if(T!=null&&T.error)throw new Error(T.error);return{...T,action:R}},onSuccess:$=>{const R=$.action;ye.success(R==="disable"?"User account disabled":"User account enabled",{description:R==="disable"?`${d==null?void 0:d.email} has been disabled and logged out.`:`${d==null?void 0:d.email} can now sign in again.`}),c(!1),d&&g(T=>{const k=new Set(T);return R==="disable"?k.add(d.id):k.delete(d.id),k}),u(null),p.invalidateQueries({queryKey:["audit-logs"]})},onError:$=>{ye.error("Failed to manage user account",{description:$.message})}}),C=($,R)=>{u({id:$,email:R}),o(!0)},P=($,R,T)=>{u({id:$,email:R,action:T}),c(!0)},M=()=>{d&&N.mutate(d.id)},D=()=>{d&&d.action&&S.mutate({userId:d.id,action:d.action})},A=$=>{const R=h.get($);return R?R.isIdle?"idle":"online":"offline"};if(!t&&!e)return n.jsx(lc,{to:"/dashboard/overview",replace:!0});const U=v==null?void 0:v.filter($=>{var T,k,W,q;if(s==="")return!0;const R=s.toLowerCase();return((T=$.email)==null?void 0:T.toLowerCase().includes(R))||((k=$.first_name)==null?void 0:k.toLowerCase().includes(R))||((W=$.last_name)==null?void 0:W.toLowerCase().includes(R))||((q=$.display_name)==null?void 0:q.toLowerCase().includes(R))}),F=$=>(w==null?void 0:w.filter(R=>R.user_id===$))||[],L={totalUsers:(v==null?void 0:v.length)||0,providerAdmins:(v==null?void 0:v.filter($=>$.is_provider_admin).length)||0,onlineNow:y.size,activeToday:(v==null?void 0:v.filter($=>{const R=new Date($.updated_at),T=new Date;return R.toDateString()===T.toDateString()}).length)||0};return n.jsxs("div",{className:"space-y-6",children:[n.jsxs("div",{children:[n.jsx("h1",{className:"text-3xl font-bold tracking-tight",children:"User Sessions"}),n.jsx("p",{className:"text-muted-foreground",children:"Manage user accounts and monitor session activity"})]}),n.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Total Users"}),n.jsx(Rr,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:L.totalUsers}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Registered accounts"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Online Now"}),n.jsx(ku,{className:"h-4 w-4 fill-green-500 text-green-500"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold text-green-600 dark:text-green-400",children:L.onlineNow}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Active sessions"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Platform Admins"}),n.jsx(yt,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:L.providerAdmins}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Admin privileges"})]})]}),n.jsxs(ee,{children:[n.jsxs(de,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[n.jsx(me,{className:"text-sm font-medium",children:"Active Today"}),n.jsx(Xt,{className:"h-4 w-4 text-muted-foreground"})]}),n.jsxs(re,{children:[n.jsx("div",{className:"text-2xl font-bold",children:L.activeToday}),n.jsx("p",{className:"text-xs text-muted-foreground",children:"Updated today"})]})]})]}),n.jsxs(ee,{children:[n.jsx(de,{children:n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsxs(me,{className:"flex items-center gap-2",children:[n.jsx(G7,{className:"h-5 w-5"}),"User Accounts"]}),n.jsxs(De,{children:[(U==null?void 0:U.length)||0," users found"]}
779)]}),n.jsxs(H,{variant:"outline",size:"sm",onClick:()=>b(),disabled:_,children:[n.jsx(sr,{className:`h-4 w-4 mr-2 ${_?"animate-spin":""}`}),"Refresh"]})]})}),n.jsxs(re,{children:[n.jsx("div",{className:"mb-4",children:n.jsxs("div",{className:"relative",children:[n.jsx(qt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),n.jsx(ie,{placeholder:"Search users...",value:s,onChange:$=>a($.target.value),className:"pl-10"})]})}),j?n.jsx("div",{className:"space-y-3",children:[...Array(5)].map(($,R)=>n.jsx(tt,{className:"h-12 w-full"},R))}):n.jsx("div",{className:"rounded-md border",children:n.jsxs(Hn,{children:[n.jsx(Vn,{children:n.jsxs(gt,{children:[n.jsx(Se,{children:"User"}),n.jsx(Se,{children:"Email"}),n.jsx(Se,{children:"Role"}),n.jsx(Se,{children:"Client Memberships"}),n.jsx(Se,{children:"Status / Last Activity"}),n.jsx(Se,{className:"w-[70px]",children:"Actions"})]})}),n.jsx(Kn,{children:U&&U.length>0?U.map($=>{const R=F($.user_id),T=$.user_id===(r==null?void 0:r.id);return n.jsxs(gt,{children:[n.jsx(be,{className:"font-medium",children:$.display_name||`${$.first_name||""} ${$.last_name||""}`.trim()||"-"}),n.jsx(be,{children:$.email}),n.jsx(be,{children:$.is_provider_admin?n.jsxs(ve,{variant:"default",className:"bg-primary",children:[n.jsx(yt,{className:"h-3 w-3 mr-1"}),"Platform Admin"]}):n.jsx(ve,{variant:"secondary",children:"User"})}),n.jsx(be,{children:n.jsxs("div",{className:"flex flex-wrap gap-1",children:[R.length>0?R.slice(0,3).map(k=>{var W;return n.jsxs(ve,{variant:"outline",className:"text-xs",children:[(W=k.client)==null?void 0:W.name," (",k.role,")"]},k.id)}):n.jsx("span",{className:"text-muted-foreground text-sm",children:"No memberships"}),R.length>3&&n.jsxs(ve,{variant:"outline",className:"text-xs",children:["+",R.length-3," more"]})]})}),n.jsx(be,{children:n.jsx("div",{className:"flex items-center gap-2",children:m.has($.user_id)?n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(N7,{className:"h-3.5 w-3.5 text-destructive"}),n.jsx("span",{className:"text-destructive font-medium text-sm",children:"Disabled"})]})}),n.jsx(Pi,{children:"Account is disabled"})]}):A($.user_id)==="online"?n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(ku,{className:"h-2.5 w-2.5 fill-green-500 text-green-500 animate-pulse"}),n.jsx("span",{className:"text-green-600 dark:text-green-400 font-medium text-sm",children:"Online"})]})}),n.jsx(Pi,{children:"User is currently active"})]}):A($.user_id)==="idle"?n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(T7,{className:"h-3.5 w-3.5 text-amber-500"}),n.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium text-sm",children:"Idle"})]})}),n.jsx(Pi,{children:"User is idle (no activity for 5+ minutes)"})]}):n.jsxs(vo,{children:[n.jsx(yo,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx(ku,{className:"h-2.5 w-2.5 fill-muted-foreground/30 text-muted-foreground/30"}),n.jsx("span",{className:"text-muted-foreground text-sm",children:is(new Date($.updated_at),{addSuffix:!0})})]})}),n.jsxs(Pi,{children:["Last seen ",is(new Date($.updated_at),{addSuffix:!0})]})]})})}),n.jsx(be,{children:n.jsxs(W2,{children:[n.jsx(H2,{asChild:!0,children:n.jsxs(H,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[n.jsx(xI,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Actions"})]})}),n.jsxs(tb,{align:"end",children:[n.jsxs(Ao,{className:"text-destructive focus:text-destructive",disabled:T,onClick:()=>C($.user_id,$.email),children:[n.jsx(Gm,{className:"h-4 w-4 mr-2"}),T?"Can't revoke own session":"Revoke All Sessions"]}),m.has($.user_id)?n.jsxs(Ao,{disabled:T,onClick:()=>P($.user_id,$.email,"enable"),children:[n.jsx(xo,{className:"h-4 w-4 mr-2"}),"Enable Account"]}):n.jsxs(Ao,{className:"text-destructive focus:text-destructive",disabled:T,onClick:()=>P($.user_id,$.email,"disable"),children:[n.jsx(Rb,{className:"h-4 w-4 mr-2"}),T?"Can't disable own account":"Disable Account"]})]})]})})]},$.id)}):n.jsx(gt,{children:n.jsx(be,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No users found"})})})]})})]})]}),n.jsx(os,{open:i,onOpenChange:o,children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsxs(zn,{className:"flex items-center gap-2",children:[n.jsx(tn,{className:"h-5 w-5 text-destructive"}),"Revoke All Sessions"]}),n.jsxs(Bn,{children:["This will immediately log out ",n.jsx("strong",{children:d==null?void 0:d.email})," from all devices and sessions. They will need to sign in again to access the platform."]})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:N.isPending,children:"Cancel"}),n.jsx(qn,{onClick:M,disabled:N.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:N.isPending?n.jsxs(n.Fragment,{children:[n.jsx(sr,{className:"h-4 w-4 mr-2 animate-spin"}),"Revoking..."]}):n.jsxs(n.Fragment,{children:[n.jsx(Gm,{className:"h-4 w-4 mr-2"}),"Revoke Sessions"]})})]})]})}),n.jsx(os,{open:l,onOpenChange:c,children:n.jsxs(Ln,{children:[n.jsxs(Fn,{children:[n.jsx(zn,{className:"flex items-center gap-2",children:(d==null?void 0:d.action)==="disable"?n.jsxs(n.Fragment,{children:[n.jsx(Rb,{className:"h-5 w-5 text-destructive"}),"Disable User Account"]}):n.jsxs(n.Fragment,{children:[n.jsx(xo,{className:"h-5 w-5 text-green-600"}),"Enable User Account"]})}),n.jsx(Bn,{children:(d==null?void 0:d.action)==="disable"?n.jsxs(n.Fragment,{children:["This will disable ",n.jsx("strong",{children:d==null?void 0:d.email}),"'s account and immediately log them out. They will not be able to sign in until the account is re-enabled."]}):n.jsxs(n.Fragment,{children:["This will re-enable ",n.jsx("strong",{children:d==null?void 0:d.email}),"'s account. They will be able to sign in again."]})})]}),n.jsxs(Un,{children:[n.jsx(Wn,{disabled:S.isPending,children:"Cancel"}),n.jsx(qn,{onClick:D,disabled:S.isPending,className:(d==null?void 0:d.action)==="disable"?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-green-600 text-white hover:bg-green-700",children:S.isPending?n.jsxs(n.Fragment,{children:[n.jsx(sr,{className:"h-4 w-4 mr-2 animate-spin"}),(d==null?void 0:d.action)==="disable"?"Disabling...":"Enabling..."]}):(d==null?void 0:d.action)==="disable"?n.jsxs(n.Fragment,{children:[n.jsx(Rb,{className:"h-4 w-4 mr-2"}),"Disable Account"]}):n.jsxs(n.Fragment,{children:[n.jsx(xo,{className:"h-4 w-4 mr-2"}),"Enable Account"]})})]})]})})]})}const UDe=new mQ;function zDe(){const{user:e,isLoading:t}=Mt();return t?n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:n.jsxs("div",{className:"text-center space-y-4",children:[n.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary border-t-transparent roun
779ded-full mx-auto"}),n.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):e?n.jsx(eee,{children:n.jsx(Nae,{children:n.jsx(yX,{})})}):n.jsx(lc,{to:"/",replace:!0})}function fD({children:e}){const{user:t,isLoading:r}=Mt();return r?n.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:n.jsxs("div",{className:"text-center space-y-4",children:[n.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-primary border-t-transparent rounded-full mx-auto"}),n.jsx("p",{className:"text-muted-foreground",children:"Loading..."})]})}):t?n.jsx(lc,{to:"/dashboard/overview",replace:!0}):n.jsx(n.Fragment,{children:e})}const BDe=()=>n.jsx(yQ,{client:UDe,children:n.jsxs(Eu,{children:[n.jsx(EK,{}),n.jsx(cG,{}),n.jsx(JJ,{children:n.jsx(AX,{children:n.jsxs(bX,{children:[n.jsx(Ut,{path:"/",element:n.jsx(fD,{children:n.jsx(Tte,{})})}),n.jsx(Ut,{path:"/login",element:n.jsx(fD,{children:n.jsx(Ete,{})})}),n.jsx(Ut,{path:"/dashboard",element:n.jsx(lc,{to:"/dashboard/overview",replace:!0})}),n.jsxs(Ut,{element:n.jsx(zDe,{}),children:[n.jsx(Ut,{path:"/dashboard/overview",element:n.jsx(Tae,{})}),n.jsx(Ut,{path:"/dashboard/monitors/http",element:n.jsx(uOe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/ssl",element:n.jsx(xOe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/dns",element:n.jsx(_Me,{})}),n.jsx(Ut,{path:"/dashboard/monitors/ping",element:n.jsx(AMe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/tcp-udp",element:n.jsx(RMe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/keyword",element:n.jsx(zMe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/smtp",element:n.jsx(HMe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/ftp",element:n.jsx(XMe,{})}),n.jsx(Ut,{path:"/dashboard/monitors/sftp",element:n.jsx(n4e,{})}),n.jsx(Ut,{path:"/dashboard/monitors/ftps",element:n.jsx(c4e,{})}),n.jsx(Ut,{path:"/dashboard/agents",element:n.jsx(K4e,{})}),n.jsx(Ut,{path:"/dashboard/alerts",element:n.jsx(X4e,{})}),n.jsx(Ut,{path:"/dashboard/groups",element:n.jsx(Z4e,{})}),n.jsx(Ut,{path:"/dashboard/commands",element:n.jsx(rDe,{})}),n.jsx(Ut,{path:"/dashboard/watchlists",element:n.jsx(NDe,{})}),n.jsx(Ut,{path:"/dashboard/clients",element:n.jsx(MDe,{})}),n.jsx(Ut,{path:"/dashboard/system-templates",element:n.jsx(RDe,{})}),n.jsx(Ut,{path:"/dashboard/platform-stats",element:n.jsx(IDe,{})}),n.jsx(Ut,{path:"/dashboard/audit-logs",element:n.jsx(LDe,{})}),n.jsx(Ut,{path:"/dashboard/user-sessions",element:n.jsx(FDe,{})}),n.jsx(Ut,{path:"/dashboard/agent/:agentId/monitors",element:n.jsx(Ise,{})}),n.jsx(Ut,{path:"/dashboard/settings",element:n.jsx(xDe,{})}),n.jsx(Ut,{path:"/dashboard/help",element:n.jsx(vDe,{})})]}),n.jsx(Ut,{path:"/privacy-policy",element:n.jsx(Fse,{})}),n.jsx(Ut,{path:"/terms-of-service",element:n.jsx(Use,{})}),n.jsx(Ut,{path:"/support",element:n.jsx(zse,{})}),n.jsx(Ut,{path:"/:clientSlug/public/:watchlistSlug",element:n.jsx(Wse,{})}),n.jsx(Ut,{path:"*",element:n.jsx(Lse,{})})]})})})]})}),qDe=localStorage.getItem("color-theme");document.documentElement.classList.add("dark");qDe==="true-black"&&document.documentElement.classList.add("theme-black");I$(document.getElementById("root")).render(n.jsx(BDe,{}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.